Commit 697c3892 authored by Daniel Golle's avatar Daniel Golle Committed by Mark Brown

regmap: apply reg_base and reg_downshift for single register ops

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.

Fixes: 0074f3f2 ("regmap: allow a defined reg_base to be added to every address")
Fixes: 86fc59ef ("regmap: add configurable downshift for addresses")
Signed-off-by: default avatarDaniel Golle <daniel@makrotopia.org>
Tested-by: default avatarColin Foster <colin.foster@in-advantage.com>
Link: https://lore.kernel.org/r/Y9clyVS3tQEHlUhA@makrotopia.orgSigned-off-by: default avatarMark Brown <broonie@kernel.org>
parent 1b929c02
......@@ -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;
reg >>= map->format.reg_downshift;
ret = map->reg_update_bits(map->bus_context, reg, mask, val);
if (ret == 0 && change)
*change = true;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment