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 <peng.fan@nxp.com>
Link: https://patch.msgid.link/20260924-regmap-lock-guard-v3-4-8a6127223c16@nxp.com
Signed-off-by: Mark Brown <broonie@kernel.org>
This commit is contained in:
Peng Fan 2026-09-24 14:30:55 +08:00 committed by Mark Brown
parent 555a1bd78b
commit 9999d5a07e
No known key found for this signature in database
GPG Key ID: 24D68B725D5487D0

View File

@ -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;
}