Re: [PATCH v2 1/2] drivers: fwnode: fix fwnode_irq_get_byname()

From: Andy Shevchenko
Date: Tue Oct 25 2022 - 12:22:03 EST


On Tue, Oct 25, 2022 at 06:11:49PM +0300, Matti Vaittinen wrote:
> The fwnode_irq_get_byname() does return 0 upon device-tree IRQ mapping
> failure. This is contradicting the function documentation and can
> potentially be a source of errors like:
>
> int probe(...) {
> ...
>
> irq = fwnode_irq_get_byname();
> if (irq <= 0)
> return irq;
>
> ...
> }
>
> Here we do correctly check the return value from fwnode_irq_get_byname()
> but the driver probe will now return success. (There was already one
> such user in-tree).
>
> Change the fwnode_irq_get_byname() to work as documented and according to
> the common convention and abd always return a negative errno upon failure.

and abd ?

...

> + ret = fwnode_irq_get(fwnode, index);
> + /* We treat mapping errors as invalid case */
> + if (ret == 0)
> + return -EINVAL;
> +
> + return ret;

This looks good.

--
With Best Regards,
Andy Shevchenko