summaryrefslogtreecommitdiffstats
path: root/drivers/nvmem
diff options
context:
space:
mode:
authorRobin van der Gracht <robin@protonic.nl>2024-01-02 18:01:00 +0100
committerSascha Hauer <s.hauer@pengutronix.de>2024-01-08 10:42:41 +0100
commit5d26d1519428b5408514c0bd68710babb7d1da18 (patch)
tree804181060f4e8f667e2c5fbdeb4114bd7eee696c /drivers/nvmem
parentcddf0f8be383c5827daa5641102852d80dcb5203 (diff)
downloadbarebox-5d26d1519428b5408514c0bd68710babb7d1da18.tar.gz
barebox-5d26d1519428b5408514c0bd68710babb7d1da18.tar.xz
nvmem: regmap: Fix nvmem size
We should add 1 to the max_register index since counting is zero based. i.e. the stm32mp151 bsec has registers 0 - 95 with reg_stride 4. Size should be (95 + 1) * 4 = 384 bytes otherwise we can't access bsec register 95 (last one). regmap_size_bytes() does take the +1 into account so we can use that. Fixes: b4abbd8a6cbb ("nvmem: add nvmem_regmap_register helper") Signed-off-by: Robin van der Gracht <robin@protonic.nl> Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de> Link: https://lore.barebox.org/20240102170100.1596372-8-a.fatoum@pengutronix.de Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
Diffstat (limited to 'drivers/nvmem')
-rw-r--r--drivers/nvmem/regmap.c4
1 files changed, 2 insertions, 2 deletions
diff --git a/drivers/nvmem/regmap.c b/drivers/nvmem/regmap.c
index fa5405d7a8..24712fbb0f 100644
--- a/drivers/nvmem/regmap.c
+++ b/drivers/nvmem/regmap.c
@@ -38,7 +38,7 @@ static int nvmem_regmap_read(void *ctx, unsigned offset, void *buf, size_t bytes
skip_bytes = offset & (stride - 1);
rbytes = roundup(bytes + skip_bytes, stride);
- if (roffset + rbytes > stride * regmap_get_max_register(map))
+ if (roffset + rbytes > regmap_size_bytes(map))
return -EINVAL;
for (i = roffset; i < roffset + rbytes; i += stride) {
@@ -78,7 +78,7 @@ nvmem_regmap_register_with_pp(struct regmap *map, const char *name,
config.priv = map;
config.stride = 1;
config.word_size = 1;
- config.size = regmap_get_max_register(map) * regmap_get_reg_stride(map);
+ config.size = regmap_size_bytes(map);
config.cell_post_process = cell_post_process;
config.reg_write = nvmem_regmap_write;
config.reg_read = nvmem_regmap_read;