diff options
author | Mark Brown <broonie@opensource.wolfsonmicro.com> | 2013-03-13 15:29:36 -0400 |
---|---|---|
committer | Mark Brown <broonie@opensource.wolfsonmicro.com> | 2013-03-26 17:38:16 -0400 |
commit | 8817796b75c8847d63d6d4523c79c24b47748a05 (patch) | |
tree | afa323b0fc93ec618da94bc54b40c2047c8a422c /drivers/base | |
parent | 0c7ed8563a0282c032936ae1c667498d59691593 (diff) |
regmap: cache: Provide a get address of value operation
Provide a helper to do the size based index into a block of registers and
use it when reading a value.
Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
Diffstat (limited to 'drivers/base')
-rw-r--r-- | drivers/base/regmap/internal.h | 7 | ||||
-rw-r--r-- | drivers/base/regmap/regcache.c | 4 |
2 files changed, 9 insertions, 2 deletions
diff --git a/drivers/base/regmap/internal.h b/drivers/base/regmap/internal.h index 6d409350f50a..95d46a5ea7e7 100644 --- a/drivers/base/regmap/internal.h +++ b/drivers/base/regmap/internal.h | |||
@@ -189,6 +189,13 @@ int regcache_write(struct regmap *map, | |||
189 | unsigned int reg, unsigned int value); | 189 | unsigned int reg, unsigned int value); |
190 | int regcache_sync(struct regmap *map); | 190 | int regcache_sync(struct regmap *map); |
191 | 191 | ||
192 | static inline const void *regcache_get_val_addr(struct regmap *map, | ||
193 | const void *base, | ||
194 | unsigned int idx) | ||
195 | { | ||
196 | return base + (map->cache_word_size * idx); | ||
197 | } | ||
198 | |||
192 | unsigned int regcache_get_val(struct regmap *map, const void *base, | 199 | unsigned int regcache_get_val(struct regmap *map, const void *base, |
193 | unsigned int idx); | 200 | unsigned int idx); |
194 | bool regcache_set_val(struct regmap *map, void *base, unsigned int idx, | 201 | bool regcache_set_val(struct regmap *map, void *base, unsigned int idx, |
diff --git a/drivers/base/regmap/regcache.c b/drivers/base/regmap/regcache.c index 0f4fb8bc37e5..229c804e409e 100644 --- a/drivers/base/regmap/regcache.c +++ b/drivers/base/regmap/regcache.c | |||
@@ -458,8 +458,8 @@ unsigned int regcache_get_val(struct regmap *map, const void *base, | |||
458 | 458 | ||
459 | /* Use device native format if possible */ | 459 | /* Use device native format if possible */ |
460 | if (map->format.parse_val) | 460 | if (map->format.parse_val) |
461 | return map->format.parse_val(base + | 461 | return map->format.parse_val(regcache_get_val_addr(map, base, |
462 | (map->cache_word_size * idx)); | 462 | idx)); |
463 | 463 | ||
464 | switch (map->cache_word_size) { | 464 | switch (map->cache_word_size) { |
465 | case 1: { | 465 | case 1: { |