[PATCH v2 04/10] regmap: deduplicate fast_io checks

From: Peng Fan

Date: Fri Nov 13 2026 - 12:15:45 EST


From: Peng Fan <peng.fan@xxxxxxx>

__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 change intended.

Signed-off-by: Peng Fan <peng.fan@xxxxxxx>
---
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 327ae2ea9729..c123bae8bd66 100644
--- a/drivers/base/regmap/regmap.c
+++ b/drivers/base/regmap/regmap.c
@@ -682,6 +682,7 @@ struct regmap *__regmap_init(struct device *dev,
{
struct regmap *map;
enum regmap_endian reg_endian, val_endian;
+ bool fast_io;
int i, j;
int ret;

@@ -702,6 +703,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;
@@ -735,8 +738,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;
@@ -766,10 +768,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.56.0