summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPhilipp Zabel <p.zabel@pengutronix.de>2014-05-16 16:25:34 +0200
committerMark Brown <broonie@linaro.org>2014-05-26 16:56:02 +0100
commit2e804b7c72d4efd2318428a2c1e40fd0e173c487 (patch)
treec4de0887bd10633a9076228deeeeab7a5559362e
parentb48d13988bee440e43a510ea8878f1f329cee189 (diff)
downloadop-kernel-dev-2e804b7c72d4efd2318428a2c1e40fd0e173c487.zip
op-kernel-dev-2e804b7c72d4efd2318428a2c1e40fd0e173c487.tar.gz
regmap: mmio: Fix regmap_mmio_write for uneven counts
Commit 932580409a9dacbf42215fa737bf06ae2c0aa624 "regmap: mmio: Add support for 1/2/8 bytes wide register address." broke regmap_mmio_write for uneven counts, for example 32-bit register addresses with no padding and 8-byte values (count = 5). Fix this by allowing all counts large enough to include some value. This check was BUG_ON(count < 4) before the last change. Signed-off-by: Philipp Zabel <p.zabel@pengutronix.de> Signed-off-by: Mark Brown <broonie@linaro.org>
-rw-r--r--drivers/base/regmap/regmap-mmio.c6
1 files changed, 3 insertions, 3 deletions
diff --git a/drivers/base/regmap/regmap-mmio.c b/drivers/base/regmap/regmap-mmio.c
index 1e03e7f..902c4fb 100644
--- a/drivers/base/regmap/regmap-mmio.c
+++ b/drivers/base/regmap/regmap-mmio.c
@@ -61,9 +61,9 @@ static int regmap_mmio_regbits_check(size_t reg_bits)
}
}
-static inline void regmap_mmio_count_check(size_t count)
+static inline void regmap_mmio_count_check(size_t count, u32 offset)
{
- BUG_ON(count % 2 != 0);
+ BUG_ON(count <= offset);
}
static int regmap_mmio_gather_write(void *context,
@@ -120,7 +120,7 @@ static int regmap_mmio_write(void *context, const void *data, size_t count)
struct regmap_mmio_context *ctx = context;
u32 offset = ctx->reg_bytes + ctx->pad_bytes;
- regmap_mmio_count_check(count);
+ regmap_mmio_count_check(count, offset);
return regmap_mmio_gather_write(context, data, ctx->reg_bytes,
data + offset, count - offset);
OpenPOWER on IntegriCloud