* [PATCH] nvmem: regmap: Fix nvmem size
@ 2023-12-19 14:14 Robin van der Gracht
2023-12-20 7:56 ` Robin van der Gracht
0 siblings, 1 reply; 2+ messages in thread
From: Robin van der Gracht @ 2023-12-19 14:14 UTC (permalink / raw)
To: barebox; +Cc: Robin van der Gracht
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).
Signed-off-by: Robin van der Gracht <robin@protonic.nl>
---
drivers/nvmem/regmap.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/nvmem/regmap.c b/drivers/nvmem/regmap.c
index fa5405d7a8..ffc96a310f 100644
--- a/drivers/nvmem/regmap.c
+++ b/drivers/nvmem/regmap.c
@@ -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_get_max_register(map) + 1) * regmap_get_reg_stride(map);
config.cell_post_process = cell_post_process;
config.reg_write = nvmem_regmap_write;
config.reg_read = nvmem_regmap_read;
--
2.40.1
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: [PATCH] nvmem: regmap: Fix nvmem size
2023-12-19 14:14 [PATCH] nvmem: regmap: Fix nvmem size Robin van der Gracht
@ 2023-12-20 7:56 ` Robin van der Gracht
0 siblings, 0 replies; 2+ messages in thread
From: Robin van der Gracht @ 2023-12-20 7:56 UTC (permalink / raw)
To: barebox
After applying this patch the last register is writable, but still not
readable.
The size is now correct:
barebox:/ ls -l /dev/stm32-bsec
crw------- 384 /dev/stm32-bsec
This now works:
mw -l -d /dev/stm32-bsec 0x0000017c+4 0x12345678
This still doesn't:
barebox:/ md -l -s /dev/stm32-bsec 0x0000017c+4
read: Invalid argument
On 2023-12-19 15:14, Robin van der Gracht wrote:
> 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).
>
> Signed-off-by: Robin van der Gracht <robin@protonic.nl>
> ---
> drivers/nvmem/regmap.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/drivers/nvmem/regmap.c b/drivers/nvmem/regmap.c
> index fa5405d7a8..ffc96a310f 100644
> --- a/drivers/nvmem/regmap.c
> +++ b/drivers/nvmem/regmap.c
> @@ -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_get_max_register(map) + 1) *
> regmap_get_reg_stride(map);
> config.cell_post_process = cell_post_process;
> config.reg_write = nvmem_regmap_write;
> config.reg_read = nvmem_regmap_read;
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2023-12-20 7:58 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-12-19 14:14 [PATCH] nvmem: regmap: Fix nvmem size Robin van der Gracht
2023-12-20 7:56 ` Robin van der Gracht
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox