Commit 61cddc57dc14a5dffa0921d9a24fd68edbb374ac

Authored by Lars-Peter Clausen
Committed by Mark Brown
1 parent d65b4e98d7

regmap: Fix cache defaults initialization from raw cache defaults

Currently registers with a value of 0 are ignored when initializing the register
defaults from raw defaults. This worked in the past, because registers without a
explicit default were assumed to have a default value of 0. This was changed in
commit b03622a8 ("regmap: Ensure rbtree syncs registers set to zero properly").
As a result registers, which have a raw default value of 0 are now assumed to
have no default. This again can result in unnecessary writes when syncing the
cache. It will also result in unnecessary reads for e.g. the first update
operation. In the case where readback is not possible this will even let the
update operation fail, if the register has not been written to before.

So this patch removes the check. Instead it adds a check to ignore raw defaults
for registers which are volatile, since those registers are not cached.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
Cc: stable@vger.kernel.org

Showing 1 changed file with 2 additions and 2 deletions Side-by-side Diff

drivers/base/regmap/regcache.c
... ... @@ -53,7 +53,7 @@
53 53 for (count = 0, i = 0; i < map->num_reg_defaults_raw; i++) {
54 54 val = regcache_get_val(map->reg_defaults_raw,
55 55 i, map->cache_word_size);
56   - if (!val)
  56 + if (regmap_volatile(map, i))
57 57 continue;
58 58 count++;
59 59 }
... ... @@ -70,7 +70,7 @@
70 70 for (i = 0, j = 0; i < map->num_reg_defaults_raw; i++) {
71 71 val = regcache_get_val(map->reg_defaults_raw,
72 72 i, map->cache_word_size);
73   - if (!val)
  73 + if (regmap_volatile(map, i))
74 74 continue;
75 75 map->reg_defaults[j].reg = i;
76 76 map->reg_defaults[j].def = val;