Skip to content

Commit f298536

Browse files
committed
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>
1 parent d939fb9 commit f298536

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

drivers/base/regmap/regmap.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -698,6 +698,9 @@ static int _regmap_read(struct regmap *map, unsigned int reg,
698698
trace_regmap_reg_read(map->dev, reg, *val);
699699
}
700700

701+
if (ret == 0 && !map->cache_bypass)
702+
regcache_write(map, reg, *val);
703+
701704
return ret;
702705
}
703706

0 commit comments

Comments
 (0)