[PATCH 32/35] iio: light: si1145: use default_trigger

From: Jonathan Cameron

Date: Sun Nov 15 2026 - 20:52:32 EST


From: Jonathan Cameron <jonathan.cameron@xxxxxxxxxxxxxxxx>

Set indio_dev->default_trigger rather than taking a reference to the
trigger in probe(). 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. Note this driver doesn't have this leak.
This avoids fragile registration ordering constraints and enables
additional refactors on top.

The copy of the trigger pointer in data->trig is only used during
probe(), so drop it.

Signed-off-by: Jonathan Cameron <jonathan.cameron@xxxxxxxxxxxxxxxx>
---
drivers/iio/light/si1145.c | 5 +----
1 file changed, 1 insertion(+), 4 deletions(-)

diff --git a/drivers/iio/light/si1145.c b/drivers/iio/light/si1145.c
index bb7c99041819..b160dd5dba86 100644
--- a/drivers/iio/light/si1145.c
+++ b/drivers/iio/light/si1145.c
@@ -166,7 +166,6 @@ struct si1145_part_info {
* @scan_mask: Saved scan mask to avoid duplicate set_chlist
* @autonomous: If automatic measurements are active (for buffer support)
* @part_info: Part information
- * @trig: Pointer to iio trigger
* @meas_rate: Value of MEAS_RATE register. Only set in HW in auto mode
* @buffer: Used to pack data read from sensor.
*/
@@ -178,7 +177,6 @@ struct si1145_data {
const struct si1145_part_info *part_info;
unsigned long scan_mask;
bool autonomous;
- struct iio_trigger *trig;
int meas_rate;
/*
* Ensure timestamp will be naturally aligned if present.
@@ -1258,8 +1256,7 @@ static int si1145_probe_trigger(struct iio_dev *indio_dev)
if (ret)
return ret;

- data->trig = trig;
- indio_dev->trig = iio_trigger_get(data->trig);
+ indio_dev->default_trigger = trig;

return 0;
}
--
2.56.1