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

From: Joshua Crofts

Date: Mon May 11 2026 - 09:57:31 EST


On Mon, 11 May 2026 at 15:42, Stepan Ionichev <sozdayvek@xxxxxxxxx> wrote:
>
> On Mon, May 11, 2026 at 15:33 +0200, Joshua Crofts wrote:
> > 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").
>
> > 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!
>
> OK, will add `struct device *dev = &pdev->dev;` in v2.

You can do this in a separate patch though, maybe for the entire
driver.

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

Link to the definition, it's described in the comments.
https://elixir.bootlin.com/linux/v7.1-rc2/source/kernel/irq/devres.c#L94

--
Kind regards

CJD