mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/herbert/cryptodev-2.6.git
synced 2026-04-27 03:49:57 -04:00
regmap: Factor out single value register syncing
In order to support sparse caches that don't store data in raw format factor out the parts of the raw block sync implementation that deal with writing a single register via _regmap_write(). Signed-off-by: Mark Brown <broonie@kernel.org> Link: https://lore.kernel.org/r/20230325-regcache-maple-v3-1-23e271f93dc7@kernel.org Signed-off-by: Mark Brown <broonie@kernel.org>
This commit is contained in:
@@ -677,6 +677,30 @@ static bool regcache_reg_present(unsigned long *cache_present, unsigned int idx)
|
||||
return test_bit(idx, cache_present);
|
||||
}
|
||||
|
||||
int regcache_sync_val(struct regmap *map, unsigned int reg, unsigned int val)
|
||||
{
|
||||
int ret;
|
||||
|
||||
if (!regcache_reg_needs_sync(map, reg, val))
|
||||
return 0;
|
||||
|
||||
map->cache_bypass = true;
|
||||
|
||||
ret = _regmap_write(map, reg, val);
|
||||
|
||||
map->cache_bypass = false;
|
||||
|
||||
if (ret != 0) {
|
||||
dev_err(map->dev, "Unable to sync register %#x. %d\n",
|
||||
reg, ret);
|
||||
return ret;
|
||||
}
|
||||
dev_dbg(map->dev, "Synced register %#x, value %#x\n",
|
||||
reg, val);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int regcache_sync_block_single(struct regmap *map, void *block,
|
||||
unsigned long *cache_present,
|
||||
unsigned int block_base,
|
||||
@@ -693,21 +717,9 @@ static int regcache_sync_block_single(struct regmap *map, void *block,
|
||||
continue;
|
||||
|
||||
val = regcache_get_val(map, block, i);
|
||||
if (!regcache_reg_needs_sync(map, regtmp, val))
|
||||
continue;
|
||||
|
||||
map->cache_bypass = true;
|
||||
|
||||
ret = _regmap_write(map, regtmp, val);
|
||||
|
||||
map->cache_bypass = false;
|
||||
if (ret != 0) {
|
||||
dev_err(map->dev, "Unable to sync register %#x. %d\n",
|
||||
regtmp, ret);
|
||||
ret = regcache_sync_val(map, regtmp, val);
|
||||
if (ret != 0)
|
||||
return ret;
|
||||
}
|
||||
dev_dbg(map->dev, "Synced register %#x, value %#x\n",
|
||||
regtmp, val);
|
||||
}
|
||||
|
||||
return 0;
|
||||
|
||||
Reference in New Issue
Block a user