From: Mark Brown Date: Sun, 24 Jul 2011 10:46:20 +0000 (+0100) Subject: regmap: Implement writable register checks X-Git-Tag: firefly_0821_release~3680^2~4325^2~54 X-Git-Url: http://demsky.eecs.uci.edu/git/?a=commitdiff_plain;h=73304781274200c341996f65220d36b3cda8e217;p=firefly-linux-kernel-4.4.55.git regmap: Implement writable register checks 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 --- diff --git a/drivers/base/regmap/regmap.c b/drivers/base/regmap/regmap.c index 7d4dc11ad86c..e57f10f485a1 100644 --- a/drivers/base/regmap/regmap.c +++ b/drivers/base/regmap/regmap.c @@ -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);