Re: [PATCH v6 3/7] iio: imu: st_lsm6dsx: Fix check for invalid samples from FIFO
From: Andy Shevchenko
Date: Wed Feb 25 2026 - 06:42:44 EST
On Wed, Feb 25, 2026 at 11:17:11AM +0100, Francesco Lavra wrote:
> The DRDY_MASK feature implemented in sensor chips marks gyroscope and
> accelerometer invalid samples (i.e. samples that have been acquired during
> the settling time of sensor filters) with the special values 0x7FFFh,
> 0x7FFE, and 0x7FFD.
> The driver checks FIFO samples against these special values in order to
> discard invalid samples; however, it does the check regardless of the type
> of samples being processed, whereas this feature is specific to gyroscope
> and accelerometer data. This could cause valid samples to be discarded.
>
> Fix the above check so that it takes into account the type of samples being
> processed. To avoid casting to __le16 * when checking sample values, clean
> up the type representation for data read from the FIFO.
...
> - u8 iio_buff[ST_LSM6DSX_IIO_BUFF_SIZE] __aligned(8);
> + struct {
> + union {
> + __le16 data[3];
> + __le32 fifo_ts;
> + };
> + aligned_s64 timestamp;
> + } iio_buff = { };
Hmm... Have you considered m68k case? IIRC there the alignment is 2 (even for
64-bit members), so theoretically the beginning of the structure can be aligned
to address 2. and hence the __le16 data[3] will have no gap to the following
timestamp. In current code it's 64-bit and not 48-bit item.
I believe it's easy to check, though.
--
With Best Regards,
Andy Shevchenko