summaryrefslogtreecommitdiff
path: root/drivers/base
diff options
context:
space:
mode:
authorMark Brown <broonie@opensource.wolfsonmicro.com>2011-10-09 12:54:25 +0100
committerMark Brown <broonie@opensource.wolfsonmicro.com>2011-10-10 10:26:48 +0100
commitb03622a80d2206c4179d6a41a0dc5cfbdfc853ee (patch)
tree7f0e02bbddfd3930e3aabe553d9efb4c423c47fa /drivers/base
parente42c5a9a4230c38ceba0a890b30a2d0dd9314bff (diff)
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>
Diffstat (limited to 'drivers/base')
-rw-r--r--drivers/base/regmap/regcache-rbtree.c11
1 files changed, 5 insertions, 6 deletions
diff --git a/drivers/base/regmap/regcache-rbtree.c b/drivers/base/regmap/regcache-rbtree.c
index 52511f95857a..e31498499b0f 100644
--- a/drivers/base/regmap/regcache-rbtree.c
+++ b/drivers/base/regmap/regcache-rbtree.c
@@ -304,7 +304,7 @@ static int regcache_rbtree_sync(struct regmap *map)
struct rb_node *node;
struct regcache_rbtree_node *rbnode;
unsigned int regtmp;
- unsigned int val, def;
+ unsigned int val;
int ret;
int i;
@@ -315,13 +315,12 @@ static int regcache_rbtree_sync(struct regmap *map)
regtmp = rbnode->base_reg + i;
val = regcache_rbtree_get_register(rbnode, i,
map->cache_word_size);
+
+ /* Is this the hardware default? If so skip. */
ret = regcache_lookup_reg(map, i);
- if (ret < 0)
- def = 0;
- else
- def = map->reg_defaults[ret].def;
- if (val == def)
+ if (ret > 0 && val == map->reg_defaults[ret].def)
continue;
+
map->cache_bypass = 1;
ret = _regmap_write(map, regtmp, val);
map->cache_bypass = 0;