[PATCH] regmap: apply reg_base and reg_downshift for single register ops
From: Daniel Golle
Date: Fri Jan 27 2023 - 22:10:45 EST
reg_base and reg_downshift currently don't have any effect if used with
simple single register operations.
Fix that by taking them into account also for _reg_read, _reg_write and
_reg_update_bits (they may still be missing also in other place, eg.
page selection code).
Fixes: 0074f3f2b1e43d ("regmap: allow a defined reg_base to be added to every address")
Fixes: 86fc59ef818beb ("regmap: add configurable downshift for addresses")
Signed-off-by: Daniel Golle <daniel@xxxxxxxxxxxxxx>
---
drivers/base/regmap/regmap.c | 6 ++++++
1 file changed, 6 insertions(+)
diff --git a/drivers/base/regmap/regmap.c b/drivers/base/regmap/regmap.c
index d12d669157f24..7b8386ec21b8c 100644
--- a/drivers/base/regmap/regmap.c
+++ b/drivers/base/regmap/regmap.c
@@ -1986,6 +1986,8 @@ int _regmap_write(struct regmap *map, unsigned int reg,
}
}
+ reg += map->reg_base;
+ reg >>= map->format.reg_downshift;
ret = map->reg_write(context, reg, val);
if (ret == 0) {
if (regmap_should_log(map))
@@ -2879,6 +2881,8 @@ static int _regmap_read(struct regmap *map, unsigned int reg,
if (!regmap_readable(map, reg))
return -EIO;
+ reg += map->reg_base;
+ reg >>= map->format.reg_downshift;
ret = map->reg_read(context, reg, val);
if (ret == 0) {
if (regmap_should_log(map))
@@ -3231,6 +3235,8 @@ static int _regmap_update_bits(struct regmap *map, unsigned int reg,
*change = false;
if (regmap_volatile(map, reg) && map->reg_update_bits) {
+ reg += map->reg_base;
+ reg >>= map->format.reg_downshift;
ret = map->reg_update_bits(map->bus_context, reg, mask, val);
if (ret == 0 && change)
*change = true;
base-commit: e2f86c02fdc96ca29ced53221a3cbf50aa6f8b49
--
2.39.1