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>,
Johan Hovold <johan@kernel.org>,
Lucas Tanure <tanureal@opensource.cirrus.com>
Cc: linux-kernel@vger.kernel.org, driver-core@lists.linux.dev,
Peng Fan <peng.fan@nxp.com>
Subject: [PATCH 3/9] regmap: deduplicate fast_io checks
Date: Tue, 10 Nov 2026 16:25:27 +0800 [thread overview]
Message-ID: <20261110-regmap-improve-v1-3-3a76b6c10ec6@nxp.com> (raw)
In-Reply-To: <20261110-regmap-improve-v1-0-3a76b6c10ec6@nxp.com>
From: Peng Fan <peng.fan@nxp.com>
__regmap_init() evaluates "(bus && bus->fast_io) || config->fast_io" in
two places to decide whether the map has to be usable from atomic
context. Compute it once into a local fast_io variable.
No functional changes.
Signed-off-by: Peng Fan <peng.fan@nxp.com>
---
drivers/base/regmap/regmap.c | 11 +++++------
1 file changed, 5 insertions(+), 6 deletions(-)
diff --git a/drivers/base/regmap/regmap.c b/drivers/base/regmap/regmap.c
index 83f1f5942135..dff6511ab50e 100644
--- a/drivers/base/regmap/regmap.c
+++ b/drivers/base/regmap/regmap.c
@@ -681,6 +681,7 @@ struct regmap *__regmap_init(struct device *dev,
const char *lock_name)
{
struct regmap *map;
+ bool fast_io;
int ret = -EINVAL;
enum regmap_endian reg_endian, val_endian;
int i, j;
@@ -700,6 +701,8 @@ struct regmap *__regmap_init(struct device *dev,
ret = -EINVAL; /* Later error paths rely on this */
+ fast_io = (bus && bus->fast_io) || config->fast_io;
+
if (config->disable_locking) {
map->lock = map->unlock = regmap_lock_unlock_none;
map->can_sleep = config->can_sleep;
@@ -733,8 +736,7 @@ struct regmap *__regmap_init(struct device *dev,
map->lock_arg = map;
} else {
- if ((bus && bus->fast_io) ||
- config->fast_io) {
+ if (fast_io) {
if (config->use_raw_spinlock) {
raw_spin_lock_init(&map->raw_spinlock);
map->lock = regmap_lock_raw_spinlock;
@@ -764,10 +766,7 @@ struct regmap *__regmap_init(struct device *dev,
* When we write in fast-paths with regmap_bulk_write() don't allocate
* scratch buffers with sleeping allocations.
*/
- if ((bus && bus->fast_io) || config->fast_io)
- map->alloc_flags = GFP_ATOMIC;
- else
- map->alloc_flags = GFP_KERNEL;
+ map->alloc_flags = fast_io ? GFP_ATOMIC : GFP_KERNEL;
map->reg_base = config->reg_base;
map->reg_shift = config->pad_bits % 8;
--
2.51.0
next prev parent reply other threads:[~2026-11-10 8:29 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-10 8:25 [PATCH 0/9] regmap: clean up and improve __regmap_init() Peng Fan (OSS)
2026-11-10 8:25 ` [PATCH 1/9] regmap-i2c: keep bus raw write limit when applying read quirk Peng Fan (OSS)
2026-11-10 8:25 ` [PATCH 2/9] regmap-i2c: avoid underflow when applying write length quirk Peng Fan (OSS)
2026-11-10 8:25 ` Peng Fan (OSS) [this message]
2026-11-10 8:25 ` [PATCH 4/9] regmap: factor out regmap_set_lock() Peng Fan (OSS)
2026-11-10 8:25 ` [PATCH 5/9] regmap: factor out regmap_init_ranges() Peng Fan (OSS)
2026-11-10 8:25 ` [PATCH 6/9] regmap: factor out format initialisation into helpers Peng Fan (OSS)
2026-11-10 8:25 ` [PATCH 7/9] regmap: drop regmap_bus::free_on_exit Peng Fan (OSS)
2026-11-10 8:25 ` [PATCH 8/9] regmap: use cleanup API in __regmap_init() Peng Fan (OSS)
2026-11-10 8:25 ` [PATCH 9/9] regmap: kunit: add test for regmap_bus::init_limits Peng Fan (OSS)
2026-11-10 11:47 ` [PATCH 0/9] regmap: clean up and improve __regmap_init() Peng Fan
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=20261110-regmap-improve-v1-3-3a76b6c10ec6@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=johan@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=peng.fan@nxp.com \
--cc=rafael@kernel.org \
--cc=tanureal@opensource.cirrus.com \
/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®