Skip to content

Commit 6e6ace0

Browse files
committed
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>
1 parent f094fea commit 6e6ace0

4 files changed

Lines changed: 7 additions & 9 deletions

File tree

‎drivers/base/regmap/regcache-indexed.c‎

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,11 +20,10 @@ static int regcache_indexed_read(struct regmap *map, unsigned int reg,
2020
int ret;
2121

2222
ret = regcache_lookup_reg(map, reg);
23-
if (ret < 0)
24-
*value = 0;
25-
else
23+
if (ret >= 0)
2624
*value = map->reg_defaults[ret].def;
27-
return 0;
25+
26+
return ret;
2827
}
2928

3029
static int regcache_indexed_write(struct regmap *map, unsigned int reg,

‎drivers/base/regmap/regcache-lzo.c‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -232,7 +232,6 @@ static int regcache_lzo_read(struct regmap *map,
232232
size_t blksize, tmp_dst_len;
233233
void *tmp_dst;
234234

235-
*value = 0;
236235
/* index of the compressed lzo block */
237236
blkindex = regcache_lzo_get_blkindex(map, reg);
238237
/* register index within the decompressed block */
@@ -261,7 +260,8 @@ static int regcache_lzo_read(struct regmap *map,
261260
/* restore the pointer and length of the compressed block */
262261
lzo_block->dst = tmp_dst;
263262
lzo_block->dst_len = tmp_dst_len;
264-
return 0;
263+
264+
return ret;
265265
}
266266

267267
static int regcache_lzo_write(struct regmap *map,

‎drivers/base/regmap/regcache-rbtree.c‎

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -193,8 +193,7 @@ static int regcache_rbtree_read(struct regmap *map,
193193
*value = regcache_rbtree_get_register(rbnode, reg_tmp,
194194
map->cache_word_size);
195195
} else {
196-
/* uninitialized registers default to 0 */
197-
*value = 0;
196+
return -ENOENT;
198197
}
199198

200199
return 0;

‎drivers/base/regmap/regcache.c‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -378,7 +378,7 @@ int regcache_lookup_reg(struct regmap *map, unsigned int reg)
378378
if (r)
379379
return r - map->reg_defaults;
380380
else
381-
return -1;
381+
return -ENOENT;
382382
}
383383

384384
int regcache_insert_reg(struct regmap *map, unsigned int reg,

0 commit comments

Comments
 (0)