mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH] regmap: mmio: Allow passing an empty config->reg_stride
@ 2023-05-11 14:27 Maxime Chevallier
  2023-05-12  4:19 ` Mark Brown
  0 siblings, 1 reply; 2+ messages in thread
From: Maxime Chevallier @ 2023-05-11 14:27 UTC (permalink / raw)
  To: Mark Brown, Greg Kroah-Hartman, Rafael J . Wysocki, Colin Foster
  Cc: Maxime Chevallier, linux-kernel, thomas.petazzoni, alexis.lothore

Regmap's stride is used for MMIO regmaps to check the correctness of
reg_width. However, it's acceptable to pass an empty config->reg_stride,
in that case the actual stride used is 1.

There are valid cases now to pass an empty stride, when using
down/upshifting of register address. In this case, the stride value
loses its sense, so ignore the reg_width when the stride isn't set.

Signed-off-by: Maxime Chevallier <maxime.chevallier@bootlin.com>
---
This patch is a followup on the discussion here [1]. The regmap core
actually supports pretty-well not passing a stride, and uses a value of
1 by default. However regmap-mmio has specific checks for that case,
which is the only place such a check needs to be added.

[1] : https://lore.kernel.org/all/20230420150617.381922-1-maxime.chevallier@bootlin.com/

 drivers/base/regmap/regmap-mmio.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/base/regmap/regmap-mmio.c b/drivers/base/regmap/regmap-mmio.c
index 3ccdd86a97e7..8132b5c101c4 100644
--- a/drivers/base/regmap/regmap-mmio.c
+++ b/drivers/base/regmap/regmap-mmio.c
@@ -448,7 +448,7 @@ static struct regmap_mmio_context *regmap_mmio_gen_context(struct device *dev,
 	if (min_stride < 0)
 		return ERR_PTR(min_stride);
 
-	if (config->reg_stride < min_stride)
+	if (config->reg_stride && config->reg_stride < min_stride)
 		return ERR_PTR(-EINVAL);
 
 	if (config->use_relaxed_mmio && config->io_port)
-- 
2.40.1


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2023-05-12  4:19 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-05-11 14:27 [PATCH] regmap: mmio: Allow passing an empty config->reg_stride Maxime Chevallier
2023-05-12  4:19 ` Mark Brown

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®