]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
regmap: reject volatile update_bits() in cache-only mode
authorbui duc phuc <phucduc.bui@gmail.com>
Thu, 28 May 2026 05:32:04 +0000 (12:32 +0700)
committerMark Brown <broonie@kernel.org>
Thu, 28 May 2026 14:15:46 +0000 (15:15 +0100)
Prevent _regmap_update_bits() from accessing hardware when the register
map is in cache-only mode.

Unlike regmap_raw_read() and _regmap_read(), the volatile
_regmap_update_bits() fast path bypasses the cache_only check. This can
result in unexpected hardware accesses while the device is suspended.

Return -EBUSY to ensure behavior is consistent with other cache-only
access paths.

Signed-off-by: bui duc phuc <phucduc.bui@gmail.com>
Link: https://patch.msgid.link/20260528053204.46783-1-phucduc.bui@gmail.com
Signed-off-by: Mark Brown <broonie@kernel.org>
drivers/base/regmap/regmap.c

index b2b26f07f4e3f7c0d345eba5f17fb13723dbd746..e6e022b0263753fcf594d045bc9e49d429f54cc4 100644 (file)
@@ -3257,6 +3257,9 @@ static int _regmap_update_bits(struct regmap *map, unsigned int reg,
                *change = false;
 
        if (regmap_volatile(map, reg) && map->reg_update_bits) {
+               if (map->cache_only)
+                       return -EBUSY;
+
                reg = regmap_reg_addr(map, reg);
                ret = map->reg_update_bits(map->bus_context, reg, mask, val);
                if (ret == 0 && change)