Commit 6e6ace00a045251bd172b9b9c2379857bbff3dc7

Authored by Mark Brown
1 parent f094fea68f

regmap: Return a sensible error code if we fail to read the cache

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>

Showing 4 changed files with 7 additions and 9 deletions Side-by-side Diff

drivers/base/regmap/regcache-indexed.c
... ... @@ -20,11 +20,10 @@
20 20 int ret;
21 21  
22 22 ret = regcache_lookup_reg(map, reg);
23   - if (ret < 0)
24   - *value = 0;
25   - else
  23 + if (ret >= 0)
26 24 *value = map->reg_defaults[ret].def;
27   - return 0;
  25 +
  26 + return ret;
28 27 }
29 28  
30 29 static int regcache_indexed_write(struct regmap *map, unsigned int reg,
drivers/base/regmap/regcache-lzo.c
... ... @@ -232,7 +232,6 @@
232 232 size_t blksize, tmp_dst_len;
233 233 void *tmp_dst;
234 234  
235   - *value = 0;
236 235 /* index of the compressed lzo block */
237 236 blkindex = regcache_lzo_get_blkindex(map, reg);
238 237 /* register index within the decompressed block */
... ... @@ -261,7 +260,8 @@
261 260 /* restore the pointer and length of the compressed block */
262 261 lzo_block->dst = tmp_dst;
263 262 lzo_block->dst_len = tmp_dst_len;
264   - return 0;
  263 +
  264 + return ret;
265 265 }
266 266  
267 267 static int regcache_lzo_write(struct regmap *map,
drivers/base/regmap/regcache-rbtree.c
... ... @@ -193,8 +193,7 @@
193 193 *value = regcache_rbtree_get_register(rbnode, reg_tmp,
194 194 map->cache_word_size);
195 195 } else {
196   - /* uninitialized registers default to 0 */
197   - *value = 0;
  196 + return -ENOENT;
198 197 }
199 198  
200 199 return 0;
drivers/base/regmap/regcache.c
... ... @@ -378,7 +378,7 @@
378 378 if (r)
379 379 return r - map->reg_defaults;
380 380 else
381   - return -1;
  381 + return -ENOENT;
382 382 }
383 383  
384 384 int regcache_insert_reg(struct regmap *map, unsigned int reg,