Re: [PATCH v2] nvmem: regmap: Fix nvmem size

2024-01-02 Thread Ahmad Fatoum
Hello Robin, On 21.12.23 15:02, Ahmad Fatoum wrote: > On 20.12.23 13:38, Robin van der Gracht wrote: >> Hi Ahmad, >> >> On 2023-12-20 10:00, Ahmad Fatoum wrote: >>> Hello Robin, >>> >>> Thanks for the fix. >>> >>> On 20.12.23 09:29, Robin van der Gracht wrote: -    if (roffset + rbytes >

Re: [PATCH v2] nvmem: regmap: Fix nvmem size

2024-01-02 Thread Sascha Hauer
On Tue, Jan 02, 2024 at 11:31:43AM +0100, Sascha Hauer wrote: > On Wed, Dec 20, 2023 at 09:29:08AM +0100, 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

Re: [PATCH v2] nvmem: regmap: Fix nvmem size

2024-01-02 Thread Sascha Hauer
On Wed, Dec 20, 2023 at 09:29:08AM +0100, 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

Re: [PATCH v2] nvmem: regmap: Fix nvmem size

2023-12-21 Thread Ahmad Fatoum
On 20.12.23 13:38, Robin van der Gracht wrote: > Hi Ahmad, > > On 2023-12-20 10:00, Ahmad Fatoum wrote: >> Hello Robin, >> >> Thanks for the fix. >> >> On 20.12.23 09:29, Robin van der Gracht wrote: >>> -    if (roffset + rbytes > stride * regmap_get_max_register(map)) >>> +    if (roffset +

Re: [PATCH v2] nvmem: regmap: Fix nvmem size

2023-12-20 Thread Robin van der Gracht
Hi Ahmad, On 2023-12-20 10:00, Ahmad Fatoum wrote: Hello Robin, Thanks for the fix. On 20.12.23 09:29, Robin van der Gracht wrote: - if (roffset + rbytes > stride * regmap_get_max_register(map)) + if (roffset + rbytes > regmap_size_bytes(map) * stride) Shouldn't stride on the

Re: [PATCH v2] nvmem: regmap: Fix nvmem size

2023-12-20 Thread Ahmad Fatoum
Hello Robin, Thanks for the fix. On 20.12.23 09:29, Robin van der Gracht wrote: > - if (roffset + rbytes > stride * regmap_get_max_register(map)) > + if (roffset + rbytes > regmap_size_bytes(map) * stride) Shouldn't stride on the right hand side be dropped? Cheers, Ahmad >

[PATCH v2] nvmem: regmap: Fix nvmem size

2023-12-20 Thread 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). regmap_size_bytes() does take the +1 into account so we can use