lkml.org 
[lkml]   [2023]   [Jan]   [27]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
Date
From
Subject[PATCH] 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
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@makrotopia.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..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

\
 
 \ /
  Last update: 2023-03-27 00:00    [W:0.137 / U:0.052 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site