Re: [PATCH 5.10 070/161] iio: imu: st_lsm6dsx: fix iio_chan_spec for sensors without event detection

Francesco Lavra
2026-02-06T08:17:45Z

[-- Attachment #1: Type: text/plain, Size: 2557 bytes --]

On Thu, 2026-02-05 at 23:44 +0100, Ben Hutchings wrote:
> On Wed, 2026-02-04 at 15:38 +0100, Greg Kroah-Hartman wrote:
> > 5.10-stable review patch.  If anyone has any objections, please let me
> > know.
> >
> > ------------------
> >
> > From: Francesco Lavra <flavra@baylibre.com>
> >
> > commit c34e2e2d67b3bb8d5a6d09b0d6dac845cdd13fb3 upstream.
> >
> > The st_lsm6dsx_acc_channels array of struct iio_chan_spec has a non-
> > NULL
> > event_spec field, indicating support for IIO events. However, event
> > detection is not supported for all sensors, and if userspace tries to
> > configure accelerometer wakeup events on a sensor device that does not
> > support them (e.g. LSM6DS0), st_lsm6dsx_write_event() dereferences a
> > NULL
> > pointer when trying to write to the wakeup register.
> > Define an additional struct iio_chan_spec array whose members have a
> > NULL
> > event_spec field, and use this array instead of st_lsm6dsx_acc_channels
> > for
> > sensors without event detection capability.
> [...]
> > @@ -1170,8 +1177,8 @@ static const struct st_lsm6dsx_settings
> >                 },
> >                 .channels = {
> >                         [ST_LSM6DSX_ID_ACC] = {
> > -                               .chan = st_lsm6dsx_acc_channels,
> > -                               .len =
> > ARRAY_SIZE(st_lsm6dsx_acc_channels),
> > +                               .chan = st_lsm6ds0_acc_channels,
> > +                               .len =
> > ARRAY_SIZE(st_lsm6ds0_acc_channels),
> >                         },
> >                         [ST_LSM6DSX_ID_GYRO] = {
> >                                 .chan = st_lsm6dsx_gyro_channels,
>
> In the upstream commit the 3rd hunk changed the entry for hardware IDs
> ST_LSM6DSO16IS_ID and ST_ISM330IS_ID.
>
> That entry was added by commit f35e1ee9cb5d "iio: imu: st_lsm6dsx: add
> support to LSM6DSO16IS" in 6.2.  So in this backport the 3rd hunk is
> changing configuration for other devices.
>
> I think the right thing to do for the 5.10-6.1 branches is to only apply
> the first 2 hunks.

Good catch. In the 5.10 branch, the third hunk is changing configuration
for ST_LSM6DSR_ID, ST_ISM330DHCX_ID, and ST_LSM6DSRX_ID, none of which
should have their configuration changed; so only the first two hunks should
be applied.

[-- Attachment #2: This is a digitally signed message part --]
[-- Type: application/pgp-signature, Size: 659 bytes --]