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>
This commit is contained in:
@@ -20,11 +20,10 @@ static int regcache_indexed_read(struct regmap *map, unsigned int reg,
|
|||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
ret = regcache_lookup_reg(map, reg);
|
ret = regcache_lookup_reg(map, reg);
|
||||||
if (ret < 0)
|
if (ret >= 0)
|
||||||
*value = 0;
|
|
||||||
else
|
|
||||||
*value = map->reg_defaults[ret].def;
|
*value = map->reg_defaults[ret].def;
|
||||||
return 0;
|
|
||||||
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int regcache_indexed_write(struct regmap *map, unsigned int reg,
|
static int regcache_indexed_write(struct regmap *map, unsigned int reg,
|
||||||
|
@@ -232,7 +232,6 @@ static int regcache_lzo_read(struct regmap *map,
|
|||||||
size_t blksize, tmp_dst_len;
|
size_t blksize, tmp_dst_len;
|
||||||
void *tmp_dst;
|
void *tmp_dst;
|
||||||
|
|
||||||
*value = 0;
|
|
||||||
/* index of the compressed lzo block */
|
/* index of the compressed lzo block */
|
||||||
blkindex = regcache_lzo_get_blkindex(map, reg);
|
blkindex = regcache_lzo_get_blkindex(map, reg);
|
||||||
/* register index within the decompressed block */
|
/* 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 */
|
/* restore the pointer and length of the compressed block */
|
||||||
lzo_block->dst = tmp_dst;
|
lzo_block->dst = tmp_dst;
|
||||||
lzo_block->dst_len = tmp_dst_len;
|
lzo_block->dst_len = tmp_dst_len;
|
||||||
return 0;
|
|
||||||
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int regcache_lzo_write(struct regmap *map,
|
static int regcache_lzo_write(struct regmap *map,
|
||||||
|
@@ -193,8 +193,7 @@ static int regcache_rbtree_read(struct regmap *map,
|
|||||||
*value = regcache_rbtree_get_register(rbnode, reg_tmp,
|
*value = regcache_rbtree_get_register(rbnode, reg_tmp,
|
||||||
map->cache_word_size);
|
map->cache_word_size);
|
||||||
} else {
|
} else {
|
||||||
/* uninitialized registers default to 0 */
|
return -ENOENT;
|
||||||
*value = 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
@@ -378,7 +378,7 @@ int regcache_lookup_reg(struct regmap *map, unsigned int reg)
|
|||||||
if (r)
|
if (r)
|
||||||
return r - map->reg_defaults;
|
return r - map->reg_defaults;
|
||||||
else
|
else
|
||||||
return -1;
|
return -ENOENT;
|
||||||
}
|
}
|
||||||
|
|
||||||
int regcache_insert_reg(struct regmap *map, unsigned int reg,
|
int regcache_insert_reg(struct regmap *map, unsigned int reg,
|
||||||
|
Reference in New Issue
Block a user