regmap: Implement writable register checks
authorMark Brown <broonie@opensource.wolfsonmicro.com>
Sun, 24 Jul 2011 10:46:20 +0000 (11:46 +0100)
committerMark Brown <broonie@opensource.wolfsonmicro.com>
Mon, 8 Aug 2011 06:56:41 +0000 (15:56 +0900)
This is mainly intended to be used by devices which can dynamically
block register writes at runtime, for other devices there is usually
limited value.

Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
drivers/base/regmap/regmap.c

index 7d4dc11ad86cf9db6d1a5abbc4576ceb037d3cc2..e57f10f485a16a41e74ddb0f32e239194b79dda5 100644 (file)
@@ -211,6 +211,13 @@ static int _regmap_raw_write(struct regmap *map, unsigned int reg,
        void *buf;
        int ret = -ENOTSUPP;
        size_t len;
+       int i;
+
+       /* Check for unwritable registers before we start */
+       if (map->writeable_reg)
+               for (i = 0; i < val_len / map->format.val_bytes; i++)
+                       if (!map->writeable_reg(map->dev, reg + i))
+                               return -EINVAL;
 
        map->format.format_reg(map->work_buf, reg);