* [PATCH] regmap: enforce register alignment to regmap::reg_stride
@ 2026-05-26 6:00 Ahmad Fatoum
2026-05-26 6:26 ` Sascha Hauer
0 siblings, 1 reply; 2+ messages in thread
From: Ahmad Fatoum @ 2026-05-26 6:00 UTC (permalink / raw)
To: barebox; +Cc: jre, Ahmad Fatoum
We currently enforce this only for regmap_bulk_read/write, but really
it's applicable to all regmap read/write operations.
Linux already enforces this everywhere, so follow suit in barebox.
Signed-off-by: Ahmad Fatoum <a.fatoum@barebox.org>
---
drivers/base/regmap/regmap.c | 14 ++++++++++++++
1 file changed, 14 insertions(+)
diff --git a/drivers/base/regmap/regmap.c b/drivers/base/regmap/regmap.c
index e4b20c07809d..f41e9d94944e 100644
--- a/drivers/base/regmap/regmap.c
+++ b/drivers/base/regmap/regmap.c
@@ -69,6 +69,9 @@ static int _regmap_bus_reg_read(void *context, unsigned int reg,
{
struct regmap *map = context;
+ if (!IS_ALIGNED(reg, map->reg_stride))
+ return -EINVAL;
+
return map->bus->reg_read(map->bus_context, reg, val);
}
@@ -78,6 +81,9 @@ static int _regmap_bus_reg_write(void *context, unsigned int reg,
{
struct regmap *map = context;
+ if (!IS_ALIGNED(reg, map->reg_stride))
+ return -EINVAL;
+
return map->bus->reg_write(map->bus_context, reg, val);
}
@@ -86,6 +92,8 @@ static int _regmap_bus_reg_seal(void *context, unsigned int reg,
{
struct regmap *map = context;
+ if (!IS_ALIGNED(reg, map->reg_stride))
+ return -EINVAL;
if (!map->bus->reg_seal)
return -EOPNOTSUPP;
@@ -182,6 +190,8 @@ struct device *regmap_get_device(struct regmap *map)
*/
int regmap_write(struct regmap *map, unsigned int reg, unsigned int val)
{
+ if (!IS_ALIGNED(reg, map->reg_stride))
+ return -EINVAL;
return map->reg_write(map, reg, val);
}
@@ -196,6 +206,8 @@ int regmap_write(struct regmap *map, unsigned int reg, unsigned int val)
*/
int regmap_read(struct regmap *map, unsigned int reg, unsigned int *val)
{
+ if (!IS_ALIGNED(reg, map->reg_stride))
+ return -EINVAL;
return map->reg_read(map, reg, val);
}
@@ -213,6 +225,8 @@ int regmap_read(struct regmap *map, unsigned int reg, unsigned int *val)
*/
int regmap_seal(struct regmap *map, unsigned int reg, unsigned int flags)
{
+ if (!IS_ALIGNED(reg, map->reg_stride))
+ return -EINVAL;
return map->reg_seal(map, reg, flags);
}
--
2.47.3
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: [PATCH] regmap: enforce register alignment to regmap::reg_stride
2026-05-26 6:00 [PATCH] regmap: enforce register alignment to regmap::reg_stride Ahmad Fatoum
@ 2026-05-26 6:26 ` Sascha Hauer
0 siblings, 0 replies; 2+ messages in thread
From: Sascha Hauer @ 2026-05-26 6:26 UTC (permalink / raw)
To: barebox, Ahmad Fatoum; +Cc: jre
On Tue, 26 May 2026 08:00:15 +0200, Ahmad Fatoum wrote:
> We currently enforce this only for regmap_bulk_read/write, but really
> it's applicable to all regmap read/write operations.
>
> Linux already enforces this everywhere, so follow suit in barebox.
>
>
Applied, thanks!
[1/1] regmap: enforce register alignment to regmap::reg_stride
https://git.pengutronix.de/cgit/barebox/commit/?id=e53874cca26e (link may not be stable)
Best regards,
--
Sascha Hauer <s.hauer@pengutronix.de>
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2026-05-26 6:27 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-05-26 6:00 [PATCH] regmap: enforce register alignment to regmap::reg_stride Ahmad Fatoum
2026-05-26 6:26 ` Sascha Hauer
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox