Skip to content

Commit 697c389

Browse files
dangowrtbroonie
authored andcommitted
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: 0074f3f ("regmap: allow a defined reg_base to be added to every address") Fixes: 86fc59e ("regmap: add configurable downshift for addresses") Signed-off-by: Daniel Golle <[email protected]> Tested-by: Colin Foster <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Mark Brown <[email protected]>
1 parent 1b929c0 commit 697c389

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

drivers/base/regmap/regmap.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1942,6 +1942,8 @@ static int _regmap_bus_reg_write(void *context, unsigned int reg,
19421942
{
19431943
struct regmap *map = context;
19441944

1945+
reg += map->reg_base;
1946+
reg >>= map->format.reg_downshift;
19451947
return map->bus->reg_write(map->bus_context, reg, val);
19461948
}
19471949

@@ -2840,6 +2842,8 @@ static int _regmap_bus_reg_read(void *context, unsigned int reg,
28402842
{
28412843
struct regmap *map = context;
28422844

2845+
reg += map->reg_base;
2846+
reg >>= map->format.reg_downshift;
28432847
return map->bus->reg_read(map->bus_context, reg, val);
28442848
}
28452849

@@ -3231,6 +3235,8 @@ static int _regmap_update_bits(struct regmap *map, unsigned int reg,
32313235
*change = false;
32323236

32333237
if (regmap_volatile(map, reg) && map->reg_update_bits) {
3238+
reg += map->reg_base;
3239+
reg >>= map->format.reg_downshift;
32343240
ret = map->reg_update_bits(map->bus_context, reg, mask, val);
32353241
if (ret == 0 && change)
32363242
*change = true;

0 commit comments

Comments
 (0)