diff options
author | Mark Brown <broonie@kernel.org> | 2023-06-13 21:07:16 +0100 |
---|---|---|
committer | Mark Brown <broonie@kernel.org> | 2023-06-14 12:27:16 +0100 |
commit | eab5abdeb79f0f694c007c3a76a97902705c86f0 (patch) | |
tree | 20f51b050d920e0fdc32bb27ac78ee7ce7c27f4b /drivers/base | |
parent | b629c698eae745eb51b6d92395e2eee44bbf5f49 (diff) | |
download | linux-eab5abdeb79f0f694c007c3a76a97902705c86f0.tar.gz linux-eab5abdeb79f0f694c007c3a76a97902705c86f0.tar.bz2 linux-eab5abdeb79f0f694c007c3a76a97902705c86f0.zip |
regmap: Check for register readability before checking cache during read
Ensure that we don't return a spurious cache hit for unreadable registers
(eg, with the flat cache which doesn't understand sparseness) by checking
for readability before we do a cache lookup.
Signed-off-by: Mark Brown <broonie@kernel.org>
Link: https://lore.kernel.org/r/20230613-b4-regmap-check-readability-before-cache-v1-1-b144c0b01ed9@kernel.org
Signed-off-by: Mark Brown <broonie@kernel.org>
Diffstat (limited to 'drivers/base')
-rw-r--r-- | drivers/base/regmap/regmap.c | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/drivers/base/regmap/regmap.c b/drivers/base/regmap/regmap.c index 89a7f1c459c1..fad66b309ef9 100644 --- a/drivers/base/regmap/regmap.c +++ b/drivers/base/regmap/regmap.c @@ -2897,6 +2897,9 @@ static int _regmap_read(struct regmap *map, unsigned int reg, int ret; void *context = _regmap_map_get_context(map); + if (!regmap_readable(map, reg)) + return -EIO; + if (!map->cache_bypass) { ret = regcache_read(map, reg, val); if (ret == 0) @@ -2906,9 +2909,6 @@ static int _regmap_read(struct regmap *map, unsigned int reg, if (map->cache_only) return -EBUSY; - if (!regmap_readable(map, reg)) - return -EIO; - ret = map->reg_read(context, reg, val); if (ret == 0) { if (regmap_should_log(map)) |