* [PATCH 01/15] iio: core: add iio_trigger_set_default_immutable()
2026-11-30 0:13 [PATCH 00/15] IIO: Immutable triggers. Close leaks in registration and use more widely Jonathan Cameron
@ 2026-11-30 0:13 ` Jonathan Cameron
2026-11-30 0:13 ` [PATCH 02/15] iio: adc: dln2-adc: use iio_trigger_set_default_immutable() Jonathan Cameron
` (13 subsequent siblings)
14 siblings, 0 replies; 18+ messages in thread
From: Jonathan Cameron @ 2026-11-30 0:13 UTC (permalink / raw)
To: linux-iio, linux, Jonathan Cameron, David Lechner, Nuno Sá,
Andy Shevchenko, Michael Hennerich, Radu Sabau, Song Qiang,
Siratul Islam, Lorenzo Bianconi, Alisa-Dariana Roman,
Ramona Bolboaca, Jean-Baptiste Maneyrol
Cc: Jonathan Cameron
From: Jonathan Cameron <jonathan.cameron@oss.qualcomm.com>
iio_trigger_set_immutable() takes a reference to the trigger immediately.
When used by a driver to associate an IIO device with a IIO trigger
registered by the same driver during probe, that has the
same problem addressed by the introduction of default_trigger [#1]:
if probe fails before INDIO_BUFFER_TRIGGERED is set, iio_dev_release()
does not drop the reference and it is leaked.
Add iio_trigger_set_default_immutable() which sets
indio_dev->default_trigger and marks the trigger read only, leaving the
IIO core to take the reference in iio_device_register(). It must be
called before the device is registered.
iio_trigger_set_immutable() remains for setting the trigger on an IIO
device that may already be registered, such as one belonging to another
driver. Document the difference.
Link: https://lore.kernel.org/linux-iio/20261116014823.3132576-2-jic23@kernel.org/ #1
Signed-off-by: Jonathan Cameron <jonathan.cameron@oss.qualcomm.com>
---
This whole series is build tested only and whilst it seems to be safe
enough some runtime testing on real devices would be much appreciated.
LLM used to prepare this.
---
drivers/iio/industrialio-trigger.c | 22 ++++++++++++++++++++++
include/linux/iio/trigger.h | 17 +++++++++++++++++
2 files changed, 39 insertions(+)
diff --git a/drivers/iio/industrialio-trigger.c b/drivers/iio/industrialio-trigger.c
index ba8fe61b3a37..5cff1bbeae2f 100644
--- a/drivers/iio/industrialio-trigger.c
+++ b/drivers/iio/industrialio-trigger.c
@@ -128,6 +128,28 @@ int iio_trigger_set_immutable(struct iio_dev *indio_dev, struct iio_trigger *tri
}
EXPORT_SYMBOL(iio_trigger_set_immutable);
+int iio_trigger_set_default_immutable(struct iio_dev *indio_dev,
+ struct iio_trigger *trig)
+{
+ struct iio_dev_opaque *iio_dev_opaque;
+
+ if (!indio_dev || !trig)
+ return -EINVAL;
+
+ /* The reference is taken in iio_device_register() */
+ if (WARN_ON(device_is_registered(&indio_dev->dev)))
+ return -EBUSY;
+
+ iio_dev_opaque = to_iio_dev_opaque(indio_dev);
+ WARN_ON(iio_dev_opaque->trig_readonly);
+
+ indio_dev->default_trigger = trig;
+ iio_dev_opaque->trig_readonly = true;
+
+ return 0;
+}
+EXPORT_SYMBOL(iio_trigger_set_default_immutable);
+
/* Search for trigger by name, assuming iio_trigger_list_lock held */
static struct iio_trigger *__iio_trigger_find_by_name(const char *name)
{
diff --git a/include/linux/iio/trigger.h b/include/linux/iio/trigger.h
index bce3b1788199..56731365a8f9 100644
--- a/include/linux/iio/trigger.h
+++ b/include/linux/iio/trigger.h
@@ -148,9 +148,26 @@ void iio_trigger_unregister(struct iio_trigger *trig_info);
* @indio_dev: IIO device structure containing the device
* @trig: trigger to assign to device
*
+ * A reference to @trig is taken immediately. This is intended for setting
+ * the trigger of an IIO device that may already be registered, such as one
+ * provided by another driver. For a driver's own IIO device prior to
+ * registration use iio_trigger_set_default_immutable() instead.
**/
int iio_trigger_set_immutable(struct iio_dev *indio_dev, struct iio_trigger *trig);
+/**
+ * iio_trigger_set_default_immutable() - set an immutable default trigger
+ *
+ * @indio_dev: IIO device structure containing the device
+ * @trig: trigger to assign to device
+ *
+ * As for setting &iio_dev.default_trigger, no reference to @trig is taken
+ * by this call. The IIO core takes one in iio_device_register(). Must be
+ * called before iio_device_register().
+ **/
+int iio_trigger_set_default_immutable(struct iio_dev *indio_dev,
+ struct iio_trigger *trig);
+
void iio_trigger_poll(struct iio_trigger *trig);
void iio_trigger_poll_nested(struct iio_trigger *trig);
--
2.56.1
^ permalink raw reply related [flat|nested] 18+ messages in thread* [PATCH 02/15] iio: adc: dln2-adc: use iio_trigger_set_default_immutable()
2026-11-30 0:13 [PATCH 00/15] IIO: Immutable triggers. Close leaks in registration and use more widely Jonathan Cameron
2026-11-30 0:13 ` [PATCH 01/15] iio: core: add iio_trigger_set_default_immutable() Jonathan Cameron
@ 2026-11-30 0:13 ` Jonathan Cameron
2026-11-30 0:13 ` [PATCH 03/15] iio: core: allow writing the current trigger when it is immutable Jonathan Cameron
` (12 subsequent siblings)
14 siblings, 0 replies; 18+ messages in thread
From: Jonathan Cameron @ 2026-11-30 0:13 UTC (permalink / raw)
To: linux-iio, linux, Jonathan Cameron, David Lechner, Nuno Sá,
Andy Shevchenko, Michael Hennerich, Radu Sabau, Song Qiang,
Siratul Islam, Lorenzo Bianconi, Alisa-Dariana Roman,
Ramona Bolboaca, Jean-Baptiste Maneyrol
Cc: Jonathan Cameron
From: Jonathan Cameron <jonathan.cameron@oss.qualcomm.com>
iio_trigger_set_immutable() takes a reference to the trigger immediately.
As this happens before devm_iio_triggered_buffer_setup() sets
INDIO_BUFFER_TRIGGERED, a failure in that call or later in probe()
leaks the reference because the IIO core only drops it for devices with
triggered modes.
Use iio_trigger_set_default_immutable() so that the IIO core takes the
reference during iio_device_register(). Also check the return value,
which was previously ignored.
Signed-off-by: Jonathan Cameron <jonathan.cameron@oss.qualcomm.com>
---
drivers/iio/adc/dln2-adc.c | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/drivers/iio/adc/dln2-adc.c b/drivers/iio/adc/dln2-adc.c
index b01c6f5a73b1..52490aa8ee7f 100644
--- a/drivers/iio/adc/dln2-adc.c
+++ b/drivers/iio/adc/dln2-adc.c
@@ -625,7 +625,9 @@ static int dln2_adc_probe(struct platform_device *pdev)
dev_err(dev, "failed to register trigger: %d\n", ret);
return ret;
}
- iio_trigger_set_immutable(indio_dev, dln2->trig);
+ ret = iio_trigger_set_default_immutable(indio_dev, dln2->trig);
+ if (ret)
+ return ret;
ret = devm_iio_triggered_buffer_setup(dev, indio_dev, NULL,
dln2_adc_trigger_h,
--
2.56.1
^ permalink raw reply related [flat|nested] 18+ messages in thread* [PATCH 03/15] iio: core: allow writing the current trigger when it is immutable
2026-11-30 0:13 [PATCH 00/15] IIO: Immutable triggers. Close leaks in registration and use more widely Jonathan Cameron
2026-11-30 0:13 ` [PATCH 01/15] iio: core: add iio_trigger_set_default_immutable() Jonathan Cameron
2026-11-30 0:13 ` [PATCH 02/15] iio: adc: dln2-adc: use iio_trigger_set_default_immutable() Jonathan Cameron
@ 2026-11-30 0:13 ` Jonathan Cameron
2026-11-30 0:13 ` [PATCH 04/15] iio: adc: ad7606: use iio_trigger_set_default_immutable() Jonathan Cameron
` (11 subsequent siblings)
14 siblings, 0 replies; 18+ messages in thread
From: Jonathan Cameron @ 2026-11-30 0:13 UTC (permalink / raw)
To: linux-iio, linux, Jonathan Cameron, David Lechner, Nuno Sá,
Andy Shevchenko, Michael Hennerich, Radu Sabau, Song Qiang,
Siratul Islam, Lorenzo Bianconi, Alisa-Dariana Roman,
Ramona Bolboaca, Jean-Baptiste Maneyrol
Cc: Jonathan Cameron
From: Jonathan Cameron <jonathan.cameron@oss.qualcomm.com>
current_trigger_store() rejects all writes with -EPERM if the trigger
has been made immutable, including writes of the name of the trigger
that is already set.
Only reject writes that would change an immutable trigger. Whilst this
is a nice usability improvement on its own. It also ensures that
drivers can use an immutable default trigger in place of a
validate_trigger() callback without breaking such userspace.
Note that such a move from validate_trigger() allowing only a single
trigger provided by the same driver, to an immutable trigger has
the visible side effect that the trigger can no longer be cleared.
It seems unlikely that any userspace relies on that behavior.
Signed-off-by: Jonathan Cameron <jonathan.cameron@oss.qualcomm.com>
---
drivers/iio/industrialio-trigger.c | 9 +++++++--
1 file changed, 7 insertions(+), 2 deletions(-)
diff --git a/drivers/iio/industrialio-trigger.c b/drivers/iio/industrialio-trigger.c
index 5cff1bbeae2f..62adbbeb36f2 100644
--- a/drivers/iio/industrialio-trigger.c
+++ b/drivers/iio/industrialio-trigger.c
@@ -470,8 +470,6 @@ static ssize_t current_trigger_store(struct device *dev,
scoped_guard(mutex, &iio_dev_opaque->mlock) {
if (iio_dev_opaque->currentmode == INDIO_BUFFER_TRIGGERED)
return -EBUSY;
- if (iio_dev_opaque->trig_readonly)
- return -EPERM;
}
trig = iio_trigger_acquire_by_name(buf);
@@ -480,6 +478,13 @@ static ssize_t current_trigger_store(struct device *dev,
goto out_trigger_put;
}
+ scoped_guard(mutex, &iio_dev_opaque->mlock) {
+ if (iio_dev_opaque->trig_readonly) {
+ ret = -EPERM;
+ goto out_trigger_put;
+ }
+ }
+
if (trig && indio_dev->info->validate_trigger) {
ret = indio_dev->info->validate_trigger(indio_dev, trig);
if (ret)
--
2.56.1
^ permalink raw reply related [flat|nested] 18+ messages in thread* [PATCH 04/15] iio: adc: ad7606: use iio_trigger_set_default_immutable()
2026-11-30 0:13 [PATCH 00/15] IIO: Immutable triggers. Close leaks in registration and use more widely Jonathan Cameron
` (2 preceding siblings ...)
2026-11-30 0:13 ` [PATCH 03/15] iio: core: allow writing the current trigger when it is immutable Jonathan Cameron
@ 2026-11-30 0:13 ` Jonathan Cameron
2026-11-30 0:13 ` [PATCH 05/15] iio: adc: ad4691: " Jonathan Cameron
` (10 subsequent siblings)
14 siblings, 0 replies; 18+ messages in thread
From: Jonathan Cameron @ 2026-11-30 0:13 UTC (permalink / raw)
To: linux-iio, linux, Jonathan Cameron, David Lechner, Nuno Sá,
Andy Shevchenko, Michael Hennerich, Radu Sabau, Song Qiang,
Siratul Islam, Lorenzo Bianconi, Alisa-Dariana Roman,
Ramona Bolboaca, Jean-Baptiste Maneyrol
Cc: Jonathan Cameron
From: Jonathan Cameron <jonathan.cameron@oss.qualcomm.com>
Use iio_trigger_set_default_immutable() 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.
When neither an IIO backend nor SPI offload is used, the driver only
works with its own trigger and used ad7606_validate_trigger() to enforce
that. An immutable trigger gives the same guarantee, so drop the
callback.
Note that this has a potential userspace ABI impact. Previously the
trigger could be cleared by writing an empty string, or any name that is
not a registered trigger, to current_trigger. That now fails with
-EPERM, as does selecting a different trigger, which previously failed
with -EINVAL. Writing the name of the current trigger still succeeds. As
the buffer cannot be enabled without this trigger, clearing it served no
useful purpose. It seems unlikely that any userspace will notice, but
it is possible something relies on this original behavior.
Signed-off-by: Jonathan Cameron <jonathan.cameron@oss.qualcomm.com>
---
drivers/iio/adc/ad7606.c | 20 +++-----------------
1 file changed, 3 insertions(+), 17 deletions(-)
diff --git a/drivers/iio/adc/ad7606.c b/drivers/iio/adc/ad7606.c
index 3a941c900f45..d20984e4275d 100644
--- a/drivers/iio/adc/ad7606.c
+++ b/drivers/iio/adc/ad7606.c
@@ -1097,17 +1097,6 @@ static irqreturn_t ad7606_interrupt(int irq, void *dev_id)
return IRQ_HANDLED;
};
-static int ad7606_validate_trigger(struct iio_dev *indio_dev,
- struct iio_trigger *trig)
-{
- struct ad7606_state *st = iio_priv(indio_dev);
-
- if (st->trig != trig)
- return -EINVAL;
-
- return 0;
-}
-
static int ad7606_buffer_postenable(struct iio_dev *indio_dev)
{
struct ad7606_state *st = iio_priv(indio_dev);
@@ -1207,7 +1196,6 @@ static const struct iio_buffer_setup_ops ad7606_backend_buffer_ops = {
static const struct iio_info ad7606_info_no_os_or_range = {
.read_raw = &ad7606_read_raw,
- .validate_trigger = &ad7606_validate_trigger,
.update_scan_mode = &ad7606_update_scan_mode,
};
@@ -1215,7 +1203,6 @@ static const struct iio_info ad7606_info_os_and_range = {
.read_raw = &ad7606_read_raw,
.write_raw = &ad7606_write_raw,
.attrs = &ad7606_attribute_group_os_and_range,
- .validate_trigger = &ad7606_validate_trigger,
.update_scan_mode = &ad7606_update_scan_mode,
};
@@ -1225,7 +1212,6 @@ static const struct iio_info ad7606_info_sw_mode = {
.read_avail = &ad7606_read_avail,
.write_raw_get_fmt = ad7606_write_raw_get_fmt,
.debugfs_reg_access = &ad7606_reg_access,
- .validate_trigger = &ad7606_validate_trigger,
.update_scan_mode = &ad7606_update_scan_mode,
};
@@ -1233,7 +1219,6 @@ static const struct iio_info ad7606_info_os = {
.read_raw = &ad7606_read_raw,
.write_raw = &ad7606_write_raw,
.attrs = &ad7606_attribute_group_os,
- .validate_trigger = &ad7606_validate_trigger,
.update_scan_mode = &ad7606_update_scan_mode,
};
@@ -1241,7 +1226,6 @@ static const struct iio_info ad7606_info_range = {
.read_raw = &ad7606_read_raw,
.write_raw = &ad7606_write_raw,
.attrs = &ad7606_attribute_group_range,
- .validate_trigger = &ad7606_validate_trigger,
.update_scan_mode = &ad7606_update_scan_mode,
};
@@ -1638,7 +1622,9 @@ int ad7606_probe(struct device *dev, int irq, void __iomem *base_address,
if (ret)
return ret;
- indio_dev->trig = iio_trigger_get(st->trig);
+ ret = iio_trigger_set_default_immutable(indio_dev, st->trig);
+ if (ret)
+ return ret;
ret = devm_request_threaded_irq(dev, irq, NULL, &ad7606_interrupt,
IRQF_TRIGGER_FALLING | IRQF_ONESHOT,
--
2.56.1
^ permalink raw reply related [flat|nested] 18+ messages in thread* [PATCH 05/15] iio: adc: ad4691: use iio_trigger_set_default_immutable()
2026-11-30 0:13 [PATCH 00/15] IIO: Immutable triggers. Close leaks in registration and use more widely Jonathan Cameron
` (3 preceding siblings ...)
2026-11-30 0:13 ` [PATCH 04/15] iio: adc: ad7606: use iio_trigger_set_default_immutable() Jonathan Cameron
@ 2026-11-30 0:13 ` Jonathan Cameron
2026-11-30 0:13 ` [PATCH 06/15] iio: proximity: vl53l0x-i2c: " Jonathan Cameron
` (9 subsequent siblings)
14 siblings, 0 replies; 18+ messages in thread
From: Jonathan Cameron @ 2026-11-30 0:13 UTC (permalink / raw)
To: linux-iio, linux, Jonathan Cameron, David Lechner, Nuno Sá,
Andy Shevchenko, Michael Hennerich, Radu Sabau, Song Qiang,
Siratul Islam, Lorenzo Bianconi, Alisa-Dariana Roman,
Ramona Bolboaca, Jean-Baptiste Maneyrol
Cc: Jonathan Cameron
From: Jonathan Cameron <jonathan.cameron@oss.qualcomm.com>
Use iio_trigger_set_default_immutable() 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.
In CNV burst mode without SPI offload the driver only works with its own
trigger, driven by the DATA_READY interrupt, and used a separate
iio_info with iio_validate_own_trigger() to enforce that. An immutable
trigger gives the same guarantee.
Dropping the trigger_validate() callback makes the two iio_info structures
identical so drop the duplicate and move the set to where the code
paths are shared.
Potential userspace ABI impact. Previously in CNV burst mode the trigger
could be cleared by writing an empty string, or any name that is not a
registered trigger, to current_trigger. That now fails with -EPERM,
as does selecting a different trigger, which previously failed with
-EINVAL. Writing the name of the current trigger still succeeds.
Whilst unlikely it is possible some userspace relies on this tear
down behavior.
Signed-off-by: Jonathan Cameron <jonathan.cameron@oss.qualcomm.com>
---
drivers/iio/adc/ad4691.c | 34 ++++++++++------------------------
1 file changed, 10 insertions(+), 24 deletions(-)
diff --git a/drivers/iio/adc/ad4691.c b/drivers/iio/adc/ad4691.c
index f63a68a009f8..40aeec52181b 100644
--- a/drivers/iio/adc/ad4691.c
+++ b/drivers/iio/adc/ad4691.c
@@ -1613,23 +1613,7 @@ static irqreturn_t ad4691_trigger_handler(int irq, void *p)
return IRQ_HANDLED;
}
-/*
- * CNV burst mode: only allow our own trigger (driven by DATA_READY IRQ).
- * Manual mode: external triggers (e.g. iio-trig-hrtimer) must be allowed
- * because manual mode has no DATA_READY IRQ to fire the internal trigger.
- * iio_trigger_ops.validate_device = iio_trigger_validate_own_device is
- * correct in both modes — it prevents other devices from hijacking our
- * internal trigger; the distinction here is only for iio_info.validate_trigger.
- */
-static const struct iio_info ad4691_cnv_burst_info = {
- .read_raw = ad4691_read_raw,
- .write_raw = ad4691_write_raw,
- .read_avail = ad4691_read_avail,
- .debugfs_reg_access = ad4691_reg_access,
- .validate_trigger = iio_validate_own_trigger,
-};
-
-static const struct iio_info ad4691_manual_info = {
+static const struct iio_info ad4691_info = {
.read_raw = ad4691_read_raw,
.write_raw = ad4691_write_raw,
.read_avail = ad4691_read_avail,
@@ -1841,7 +1825,6 @@ static int ad4691_setup_triggered_buffer(struct iio_dev *indio_dev,
else
indio_dev->channels = st->info->sw_info->channels;
indio_dev->num_channels = st->info->sw_info->num_channels;
- indio_dev->info = st->manual_mode ? &ad4691_manual_info : &ad4691_cnv_burst_info;
/*
* Manual mode relies on an external trigger (e.g. iio-trig-hrtimer);
@@ -1870,7 +1853,14 @@ static int ad4691_setup_triggered_buffer(struct iio_dev *indio_dev,
if (ret)
return dev_err_probe(dev, ret, "IIO trigger register failed\n");
- indio_dev->trig = iio_trigger_get(trig);
+ /*
+ * CNV burst mode only works with this trigger, driven by the
+ * DATA_READY IRQ, so make it immutable. Manual mode instead relies on
+ * an external trigger (e.g. iio-trig-hrtimer).
+ */
+ ret = iio_trigger_set_default_immutable(indio_dev, trig);
+ if (ret)
+ return ret;
/*
* The GP pin named in interrupt-names asserts at end-of-conversion.
@@ -1935,11 +1925,6 @@ static int ad4691_setup_offload(struct iio_dev *indio_dev,
else
indio_dev->channels = st->info->offload_info->channels;
indio_dev->num_channels = st->info->offload_info->num_channels;
- /*
- * Offload path uses DMA directly; no IIO trigger is involved, so
- * external triggers are not restricted (no validate_trigger).
- */
- indio_dev->info = &ad4691_manual_info;
if (st->manual_mode) {
st->offload_trigger =
@@ -2038,6 +2023,7 @@ static int ad4691_probe(struct spi_device *spi)
return dev_err_probe(dev, ret, "Failed to get SPI offload\n");
indio_dev->name = st->info->name;
+ indio_dev->info = &ad4691_info;
indio_dev->modes = INDIO_DIRECT_MODE;
if (spi_offload)
--
2.56.1
^ permalink raw reply related [flat|nested] 18+ messages in thread* [PATCH 06/15] iio: proximity: vl53l0x-i2c: use iio_trigger_set_default_immutable()
2026-11-30 0:13 [PATCH 00/15] IIO: Immutable triggers. Close leaks in registration and use more widely Jonathan Cameron
` (4 preceding siblings ...)
2026-11-30 0:13 ` [PATCH 05/15] iio: adc: ad4691: " Jonathan Cameron
@ 2026-11-30 0:13 ` Jonathan Cameron
2026-11-30 0:13 ` [PATCH 07/15] iio: proximity: vl53l1x-i2c: " Jonathan Cameron
` (8 subsequent siblings)
14 siblings, 0 replies; 18+ messages in thread
From: Jonathan Cameron @ 2026-11-30 0:13 UTC (permalink / raw)
To: linux-iio, linux, Jonathan Cameron, David Lechner, Nuno Sá,
Andy Shevchenko, Michael Hennerich, Radu Sabau, Song Qiang,
Siratul Islam, Lorenzo Bianconi, Alisa-Dariana Roman,
Ramona Bolboaca, Jean-Baptiste Maneyrol
Cc: Jonathan Cameron
From: Jonathan Cameron <jonathan.cameron@oss.qualcomm.com>
Use iio_trigger_set_default_immutable() 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.
The driver only accepts its own trigger, driven by its interrupt, and
used vl53l0x_validate_trigger() to enforce that. That callback is
equivalent to iio_validate_own_trigger(). An immutable trigger
gives the same guarantee, so drop the callback. Without an interrupt no
triggered buffer is set up, so there is no current_trigger attribute and
the callback was never reached.
Potential userspace ABI impact. Previously the trigger could be cleared
by writing an empty string, or any name that is not a registered trigger,
to current_trigger. That now fails with -EPERM, as does selecting a
different trigger, which previously failed with -EINVAL. Writing the name
of the current trigger still succeeds. As the buffer cannot be enabled
without this trigger, clearing it served no useful purpose.
It is possible some userspace may rely on the teardown behavior even
though that would never have worked with existing immutable triggers.
Signed-off-by: Jonathan Cameron <jonathan.cameron@oss.qualcomm.com>
---
drivers/iio/proximity/vl53l0x-i2c.c | 12 +++---------
1 file changed, 3 insertions(+), 9 deletions(-)
diff --git a/drivers/iio/proximity/vl53l0x-i2c.c b/drivers/iio/proximity/vl53l0x-i2c.c
index 6c595e647d75..8019b4134ae4 100644
--- a/drivers/iio/proximity/vl53l0x-i2c.c
+++ b/drivers/iio/proximity/vl53l0x-i2c.c
@@ -237,16 +237,8 @@ static int vl53l0x_read_raw(struct iio_dev *indio_dev,
}
}
-static int vl53l0x_validate_trigger(struct iio_dev *indio_dev, struct iio_trigger *trig)
-{
- struct vl53l0x_data *data = iio_priv(indio_dev);
-
- return data->trig == trig ? 0 : -EINVAL;
-}
-
static const struct iio_info vl53l0x_info = {
.read_raw = vl53l0x_read_raw,
- .validate_trigger = vl53l0x_validate_trigger,
};
static void vl53l0x_power_off(void *_data)
@@ -374,7 +366,9 @@ static int vl53l0x_probe(struct i2c_client *client)
if (ret)
return ret;
- indio_dev->trig = iio_trigger_get(data->trig);
+ ret = iio_trigger_set_default_immutable(indio_dev, data->trig);
+ if (ret)
+ return ret;
ret = vl53l0x_configure_irq(client, indio_dev);
if (ret)
--
2.56.1
^ permalink raw reply related [flat|nested] 18+ messages in thread* [PATCH 07/15] iio: proximity: vl53l1x-i2c: use iio_trigger_set_default_immutable()
2026-11-30 0:13 [PATCH 00/15] IIO: Immutable triggers. Close leaks in registration and use more widely Jonathan Cameron
` (5 preceding siblings ...)
2026-11-30 0:13 ` [PATCH 06/15] iio: proximity: vl53l0x-i2c: " Jonathan Cameron
@ 2026-11-30 0:13 ` Jonathan Cameron
2026-11-30 0:13 ` [PATCH 08/15] iio: humidity: hts221: use iio_dev->trig in iio_trigger_notify_done() Jonathan Cameron
` (7 subsequent siblings)
14 siblings, 0 replies; 18+ messages in thread
From: Jonathan Cameron @ 2026-11-30 0:13 UTC (permalink / raw)
To: linux-iio, linux, Jonathan Cameron, David Lechner, Nuno Sá,
Andy Shevchenko, Michael Hennerich, Radu Sabau, Song Qiang,
Siratul Islam, Lorenzo Bianconi, Alisa-Dariana Roman,
Ramona Bolboaca, Jean-Baptiste Maneyrol
Cc: Jonathan Cameron
From: Jonathan Cameron <jonathan.cameron@oss.qualcomm.com>
Use iio_trigger_set_default_immutable() 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.
The driver only accepts its own trigger, using iio_validate_own_trigger()
to enforce that. An immutable trigger gives the same guarantee, so drop
the callback.
Potential userspace ABI impact. Previously the trigger could be cleared
by writing an empty string, or any name that is not a registered trigger,
to current_trigger. That now fails with -EPERM, as does selecting a
different trigger, which previously failed with -EINVAL. Writing the
name of the current trigger still succeeds. It is possible some userspace
relies on the teardown behaviour though that userspace would be broken
for existing immutable triggers.
Signed-off-by: Jonathan Cameron <jonathan.cameron@oss.qualcomm.com>
---
drivers/iio/proximity/vl53l1x-i2c.c | 5 +++--
1 file changed, 3 insertions(+), 2 deletions(-)
diff --git a/drivers/iio/proximity/vl53l1x-i2c.c b/drivers/iio/proximity/vl53l1x-i2c.c
index 5414ab09d817..bf584be6ecf8 100644
--- a/drivers/iio/proximity/vl53l1x-i2c.c
+++ b/drivers/iio/proximity/vl53l1x-i2c.c
@@ -543,7 +543,6 @@ static int vl53l1x_read_raw(struct iio_dev *indio_dev,
static const struct iio_info vl53l1x_info = {
.read_raw = vl53l1x_read_raw,
- .validate_trigger = iio_validate_own_trigger,
};
static irqreturn_t vl53l1x_trigger_handler(int irq, void *priv)
@@ -715,7 +714,9 @@ static int vl53l1x_probe(struct i2c_client *client)
if (ret)
return ret;
- indio_dev->trig = iio_trigger_get(trig);
+ ret = iio_trigger_set_default_immutable(indio_dev, trig);
+ if (ret)
+ return ret;
ret = vl53l1x_configure_irq(dev, client->irq, indio_dev);
if (ret)
--
2.56.1
^ permalink raw reply related [flat|nested] 18+ messages in thread* [PATCH 08/15] iio: humidity: hts221: use iio_dev->trig in iio_trigger_notify_done()
2026-11-30 0:13 [PATCH 00/15] IIO: Immutable triggers. Close leaks in registration and use more widely Jonathan Cameron
` (6 preceding siblings ...)
2026-11-30 0:13 ` [PATCH 07/15] iio: proximity: vl53l1x-i2c: " Jonathan Cameron
@ 2026-11-30 0:13 ` Jonathan Cameron
2026-11-30 8:20 ` Lorenzo Bianconi
2026-11-30 0:13 ` [PATCH 09/15] iio: humidity: hts221: use iio_trigger_set_default_immutable() Jonathan Cameron
` (6 subsequent siblings)
14 siblings, 1 reply; 18+ messages in thread
From: Jonathan Cameron @ 2026-11-30 0:13 UTC (permalink / raw)
To: linux-iio, linux, Jonathan Cameron, David Lechner, Nuno Sá,
Andy Shevchenko, Michael Hennerich, Radu Sabau, Song Qiang,
Siratul Islam, Lorenzo Bianconi, Alisa-Dariana Roman,
Ramona Bolboaca, Jean-Baptiste Maneyrol
Cc: Jonathan Cameron
From: Jonathan Cameron <jonathan.cameron@oss.qualcomm.com>
The trigger handler should notify the trigger that is currently in use
by the device, which is iio_dev->trig. As the driver only accepts its
own trigger, this is always the same as hw->trig, but using
iio_dev->trig is more obviously correct and matches other IIO drivers.
It will also remove one confusing difference in a rework series that
will follow shortly.
Signed-off-by: Jonathan Cameron <jonathan.cameron@oss.qualcomm.com>
---
drivers/iio/humidity/hts221_buffer.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/iio/humidity/hts221_buffer.c b/drivers/iio/humidity/hts221_buffer.c
index 25e7eff0436d..ee81d5e73ab5 100644
--- a/drivers/iio/humidity/hts221_buffer.c
+++ b/drivers/iio/humidity/hts221_buffer.c
@@ -183,7 +183,7 @@ static irqreturn_t hts221_buffer_handler_thread(int irq, void *p)
iio_get_time_ns(iio_dev));
out:
- iio_trigger_notify_done(hw->trig);
+ iio_trigger_notify_done(iio_dev->trig);
return IRQ_HANDLED;
}
--
2.56.1
^ permalink raw reply related [flat|nested] 18+ messages in thread* Re: [PATCH 08/15] iio: humidity: hts221: use iio_dev->trig in iio_trigger_notify_done()
2026-11-30 0:13 ` [PATCH 08/15] iio: humidity: hts221: use iio_dev->trig in iio_trigger_notify_done() Jonathan Cameron
@ 2026-11-30 8:20 ` Lorenzo Bianconi
0 siblings, 0 replies; 18+ messages in thread
From: Lorenzo Bianconi @ 2026-11-30 8:20 UTC (permalink / raw)
To: Jonathan Cameron
Cc: linux-iio, linux, David Lechner, Nuno Sá, Andy Shevchenko,
Michael Hennerich, Radu Sabau, Song Qiang, Siratul Islam,
Alisa-Dariana Roman, Ramona Bolboaca, Jean-Baptiste Maneyrol,
Jonathan Cameron
[-- Attachment #1: Type: text/plain, Size: 1237 bytes --]
On Nov 30, Jonathan Cameron wrote:
> From: Jonathan Cameron <jonathan.cameron@oss.qualcomm.com>
>
> The trigger handler should notify the trigger that is currently in use
> by the device, which is iio_dev->trig. As the driver only accepts its
> own trigger, this is always the same as hw->trig, but using
> iio_dev->trig is more obviously correct and matches other IIO drivers.
> It will also remove one confusing difference in a rework series that
> will follow shortly.
>
> Signed-off-by: Jonathan Cameron <jonathan.cameron@oss.qualcomm.com>
Reviewed-by: Lorenzo Bianconi <lorenzo@kernel.org>
> ---
> drivers/iio/humidity/hts221_buffer.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/drivers/iio/humidity/hts221_buffer.c b/drivers/iio/humidity/hts221_buffer.c
> index 25e7eff0436d..ee81d5e73ab5 100644
> --- a/drivers/iio/humidity/hts221_buffer.c
> +++ b/drivers/iio/humidity/hts221_buffer.c
> @@ -183,7 +183,7 @@ static irqreturn_t hts221_buffer_handler_thread(int irq, void *p)
> iio_get_time_ns(iio_dev));
>
> out:
> - iio_trigger_notify_done(hw->trig);
> + iio_trigger_notify_done(iio_dev->trig);
>
> return IRQ_HANDLED;
> }
>
> --
> 2.56.1
>
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 228 bytes --]
^ permalink raw reply [flat|nested] 18+ messages in thread
* [PATCH 09/15] iio: humidity: hts221: use iio_trigger_set_default_immutable()
2026-11-30 0:13 [PATCH 00/15] IIO: Immutable triggers. Close leaks in registration and use more widely Jonathan Cameron
` (7 preceding siblings ...)
2026-11-30 0:13 ` [PATCH 08/15] iio: humidity: hts221: use iio_dev->trig in iio_trigger_notify_done() Jonathan Cameron
@ 2026-11-30 0:13 ` Jonathan Cameron
2026-11-30 8:21 ` Lorenzo Bianconi
2026-11-30 0:13 ` [PATCH 10/15] iio: adc: ad_sigma_delta: use an immutable default trigger Jonathan Cameron
` (5 subsequent siblings)
14 siblings, 1 reply; 18+ messages in thread
From: Jonathan Cameron @ 2026-11-30 0:13 UTC (permalink / raw)
To: linux-iio, linux, Jonathan Cameron, David Lechner, Nuno Sá,
Andy Shevchenko, Michael Hennerich, Radu Sabau, Song Qiang,
Siratul Islam, Lorenzo Bianconi, Alisa-Dariana Roman,
Ramona Bolboaca, Jean-Baptiste Maneyrol
Cc: Jonathan Cameron
From: Jonathan Cameron <jonathan.cameron@oss.qualcomm.com>
Use iio_trigger_set_default_immutable() 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.
Previously the reference was taken even if devm_iio_trigger_register()
failed, hitting the WARN_ONCE() in iio_trigger_get() for an unregistered
trigger. Return the error before setting the default trigger instead.
The driver only accepts its own data ready trigger and used
hts221_validate_trigger() to enforce that. That callback is equivalent
to iio_validate_own_trigger(). An immutable trigger gives the same
guarantee.
Potential userspace ABI impact. Previously the trigger could be cleared
by writing an empty string, or any name that is not a registered trigger,
to current_trigger. That now fails with -EPERM, as does selecting a
different trigger, which previously failed with -EINVAL. Writing the name
of the current trigger still succeeds. Userspace software may exist that
is dependent on the tear down behavior however that userspace would not
have worked with the existing immutable triggers so needs fixing anyway.
Signed-off-by: Jonathan Cameron <jonathan.cameron@oss.qualcomm.com>
---
drivers/iio/humidity/hts221_buffer.c | 6 +++---
drivers/iio/humidity/hts221_core.c | 9 ---------
2 files changed, 3 insertions(+), 12 deletions(-)
diff --git a/drivers/iio/humidity/hts221_buffer.c b/drivers/iio/humidity/hts221_buffer.c
index ee81d5e73ab5..5e6f9c9eb08d 100644
--- a/drivers/iio/humidity/hts221_buffer.c
+++ b/drivers/iio/humidity/hts221_buffer.c
@@ -134,10 +134,10 @@ int hts221_allocate_trigger(struct iio_dev *iio_dev)
hw->trig->ops = &hts221_trigger_ops;
err = devm_iio_trigger_register(hw->dev, hw->trig);
+ if (err)
+ return err;
- iio_dev->trig = iio_trigger_get(hw->trig);
-
- return err;
+ return iio_trigger_set_default_immutable(iio_dev, hw->trig);
}
static int hts221_buffer_preenable(struct iio_dev *iio_dev)
diff --git a/drivers/iio/humidity/hts221_core.c b/drivers/iio/humidity/hts221_core.c
index 47a10884d812..2b5e71aa7b2e 100644
--- a/drivers/iio/humidity/hts221_core.c
+++ b/drivers/iio/humidity/hts221_core.c
@@ -522,19 +522,10 @@ static int hts221_write_raw(struct iio_dev *iio_dev,
return ret;
}
-static int hts221_validate_trigger(struct iio_dev *iio_dev,
- struct iio_trigger *trig)
-{
- struct hts221_hw *hw = iio_priv(iio_dev);
-
- return hw->trig == trig ? 0 : -EINVAL;
-}
-
static const struct iio_info hts221_info = {
.read_raw = hts221_read_raw,
.write_raw = hts221_write_raw,
.read_avail = hts221_read_avail,
- .validate_trigger = hts221_validate_trigger,
};
static const unsigned long hts221_scan_masks[] = {0x3, 0x0};
--
2.56.1
^ permalink raw reply related [flat|nested] 18+ messages in thread* Re: [PATCH 09/15] iio: humidity: hts221: use iio_trigger_set_default_immutable()
2026-11-30 0:13 ` [PATCH 09/15] iio: humidity: hts221: use iio_trigger_set_default_immutable() Jonathan Cameron
@ 2026-11-30 8:21 ` Lorenzo Bianconi
0 siblings, 0 replies; 18+ messages in thread
From: Lorenzo Bianconi @ 2026-11-30 8:21 UTC (permalink / raw)
To: Jonathan Cameron
Cc: linux-iio, linux, David Lechner, Nuno Sá, Andy Shevchenko,
Michael Hennerich, Radu Sabau, Song Qiang, Siratul Islam,
Alisa-Dariana Roman, Ramona Bolboaca, Jean-Baptiste Maneyrol,
Jonathan Cameron
[-- Attachment #1: Type: text/plain, Size: 3136 bytes --]
On Nov 30, Jonathan Cameron wrote:
> From: Jonathan Cameron <jonathan.cameron@oss.qualcomm.com>
>
> Use iio_trigger_set_default_immutable() 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.
>
> Previously the reference was taken even if devm_iio_trigger_register()
> failed, hitting the WARN_ONCE() in iio_trigger_get() for an unregistered
> trigger. Return the error before setting the default trigger instead.
>
> The driver only accepts its own data ready trigger and used
> hts221_validate_trigger() to enforce that. That callback is equivalent
> to iio_validate_own_trigger(). An immutable trigger gives the same
> guarantee.
>
> Potential userspace ABI impact. Previously the trigger could be cleared
> by writing an empty string, or any name that is not a registered trigger,
> to current_trigger. That now fails with -EPERM, as does selecting a
> different trigger, which previously failed with -EINVAL. Writing the name
> of the current trigger still succeeds. Userspace software may exist that
> is dependent on the tear down behavior however that userspace would not
> have worked with the existing immutable triggers so needs fixing anyway.
>
> Signed-off-by: Jonathan Cameron <jonathan.cameron@oss.qualcomm.com>
Reviewed-by: Lorenzo Bianconi <lorenzo@kernel.org>
> ---
> drivers/iio/humidity/hts221_buffer.c | 6 +++---
> drivers/iio/humidity/hts221_core.c | 9 ---------
> 2 files changed, 3 insertions(+), 12 deletions(-)
>
> diff --git a/drivers/iio/humidity/hts221_buffer.c b/drivers/iio/humidity/hts221_buffer.c
> index ee81d5e73ab5..5e6f9c9eb08d 100644
> --- a/drivers/iio/humidity/hts221_buffer.c
> +++ b/drivers/iio/humidity/hts221_buffer.c
> @@ -134,10 +134,10 @@ int hts221_allocate_trigger(struct iio_dev *iio_dev)
> hw->trig->ops = &hts221_trigger_ops;
>
> err = devm_iio_trigger_register(hw->dev, hw->trig);
> + if (err)
> + return err;
>
> - iio_dev->trig = iio_trigger_get(hw->trig);
> -
> - return err;
> + return iio_trigger_set_default_immutable(iio_dev, hw->trig);
> }
>
> static int hts221_buffer_preenable(struct iio_dev *iio_dev)
> diff --git a/drivers/iio/humidity/hts221_core.c b/drivers/iio/humidity/hts221_core.c
> index 47a10884d812..2b5e71aa7b2e 100644
> --- a/drivers/iio/humidity/hts221_core.c
> +++ b/drivers/iio/humidity/hts221_core.c
> @@ -522,19 +522,10 @@ static int hts221_write_raw(struct iio_dev *iio_dev,
> return ret;
> }
>
> -static int hts221_validate_trigger(struct iio_dev *iio_dev,
> - struct iio_trigger *trig)
> -{
> - struct hts221_hw *hw = iio_priv(iio_dev);
> -
> - return hw->trig == trig ? 0 : -EINVAL;
> -}
> -
> static const struct iio_info hts221_info = {
> .read_raw = hts221_read_raw,
> .write_raw = hts221_write_raw,
> .read_avail = hts221_read_avail,
> - .validate_trigger = hts221_validate_trigger,
> };
>
> static const unsigned long hts221_scan_masks[] = {0x3, 0x0};
>
> --
> 2.56.1
>
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 228 bytes --]
^ permalink raw reply [flat|nested] 18+ messages in thread
* [PATCH 10/15] iio: adc: ad_sigma_delta: use an immutable default trigger
2026-11-30 0:13 [PATCH 00/15] IIO: Immutable triggers. Close leaks in registration and use more widely Jonathan Cameron
` (8 preceding siblings ...)
2026-11-30 0:13 ` [PATCH 09/15] iio: humidity: hts221: use iio_trigger_set_default_immutable() Jonathan Cameron
@ 2026-11-30 0:13 ` Jonathan Cameron
2026-11-30 0:13 ` [PATCH 11/15] iio: adc: ad_sigma_delta: drop ad_sd_validate_trigger() Jonathan Cameron
` (4 subsequent siblings)
14 siblings, 0 replies; 18+ messages in thread
From: Jonathan Cameron @ 2026-11-30 0:13 UTC (permalink / raw)
To: linux-iio, linux, Jonathan Cameron, David Lechner, Nuno Sá,
Andy Shevchenko, Michael Hennerich, Radu Sabau, Song Qiang,
Siratul Islam, Lorenzo Bianconi, Alisa-Dariana Roman,
Ramona Bolboaca, Jean-Baptiste Maneyrol
Cc: Jonathan Cameron
From: Jonathan Cameron <jonathan.cameron@oss.qualcomm.com>
Use iio_trigger_set_default_immutable() rather than taking a reference
to the trigger in devm_ad_sd_probe_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 of devm_ad_sd_setup_buffer_and_trigger() register the device
with devm_iio_device_register() and none of them, nor the library
itself, access indio_dev->trig before that point. The data ready
interrupt handler polls sigma_delta->trig directly.
All users other than ad7780 restrict the trigger to the device's own via
ad_sd_validate_trigger(). The library relies on that trigger: the data
ready interrupt it requests polls sigma_delta->trig and the buffer
enable and disable paths manage that interrupt. Making the trigger
immutable has the IIO core enforce this for all users.
ad_sd_validate_trigger() is removed in a following patch.
This changes the behaviour of ad7780, which previously allowed any
trigger to be bound. Given the above, using any other trigger was
unlikely to work as expected.
Potential userspace ABI impact. Previously the trigger could be cleared
by writing an empty string, or any name that is not a registered trigger,
to current_trigger. That now fails with -EPERM, as does selecting a
different trigger, which previously failed with -EINVAL. Writing the
name of the current trigger still succeeds. It is possible some userspace
code relies on this tear down behaviour though note that code won't
work with existing immutable triggers.
Signed-off-by: Jonathan Cameron <jonathan.cameron@oss.qualcomm.com>
---
drivers/iio/adc/ad_sigma_delta.c | 6 ++++--
1 file changed, 4 insertions(+), 2 deletions(-)
diff --git a/drivers/iio/adc/ad_sigma_delta.c b/drivers/iio/adc/ad_sigma_delta.c
index 8e96e88c9de6..6a5af8ffa281 100644
--- a/drivers/iio/adc/ad_sigma_delta.c
+++ b/drivers/iio/adc/ad_sigma_delta.c
@@ -796,8 +796,10 @@ static int devm_ad_sd_probe_trigger(struct device *dev, struct iio_dev *indio_de
if (ret)
return ret;
- /* select default trigger */
- indio_dev->trig = iio_trigger_get(sigma_delta->trig);
+ ret = iio_trigger_set_default_immutable(indio_dev,
+ sigma_delta->trig);
+ if (ret)
+ return ret;
}
return 0;
--
2.56.1
^ permalink raw reply related [flat|nested] 18+ messages in thread* [PATCH 11/15] iio: adc: ad_sigma_delta: drop ad_sd_validate_trigger()
2026-11-30 0:13 [PATCH 00/15] IIO: Immutable triggers. Close leaks in registration and use more widely Jonathan Cameron
` (9 preceding siblings ...)
2026-11-30 0:13 ` [PATCH 10/15] iio: adc: ad_sigma_delta: use an immutable default trigger Jonathan Cameron
@ 2026-11-30 0:13 ` Jonathan Cameron
2026-11-30 0:13 ` [PATCH 12/15] iio: imu: inv_mpu6050: use iio_trigger_set_default_immutable() Jonathan Cameron
` (3 subsequent siblings)
14 siblings, 0 replies; 18+ messages in thread
From: Jonathan Cameron @ 2026-11-30 0:13 UTC (permalink / raw)
To: linux-iio, linux, Jonathan Cameron, David Lechner, Nuno Sá,
Andy Shevchenko, Michael Hennerich, Radu Sabau, Song Qiang,
Siratul Islam, Lorenzo Bianconi, Alisa-Dariana Roman,
Ramona Bolboaca, Jean-Baptiste Maneyrol
Cc: Jonathan Cameron
From: Jonathan Cameron <jonathan.cameron@oss.qualcomm.com>
The default trigger set up by devm_ad_sd_setup_buffer_and_trigger() is
now immutable, so the IIO core rejects any attempt to change it before
validate_trigger() would be called. Drop the callback from all users and
remove it from the library.
Signed-off-by: Jonathan Cameron <jonathan.cameron@oss.qualcomm.com>
---
drivers/iio/adc/ad7124.c | 1 -
drivers/iio/adc/ad7173.c | 1 -
drivers/iio/adc/ad7191.c | 1 -
drivers/iio/adc/ad7192.c | 3 ---
drivers/iio/adc/ad7791.c | 2 --
drivers/iio/adc/ad7793.c | 2 --
drivers/iio/adc/ad_sigma_delta.c | 19 -------------------
drivers/iio/adc/max11205.c | 1 -
include/linux/iio/adc/ad_sigma_delta.h | 2 --
9 files changed, 32 deletions(-)
diff --git a/drivers/iio/adc/ad7124.c b/drivers/iio/adc/ad7124.c
index c2c1662bd10d..e0b6e79d9927 100644
--- a/drivers/iio/adc/ad7124.c
+++ b/drivers/iio/adc/ad7124.c
@@ -936,7 +936,6 @@ static const struct iio_info ad7124_info = {
.read_raw = ad7124_read_raw,
.write_raw = ad7124_write_raw,
.debugfs_reg_access = &ad7124_reg_access,
- .validate_trigger = ad_sd_validate_trigger,
.update_scan_mode = ad7124_update_scan_mode,
};
diff --git a/drivers/iio/adc/ad7173.c b/drivers/iio/adc/ad7173.c
index ece526def7a3..3051446e9f5d 100644
--- a/drivers/iio/adc/ad7173.c
+++ b/drivers/iio/adc/ad7173.c
@@ -1541,7 +1541,6 @@ static const struct iio_info ad7173_info = {
.read_raw = &ad7173_read_raw,
.write_raw = &ad7173_write_raw,
.debugfs_reg_access = &ad7173_debug_reg_access,
- .validate_trigger = ad_sd_validate_trigger,
.update_scan_mode = ad7173_update_scan_mode,
.write_event_config = ad7173_write_event_config,
.read_event_config = ad7173_read_event_config,
diff --git a/drivers/iio/adc/ad7191.c b/drivers/iio/adc/ad7191.c
index 071d26191b3c..31234e0b7189 100644
--- a/drivers/iio/adc/ad7191.c
+++ b/drivers/iio/adc/ad7191.c
@@ -426,7 +426,6 @@ static const struct iio_info ad7191_info = {
.write_raw = ad7191_write_raw,
.write_raw_get_fmt = ad7191_write_raw_get_fmt,
.read_avail = ad7191_read_avail,
- .validate_trigger = ad_sd_validate_trigger,
};
static const struct iio_chan_spec ad7191_channels[] = {
diff --git a/drivers/iio/adc/ad7192.c b/drivers/iio/adc/ad7192.c
index 5aa540c10b5f..aaa2653d7746 100644
--- a/drivers/iio/adc/ad7192.c
+++ b/drivers/iio/adc/ad7192.c
@@ -1111,7 +1111,6 @@ static const struct iio_info ad7192_info = {
.write_raw_get_fmt = ad7192_write_raw_get_fmt,
.read_avail = ad7192_read_avail,
.attrs = &ad7192_attribute_group,
- .validate_trigger = ad_sd_validate_trigger,
.update_scan_mode = ad7192_update_scan_mode,
};
@@ -1120,7 +1119,6 @@ static const struct iio_info ad7194_info = {
.write_raw = ad7192_write_raw,
.write_raw_get_fmt = ad7192_write_raw_get_fmt,
.read_avail = ad7192_read_avail,
- .validate_trigger = ad_sd_validate_trigger,
};
static const struct iio_info ad7195_info = {
@@ -1129,7 +1127,6 @@ static const struct iio_info ad7195_info = {
.write_raw_get_fmt = ad7192_write_raw_get_fmt,
.read_avail = ad7192_read_avail,
.attrs = &ad7195_attribute_group,
- .validate_trigger = ad_sd_validate_trigger,
.update_scan_mode = ad7192_update_scan_mode,
};
diff --git a/drivers/iio/adc/ad7791.c b/drivers/iio/adc/ad7791.c
index 10aa40ca35e7..b9a9da5e2e86 100644
--- a/drivers/iio/adc/ad7791.c
+++ b/drivers/iio/adc/ad7791.c
@@ -367,13 +367,11 @@ static const struct iio_info ad7791_info = {
.read_raw = &ad7791_read_raw,
.write_raw = &ad7791_write_raw,
.attrs = &ad7791_attribute_group,
- .validate_trigger = ad_sd_validate_trigger,
};
static const struct iio_info ad7791_no_filter_info = {
.read_raw = &ad7791_read_raw,
.write_raw = &ad7791_write_raw,
- .validate_trigger = ad_sd_validate_trigger,
};
static int ad7791_setup(struct ad7791_state *st,
diff --git a/drivers/iio/adc/ad7793.c b/drivers/iio/adc/ad7793.c
index 937c8b09ad45..d2d6620dd909 100644
--- a/drivers/iio/adc/ad7793.c
+++ b/drivers/iio/adc/ad7793.c
@@ -543,7 +543,6 @@ static const struct iio_info ad7793_info = {
.write_raw_get_fmt = &ad7793_write_raw_get_fmt,
.read_avail = ad7793_read_avail,
.attrs = &ad7793_attribute_group,
- .validate_trigger = ad_sd_validate_trigger,
};
static const struct iio_info ad7797_info = {
@@ -551,7 +550,6 @@ static const struct iio_info ad7797_info = {
.write_raw = &ad7793_write_raw,
.write_raw_get_fmt = &ad7793_write_raw_get_fmt,
.attrs = &ad7797_attribute_group,
- .validate_trigger = ad_sd_validate_trigger,
};
#define __AD7793_CHANNEL(_si, _channel1, _channel2, _address, _bits, \
diff --git a/drivers/iio/adc/ad_sigma_delta.c b/drivers/iio/adc/ad_sigma_delta.c
index 6a5af8ffa281..4b0de90b3170 100644
--- a/drivers/iio/adc/ad_sigma_delta.c
+++ b/drivers/iio/adc/ad_sigma_delta.c
@@ -728,25 +728,6 @@ static irqreturn_t ad_sd_data_rdy_trig_poll(int irq, void *private)
return IRQ_NONE;
}
-/**
- * ad_sd_validate_trigger() - validate_trigger callback for ad_sigma_delta devices
- * @indio_dev: The IIO device
- * @trig: The new trigger
- *
- * Returns: 0 if the 'trig' matches the trigger registered by the ad_sigma_delta
- * device, -EINVAL otherwise.
- */
-int ad_sd_validate_trigger(struct iio_dev *indio_dev, struct iio_trigger *trig)
-{
- struct ad_sigma_delta *sigma_delta = iio_device_get_drvdata(indio_dev);
-
- if (sigma_delta->trig != trig)
- return -EINVAL;
-
- return 0;
-}
-EXPORT_SYMBOL_NS_GPL(ad_sd_validate_trigger, "IIO_AD_SIGMA_DELTA");
-
static int devm_ad_sd_probe_trigger(struct device *dev, struct iio_dev *indio_dev)
{
struct ad_sigma_delta *sigma_delta = iio_device_get_drvdata(indio_dev);
diff --git a/drivers/iio/adc/max11205.c b/drivers/iio/adc/max11205.c
index e46e90400bdc..7accce27a62a 100644
--- a/drivers/iio/adc/max11205.c
+++ b/drivers/iio/adc/max11205.c
@@ -67,7 +67,6 @@ static int max11205_read_raw(struct iio_dev *indio_dev,
static const struct iio_info max11205_iio_info = {
.read_raw = max11205_read_raw,
- .validate_trigger = ad_sd_validate_trigger,
};
static const struct iio_chan_spec max11205_channels[] = {
diff --git a/include/linux/iio/adc/ad_sigma_delta.h b/include/linux/iio/adc/ad_sigma_delta.h
index 6e70a412e218..282e7b32c11e 100644
--- a/include/linux/iio/adc/ad_sigma_delta.h
+++ b/include/linux/iio/adc/ad_sigma_delta.h
@@ -213,6 +213,4 @@ int ad_sd_init(struct ad_sigma_delta *sigma_delta, struct iio_dev *indio_dev,
int devm_ad_sd_setup_buffer_and_trigger(struct device *dev, struct iio_dev *indio_dev);
-int ad_sd_validate_trigger(struct iio_dev *indio_dev, struct iio_trigger *trig);
-
#endif
--
2.56.1
^ permalink raw reply related [flat|nested] 18+ messages in thread* [PATCH 12/15] iio: imu: inv_mpu6050: use iio_trigger_set_default_immutable()
2026-11-30 0:13 [PATCH 00/15] IIO: Immutable triggers. Close leaks in registration and use more widely Jonathan Cameron
` (10 preceding siblings ...)
2026-11-30 0:13 ` [PATCH 11/15] iio: adc: ad_sigma_delta: drop ad_sd_validate_trigger() Jonathan Cameron
@ 2026-11-30 0:13 ` Jonathan Cameron
2026-11-30 0:13 ` [PATCH 13/15] iio: core: add devm_iio_trigger_set_immutable() Jonathan Cameron
` (2 subsequent siblings)
14 siblings, 0 replies; 18+ messages in thread
From: Jonathan Cameron @ 2026-11-30 0:13 UTC (permalink / raw)
To: linux-iio, linux, Jonathan Cameron, David Lechner, Nuno Sá,
Andy Shevchenko, Michael Hennerich, Radu Sabau, Song Qiang,
Siratul Islam, Lorenzo Bianconi, Alisa-Dariana Roman,
Ramona Bolboaca, Jean-Baptiste Maneyrol
Cc: Jonathan Cameron
From: Jonathan Cameron <jonathan.cameron@oss.qualcomm.com>
Use iio_trigger_set_default_immutable() rather than taking a reference
to the trigger in inv_mpu6050_probe_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.
The interrupt handler polls st->trig directly and indio_dev->trig is
only used in the trigger handler, so neither can run with it unset.
The driver only supports buffered capture with its own trigger and used
inv_mpu6050_validate_trigger() to enforce that. An immutable trigger
gives the same guarantee so use one of those instead.
Potential userspace ABI impact. Previously the trigger could be cleared
by writing an empty string, or any name that is not a registered trigger,
to current_trigger. That now fails with -EPERM, as does selecting a
different trigger, which previously failed with -EINVAL. Writing the
name of the current trigger still succeeds. There may be userspace that
relies on the tear down behavior but note that would not work with existing
immutable triggers.
Signed-off-by: Jonathan Cameron <jonathan.cameron@oss.qualcomm.com>
---
drivers/iio/imu/inv_mpu6050/inv_mpu_core.c | 21 ---------------------
drivers/iio/imu/inv_mpu6050/inv_mpu_trigger.c | 4 +---
2 files changed, 1 insertion(+), 24 deletions(-)
diff --git a/drivers/iio/imu/inv_mpu6050/inv_mpu_core.c b/drivers/iio/imu/inv_mpu6050/inv_mpu_core.c
index 3d2e2b5ec676..f8c375c84dbd 100644
--- a/drivers/iio/imu/inv_mpu6050/inv_mpu_core.c
+++ b/drivers/iio/imu/inv_mpu6050/inv_mpu_core.c
@@ -1526,26 +1526,6 @@ static ssize_t inv_attr_show(struct device *dev, struct device_attribute *attr,
}
}
-/**
- * inv_mpu6050_validate_trigger() - validate_trigger callback for invensense
- * MPU6050 device.
- * @indio_dev: The IIO device
- * @trig: The new trigger
- *
- * Returns: 0 if the 'trig' matches the trigger registered by the MPU6050
- * device, -EINVAL otherwise.
- */
-static int inv_mpu6050_validate_trigger(struct iio_dev *indio_dev,
- struct iio_trigger *trig)
-{
- struct inv_mpu6050_state *st = iio_priv(indio_dev);
-
- if (st->trig != trig)
- return -EINVAL;
-
- return 0;
-}
-
static const struct iio_mount_matrix *
inv_get_mount_matrix(const struct iio_dev *indio_dev,
const struct iio_chan_spec *chan)
@@ -1857,7 +1837,6 @@ static const struct iio_info mpu_info = {
.write_event_config = inv_mpu6050_write_event_config,
.read_event_value = inv_mpu6050_read_event_value,
.write_event_value = inv_mpu6050_write_event_value,
- .validate_trigger = inv_mpu6050_validate_trigger,
.debugfs_reg_access = &inv_mpu6050_reg_access,
};
diff --git a/drivers/iio/imu/inv_mpu6050/inv_mpu_trigger.c b/drivers/iio/imu/inv_mpu6050/inv_mpu_trigger.c
index 5b76c3a7fbd8..99f12bb9a9df 100644
--- a/drivers/iio/imu/inv_mpu6050/inv_mpu_trigger.c
+++ b/drivers/iio/imu/inv_mpu6050/inv_mpu_trigger.c
@@ -330,7 +330,5 @@ int inv_mpu6050_probe_trigger(struct iio_dev *indio_dev, int irq_type)
if (ret)
return ret;
- indio_dev->trig = iio_trigger_get(st->trig);
-
- return 0;
+ return iio_trigger_set_default_immutable(indio_dev, st->trig);
}
--
2.56.1
^ permalink raw reply related [flat|nested] 18+ messages in thread* [PATCH 13/15] iio: core: add devm_iio_trigger_set_immutable()
2026-11-30 0:13 [PATCH 00/15] IIO: Immutable triggers. Close leaks in registration and use more widely Jonathan Cameron
` (11 preceding siblings ...)
2026-11-30 0:13 ` [PATCH 12/15] iio: imu: inv_mpu6050: use iio_trigger_set_default_immutable() Jonathan Cameron
@ 2026-11-30 0:13 ` Jonathan Cameron
2026-11-30 0:13 ` [PATCH 14/15] iio: potentiostat: lmp91000: use devm managed probe Jonathan Cameron
2026-11-30 0:13 ` [PATCH 15/15] iio: potentiostat: lmp91000: undo immutable trigger on unbind Jonathan Cameron
14 siblings, 0 replies; 18+ messages in thread
From: Jonathan Cameron @ 2026-11-30 0:13 UTC (permalink / raw)
To: linux-iio, linux, Jonathan Cameron, David Lechner, Nuno Sá,
Andy Shevchenko, Michael Hennerich, Radu Sabau, Song Qiang,
Siratul Islam, Lorenzo Bianconi, Alisa-Dariana Roman,
Ramona Bolboaca, Jean-Baptiste Maneyrol
Cc: Jonathan Cameron
From: Jonathan Cameron <jonathan.cameron@oss.qualcomm.com>
The lmp91000 uses iio_trigger_set_immutable() to set its trigger
as the one used by an IIO device belonging to another driver. This
is then used to drive data capture which the lmp91000 uses via
a callback buffer. Nothing undoes this when the calling driver is
unbound or fails to probe, leaving the other device with an
immutable reference to a trigger that has been unregistered.
That reference also pins the module that provided the trigger, and a
subsequent call when the driver binds again hits the WARN_ON() for an
already immutable trigger and overwrites the earlier reference without
dropping it.
Add devm_iio_trigger_set_immutable() which registers an action to clear
the trigger, mark it no longer immutable and drop the reference when the
calling device is unbound.
Signed-off-by: Jonathan Cameron <jonathan.cameron@oss.qualcomm.com>
---
There are other life cycle problems that need looking into for this
unusual device, but they aren't the scope of this particular series!
---
drivers/iio/industrialio-trigger.c | 31 +++++++++++++++++++++++++++++++
include/linux/iio/trigger.h | 20 ++++++++++++++++++++
2 files changed, 51 insertions(+)
diff --git a/drivers/iio/industrialio-trigger.c b/drivers/iio/industrialio-trigger.c
index 62adbbeb36f2..444a1cff1f7f 100644
--- a/drivers/iio/industrialio-trigger.c
+++ b/drivers/iio/industrialio-trigger.c
@@ -128,6 +128,37 @@ int iio_trigger_set_immutable(struct iio_dev *indio_dev, struct iio_trigger *tri
}
EXPORT_SYMBOL(iio_trigger_set_immutable);
+static void iio_trigger_clear_immutable(void *data)
+{
+ struct iio_dev *indio_dev = data;
+ struct iio_dev_opaque *iio_dev_opaque = to_iio_dev_opaque(indio_dev);
+ struct iio_trigger *trig;
+
+ scoped_guard(mutex, &iio_dev_opaque->mlock) {
+ trig = indio_dev->trig;
+ indio_dev->trig = NULL;
+ iio_dev_opaque->trig_readonly = false;
+ }
+
+ if (trig)
+ iio_trigger_put(trig);
+}
+
+int devm_iio_trigger_set_immutable(struct device *dev,
+ struct iio_dev *indio_dev,
+ struct iio_trigger *trig)
+{
+ int ret;
+
+ ret = iio_trigger_set_immutable(indio_dev, trig);
+ if (ret)
+ return ret;
+
+ return devm_add_action_or_reset(dev, iio_trigger_clear_immutable,
+ indio_dev);
+}
+EXPORT_SYMBOL(devm_iio_trigger_set_immutable);
+
int iio_trigger_set_default_immutable(struct iio_dev *indio_dev,
struct iio_trigger *trig)
{
diff --git a/include/linux/iio/trigger.h b/include/linux/iio/trigger.h
index 56731365a8f9..081febe21690 100644
--- a/include/linux/iio/trigger.h
+++ b/include/linux/iio/trigger.h
@@ -155,6 +155,26 @@ void iio_trigger_unregister(struct iio_trigger *trig_info);
**/
int iio_trigger_set_immutable(struct iio_dev *indio_dev, struct iio_trigger *trig);
+/**
+ * devm_iio_trigger_set_immutable() - Resource-managed iio_trigger_set_immutable()
+ *
+ * @dev: device to which the lifetime of the immutable trigger setting is bound
+ * @indio_dev: IIO device structure containing the device
+ * @trig: trigger to assign to device
+ *
+ * As iio_trigger_set_immutable(), but when @dev is unbound the trigger is
+ * removed from @indio_dev, it is no longer marked immutable and the
+ * reference to @trig is dropped. Intended for a driver setting its trigger
+ * on an IIO device provided by another driver. The caller must ensure that
+ * @indio_dev remains valid when the action runs, for example by calling
+ * this after obtaining the IIO channels with devm managed release so that
+ * they are released after this action has run. Any buffer using @trig must
+ * be disabled before the action runs.
+ **/
+int devm_iio_trigger_set_immutable(struct device *dev,
+ struct iio_dev *indio_dev,
+ struct iio_trigger *trig);
+
/**
* iio_trigger_set_default_immutable() - set an immutable default trigger
*
--
2.56.1
^ permalink raw reply related [flat|nested] 18+ messages in thread* [PATCH 14/15] iio: potentiostat: lmp91000: use devm managed probe
2026-11-30 0:13 [PATCH 00/15] IIO: Immutable triggers. Close leaks in registration and use more widely Jonathan Cameron
` (12 preceding siblings ...)
2026-11-30 0:13 ` [PATCH 13/15] iio: core: add devm_iio_trigger_set_immutable() Jonathan Cameron
@ 2026-11-30 0:13 ` Jonathan Cameron
2026-11-30 0:13 ` [PATCH 15/15] iio: potentiostat: lmp91000: undo immutable trigger on unbind Jonathan Cameron
14 siblings, 0 replies; 18+ messages in thread
From: Jonathan Cameron @ 2026-11-30 0:13 UTC (permalink / raw)
To: linux-iio, linux, Jonathan Cameron, David Lechner, Nuno Sá,
Andy Shevchenko, Michael Hennerich, Radu Sabau, Song Qiang,
Siratul Islam, Lorenzo Bianconi, Alisa-Dariana Roman,
Ramona Bolboaca, Jean-Baptiste Maneyrol
Cc: Jonathan Cameron
From: Jonathan Cameron <jonathan.cameron@oss.qualcomm.com>
Convert the remaining calls in lmp91000_probe() to their devm
equivalents with the exception of the immutable trigger (next patch).
The explicit iio_channel_stop_all_cb() in remove is not needed:
iio_device_unregister() disables all buffers, which stops the callback
buffer via lmp91000_buffer_predisable(), and direct reads stop it
themselves.
This is a precursor to using a devm managed helper to undo the setting
of the immutable trigger on the ADC device, which must run before the
callback buffer, and with it the reference to that device, is released.
Signed-off-by: Jonathan Cameron <jonathan.cameron@oss.qualcomm.com>
---
drivers/iio/potentiostat/lmp91000.c | 62 ++++++++++++-------------------------
1 file changed, 19 insertions(+), 43 deletions(-)
diff --git a/drivers/iio/potentiostat/lmp91000.c b/drivers/iio/potentiostat/lmp91000.c
index 676e5e962a93..b32608423c58 100644
--- a/drivers/iio/potentiostat/lmp91000.c
+++ b/drivers/iio/potentiostat/lmp91000.c
@@ -292,6 +292,11 @@ static const struct iio_buffer_setup_ops lmp91000_buffer_setup_ops = {
.predisable = lmp91000_buffer_predisable,
};
+static void lmp91000_release_cb_buffer(void *cb_buffer)
+{
+ iio_channel_release_all_cb(cb_buffer);
+}
+
static int lmp91000_probe(struct i2c_client *client)
{
struct device *dev = &client->dev;
@@ -308,7 +313,6 @@ static int lmp91000_probe(struct i2c_client *client)
indio_dev->num_channels = ARRAY_SIZE(lmp91000_channels);
indio_dev->name = LMP91000_DRV_NAME;
indio_dev->modes = INDIO_DIRECT_MODE;
- i2c_set_clientdata(client, indio_dev);
data = iio_priv(indio_dev);
data->dev = dev;
@@ -330,69 +334,42 @@ static int lmp91000_probe(struct i2c_client *client)
if (ret)
return ret;
- ret = iio_trigger_register(data->trig);
+ ret = devm_iio_trigger_register(dev, data->trig);
if (ret) {
dev_err(dev, "cannot register iio trigger.\n");
return ret;
}
- ret = iio_triggered_buffer_setup(indio_dev, NULL,
- &lmp91000_buffer_handler,
- &lmp91000_buffer_setup_ops);
+ ret = devm_iio_triggered_buffer_setup(dev, indio_dev, NULL,
+ &lmp91000_buffer_handler,
+ &lmp91000_buffer_setup_ops);
if (ret)
- goto error_unreg_trigger;
+ return ret;
data->cb_buffer = iio_channel_get_all_cb(dev, &lmp91000_buffer_cb,
indio_dev);
-
if (IS_ERR(data->cb_buffer)) {
if (PTR_ERR(data->cb_buffer) == -ENODEV)
- ret = -EPROBE_DEFER;
- else
- ret = PTR_ERR(data->cb_buffer);
+ return -EPROBE_DEFER;
- goto error_unreg_buffer;
+ return PTR_ERR(data->cb_buffer);
}
+ ret = devm_add_action_or_reset(dev, lmp91000_release_cb_buffer,
+ data->cb_buffer);
+ if (ret)
+ return ret;
+
data->adc_chan = iio_channel_cb_get_channels(data->cb_buffer);
ret = iio_trigger_set_immutable(iio_channel_cb_get_iio_dev(data->cb_buffer),
data->trig);
if (ret) {
dev_err(dev, "cannot set immutable trigger.\n");
- goto error_unreg_cb_buffer;
+ return ret;
}
- ret = iio_device_register(indio_dev);
- if (ret)
- goto error_unreg_cb_buffer;
-
- return 0;
-
-error_unreg_cb_buffer:
- iio_channel_release_all_cb(data->cb_buffer);
-
-error_unreg_buffer:
- iio_triggered_buffer_cleanup(indio_dev);
-
-error_unreg_trigger:
- iio_trigger_unregister(data->trig);
-
- return ret;
-}
-
-static void lmp91000_remove(struct i2c_client *client)
-{
- struct iio_dev *indio_dev = i2c_get_clientdata(client);
- struct lmp91000_data *data = iio_priv(indio_dev);
-
- iio_device_unregister(indio_dev);
-
- iio_channel_stop_all_cb(data->cb_buffer);
- iio_channel_release_all_cb(data->cb_buffer);
-
- iio_triggered_buffer_cleanup(indio_dev);
- iio_trigger_unregister(data->trig);
+ return devm_iio_device_register(dev, indio_dev);
}
static const struct of_device_id lmp91000_of_match[] = {
@@ -415,7 +392,6 @@ static struct i2c_driver lmp91000_driver = {
.of_match_table = lmp91000_of_match,
},
.probe = lmp91000_probe,
- .remove = lmp91000_remove,
.id_table = lmp91000_id,
};
module_i2c_driver(lmp91000_driver);
--
2.56.1
^ permalink raw reply related [flat|nested] 18+ messages in thread* [PATCH 15/15] iio: potentiostat: lmp91000: undo immutable trigger on unbind
2026-11-30 0:13 [PATCH 00/15] IIO: Immutable triggers. Close leaks in registration and use more widely Jonathan Cameron
` (13 preceding siblings ...)
2026-11-30 0:13 ` [PATCH 14/15] iio: potentiostat: lmp91000: use devm managed probe Jonathan Cameron
@ 2026-11-30 0:13 ` Jonathan Cameron
14 siblings, 0 replies; 18+ messages in thread
From: Jonathan Cameron @ 2026-11-30 0:13 UTC (permalink / raw)
To: linux-iio, linux, Jonathan Cameron, David Lechner, Nuno Sá,
Andy Shevchenko, Michael Hennerich, Radu Sabau, Song Qiang,
Siratul Islam, Lorenzo Bianconi, Alisa-Dariana Roman,
Ramona Bolboaca, Jean-Baptiste Maneyrol
Cc: Jonathan Cameron
From: Jonathan Cameron <jonathan.cameron@oss.qualcomm.com>
The driver sets its trigger as the immutable trigger of the ADC device
it uses via a callback buffer, but never undoes that. On unbind, or if
probe fails after that point, the ADC device is left holding a reference
to a trigger that has been unregistered, which also pins this module,
and binding again hits the WARN_ON() for an already immutable trigger
and leaks the earlier reference.
Use devm_iio_trigger_set_immutable() so that this is undone on unbind.
Signed-off-by: Jonathan Cameron <jonathan.cameron@oss.qualcomm.com>
---
LLM assisted. Built only. Probably a long shot (given the fix sent
out earlier today rather implies the upstream version of this driver
has not worked for a long time), but I'd really like some testing on
this one if possible!
---
drivers/iio/potentiostat/lmp91000.c | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/drivers/iio/potentiostat/lmp91000.c b/drivers/iio/potentiostat/lmp91000.c
index b32608423c58..ea5c8309159c 100644
--- a/drivers/iio/potentiostat/lmp91000.c
+++ b/drivers/iio/potentiostat/lmp91000.c
@@ -301,7 +301,7 @@ static int lmp91000_probe(struct i2c_client *client)
{
struct device *dev = &client->dev;
struct lmp91000_data *data;
- struct iio_dev *indio_dev;
+ struct iio_dev *indio_dev, *adc_dev;
int ret;
indio_dev = devm_iio_device_alloc(dev, sizeof(*data));
@@ -362,8 +362,8 @@ static int lmp91000_probe(struct i2c_client *client)
data->adc_chan = iio_channel_cb_get_channels(data->cb_buffer);
- ret = iio_trigger_set_immutable(iio_channel_cb_get_iio_dev(data->cb_buffer),
- data->trig);
+ adc_dev = iio_channel_cb_get_iio_dev(data->cb_buffer);
+ ret = devm_iio_trigger_set_immutable(dev, adc_dev, data->trig);
if (ret) {
dev_err(dev, "cannot set immutable trigger.\n");
return ret;
--
2.56.1
^ permalink raw reply related [flat|nested] 18+ messages in thread