]> git.itanic.dy.fi Git - linux-stable/commitdiff
regmap: cache: Return error in cache sync operations for REGCACHE_NONE
authorAlexander Stein <alexander.stein@ew.tq-group.com>
Mon, 13 Mar 2023 07:18:11 +0000 (08:18 +0100)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Tue, 30 May 2023 11:38:34 +0000 (12:38 +0100)
[ Upstream commit fd883d79e4dcd2417c2b80756f22a2ff03b0f6e0 ]

There is no sense in doing a cache sync on REGCACHE_NONE regmaps.
Instead of panicking the kernel due to missing cache_ops, return an error
to client driver.

Signed-off-by: Alexander Stein <alexander.stein@ew.tq-group.com>
Link: https://lore.kernel.org/r/20230313071812.13577-1-alexander.stein@ew.tq-group.com
Signed-off-by: Mark Brown <broonie@kernel.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
drivers/base/regmap/regcache.c

index 773560348337fed60b363ee8f40e341fcc2044b7..b78e4b6e2c9dac25cbd29137ef466a1040b80707 100644 (file)
@@ -347,6 +347,9 @@ int regcache_sync(struct regmap *map)
        const char *name;
        bool bypass;
 
+       if (WARN_ON(map->cache_type == REGCACHE_NONE))
+               return -EINVAL;
+
        BUG_ON(!map->cache_ops);
 
        map->lock(map->lock_arg);
@@ -416,6 +419,9 @@ int regcache_sync_region(struct regmap *map, unsigned int min,
        const char *name;
        bool bypass;
 
+       if (WARN_ON(map->cache_type == REGCACHE_NONE))
+               return -EINVAL;
+
        BUG_ON(!map->cache_ops);
 
        map->lock(map->lock_arg);