Skip to contentSkip to conversation

regmap: Bypass the cache when applying patches

PATCH New Mark Brown 1 participant 2 messages Jan 25, 2012

Subsystems (2)
lore
Share & tools
lore
author
#1 lore raw

PATCH 2/2 regmap: Skip patch application when the cache is not dirty on sync

In reply to Mark Brown

On the basis that if we don't actually need to resync the cache then the patches are probably also already applied.

---
 drivers/base/regmap/regcache.c |    5 +++--
 1 files changed, 3 insertions(+), 2 deletions(-)
drivers/base/regmap/regcache.c +3 -2
index bfe48e4..d103401 100644
@@ -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

Mark Brown

author
#0 lore raw

PATCH 1/2 regmap: Bypass the cache when applying patches

Otherwise any patch that affects a register which is writable may trash cached values.

---
 drivers/base/regmap/regcache.c |    2 ++
 1 files changed, 2 insertions(+), 0 deletions(-)
drivers/base/regmap/regcache.c +2 -0
index 0d54668..bfe48e4 100644
@@ -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