Skip to content

Commit

Permalink
regmap: regcache: allow read-only regs to be cached
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Ionut Nicu authored and Mark Brown committed Aug 9, 2013
1 parent 1767da9 commit 515f226
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
3 changes: 0 additions & 3 deletions drivers/base/regmap/regcache.c
Original file line number Diff line number Diff line change
Expand Up @@ -241,9 +241,6 @@ int regcache_write(struct regmap *map,

BUG_ON(!map->cache_ops);

if (!regmap_writeable(map, reg))
return -EIO;

if (!regmap_volatile(map, reg))
return map->cache_ops->write(map, reg, value);

Expand Down
3 changes: 3 additions & 0 deletions drivers/base/regmap/regmap.c
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit 515f226

Please sign in to comment.