regmap-mmio.c (c0cc6fe1d09e3f1baecbdf8922473c8e7d3a5317) regmap-mmio.c (f01ee60fffa4dc6c77122121233a793f7f696e67)
1/*
2 * Register map access API - MMIO support
3 *
4 * Copyright (c) 2012, NVIDIA CORPORATION. All rights reserved.
5 *
6 * This program is free software; you can redistribute it and/or modify it
7 * under the terms and conditions of the GNU General Public License,
8 * version 2, as published by the Free Software Foundation.

--- 116 unchanged lines hidden (view full) ---

125 .read = regmap_mmio_read,
126 .free_context = regmap_mmio_free_context,
127};
128
129struct regmap_mmio_context *regmap_mmio_gen_context(void __iomem *regs,
130 const struct regmap_config *config)
131{
132 struct regmap_mmio_context *ctx;
1/*
2 * Register map access API - MMIO support
3 *
4 * Copyright (c) 2012, NVIDIA CORPORATION. All rights reserved.
5 *
6 * This program is free software; you can redistribute it and/or modify it
7 * under the terms and conditions of the GNU General Public License,
8 * version 2, as published by the Free Software Foundation.

--- 116 unchanged lines hidden (view full) ---

125 .read = regmap_mmio_read,
126 .free_context = regmap_mmio_free_context,
127};
128
129struct regmap_mmio_context *regmap_mmio_gen_context(void __iomem *regs,
130 const struct regmap_config *config)
131{
132 struct regmap_mmio_context *ctx;
133 int min_stride;
133
134 if (config->reg_bits != 32)
135 return ERR_PTR(-EINVAL);
136
137 if (config->pad_bits)
138 return ERR_PTR(-EINVAL);
139
140 switch (config->val_bits) {
141 case 8:
134
135 if (config->reg_bits != 32)
136 return ERR_PTR(-EINVAL);
137
138 if (config->pad_bits)
139 return ERR_PTR(-EINVAL);
140
141 switch (config->val_bits) {
142 case 8:
143 /* The core treats 0 as 1 */
144 min_stride = 0;
145 break;
142 case 16:
146 case 16:
147 min_stride = 2;
148 break;
143 case 32:
149 case 32:
150 min_stride = 4;
151 break;
144#ifdef CONFIG_64BIT
145 case 64:
152#ifdef CONFIG_64BIT
153 case 64:
154 min_stride = 8;
155 break;
146#endif
147 break;
148 default:
149 return ERR_PTR(-EINVAL);
150 }
151
156#endif
157 break;
158 default:
159 return ERR_PTR(-EINVAL);
160 }
161
162 if (config->reg_stride < min_stride)
163 return ERR_PTR(-EINVAL);
164
152 ctx = kzalloc(GFP_KERNEL, sizeof(*ctx));
153 if (!ctx)
154 return ERR_PTR(-ENOMEM);
155
156 ctx->regs = regs;
157 ctx->val_bytes = config->val_bits / 8;
158
159 return ctx;

--- 52 unchanged lines hidden ---
165 ctx = kzalloc(GFP_KERNEL, sizeof(*ctx));
166 if (!ctx)
167 return ERR_PTR(-ENOMEM);
168
169 ctx->regs = regs;
170 ctx->val_bytes = config->val_bits / 8;
171
172 return ctx;

--- 52 unchanged lines hidden ---