Skip to contentSkip to conversation

regmap: Fix regcache-rbtree sync

PATCH Applied Lars-Peter Clausen 2 participants 2 messages Mar 13, 2013

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

PATCH 1/1 regmap: Fix regcache-rbtree sync

The last register block, which falls into the specified range, is not handled correctly. The formula which calculates the number of register which should be synced is inverse (and off by one). E.g. if all registers in that block should be synced only one is synced, and if only one should be synced all (but one) are synced. To calculate the number of registers that need to be synced we need to subtract the number of the first register in the block from the max register number and add one. This patch updates the code accordingly.

The issue was introduced in commit ac8d91c ("regmap: Supply ranges to the sync operations").

---
 drivers/base/regmap/regcache-rbtree.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/base/regmap/regcache-rbtree.c +1 -1
index 0453196..a1f67eb 100644
@@ -398,7 +398,7 @@ static int regcache_rbtree_sync(struct regmap *map, unsigned int min,
 			base = 0;
 
 		if (max < rbnode->base_reg + rbnode->blklen)
-			end = rbnode->base_reg + rbnode->blklen - max;
+			end = max - rbnode->base_reg + 1;
 		else
 			end = rbnode->blklen;
 
Signature · 1 line
1.8.0
Applied
#1 lore raw
Quoted 2 lines · Lars-Peter Clausen

The last register block, which falls into the specified range, is not handled correctly. The formula which calculates the number of register which should be

Applied, thanks.