[PATCH master 2/7] nvmem: bsec: correct regmap's max_register

Ahmad Fatoum a.fatoum at pengutronix.de
Tue Jan 2 09:00:55 PST 2024


The max_register must be a multiple of the register stride, which is not
the case for (384 / 4) - 1 == 95. Instead, we should be setting 380, so
fix the calculation to do this.

Fixes: 094ce0ee7cdf ("nvmem: bsec: correct regmap's max_register")
Reported-by: Robin van der Gracht <robin at protonic.nl>
Signed-off-by: Ahmad Fatoum <a.fatoum at pengutronix.de>
---
 drivers/nvmem/bsec.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/nvmem/bsec.c b/drivers/nvmem/bsec.c
index 889f14428d59..22e30c6c2e82 100644
--- a/drivers/nvmem/bsec.c
+++ b/drivers/nvmem/bsec.c
@@ -218,7 +218,7 @@ static int stm32_bsec_probe(struct device *dev)
 	priv->map_config.reg_bits = 32;
 	priv->map_config.val_bits = 32;
 	priv->map_config.reg_stride = 4;
-	priv->map_config.max_register = (data->size / 4) - 1;
+	priv->map_config.max_register = data->size - priv->map_config.reg_stride;
 
 	priv->lower = data->lower;
 
-- 
2.39.2




More information about the barebox mailing list