Hi Greg,
On Tue, Mar 07, 2023 at 05:53:02PM +0100, Greg Kroah-Hartman wrote:
From: Daniel Golle daniel@makrotopia.org
[ Upstream commit 697c3892d825fb78f42ec8e53bed065dd728db3e ]
reg_base and reg_downshift currently don't have any effect if used with a regmap_bus or regmap_config which only offers single register operations (ie. reg_read, reg_write and optionally reg_update_bits).
Fix that and take them into account also for regmap_bus with only reg_read and read_write operations by applying reg_base and reg_downshift in _regmap_bus_reg_write, _regmap_bus_reg_read.
Also apply reg_base and reg_downshift in _regmap_update_bits, but only in case the operation is carried out with a reg_update_bits call defined in either regmap_bus or regmap_config.
I was waiting for this one to be back-ported. Anyone else can disagree with me, but I'm on the fence as to whether it should go back to stable branches.
The only user of reg_base and reg_downshift in 6.1 / 6.2 is drivers/mfd/ocelot-spi.c, and these don't use reg_read() or reg_write() so are unaffected by this fix.
On one hand, it isn't fixing any existing 'bugs'. On the other hand, the documentation I wrote was confusing / misleading, and people developing against the stable kernels might get behavior that they didn't expect. Daniel had the misfortune of experiencing this.
Again, I'm on the fence - I just want to make sure the scope is understood.
Thanks!
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@makrotopia.org Tested-by: Colin Foster colin.foster@in-advantage.com Link: https://lore.kernel.org/r/Y9clyVS3tQEHlUhA@makrotopia.org Signed-off-by: Mark Brown broonie@kernel.org Signed-off-by: Sasha Levin sashal@kernel.org
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..d2a54eb0efd9b 100644 --- a/drivers/base/regmap/regmap.c +++ b/drivers/base/regmap/regmap.c @@ -1942,6 +1942,8 @@ static int _regmap_bus_reg_write(void *context, unsigned int reg, { struct regmap *map = context;
- reg += map->reg_base;
- reg >>= map->format.reg_downshift; return map->bus->reg_write(map->bus_context, reg, val);
} @@ -2840,6 +2842,8 @@ static int _regmap_bus_reg_read(void *context, unsigned int reg, { struct regmap *map = context;
- reg += map->reg_base;
- reg >>= map->format.reg_downshift; return map->bus->reg_read(map->bus_context, reg, val);
} @@ -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;
ret = map->reg_update_bits(map->bus_context, reg, mask, val); if (ret == 0 && change) *change = true;reg >>= map->format.reg_downshift;
-- 2.39.2