regmap: cache: Use regcache_get_value() to check if we updated
authorMark Brown <broonie@opensource.wolfsonmicro.com>
Thu, 21 Feb 2013 18:07:01 +0000 (18:07 +0000)
committerMark Brown <broonie@opensource.wolfsonmicro.com>
Mon, 4 Mar 2013 02:30:27 +0000 (10:30 +0800)
Factor things out a little.

Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
drivers/base/regmap/regcache.c

index f0a3db6ff9c2dd5a288dce309b6a3be0cc2f6a2c..6948996d249867eb9a9fb61618e6a44e2d4d13e0 100644 (file)
@@ -418,25 +418,22 @@ EXPORT_SYMBOL_GPL(regcache_cache_bypass);
 bool regcache_set_val(struct regmap *map, void *base, unsigned int idx,
                      unsigned int val)
 {
+       if (regcache_get_val(map, base, idx) == val)
+               return true;
+
        switch (map->cache_word_size) {
        case 1: {
                u8 *cache = base;
-               if (cache[idx] == val)
-                       return true;
                cache[idx] = val;
                break;
        }
        case 2: {
                u16 *cache = base;
-               if (cache[idx] == val)
-                       return true;
                cache[idx] = val;
                break;
        }
        case 4: {
                u32 *cache = base;
-               if (cache[idx] == val)
-                       return true;
                cache[idx] = val;
                break;
        }