Commit 8817796b authored by Mark Brown's avatar Mark Brown

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: default avatarMark Brown <broonie@opensource.wolfsonmicro.com>
parent 0c7ed856
...@@ -189,6 +189,13 @@ int regcache_write(struct regmap *map, ...@@ -189,6 +189,13 @@ int regcache_write(struct regmap *map,
unsigned int reg, unsigned int value); unsigned int reg, unsigned int value);
int regcache_sync(struct regmap *map); int regcache_sync(struct regmap *map);
static inline const void *regcache_get_val_addr(struct regmap *map,
const void *base,
unsigned int idx)
{
return base + (map->cache_word_size * idx);
}
unsigned int regcache_get_val(struct regmap *map, const void *base, unsigned int regcache_get_val(struct regmap *map, const void *base,
unsigned int idx); unsigned int idx);
bool regcache_set_val(struct regmap *map, void *base, unsigned int idx, bool regcache_set_val(struct regmap *map, void *base, unsigned int idx,
......
...@@ -458,8 +458,8 @@ unsigned int regcache_get_val(struct regmap *map, const void *base, ...@@ -458,8 +458,8 @@ unsigned int regcache_get_val(struct regmap *map, const void *base,
/* Use device native format if possible */ /* Use device native format if possible */
if (map->format.parse_val) if (map->format.parse_val)
return map->format.parse_val(base + return map->format.parse_val(regcache_get_val_addr(map, base,
(map->cache_word_size * idx)); idx));
switch (map->cache_word_size) { switch (map->cache_word_size) {
case 1: { case 1: {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment