Re: [PATCH v2 1/2] iio: mpl3115: add threshold events support

From: Andy Shevchenko
Date: Mon Nov 03 2025 - 03:22:32 EST


On Sun, Nov 02, 2025 at 10:38:08AM +0000, Jonathan Cameron wrote:
> On Fri, 31 Oct 2025 21:18:22 +0100
> Antoni Pokusinski <apokusinski01@xxxxxxxxx> wrote:

...


> Generally looks good to me, but some comments on the 24 bit value reading.

> > + i2c_smbus_read_i2c_block_data(data->client,
> > + MPL3115_OUT_PRESS,
> > + 3, (u8 *)&val_press);
>
> This is an oddity. Why read into a __be32 when it's a 24bit number?
> I guess it doesn't really matter as you just need a big enough space
> and throw the value away. However, I'd read it into a u8 [3]; then size off that
> as well.
>
> There are two existing cases of this in the driver. One of them should use
> get_unaligned_be24 on a u8[3] buffer. The other one is more complex as it's
> reading directly into the scan buffer that gets pushed to the kfifo and is
> reading into a u8 buffer ultimately anyway so at least there is no
> real suggestion of it being 32 bits (just a +4 shift to deal with natural
> alignment as the storage has to be power of 2 in that case.).
>
> hmm. I think either we should tidy up the easy case (_read_info_raw) +
> use a u8[3] here or just stick to this being odd.
> My preference would be to have another patch tidying up the other case
> + use a u8[3] here.

Just a side question... Wondering, if we actually can defined __be24 and __le24
types (or at least u24) for really explicit cases.

--
With Best Regards,
Andy Shevchenko