[PATCH 23/35] iio: common: st_sensors: use default_trigger
From: Jonathan Cameron
Date: Sun Nov 15 2026 - 20:52:16 EST
From: Jonathan Cameron <jonathan.cameron@xxxxxxxxxxxxxxxx>
Set indio_dev->default_trigger rather than taking a reference to the
trigger in st_sensors_allocate_trigger(). The IIO core now takes the
reference during iio_device_register(), so it is not leaked if probe()
fails after the trigger is set up.
All users (st_accel, st_gyro, st_magn and st_pressure) allocate the
triggered buffer and trigger before calling devm_iio_device_register()
and do not access indio_dev->trig before that point. The interrupt
handlers are passed the trigger directly.
The ordering is such in here that their is no leak today, but in general
this change will make things less fragile going forwards.
Signed-off-by: Jonathan Cameron <jonathan.cameron@xxxxxxxxxxxxxxxx>
---
drivers/iio/common/st_sensors/st_sensors_trigger.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/iio/common/st_sensors/st_sensors_trigger.c b/drivers/iio/common/st_sensors/st_sensors_trigger.c
index 7b3e9732cc3e..c450b1e2812d 100644
--- a/drivers/iio/common/st_sensors/st_sensors_trigger.c
+++ b/drivers/iio/common/st_sensors/st_sensors_trigger.c
@@ -219,7 +219,7 @@ int st_sensors_allocate_trigger(struct iio_dev *indio_dev,
dev_err(parent, "failed to register iio trigger.\n");
return err;
}
- indio_dev->trig = iio_trigger_get(sdata->trig);
+ indio_dev->default_trigger = sdata->trig;
return 0;
}
--
2.56.1