[v2,1/2] regmap: cache: Return error in cache sync operations for REGCACHE_NONE

Message ID 20230313071812.13577-1-alexander.stein@ew.tq-group.com
State New
Headers
Series [v2,1/2] regmap: cache: Return error in cache sync operations for REGCACHE_NONE |

Commit Message

Alexander Stein March 13, 2023, 7:18 a.m. UTC
  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>
---
Changes in v2:
* Reworded the reasoning in the commit message
* Use WARN_ON to indicate there is an implementation error
* Return -EINVAL instead

 drivers/base/regmap/regcache.c | 6 ++++++
 1 file changed, 6 insertions(+)
  

Comments

Mark Brown March 13, 2023, 7:07 p.m. UTC | #1
On Mon, 13 Mar 2023 08:18:11 +0100, Alexander Stein wrote:
> 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.
> 
> 

Applied to

   https://git.kernel.org/pub/scm/linux/kernel/git/broonie/regmap.git for-next

Thanks!

[1/2] regmap: cache: Return error in cache sync operations for REGCACHE_NONE
      commit: fd883d79e4dcd2417c2b80756f22a2ff03b0f6e0
[2/2] regmap: cache: Fix return value
      commit: 24d80fde40c995b2e2faaf72034e12e60a416630

All being well this means that it will be integrated into the linux-next
tree (usually sometime in the next 24 hours) and sent to Linus during
the next merge window (or sooner if it is a bug fix), however if
problems are discovered then the patch may be dropped or reverted.

You may get further e-mails resulting from automated or manual testing
and review of the tree, please engage with people reporting problems and
send followup patches addressing any issues that are reported if needed.

If any updates are required or you are submitting further changes they
should be sent as incremental updates against current git, existing
patches will not be replaced.

Please add any relevant lists and maintainers to the CCs when replying
to this mail.

Thanks,
Mark
  

Patch

diff --git a/drivers/base/regmap/regcache.c b/drivers/base/regmap/regcache.c
index 362e043e26d86..8031007b4887d 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 (WARN_ON(map->cache_type == REGCACHE_NONE))
+		return -EINVAL;
+
 	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 (WARN_ON(map->cache_type == REGCACHE_NONE))
+		return -EINVAL;
+
 	BUG_ON(!map->cache_ops);
 
 	map->lock(map->lock_arg);