Re: [PATCH v2] regmap-i2c: Subtract reg size from max_write

From: Andy Shevchenko
Date: Tue Jun 04 2024 - 05:16:32 EST


On Mon, Jun 3, 2024 at 3:08 PM Mark Brown <broonie@xxxxxxxxxx> wrote:
>
> On Sun, Jun 02, 2024 at 10:29:07AM +0300, Andy Shevchenko wrote:
>
> > > (bus->max_raw_write == 0 || bus->max_raw_write > quirks->max_write_len))
> > > - max_write = quirks->max_write_len;
> > > + max_write = quirks->max_write_len -
> > > + (config->reg_bits + config->pad_bits) / BITS_PER_BYTE;
>
> > Interesting. regmap-spi does this slightly differently, i.e. reg/8 + pad/8.
> > I'm wondering which one is more correct (potential off-by-one I suppose).
>
> The above seems more correct if we have less than a full byte of padding.

Hmm... So, if we have

bits pad x/8+y/8 (x+y)/8
4..7 0..3 0 0 // x + y from 4 up to 7
4..7 4..7 0 1 // x + y from 8 up to 11
4..7 8..11 1 1 // x + y from 12 up to 15
8..15 0..7 1 1 // x + y from 8 up to 15
8..15 8..15 2 2 // x + y from 16 up to 23

The only difference AFAICS is the case 2.
Do we need to patch regmap SPI for that?

I think SPI just works since we don't really have devices that use
less than 8 bits per register, and hence we never enter into such a
case (while I2C is naturally using 7-bit addresses).

--
With Best Regards,
Andy Shevchenko