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

Ben Hutchings
2026-02-05T22:45:04Z

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

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.

Ben.

--
Ben Hutchings
Horngren's Observation:
Among economists, the real world is often a special case.

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