Skip to content

Commit b03622a

Browse files
committed
regmap: Ensure rbtree syncs registers set to zero properly
Simplify the check for registers set at their default value by avoiding picking a default value in the case where we don't have one. Instead we only compare the current value to the current value when we looked one up. This fixes the case where we don't have a default stored but the value was set to zero when that isn't the chip default. Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com> Acked-by: Dimitris Papastamos <dp@opensource.wolfsonmicro.com>
1 parent e42c5a9 commit b03622a

1 file changed

Lines changed: 5 additions & 6 deletions

File tree

‎drivers/base/regmap/regcache-rbtree.c‎

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -304,7 +304,7 @@ static int regcache_rbtree_sync(struct regmap *map)
304304
struct rb_node *node;
305305
struct regcache_rbtree_node *rbnode;
306306
unsigned int regtmp;
307-
unsigned int val, def;
307+
unsigned int val;
308308
int ret;
309309
int i;
310310

@@ -315,13 +315,12 @@ static int regcache_rbtree_sync(struct regmap *map)
315315
regtmp = rbnode->base_reg + i;
316316
val = regcache_rbtree_get_register(rbnode, i,
317317
map->cache_word_size);
318+
319+
/* Is this the hardware default? If so skip. */
318320
ret = regcache_lookup_reg(map, i);
319-
if (ret < 0)
320-
def = 0;
321-
else
322-
def = map->reg_defaults[ret].def;
323-
if (val == def)
321+
if (ret > 0 && val == map->reg_defaults[ret].def)
324322
continue;
323+
325324
map->cache_bypass = 1;
326325
ret = _regmap_write(map, regtmp, val);
327326
map->cache_bypass = 0;

0 commit comments

Comments
 (0)