mail archive of the barebox mailing list
 help / color / mirror / Atom feed
From: Robin van der Gracht <robin@protonic.nl>
To: Ahmad Fatoum <a.fatoum@pengutronix.de>
Cc: barebox@lists.infradead.org, michiel.schelfhout@protonic.nl
Subject: Re: [PATCH v2] nvmem: regmap: Fix nvmem size
Date: Wed, 20 Dec 2023 13:38:43 +0100	[thread overview]
Message-ID: <97b2f99e62f57627604f11cce4c95b6b@protonic.nl> (raw)
In-Reply-To: <27a9d947-2358-4e05-ba77-32b26b3b3125@pengutronix.de>

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 right hand side be dropped?

roffset = register index * stride.

I.e. 380 for register with index 95.

For stm32mp1x bsec:
  map->format.val_bytes = 4
  map->reg_stride = 4

regmap_size_bytes() = map->format.val_bytes * (95 + 1) / map->reg_stride 
= 96

So the result with the stride on the right size is correct.

I moved stride from left to right to be consistent with the size 
calculation
in nvmem_regmap_register_with_pp()

Kind regards,
Robin


> 
> Cheers,
> Ahmad
> 
>>  		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) * regmap_get_reg_stride(map);
>>  	config.cell_post_process = cell_post_process;
>>  	config.reg_write = nvmem_regmap_write;
>>  	config.reg_read = nvmem_regmap_read;



  reply	other threads:[~2023-12-20 13:48 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-12-20  8:29 Robin van der Gracht
2023-12-20  9:00 ` Ahmad Fatoum
2023-12-20 12:38   ` Robin van der Gracht [this message]
2023-12-21 14:02     ` Ahmad Fatoum
2024-01-02 17:03       ` Ahmad Fatoum
2024-01-02 10:31 ` Sascha Hauer
2024-01-02 10:53   ` Sascha Hauer

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=97b2f99e62f57627604f11cce4c95b6b@protonic.nl \
    --to=robin@protonic.nl \
    --cc=a.fatoum@pengutronix.de \
    --cc=barebox@lists.infradead.org \
    --cc=michiel.schelfhout@protonic.nl \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox