Skip to contentSkip to conversation

regmap: rbtree: Fix register default look-up in sync

PATCH In review Lars-Peter Clausen 2 participants 2 messages Mar 23, 2012 – Mar 24, 2012

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 regmap: rbtree: Fix register default look-up in sync

The code currently passes the register offset in the current block to regcache_lookup_reg. This works fine as long as there is only one block and with base register of 0, but in all other cases it will look-up the default for a wrong register, which can cause unnecessary register writes. This patch fixes it by passing the actual register number to regcache_lookup_reg.

---
 drivers/base/regmap/regcache-rbtree.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)
drivers/base/regmap/regcache-rbtree.c +1 -1
index 8d51916..de7241c 100644
@@ -395,7 +395,7 @@ static int regcache_rbtree_sync(struct regmap *map, unsigned int min,
 							   map->cache_word_size);
 
 			/* Is this the hardware default?  If so skip. */
-			ret = regcache_lookup_reg(map, i);
+			ret = regcache_lookup_reg(map, regtmp);
 			if (ret >= 0 && val == map->reg_defaults[ret].def)
 				continue;
 
Signature · 1 line
1.7.9.1
#1 lore raw
Quoted 8 lines · Lars-Peter Clausen

The code currently passes the register offset in the current block to regcache_lookup_reg. This works fine as long as there is only one block and with base register of 0, but in all other cases it will look-up the default for a wrong register, which can cause unnecessary register writes. This patch fixes it by passing the actual register number to regcache_lookup_reg.

Good catch - I'm fairly surprised nobody (including me) noticed it over the couple of kernel releases it's been there. Will apply once we've got an -rc1.