diff options
author | Mark Brown <broonie@opensource.wolfsonmicro.com> | 2013-02-21 18:39:47 +0000 |
---|---|---|
committer | Mark Brown <broonie@opensource.wolfsonmicro.com> | 2013-03-04 10:30:28 +0800 |
commit | eb4cb76ff00e27858e5c80f69dbe8cc15364578c (patch) | |
tree | 3e8581964ce87f77fa881294aae3094cafd859a4 /drivers/base/regmap | |
parent | 8a819ff8abac9ad49f120c84cce01878b3d235c2 (diff) | |
download | linux-3.10-eb4cb76ff00e27858e5c80f69dbe8cc15364578c.tar.gz linux-3.10-eb4cb76ff00e27858e5c80f69dbe8cc15364578c.tar.bz2 linux-3.10-eb4cb76ff00e27858e5c80f69dbe8cc15364578c.zip |
regmap: cache: Store caches in native register format where possible
This allows the cached data to be sent directly to the device when
we sync it.
Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
Diffstat (limited to 'drivers/base/regmap')
-rw-r--r-- | drivers/base/regmap/regcache.c | 16 |
1 files changed, 14 insertions, 2 deletions
diff --git a/drivers/base/regmap/regcache.c b/drivers/base/regmap/regcache.c index 6948996d249..0f4fb8bc37e 100644 --- a/drivers/base/regmap/regcache.c +++ b/drivers/base/regmap/regcache.c @@ -45,8 +45,8 @@ static int regcache_hw_init(struct regmap *map) tmp_buf = kmalloc(map->cache_size_raw, GFP_KERNEL); if (!tmp_buf) return -EINVAL; - ret = regmap_bulk_read(map, 0, tmp_buf, - map->num_reg_defaults_raw); + ret = regmap_raw_read(map, 0, tmp_buf, + map->num_reg_defaults_raw); map->cache_bypass = cache_bypass; if (ret < 0) { kfree(tmp_buf); @@ -421,6 +421,13 @@ bool regcache_set_val(struct regmap *map, void *base, unsigned int idx, if (regcache_get_val(map, base, idx) == val) return true; + /* Use device native format if possible */ + if (map->format.format_val) { + map->format.format_val(base + (map->cache_word_size * idx), + val, 0); + return false; + } + switch (map->cache_word_size) { case 1: { u8 *cache = base; @@ -449,6 +456,11 @@ unsigned int regcache_get_val(struct regmap *map, const void *base, if (!base) return -EINVAL; + /* Use device native format if possible */ + if (map->format.parse_val) + return map->format.parse_val(base + + (map->cache_word_size * idx)); + switch (map->cache_word_size) { case 1: { const u8 *cache = base; |