diff options
author | Ionut Nicu <ioan.nicu.ext@nsn.com> | 2013-08-09 12:09:20 +0200 |
---|---|---|
committer | Mark Brown <broonie@linaro.org> | 2013-08-09 12:47:29 +0100 |
commit | 515f2261703d09c6b647a5687b7d657dd5911065 (patch) | |
tree | 8d8a3264f62d32c91463f3ff392db15debb30262 /drivers/base/regmap/regmap.c | |
parent | 1767da9e8e9a1dc1416d6bb1029b8cf5659dac2a (diff) | |
download | kernel_goldelico_gta04-515f2261703d09c6b647a5687b7d657dd5911065.zip kernel_goldelico_gta04-515f2261703d09c6b647a5687b7d657dd5911065.tar.gz kernel_goldelico_gta04-515f2261703d09c6b647a5687b7d657dd5911065.tar.bz2 |
regmap: regcache: allow read-only regs to be cached
The regmap_writeable() check should not be done in
regcache_write() because this prevents read-only
registers to be cached. After a read on a read-only
register its value will not be stored in the cache
and the next time someone will try to read it the
value will be read from the bus instead of the
cache.
Instead the regmap_writeable() check should be done
in _regmap_write() to prevent callers from writing
to read-only registers.
Signed-off-by: Ionut Nicu <ioan.nicu.ext@nsn.com>
Signed-off-by: Mark Brown <broonie@linaro.org>
Diffstat (limited to 'drivers/base/regmap/regmap.c')
-rw-r--r-- | drivers/base/regmap/regmap.c | 3 |
1 files changed, 3 insertions, 0 deletions
diff --git a/drivers/base/regmap/regmap.c b/drivers/base/regmap/regmap.c index e0d0c7d..0e85367 100644 --- a/drivers/base/regmap/regmap.c +++ b/drivers/base/regmap/regmap.c @@ -1261,6 +1261,9 @@ int _regmap_write(struct regmap *map, unsigned int reg, int ret; void *context = _regmap_map_get_context(map); + if (!regmap_writeable(map, reg)) + return -EIO; + if (!map->cache_bypass && !map->defer_caching) { ret = regcache_write(map, reg, val); if (ret != 0) |