The issue that I encountered is when doing regmap_update_bits on a write only register. In regcache path this will not do the right thing as the register is not readable and driver which is using regmap_update_bits will never notice that it can not do a update bits on write only register leading to inconsistent writes and random hardware behavior.
There seems to be missing checks in regcache_read() which is now added by moving the orignal check in _regmap_read() before accessing regcache.
Cc: stable@vger.kernel.org Fixes: 5d1729e7f02f ("regmap: Incorporate the regcache core into regmap") Reported-by: Marek Szyprowski m.szyprowski@samsung.com Signed-off-by: Srinivas Kandagatla srinivas.kandagatla@linaro.org --- drivers/base/regmap/regmap.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/drivers/base/regmap/regmap.c b/drivers/base/regmap/regmap.c index 297e95be25b3..3ed37a09a8e9 100644 --- a/drivers/base/regmap/regmap.c +++ b/drivers/base/regmap/regmap.c @@ -2677,6 +2677,9 @@ static int _regmap_read(struct regmap *map, unsigned int reg, int ret; void *context = _regmap_map_get_context(map);
+ if (!regmap_readable(map, reg)) + return -EIO; + if (!map->cache_bypass) { ret = regcache_read(map, reg, val); if (ret == 0) @@ -2686,9 +2689,6 @@ static int _regmap_read(struct regmap *map, unsigned int reg, if (map->cache_only) return -EBUSY;
- if (!regmap_readable(map, reg)) - return -EIO; - ret = map->reg_read(context, reg, val); if (ret == 0) { if (regmap_should_log(map))