From 9999d5a07ee037d4653c7231884b0a1e45be801c Mon Sep 17 00:00:00 2001 From: Peng Fan Date: Thu, 24 Sep 2026 14:30:55 +0800 Subject: [PATCH] regmap: debugfs: use the regmap scoped lock guard Convert the open-coded map->lock()/map->unlock() users in the debugfs cache_only and cache_bypass write handlers to the regmap scoped guard. regmap_cache_bypass_write_file() uses guard(regmap)() since the locked region runs to the return. regmap_cache_only_write_file() uses scoped_guard(regmap, ...) because the subsequent regcache_sync() must run with the lock released - it takes the regmap lock itself - so it stays outside the guarded scope exactly as before. No functional change. Assisted-by: LLM Signed-off-by: Peng Fan Link: https://patch.msgid.link/20260924-regmap-lock-guard-v3-4-8a6127223c16@nxp.com Signed-off-by: Mark Brown --- drivers/base/regmap/regmap-debugfs.c | 24 ++++++++++-------------- 1 file changed, 10 insertions(+), 14 deletions(-) diff --git a/drivers/base/regmap/regmap-debugfs.c b/drivers/base/regmap/regmap-debugfs.c index 18f1c60749fe..ec207548a6bb 100644 --- a/drivers/base/regmap/regmap-debugfs.c +++ b/drivers/base/regmap/regmap-debugfs.c @@ -471,18 +471,16 @@ static ssize_t regmap_cache_only_write_file(struct file *file, if (err) return count; - map->lock(map->lock_arg); - - if (new_val && !map->cache_only) { - dev_warn(map->dev, "debugfs cache_only=Y forced\n"); - add_taint(TAINT_USER, LOCKDEP_STILL_OK); - } else if (!new_val && map->cache_only) { - dev_warn(map->dev, "debugfs cache_only=N forced: syncing cache\n"); - require_sync = true; + scoped_guard(regmap, map) { + if (new_val && !map->cache_only) { + dev_warn(map->dev, "debugfs cache_only=Y forced\n"); + add_taint(TAINT_USER, LOCKDEP_STILL_OK); + } else if (!new_val && map->cache_only) { + dev_warn(map->dev, "debugfs cache_only=N forced: syncing cache\n"); + require_sync = true; + } + map->cache_only = new_val; } - map->cache_only = new_val; - - map->unlock(map->lock_arg); if (require_sync) { err = regcache_sync(map); @@ -513,7 +511,7 @@ static ssize_t regmap_cache_bypass_write_file(struct file *file, if (err) return count; - map->lock(map->lock_arg); + guard(regmap)(map); if (new_val && !map->cache_bypass) { dev_warn(map->dev, "debugfs cache_bypass=Y forced\n"); @@ -523,8 +521,6 @@ static ssize_t regmap_cache_bypass_write_file(struct file *file, } map->cache_bypass = new_val; - map->unlock(map->lock_arg); - return count; }