diff options
| author | Xiubo Li <Li.Xiubo@freescale.com> | 2014-03-28 01:12:56 -0400 |
|---|---|---|
| committer | Mark Brown <broonie@linaro.org> | 2014-03-28 07:12:05 -0400 |
| commit | 451485ba6bfbed36220b9e710fca0525f62e771d (patch) | |
| tree | aab504ba27ca65b06fba3cb5cb70d7498b30ea9e /drivers/base | |
| parent | 932580409a9dacbf42215fa737bf06ae2c0aa624 (diff) | |
regmap: mmio: Add regmap_mmio_regbits_check.
Fix the support for 1/2/8 bytes wide register address checking.
Signed-off-by: Xiubo Li <Li.Xiubo@freescale.com>
Signed-off-by: Mark Brown <broonie@linaro.org>
Diffstat (limited to 'drivers/base')
| -rw-r--r-- | drivers/base/regmap/regmap-mmio.c | 20 |
1 files changed, 18 insertions, 2 deletions
diff --git a/drivers/base/regmap/regmap-mmio.c b/drivers/base/regmap/regmap-mmio.c index ed080a47b1f8..de45a1e1548f 100644 --- a/drivers/base/regmap/regmap-mmio.c +++ b/drivers/base/regmap/regmap-mmio.c | |||
| @@ -47,6 +47,21 @@ static inline void regmap_mmio_regsize_check(size_t reg_size) | |||
| 47 | } | 47 | } |
| 48 | } | 48 | } |
| 49 | 49 | ||
| 50 | static int regmap_mmio_regbits_check(size_t reg_bits) | ||
| 51 | { | ||
| 52 | switch (reg_bits) { | ||
| 53 | case 8: | ||
| 54 | case 16: | ||
| 55 | case 32: | ||
| 56 | #ifdef CONFIG_64BIT | ||
| 57 | case 64: | ||
| 58 | #endif | ||
| 59 | return 0; | ||
| 60 | default: | ||
| 61 | return -EINVAL; | ||
| 62 | } | ||
| 63 | } | ||
| 64 | |||
| 50 | static inline void regmap_mmio_count_check(size_t count) | 65 | static inline void regmap_mmio_count_check(size_t count) |
| 51 | { | 66 | { |
| 52 | BUG_ON(count % 2 != 0); | 67 | BUG_ON(count % 2 != 0); |
| @@ -191,8 +206,9 @@ static struct regmap_mmio_context *regmap_mmio_gen_context(struct device *dev, | |||
| 191 | int min_stride; | 206 | int min_stride; |
| 192 | int ret; | 207 | int ret; |
| 193 | 208 | ||
| 194 | if (config->reg_bits != 32) | 209 | ret = regmap_mmio_regbits_check(config->reg_bits); |
| 195 | return ERR_PTR(-EINVAL); | 210 | if (ret) |
| 211 | return ERR_PTR(ret); | ||
| 196 | 212 | ||
| 197 | if (config->pad_bits) | 213 | if (config->pad_bits) |
| 198 | return ERR_PTR(-EINVAL); | 214 | return ERR_PTR(-EINVAL); |
