]> git.proxmox.com Git - mirror_ubuntu-eoan-kernel.git/commitdiff
regmap: cache: Provide a get address of value operation
authorMark Brown <broonie@opensource.wolfsonmicro.com>
Wed, 13 Mar 2013 19:29:36 +0000 (19:29 +0000)
committerMark Brown <broonie@opensource.wolfsonmicro.com>
Tue, 26 Mar 2013 21:38:16 +0000 (21:38 +0000)
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>
drivers/base/regmap/internal.h
drivers/base/regmap/regcache.c

index 6d409350f50aa52b2b19e0113fa69c4998bffc9f..95d46a5ea7e706296da635025697c1ac6ed15b3b 100644 (file)
@@ -189,6 +189,13 @@ int regcache_write(struct regmap *map,
                        unsigned int reg, unsigned int value);
 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 idx);
 bool regcache_set_val(struct regmap *map, void *base, unsigned int idx,
index 0f4fb8bc37e5d91c05732bc53f8d55236d9f0ee9..229c804e409eac7792f8262b9556da0e91a294c7 100644 (file)
@@ -458,8 +458,8 @@ unsigned int regcache_get_val(struct regmap *map, const void *base,
 
        /* Use device native format if possible */
        if (map->format.parse_val)
-               return map->format.parse_val(base +
-                                            (map->cache_word_size * idx));
+               return map->format.parse_val(regcache_get_val_addr(map, base,
+                                                                  idx));
 
        switch (map->cache_word_size) {
        case 1: {