]> git.kernelconcepts.de Git - karo-tx-linux.git/commitdiff
regmap: Return a sensible error code if we fail to read the cache
authorMark Brown <broonie@opensource.wolfsonmicro.com>
Sun, 9 Oct 2011 12:23:31 +0000 (13:23 +0100)
committerMark Brown <broonie@opensource.wolfsonmicro.com>
Mon, 10 Oct 2011 09:24:03 +0000 (10:24 +0100)
If a register isn't cached then let callers know that so they can fall
back or error handle appropriately.

Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
Acked-by: Dimitris Papastamos <dp@opensource.wolfsonmicro.com>
drivers/base/regmap/regcache-indexed.c
drivers/base/regmap/regcache-lzo.c
drivers/base/regmap/regcache-rbtree.c
drivers/base/regmap/regcache.c

index 2e10bb13bfc496425e33976be992648a8201ca8e..507731ad8ec1e95a591faf5e6854fd12d098a7c9 100644 (file)
@@ -20,11 +20,10 @@ static int regcache_indexed_read(struct regmap *map, unsigned int reg,
        int ret;
 
        ret = regcache_lookup_reg(map, reg);
-       if (ret < 0)
-               *value = 0;
-       else
+       if (ret >= 0)
                *value = map->reg_defaults[ret].def;
-       return 0;
+
+       return ret;
 }
 
 static int regcache_indexed_write(struct regmap *map, unsigned int reg,
index ad6af925f56cca42e73fdf1fffef8bb415679a7f..066aeece3626265610d17f25785dd2dd1f6ebc5f 100644 (file)
@@ -232,7 +232,6 @@ static int regcache_lzo_read(struct regmap *map,
        size_t blksize, tmp_dst_len;
        void *tmp_dst;
 
-       *value = 0;
        /* index of the compressed lzo block */
        blkindex = regcache_lzo_get_blkindex(map, reg);
        /* register index within the decompressed block */
@@ -261,7 +260,8 @@ static int regcache_lzo_read(struct regmap *map,
        /* restore the pointer and length of the compressed block */
        lzo_block->dst = tmp_dst;
        lzo_block->dst_len = tmp_dst_len;
-       return 0;
+
+       return ret;
 }
 
 static int regcache_lzo_write(struct regmap *map,
index 40f23dd8478c48200e0c668bf47239188ad25916..887dbce63aff8704cd09fcaf32ccf3dc641b730b 100644 (file)
@@ -193,8 +193,7 @@ static int regcache_rbtree_read(struct regmap *map,
                *value = regcache_rbtree_get_register(rbnode, reg_tmp,
                                                      map->cache_word_size);
        } else {
-               /* uninitialized registers default to 0 */
-               *value = 0;
+               return -ENOENT;
        }
 
        return 0;
index c5379c86de883b0239aa0613aefe99964b1a7fc5..409abd282c6c90e9684719b8522002b1d1f4acf6 100644 (file)
@@ -378,7 +378,7 @@ int regcache_lookup_reg(struct regmap *map, unsigned int reg)
        if (r)
                return r - map->reg_defaults;
        else
-               return -1;
+               return -ENOENT;
 }
 
 int regcache_insert_reg(struct regmap *map, unsigned int reg,