[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <DM5PR12MB1850B893A94623B610ED4552C05A9@DM5PR12MB1850.namprd12.prod.outlook.com>
Date: Thu, 20 Jan 2022 11:30:08 +0000
From: Akhil R <akhilrajeev@...dia.com>
To: Andy Shevchenko <andy.shevchenko@...il.com>,
Uwe Kleine-König
<u.kleine-koenig@...gutronix.de>
CC: Christian Koenig <christian.koenig@....com>,
Dmitry Osipenko <digetx@...il.com>,
Greg Kroah-Hartman <gregkh@...uxfoundation.org>,
Jonathan Hunter <jonathanh@...dia.com>,
Laxman Dewangan <ldewangan@...dia.com>,
linux-i2c <linux-i2c@...r.kernel.org>,
Linux Kernel Mailing List <linux-kernel@...r.kernel.org>,
linux-tegra <linux-tegra@...r.kernel.org>,
"Rafael J. Wysocki" <rafael@...nel.org>,
Sumit Semwal <sumit.semwal@...aro.org>,
Thierry Reding <thierry.reding@...il.com>,
Wolfram Sang <wsa@...nel.org>, Len Brown <lenb@...nel.org>,
ACPI Devel Maling List <linux-acpi@...r.kernel.org>
Subject: RE: [PATCH v2 3/3] i2c: smbus: Use device_*() functions instead of
of_*()
> > > ...
> > >
> > > > > 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.
> > >
> > The description in of_irq_get*() says -
> > /* Return: Linux IRQ number on success, or 0 on the IRQ mapping
> > failure, or
> > * -EPROBE_DEFER if the IRQ domain is not yet created, or error code
> > in case
> > * of any other failure.
> > */
> > As I see from the code of fwnode_irq_get(), which is used in this
> > case, returns either the return value of of_irq_get() or error code
> > from acpi_irq_get() when it fails, or res.start if it didn't fail. I
> > guess, any of these would not be 0 unless there is an error.
>
> of_irq_get*() seems inconsistent...
>
> Uwe, what do you think?
>
A bit tricky. You are right, as we don't often see a return value of '0' as
an error in Linux. But here since it is a number which is expected, it might
be reasonable to allot 0 to an error as well. Not sure of the exact rationale
in those functions though.
Thanks,
Akhil
Powered by blists - more mailing lists