From: "Peng Fan (OSS)" <peng.fan@oss.nxp.com>
To: Mark Brown <broonie@kernel.org>,
Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
"Rafael J. Wysocki" <rafael@kernel.org>,
Danilo Krummrich <dakr@kernel.org>
Cc: linux-kernel@vger.kernel.org, driver-core@lists.linux.dev,
Peng Fan <peng.fan@nxp.com>
Subject: [PATCH RFC 4/4] regmap: debugfs: use the regmap scoped lock guard
Date: Mon, 21 Sep 2026 14:03:36 +0800 [thread overview]
Message-ID: <20260921-regmap-lock-guard-v1-4-cdbd97b46074@nxp.com> (raw)
In-Reply-To: <20260921-regmap-lock-guard-v1-0-cdbd97b46074@nxp.com>
From: Peng Fan <peng.fan@nxp.com>
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: Claude:claude-opus-4.8
Signed-off-by: Peng Fan <peng.fan@nxp.com>
---
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;
}
--
2.51.0
prev parent reply other threads:[~2026-09-21 6:06 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-09-21 6:03 [PATCH RFC 0/4] regmap: convert map->lock/unlock users to a scoped guard Peng Fan (OSS)
2026-09-21 6:03 ` [PATCH RFC 1/4] regmap: convert lock/unlock " Peng Fan (OSS)
2026-09-21 6:03 ` [PATCH RFC 2/4] regcache: use the regmap scoped lock guard Peng Fan (OSS)
2026-09-21 9:19 ` Mark Brown
2026-09-22 0:32 ` Peng Fan
2026-09-21 6:03 ` [PATCH RFC 3/4] regcache: rbtree: " Peng Fan (OSS)
2026-09-21 6:03 ` Peng Fan (OSS) [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20260921-regmap-lock-guard-v1-4-cdbd97b46074@nxp.com \
--to=peng.fan@oss.nxp.com \
--cc=broonie@kernel.org \
--cc=dakr@kernel.org \
--cc=driver-core@lists.linux.dev \
--cc=gregkh@linuxfoundation.org \
--cc=linux-kernel@vger.kernel.org \
--cc=peng.fan@nxp.com \
--cc=rafael@kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®