[PATCH 1/2] regmap: cache: Do not panic for REGCACHE_NONE regmap

From: Alexander Stein
Date: Fri Mar 10 2023 - 02:39:32 EST


Most regcache operations do check for REGCACHE_NONE, before ensuring
doing BUG_ON(!map->cache_ops). The missing regcache_sync* functions
panic on REGCACHE_NONE regmaps instead. Add an early return for non-cached
ones.

Signed-off-by: Alexander Stein <alexander.stein@xxxxxxxxxxxxxxx>
---
drivers/base/regmap/regcache.c | 6 ++++++
1 file changed, 6 insertions(+)

diff --git a/drivers/base/regmap/regcache.c b/drivers/base/regmap/regcache.c
index 362e043e26d8..b61763dbfc68 100644
--- a/drivers/base/regmap/regcache.c
+++ b/drivers/base/regmap/regcache.c
@@ -349,6 +349,9 @@ int regcache_sync(struct regmap *map)
const char *name;
bool bypass;

+ if (map->cache_type == REGCACHE_NONE)
+ return 0;
+
BUG_ON(!map->cache_ops);

map->lock(map->lock_arg);
@@ -418,6 +421,9 @@ int regcache_sync_region(struct regmap *map, unsigned int min,
const char *name;
bool bypass;

+ if (map->cache_type == REGCACHE_NONE)
+ return 0;
+
BUG_ON(!map->cache_ops);

map->lock(map->lock_arg);
--
2.34.1