diff options
author | Xiubo Li <Li.Xiubo@freescale.com> | 2014-03-27 00:42:42 -0400 |
---|---|---|
committer | Mark Brown <broonie@linaro.org> | 2014-03-27 06:55:55 -0400 |
commit | 41b0c2c976a8758a2b7f5b14cbc5d1a7436932cc (patch) | |
tree | 244ce5d605911d4a9e4c455b3789a5f23bf3476f /drivers/base/regmap/regmap-mmio.c | |
parent | 38dbfb59d1175ef458d006556061adeaa8751b72 (diff) |
regmap: mmio: add regmap_mmio_{regsize, count}_check.
Signed-off-by: Xiubo Li <Li.Xiubo@freescale.com>
Signed-off-by: Mark Brown <broonie@linaro.org>
Diffstat (limited to 'drivers/base/regmap/regmap-mmio.c')
-rw-r--r-- | drivers/base/regmap/regmap-mmio.c | 16 |
1 files changed, 13 insertions, 3 deletions
diff --git a/drivers/base/regmap/regmap-mmio.c b/drivers/base/regmap/regmap-mmio.c index 81f977510775..4f1efce94034 100644 --- a/drivers/base/regmap/regmap-mmio.c +++ b/drivers/base/regmap/regmap-mmio.c | |||
@@ -30,6 +30,16 @@ struct regmap_mmio_context { | |||
30 | struct clk *clk; | 30 | struct clk *clk; |
31 | }; | 31 | }; |
32 | 32 | ||
33 | static inline void regmap_mmio_regsize_check(size_t reg_size) | ||
34 | { | ||
35 | BUG_ON(reg_size != 4); | ||
36 | } | ||
37 | |||
38 | static inline void regmap_mmio_count_check(size_t count) | ||
39 | { | ||
40 | BUG_ON(count < 4); | ||
41 | } | ||
42 | |||
33 | static int regmap_mmio_gather_write(void *context, | 43 | static int regmap_mmio_gather_write(void *context, |
34 | const void *reg, size_t reg_size, | 44 | const void *reg, size_t reg_size, |
35 | const void *val, size_t val_size) | 45 | const void *val, size_t val_size) |
@@ -38,7 +48,7 @@ static int regmap_mmio_gather_write(void *context, | |||
38 | u32 offset; | 48 | u32 offset; |
39 | int ret; | 49 | int ret; |
40 | 50 | ||
41 | BUG_ON(reg_size != 4); | 51 | regmap_mmio_regsize_check(reg_size); |
42 | 52 | ||
43 | if (!IS_ERR(ctx->clk)) { | 53 | if (!IS_ERR(ctx->clk)) { |
44 | ret = clk_enable(ctx->clk); | 54 | ret = clk_enable(ctx->clk); |
@@ -81,7 +91,7 @@ static int regmap_mmio_gather_write(void *context, | |||
81 | 91 | ||
82 | static int regmap_mmio_write(void *context, const void *data, size_t count) | 92 | static int regmap_mmio_write(void *context, const void *data, size_t count) |
83 | { | 93 | { |
84 | BUG_ON(count < 4); | 94 | regmap_mmio_count_check(count); |
85 | 95 | ||
86 | return regmap_mmio_gather_write(context, data, 4, data + 4, count - 4); | 96 | return regmap_mmio_gather_write(context, data, 4, data + 4, count - 4); |
87 | } | 97 | } |
@@ -94,7 +104,7 @@ static int regmap_mmio_read(void *context, | |||
94 | u32 offset; | 104 | u32 offset; |
95 | int ret; | 105 | int ret; |
96 | 106 | ||
97 | BUG_ON(reg_size != 4); | 107 | regmap_mmio_regsize_check(reg_size); |
98 | 108 | ||
99 | if (!IS_ERR(ctx->clk)) { | 109 | if (!IS_ERR(ctx->clk)) { |
100 | ret = clk_enable(ctx->clk); | 110 | ret = clk_enable(ctx->clk); |