regmap: Cache single values read from the chip
authorMark Brown <broonie@opensource.wolfsonmicro.com>
Mon, 30 Apr 2012 20:25:05 +0000 (21:25 +0100)
committerMark Brown <broonie@opensource.wolfsonmicro.com>
Mon, 30 Apr 2012 21:57:10 +0000 (22:57 +0100)
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>
drivers/base/regmap/regmap.c

index 178989a8949eabb98f3610db4d27dad5007e73f6..3e551223f4dff9d0e870aae8c993948b090c8d49 100644 (file)
@@ -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;
 }
 
This page took 0.027876 seconds and 5 git commands to generate.