Re: [PATCH] iio: trigger: iio-trig-interrupt: use devm_* helpers

From: Joshua Crofts

Date: Mon May 11 2026 - 09:39:07 EST


On Mon, 11 May 2026 at 15:23, Stepan Ionichev <sozdayvek@xxxxxxxxx> wrote:
>
> 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.

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).

> @@ -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!

> + 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;

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.

--
Kind regards

CJD