Re: [PATCH v2 3/3] i2c: smbus: Use device_*() functions instead of of_*()

From: Andy Shevchenko
Date: Thu Jan 20 2022 - 05:13:43 EST


On Thu, Jan 20, 2022 at 11:48 AM Akhil R <akhilrajeev@xxxxxxxxxx> wrote:
> > On Wed, Jan 12, 2022 at 4:15 PM Akhil R <akhilrajeev@xxxxxxxxxx> wrote:

...

> > This change reveals potential issue:
> >
> > > - irq = of_irq_get_byname(adapter->dev.of_node, "smbus_alert");
> > > + irq = device_irq_get_byname(adapter->dev.parent, "smbus_alert");
> >
> > > if (irq <= 0)
> >
> > I guess this '= 0' part should be fixed first.
>
> '0' is a failure as per the documentation of of_irq_get_byname() as well as
> of_irq_get(). The case is different for acpi_irq_get(), but it is handled in
> fwnode_irq_get(). If I understood it right, a return value of '0' should be
> considered a failure here.

Depends. I have no idea what the original code does here. But
returning an error or 0 from this function seems confusing to me.


--
With Best Regards,
Andy Shevchenko