summaryrefslogtreecommitdiff
path: root/drivers
diff options
context:
space:
mode:
authorMark Brown <broonie@opensource.wolfsonmicro.com>2012-05-01 00:25:05 +0400
committerMark Brown <broonie@opensource.wolfsonmicro.com>2012-05-01 01:57:10 +0400
commitf298536728d02c19f11bda8d712ff61d767bab32 (patch)
tree7666d562d16a143a9549d0a6feb66b558e22fcbb /drivers
parentd939fb9a78b4743bc4bc3cc415894ed42050c5cc (diff)
downloadlinux-f298536728d02c19f11bda8d712ff61d767bab32.tar.xz
regmap: Cache single values read from the chip
If we don't have a cached value for a register and we can cache it then when we do a read a value we should add it to the cache to save rereading it later on. Do this for single register reads, for block reads the code would be a little more complex and this covers most practical usage. Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
Diffstat (limited to 'drivers')
-rw-r--r--drivers/base/regmap/regmap.c3
1 files changed, 3 insertions, 0 deletions
diff --git a/drivers/base/regmap/regmap.c b/drivers/base/regmap/regmap.c
index 178989a8949e..3e551223f4df 100644
--- a/drivers/base/regmap/regmap.c
+++ b/drivers/base/regmap/regmap.c
@@ -698,6 +698,9 @@ static int _regmap_read(struct regmap *map, unsigned int reg,
trace_regmap_reg_read(map->dev, reg, *val);
}
+ if (ret == 0 && !map->cache_bypass)
+ regcache_write(map, reg, *val);
+
return ret;
}