Re: [PATCH] iio: st_sensors: fix trigger allocation
From: Aleksandrs Vinarskis
Date: Sun Mar 01 2026 - 05:52:14 EST
On Saturday, February 28th, 2026 at 20:22, David Lechner <dlechner@xxxxxxxxxxxx> wrote:
> On 2/28/26 11:11 AM, Aleksandrs Vinarskis wrote:
> > Current hardcoded name prevents adding multiple st-sensors devices
> > on the same platform. Fix by aligning trigger name with other drivers.
> >
> > Signed-off-by: Aleksandrs Vinarskis <alex@xxxxxxxxxxxxx>
> > ---
> > Some platforms such as Dell XPS 9345 contains multiple accelerometers.
> > Fix st_sensors that currently only allows one device at the time.
> > ---
> > drivers/iio/common/st_sensors/st_sensors_trigger.c | 5 +++--
> > 1 file changed, 3 insertions(+), 2 deletions(-)
> >
> > diff --git a/drivers/iio/common/st_sensors/st_sensors_trigger.c b/drivers/iio/common/st_sensors/st_sensors_trigger.c
> > index 8a8ab688d7980f6dd43c660f90a0eba32c38388b..3b5615d1b6dd66ee0af6ccc83eb2fbd7b2c64d29 100644
> > --- a/drivers/iio/common/st_sensors/st_sensors_trigger.c
> > +++ b/drivers/iio/common/st_sensors/st_sensors_trigger.c
> > @@ -124,8 +124,9 @@ int st_sensors_allocate_trigger(struct iio_dev *indio_dev,
> > unsigned long irq_trig;
> > int err;
> >
> > - sdata->trig = devm_iio_trigger_alloc(parent, "%s-trigger",
> > - indio_dev->name);
> > + sdata->trig = devm_iio_trigger_alloc(parent, "%s-dev%d",
> > + indio_dev->name,
> > + iio_device_id(indio_dev));
>
> Is this something that could potentially break userspace? Or are all of these
> just "always there" triggers that userspace doesn't have to touch?
I don't see why it would. This simply makes the name of the registered
trigger globally unique, the same way like other drivers already do.
Userspace does care about these but it relies on capabilities as per
my understanding to figure what sensor it is. I have tested it with
`monitor-sensors`, which relies on `iio-sensor-proxy`: in both cases
accelerator device was detected.
Alex
>
> > if (sdata->trig == NULL) {
> > dev_err(parent, "failed to allocate iio trigger.\n");
> > return -ENOMEM;
> >
> > ---
> > base-commit: 3fa5e5702a82d259897bd7e209469bc06368bf31
> > change-id: 20260228-st-iio-trigger-8ee1f219b566
> >
> > Best regards,
>
>