iio: trigger: iio-trig-interrupt: use devm_* helpers
PATCH 1/1 iio: trigger: iio-trig-interrupt: use devm_* helpers
Convert to devm_iio_trigger_alloc(), devm_request_irq() and devm_iio_trigger_register(). The driver-managed lifecycle removes the manual error-cleanup ladder in probe and the entire .remove callback.
Drop the now-unused iio_interrupt_trigger_info structure: its only purpose was to hold the IRQ number for the manual free_irq() call in .remove, which is no longer needed. The matching linux/slab.h include is also dropped.
No functional change.
--- drivers/iio/trigger/iio-trig-interrupt.c | 63 ++++-------------------- 1 file changed, 9 insertions(+), 54 deletions(-)
drivers/iio/trigger/iio-trig-interrupt.c +9 -54
@@ -9,16 +9,11 @@#include <linux/module.h> #include <linux/platform_device.h> #include <linux/interrupt.h> -#include <linux/slab.h> #include <linux/iio/iio.h> #include <linux/iio/trigger.h> -struct iio_interrupt_trigger_info { -unsigned int irq; -}; -static irqreturn_t iio_interrupt_trigger_poll (int irq,void *private) {iio_trigger_poll (private);
@@ -27,11 +22,10 @@ static irqreturn_t iio_interrupt_trigger_poll(int irq, void *private)static int iio_interrupt_trigger_probe (struct platform_device *pdev) { -struct iio_interrupt_trigger_info *trig_info;struct iio_trigger *trig;unsigned long irqflags;struct resource *irq_res; -int irq, ret =0 ; +int irq, ret; irq_res =platform_get_resource (pdev,IORESOURCE_IRQ ,0 );
@@ -42,61 +36,22 @@ static int iio_interrupt_trigger_probe(struct platform_device *pdev) irq = irq_res->start; - trig =iio_trigger_alloc (NULL ,"irqtrig%d" , irq); -if (!trig) { - ret = -ENOMEM ; - goto error_ret; - } + trig =devm_iio_trigger_alloc (&pdev->dev,"irqtrig%d" , irq); +if (!trig) +return -ENOMEM ; - trig_info =kzalloc_obj (*trig_info); -if (!trig_info) { - ret = -ENOMEM ; - goto error_free_trigger; - } -iio_trigger_set_drvdata (trig, trig_info); - trig_info->irq = irq; - ret =request_irq (irq, iio_interrupt_trigger_poll, - irqflags, trig->name, trig); + ret =devm_request_irq (&pdev->dev, irq, iio_interrupt_trigger_poll, + irqflags, trig->name, trig);if (ret) { -dev_err (&pdev->dev, -"request IRQ-%d failed" , irq); - goto error_free_trig_info; +dev_err (&pdev->dev,"request IRQ-%d failed" , irq); +return ret; } - ret =iio_trigger_register (trig); -if (ret) - goto error_release_irq; -platform_set_drvdata (pdev, trig); - -return 0 ; - -/* First clean up the partly allocated trigger */ -error_release_irq: -free_irq (irq, trig); -error_free_trig_info: -kfree (trig_info); -error_free_trigger: -iio_trigger_free (trig); -error_ret: -return ret; -} - -static void iio_interrupt_trigger_remove (struct platform_device *pdev) -{ -struct iio_trigger *trig; -struct iio_interrupt_trigger_info *trig_info; - - trig =platform_get_drvdata (pdev); - trig_info =iio_trigger_get_drvdata (trig); -iio_trigger_unregister (trig); -free_irq (trig_info->irq, trig); -kfree (trig_info); -iio_trigger_free (trig); +return devm_iio_trigger_register (&pdev->dev, trig); }static struct platform_driver iio_interrupt_trigger_driver = { .probe = iio_interrupt_trigger_probe, - .remove = iio_interrupt_trigger_remove, .driver = { .name ="iio_interrupt_trigger" , },
Signature · 1 line
2.43.0
Quoted 6 lines · Stepan Ionichev
Convert to
devm_iio_trigger_alloc(),devm_request_irq()anddevm_iio_trigger_register(). The driver-managed lifecycle removes the manual error-cleanup ladder in probe and the entire .remove callback.
Quoted 6 lines
Drop the now-unused
iio_interrupt_trigger_infostructure: its only purpose was to hold the IRQ number for the manualfree_irq()call in .remove, which is no longer needed. The matchinglinux/slab.hinclude is also dropped.No functional change.
I would say that this is a functional change, you are changing how resources are managed and how teardown works. (But maybe I'm wrong).
drivers/iio/trigger/iio-trig-interrupt.c static int iio_interrupt_trigger_probe(struct platform_device *pdev) · line 39
Quoted 10 lines
drivers/iio/trigger/iio-trig-interrupt.c +1
-5@@ -42,61 +36,22 @@ static int iio_interrupt_trigger_probe(struct platform_device *pdev) irq = irq_res->start; - trig =iio_trigger_alloc (NULL ,"irqtrig%d" , irq); -if (!trig) { - ret = -ENOMEM ; - goto error_ret; - } + trig =devm_iio_trigger_alloc (&pdev->dev,"irqtrig%d" , irq);
You can deal with this in another patch, but consider introducing a local struct device variable, so you don't have to use &pdev->dev constantly. It makes the code easier to read and saves space!
Quoted 10 lines
drivers/iio/trigger/iio-trig-interrupt.c +2
-7+if (!trig) +return -ENOMEM ; - trig_info =kzalloc_obj (*trig_info); -if (!trig_info) { - ret = -ENOMEM ; - goto error_free_trigger; - } -iio_trigger_set_drvdata (trig, trig_info); - trig_info->irq = irq;
drivers/iio/trigger/iio-trig-interrupt.c static int iio_interrupt_trigger_probe(struct platform_device *pdev) · line 47
Quoted 10 lines
drivers/iio/trigger/iio-trig-interrupt.c +4
-5- ret =request_irq (irq, iio_interrupt_trigger_poll, - irqflags, trig->name, trig); + ret =devm_request_irq (&pdev->dev, irq, iio_interrupt_trigger_poll, + irqflags, trig->name, trig);if (ret) { -dev_err (&pdev->dev, -"request IRQ-%d failed" , irq); - goto error_free_trig_info; +dev_err (&pdev->dev,"request IRQ-%d failed" , irq); +return ret;
If I'm not mistaken, devm_request_irq automatically throws an error on failure, so the dev_err() call is redundant, just keep the return.
Signature · 3 lines
Kind regards CJD
Quoted 3 lines · Joshua Crofts
I would say that this is a functional change, you are changing how resources are managed and how teardown works. (But maybe I'm wrong).
Fair point -- the user-visible behavior on success or on module unload is the same, but the lifetime/ownership model changes. I will reword that in v2 ("convert to devm-managed lifecycle" instead of "no functional change").
Quoted 3 lines
consider introducing a local struct device variable, so you don't have to use
&pdev->devconstantly. It makes the code easier to read and saves space!
OK, will add struct device *dev = &pdev->dev; in v2.
Quoted 3 lines
If I'm not mistaken,
devm_request_irqautomatically throws an error on failure, so thedev_err()call is redundant, just keep the return.
I do not see this in the source. devm_request_irq() in kernel/irq/devres.c wraps request_threaded_irq() with a devres action; neither prints on failure. The caller still needs the error message.
In v2 I can switch from dev_err() to dev_err_probe(), which handles -EPROBE_DEFER cleanly:
if (ret)
return dev_err_probe(dev, ret,
"request IRQ-%d failed\n", irq);
If I missed where devm_request_irq() prints, please point me to it.
Stepan
Quoted 11 lines · Stepan Ionichev
Quoted 3 lines · Joshua Crofts
I would say that this is a functional change, you are changing how resources are managed and how teardown works. (But maybe I'm wrong).
Fair point -- the user-visible behavior on success or on module unload is the same, but the lifetime/ownership model changes. I will reword that in v2 ("convert to devm-managed lifecycle" instead of "no functional change").
Quoted 5 lines
Quoted 3 lines
consider introducing a local struct device variable, so you don't have to use
&pdev->devconstantly. It makes the code easier to read and saves space!OK, will add
struct device *dev = &pdev->dev;in v2.
You can do this in a separate patch though, maybe for the entire driver.
Quoted 12 lines
Quoted 3 lines
If I'm not mistaken,
devm_request_irqautomatically throws an error on failure, so thedev_err()call is redundant, just keep the return.I do not see this in the source.
devm_request_irq()inkernel/irq/devres.cwrapsrequest_threaded_irq()with a devres action; neither prints on failure. The caller still needs the error message.In v2 I can switch from
dev_err()todev_err_probe(), which handles -EPROBE_DEFER cleanly:
Quoted 6 lines
if (ret)
return dev_err_probe(dev, ret,
"request IRQ-%d failed\n", irq);If I missed where
devm_request_irq()prints, please point me to it.
Link to the definition, it's described in the comments.
https://elixir.bootlin.com/linux/v7.1-rc2/source/kernel/irq/devres.c#L94
Signature · 3 lines
Kind regards CJD
Quoted 1 line · Joshua Crofts
On Mon, 11 May 2026 at 15:23, Stepan Ionichev <[email protected]> wrote:
...
Quoted 5 lines
Quoted 1 line
No functional change.
I would say that this is a functional change, you are changing how resources are managed and how teardown works. (But maybe I'm wrong).
Actually yes, this is quite a change that might have some subtle differences.
...
Quoted 6 lines
drivers/iio/trigger/iio-trig-interrupt.c static int iio_interrupt_trigger_probe(struct platform_device *pdev) · line 39
Quoted 6 lines
drivers/iio/trigger/iio-trig-interrupt.c +1
-5- trig =iio_trigger_alloc (NULL ,"irqtrig%d" , irq); -if (!trig) { - ret = -ENOMEM ; - goto error_ret; - } + trig =devm_iio_trigger_alloc (&pdev->dev,"irqtrig%d" , irq);
Looking at this and taking into account the above, have you checked the
- trigger lifetime versus platform device
- parent-child relationship in the sysfs
The latter might lead to interesting side-effects.
Quoted 2 lines
Quoted 2 lines
drivers/iio/trigger/iio-trig-interrupt.c +2
-0+if (!trig) +return -ENOMEM ;
Signature · 2 lines
With Best Regards, Andy Shevchenko
Quoted 3 lines · Stepan Ionichev
Convert to
devm_iio_trigger_alloc(),devm_request_irq()anddevm_iio_trigger_register(). The driver-managed lifecycle removes the manual error-cleanup ladder in probe and the entire .remove
.remove()
Quoted 5 lines
callback.
Drop the now-unused
iio_interrupt_trigger_infostructure: its only purpose was to hold the IRQ number for the manualfree_irq()call in .remove, which is no longer needed. The matching
.remove()
Quoted 3 lines
linux/slab.hinclude is also dropped.No functional change.
...
drivers/iio/trigger/iio-trig-interrupt.c static int iio_interrupt_trigger_probe(struct platform_device *pdev)
Quoted 8 lines
drivers/iio/trigger/iio-trig-interrupt.c +3
-3+ ret =devm_request_irq (&pdev->dev, irq, iio_interrupt_trigger_poll, + irqflags, trig->name, trig);if (ret) { -dev_err (&pdev->dev, -"request IRQ-%d failed" , irq); - goto error_free_trig_info; +dev_err (&pdev->dev,"request IRQ-%d failed" , irq);
No, drop this now duplicate message.
Quoted 2 lines
drivers/iio/trigger/iio-trig-interrupt.c +1
-0+return ret; }
Signature · 2 lines
With Best Regards, Andy Shevchenko
PATCH v2 1/1 iio: trigger: iio-trig-interrupt: use devm_* helpers
In reply to Stepan IonichevConvert to devm_iio_trigger_alloc(), devm_request_irq() and devm_iio_trigger_register(). The driver-managed lifecycle removes the manual error-cleanup ladder in probe and the entire .remove() callback.
Drop the now-unused iio_interrupt_trigger_info structure: its only purpose was to hold the IRQ number for the manual free_irq() call in .remove(), which is no longer needed. The matching linux/slab.h include is also dropped.
---
v2:
- Drop the dev_err() call after devm_request_irq(); really_probe() in the driver core already logs probe failures, so the message would be duplicate (per Andy)
- Use a local struct device *dev = &pdev->dev (per Joshua)
- Drop the "No functional change" claim from the commit message; the resource lifecycle model changes (per Joshua)
- Use .remove() function notation in the commit message (per Andy)
drivers/iio/trigger/iio-trig-interrupt.c | 64 ++++-------------------- 1 file changed, 9 insertions(+), 55 deletions(-)
drivers/iio/trigger/iio-trig-interrupt.c +9 -55
@@ -9,16 +9,11 @@#include <linux/module.h> #include <linux/platform_device.h> #include <linux/interrupt.h> -#include <linux/slab.h> #include <linux/iio/iio.h> #include <linux/iio/trigger.h> -struct iio_interrupt_trigger_info { -unsigned int irq; -}; -static irqreturn_t iio_interrupt_trigger_poll (int irq,void *private) {iio_trigger_poll (private);
@@ -27,11 +22,11 @@ static irqreturn_t iio_interrupt_trigger_poll(int irq, void *private)static int iio_interrupt_trigger_probe (struct platform_device *pdev) { -struct iio_interrupt_trigger_info *trig_info; +struct device *dev = &pdev->dev;struct iio_trigger *trig;unsigned long irqflags;struct resource *irq_res; -int irq, ret =0 ; +int irq, ret; irq_res =platform_get_resource (pdev,IORESOURCE_IRQ ,0 );
@@ -42,61 +37,20 @@ static int iio_interrupt_trigger_probe(struct platform_device *pdev) irq = irq_res->start; - trig =iio_trigger_alloc (NULL ,"irqtrig%d" , irq); -if (!trig) { - ret = -ENOMEM ; - goto error_ret; - } - - trig_info =kzalloc_obj (*trig_info); -if (!trig_info) { - ret = -ENOMEM ; - goto error_free_trigger; - } -iio_trigger_set_drvdata (trig, trig_info); - trig_info->irq = irq; - ret =request_irq (irq, iio_interrupt_trigger_poll, - irqflags, trig->name, trig); -if (ret) { -dev_err (&pdev->dev, -"request IRQ-%d failed" , irq); - goto error_free_trig_info; - } + trig =devm_iio_trigger_alloc (dev,"irqtrig%d" , irq); +if (!trig) +return -ENOMEM ; - ret =iio_trigger_register (trig); + ret =devm_request_irq (dev, irq, iio_interrupt_trigger_poll, + irqflags, trig->name, trig);if (ret) - goto error_release_irq; -platform_set_drvdata (pdev, trig); - -return 0 ; - -/* First clean up the partly allocated trigger */ -error_release_irq: -free_irq (irq, trig); -error_free_trig_info: -kfree (trig_info); -error_free_trigger: -iio_trigger_free (trig); -error_ret: -return ret; -} - -static void iio_interrupt_trigger_remove (struct platform_device *pdev) -{ -struct iio_trigger *trig; -struct iio_interrupt_trigger_info *trig_info; +return ret; - trig =platform_get_drvdata (pdev); - trig_info =iio_trigger_get_drvdata (trig); -iio_trigger_unregister (trig); -free_irq (trig_info->irq, trig); -kfree (trig_info); -iio_trigger_free (trig); +return devm_iio_trigger_register (dev, trig); }static struct platform_driver iio_interrupt_trigger_driver = { .probe = iio_interrupt_trigger_probe, - .remove = iio_interrupt_trigger_remove, .driver = { .name ="iio_interrupt_trigger" , },
Signature · 1 line
2.43.0
Quoted 6 lines · Stepan Ionichev
Convert to
devm_iio_trigger_alloc(),devm_request_irq()anddevm_iio_trigger_register(). The driver-managed lifecycle removes the manual error-cleanup ladder in probe and the entire .remove() callback.
Quoted 6 lines
Drop the now-unused
iio_interrupt_trigger_infostructure: its only purpose was to hold the IRQ number for the manualfree_irq()call in .remove(), which is no longer needed. The matchinglinux/slab.hinclude is also dropped.Signed-off-by Stepan Ionichev <[email protected]>
I know they might be trivial changes, but please slow down when sending new versions - I didn't even finish writing a follow up message to you and already got a new version in my inbox. Ideally wait at least 24 hours before sending, thanks.
(FYI Stepan, you will receive this message twice as I initially only sent it to you).
--
Kind regards
CJD
Quoted 132 lines · Stepan Ionichev
Convert to
devm_iio_trigger_alloc(),devm_request_irq()anddevm_iio_trigger_register(). The driver-managed lifecycle removes the manual error-cleanup ladder in probe and the entire .remove() callback.Drop the now-unused
iio_interrupt_trigger_infostructure: its only purpose was to hold the IRQ number for the manualfree_irq()call in .remove(), which is no longer needed. The matchinglinux/slab.hinclude is also dropped.Signed-off-by Stepan Ionichev <[email protected]>---
v2:
- Drop thedev_err()call afterdevm_request_irq();really_probe()in the driver core already logs probe failures, so the message would be duplicate (per Andy)
- Use a local struct device *dev =&pdev->dev(per Joshua)
- Drop the "No functional change" claim from the commit message; the resource lifecycle model changes (per Joshua)
- Use .remove() function notation in the commit message (per Andy)drivers/iio/trigger/iio-trig-interrupt.c | 64 ++++-------------------- 1 file changed, 9 insertions(+), 55 deletions(-)drivers/iio/trigger/iio-trig-interrupt.c +9
-56@@ -9,16 +9,11 @@#include <linux/module.h> #include <linux/platform_device.h> #include <linux/interrupt.h> -#include <linux/slab.h> #include <linux/iio/iio.h> #include <linux/iio/trigger.h> -struct iio_interrupt_trigger_info { -unsigned int irq; -}; -static irqreturn_t iio_interrupt_trigger_poll (int irq,void *private) {iio_trigger_poll (private);@@ -27,11 +22,11 @@ static irqreturn_t iio_interrupt_trigger_poll(int irq, void *private)static int iio_interrupt_trigger_probe (struct platform_device *pdev) { -struct iio_interrupt_trigger_info *trig_info; +struct device *dev = &pdev->dev;struct iio_trigger *trig;unsigned long irqflags;struct resource *irq_res; -int irq, ret =0 ; +int irq, ret; irq_res =platform_get_resource (pdev,IORESOURCE_IRQ ,0 );@@ -42,61 +37,20 @@ static int iio_interrupt_trigger_probe(struct platform_device *pdev) irq = irq_res->start; - trig =iio_trigger_alloc (NULL ,"irqtrig%d" , irq); -if (!trig) { - ret = -ENOMEM ; - goto error_ret; - } - - trig_info =kzalloc_obj (*trig_info); -if (!trig_info) { - ret = -ENOMEM ; - goto error_free_trigger; - } -iio_trigger_set_drvdata (trig, trig_info); - trig_info->irq = irq; - ret =request_irq (irq, iio_interrupt_trigger_poll, - irqflags, trig->name, trig); -if (ret) { -dev_err (&pdev->dev, -"request IRQ-%d failed" , irq); - goto error_free_trig_info; - } + trig =devm_iio_trigger_alloc (dev,"irqtrig%d" , irq); +if (!trig) +return -ENOMEM ; - ret =iio_trigger_register (trig); + ret =devm_request_irq (dev, irq, iio_interrupt_trigger_poll, + irqflags, trig->name, trig);if (ret) - goto error_release_irq; -platform_set_drvdata (pdev, trig); - -return 0 ; - -/* First clean up the partly allocated trigger */ -error_release_irq: -free_irq (irq, trig); -error_free_trig_info: -kfree (trig_info); -error_free_trigger: -iio_trigger_free (trig); -error_ret: -return ret; -} - -static void iio_interrupt_trigger_remove (struct platform_device *pdev) -{ -struct iio_trigger *trig; -struct iio_interrupt_trigger_info *trig_info; +return ret; - trig =platform_get_drvdata (pdev); - trig_info =iio_trigger_get_drvdata (trig); -iio_trigger_unregister (trig); -free_irq (trig_info->irq, trig); -kfree (trig_info); -iio_trigger_free (trig); +return devm_iio_trigger_register (dev, trig); }static struct platform_driver iio_interrupt_trigger_driver = { .probe = iio_interrupt_trigger_probe, - .remove = iio_interrupt_trigger_remove, .driver = { .name ="iio_interrupt_trigger" , }, --2.43.0
Jonathan Cameron
maintainerQuoted 11 lines · On Mon, 11 May 2026 11:32:29 +0500 Stepan Ionichev <[email protected]> wrote:
Convert to
devm_iio_trigger_alloc(),devm_request_irq()anddevm_iio_trigger_register(). The driver-managed lifecycle removes the manual error-cleanup ladder in probe and the entire .remove() callback.Drop the now-unused
iio_interrupt_trigger_infostructure: its only purpose was to hold the IRQ number for the manualfree_irq()call in .remove(), which is no longer needed. The matchinglinux/slab.hinclude is also dropped.Signed-off-by Stepan Ionichev <[email protected]>
Silly question for you - how does this driver actually bind on a modern platform? That is - how do we get one of these?
Quoted 63 lines
---
v2:
- Drop thedev_err()call afterdevm_request_irq();really_probe()in the driver core already logs probe failures, so the message would be duplicate (per Andy)
- Use a local struct device *dev =&pdev->dev(per Joshua)
- Drop the "No functional change" claim from the commit message; the resource lifecycle model changes (per Joshua)
- Use .remove() function notation in the commit message (per Andy)drivers/iio/trigger/iio-trig-interrupt.c | 64 ++++-------------------- 1 file changed, 9 insertions(+), 55 deletions(-)drivers/iio/trigger/iio-trig-interrupt.c +2
-18@@ -9,16 +9,11 @@#include <linux/module.h> #include <linux/platform_device.h> #include <linux/interrupt.h> -#include <linux/slab.h> #include <linux/iio/iio.h> #include <linux/iio/trigger.h> -struct iio_interrupt_trigger_info { -unsigned int irq; -}; -static irqreturn_t iio_interrupt_trigger_poll (int irq,void *private) {iio_trigger_poll (private);@@ -27,11 +22,11 @@ static irqreturn_t iio_interrupt_trigger_poll(int irq, void *private)static int iio_interrupt_trigger_probe (struct platform_device *pdev) { -struct iio_interrupt_trigger_info *trig_info; +struct device *dev = &pdev->dev;struct iio_trigger *trig;unsigned long irqflags;struct resource *irq_res; -int irq, ret =0 ; +int irq, ret; irq_res =platform_get_resource (pdev,IORESOURCE_IRQ ,0 );@@ -42,61 +37,20 @@ static int iio_interrupt_trigger_probe(struct platform_device *pdev) irq = irq_res->start; - trig =iio_trigger_alloc (NULL ,"irqtrig%d" , irq); -if (!trig) { - ret = -ENOMEM ; - goto error_ret; - } - - trig_info =kzalloc_obj (*trig_info); -if (!trig_info) { - ret = -ENOMEM ; - goto error_free_trigger; - }
drivers/iio/trigger/iio-trig-interrupt.c static int iio_interrupt_trigger_probe(struct platform_device *pdev) · line 40
Quoted 10 lines
drivers/iio/trigger/iio-trig-interrupt.c +1
-9-iio_trigger_set_drvdata (trig, trig_info); - trig_info->irq = irq; - ret =request_irq (irq, iio_interrupt_trigger_poll, - irqflags, trig->name, trig); -if (ret) { -dev_err (&pdev->dev, -"request IRQ-%d failed" , irq); - goto error_free_trig_info; - } + trig =devm_iio_trigger_alloc (dev,"irqtrig%d" , irq);
Passing a parent to the underlying iio_trigger_alloc() is a functional change that needs to be clearly laid out. Do that as a precursor patch where you can then describe the effects that has. Honestly I can't remember so I'd like to see some analysis presented before I look at it!
Quoted 44 lines
drivers/iio/trigger/iio-trig-interrupt.c +6
-28+if (!trig) +return -ENOMEM ; - ret =iio_trigger_register (trig); + ret =devm_request_irq (dev, irq, iio_interrupt_trigger_poll, + irqflags, trig->name, trig);if (ret) - goto error_release_irq; -platform_set_drvdata (pdev, trig); - -return 0 ; - -/* First clean up the partly allocated trigger */ -error_release_irq: -free_irq (irq, trig); -error_free_trig_info: -kfree (trig_info); -error_free_trigger: -iio_trigger_free (trig); -error_ret: -return ret; -} - -static void iio_interrupt_trigger_remove (struct platform_device *pdev) -{ -struct iio_trigger *trig; -struct iio_interrupt_trigger_info *trig_info; +return ret; - trig =platform_get_drvdata (pdev); - trig_info =iio_trigger_get_drvdata (trig); -iio_trigger_unregister (trig); -free_irq (trig_info->irq, trig); -kfree (trig_info); -iio_trigger_free (trig); +return devm_iio_trigger_register (dev, trig); }static struct platform_driver iio_interrupt_trigger_driver = { .probe = iio_interrupt_trigger_probe, - .remove = iio_interrupt_trigger_remove, .driver = { .name ="iio_interrupt_trigger" , },
Quoted 9 lines · Stepan Ionichev
Convert to
devm_iio_trigger_alloc(),devm_request_irq()anddevm_iio_trigger_register(). The driver-managed lifecycle removes the manual error-cleanup ladder in probe and the entire .remove() callback.Drop the now-unused
iio_interrupt_trigger_infostructure: its only purpose was to hold the IRQ number for the manualfree_irq()call in .remove(), which is no longer needed. The matchinglinux/slab.hinclude is also dropped.
...
Quoted 6 lines
Signed-off-by Stepan Ionichev <[email protected]>---
v2:
- Drop thedev_err()call afterdevm_request_irq();really_probe()in the driver core already logs probe failures, so the message would be duplicate (per Andy)
FWIW, it's IRQ core (not driver core!) that does printing.
Quoted 4 lines
- Use a local struct device *dev =
&pdev->dev(per Joshua)
- Drop the "No functional change" claim from the commit message; the resource lifecycle model changes (per Joshua)
- Use .remove() function notation in the commit message (per Andy)
Signature · 2 lines
With Best Regards, Andy Shevchenko
Quoted 5 lines · Andy Shevchenko
Looking at this and taking into account the above, have you checked the
- trigger lifetime versus platform device
- parent-child relationship in the sysfsThe latter might lead to interesting side-effects.
You are right -- the parent change is the real concern here, not just the cleanup ladder.
Checked the rest of IIO: there are 26 other devm_iio_trigger_alloc() callers in drivers/iio/, and all of them pass a non-NULL parent (typically &client->dev, &spi->dev or &indio_dev->dev). The iio-trig-interrupt driver with NULL parent is the only exception.
devm_iio_trigger_alloc() requires a non-NULL parent for devres tracking, so the conversion necessarily introduces one. The trigger then becomes a child of the platform device both in the device tree and in sysfs, and its lifetime is tied to pdev unbind instead of the (former) manual .remove().
If preserving the parent-less behavior is required for userspace or for any subtle reason I have not thought of, please drop both v1 and v2 of this patch. I do not have the IIO trigger framework background to argue that the parent change is safe.
If the conversion is acceptable (in line with the rest of IIO), v2 already addresses the dev_err()/local-device/commit-message nits.
Stepan
Quoted 4 lines · Joshua Crofts
I know they might be trivial changes, but please slow down when sending new versions - I didn't even finish writing a follow up message to you and already got a new version in my inbox. Ideally wait at least 24 hours before sending, thanks.
Sorry, you are right. I will wait at least 24 hours for further review before sending the next version of this and any other patch with open feedback. Noted for the future.
Stepan
Quoted 2 lines · Jonathan Cameron
Silly question for you - how does this driver actually bind on a modern platform? That is - how do we get one of these?
It does not, as far as I can see.
Grep across the mainline tree:
- The string "iio_interrupt_trigger" appears only in the driver itself (drivers/iio/trigger/iio-trig-interrupt.c:101 — the .driver.name).
- No .of_match_table and no .id_table on the driver.
- No platform_device_register*() call anywhere in arch/, drivers/ or board files that would create a device named "iio_interrupt_trigger".
- No Documentation/devicetree/bindings/ entry.
So the only way to instantiate it on a current kernel is an explicit out-of-tree platform_device_register("iio_interrupt_trigger", ...), and nothing in mainline does that.
Given that, please drop v1 and v2 of this patch. The cleanup-for-its- own-sake is not worth the parent / sysfs-hierarchy change Andy flagged when there are no in-tree users to validate it against.
If at some point a user appears in mainline (DT binding, ACPI hookup or a board file), the devm_* conversion can come along with that work.
Sorry for the noise.
Stepan
Jonathan Cameron
maintainerQuoted 19 lines · On Wed, 13 May 2026 13:33:42 +0500 Stepan Ionichev <[email protected]> wrote:
Quoted 2 lines · Jonathan Cameron
Silly question for you - how does this driver actually bind on a modern platform? That is - how do we get one of these?
It does not, as far as I can see.
Grep across the mainline tree:
- The string "
iio_interrupt_trigger" appears only in the driver itself (drivers/iio/trigger/iio-trig-interrupt.c:101— the .driver.name).
- No .of_match_table and no .id_table on the driver.
- No platform_device_register*() call anywhere inarch/,drivers/or board files that would create a device named "iio_interrupt_trigger".
- NoDocumentation/devicetree/bindings/entry.So the only way to instantiate it on a current kernel is an explicit out-of-tree
platform_device_register("iio_interrupt_trigger", ...), and nothing in mainline does that.
Quoted 8 lines
Given that, please drop v1 and v2 of this patch. The cleanup-for-its- own-sake is not worth the parent / sysfs-hierarchy change Andy flagged when there are no in-tree users to validate it against.
If at some point a user appears in mainline (DT binding, ACPI hookup or a board file), the devm_* conversion can come along with that work.
Sorry for the noise.
No problem! You got us looking at it.
So wider question for anyone reading - do we actually want to keep
this driver? Meh, to catch peoples attention better than in this
thread I'll propose a patch dropping it and see what responses we get.
Jonathan
Quoted 2 lines
Stepan
Quoted 2 lines · Jonathan Cameron
On Wed, 13 May 2026 13:33:42 +0500
Stepan Ionichev <[email protected]> wrote:
...
Quoted 3 lines
So wider question for anyone reading - do we actually want to keep
this driver? Meh, to catch peoples attention better than in this
thread I'll propose a patch dropping it and see what responses we get.
I believe people learnt my opinion about code removal — always green light from me (assuming no users)!
Signature · 2 lines
With Best Regards, Andy Shevchenko