regmap: Bypass the cache when applying patches
Subsystems (2)
PATCH 1/2 regmap: Bypass the cache when applying patches
Otherwise any patch that affects a register which is writable may trash cached values.
Signed-off-by Mark Brown <[email protected]>
--- drivers/base/regmap/regcache.c | 2 ++ 1 files changed, 2 insertions(+), 0 deletions(-)
drivers/base/regmap/regcache.c +2 -0
@@ -268,6 +268,7 @@ int regcache_sync(struct regmap *map)trace_regcache_sync (map->dev, name,"start" );/* Apply any patch first */ + map->cache_bypass =1 ;for (i =0 ; i < map->patch_regs; i++) { ret =_regmap_write (map, map->patch[i].reg, map->patch[i].def);if (ret !=0 ) {
@@ -276,6 +277,7 @@ int regcache_sync(struct regmap *map) goto out; } } + map->cache_bypass =0 ;if (!map->cache_dirty) goto out;
Signature · 1 line
1.7.9.rc1
PATCH 2/2 regmap: Skip patch application when the cache is not dirty on sync
On the basis that if we don't actually need to resync the cache then the patches are probably also already applied.
Signed-off-by Mark Brown <[email protected]>
--- drivers/base/regmap/regcache.c | 5 +++-- 1 files changed, 3 insertions(+), 2 deletions(-)
drivers/base/regmap/regcache.c +3 -2
@@ -267,6 +267,9 @@ int regcache_sync(struct regmap *map) name = map->cache_ops->name;trace_regcache_sync (map->dev, name,"start" ); +if (!map->cache_dirty) + goto out; +/* Apply any patch first */ map->cache_bypass =1 ;for (i =0 ; i < map->patch_regs; i++) {
@@ -279,8 +282,6 @@ int regcache_sync(struct regmap *map) } map->cache_bypass =0 ; -if (!map->cache_dirty) - goto out;if (map->cache_ops->sync) { ret = map->cache_ops->sync (map); }else {
Signature · 1 line
1.7.9.rc1