From: "Vaittinen, Matti" <Matti.Vaittinen@fi.rohmeurope.com>
To: Andy Shevchenko <andriy.shevchenko@linux.intel.com>,
Matti Vaittinen <mazziesaccount@gmail.com>
Cc: Daniel Scally <djrscally@gmail.com>,
Heikki Krogerus <heikki.krogerus@linux.intel.com>,
Sakari Ailus <sakari.ailus@linux.intel.com>,
Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
"Rafael J. Wysocki" <rafael@kernel.org>,
Wolfram Sang <wsa@kernel.org>, Akhil R <akhilrajeev@nvidia.com>,
"linux-acpi@vger.kernel.org" <linux-acpi@vger.kernel.org>,
"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
"linux-i2c@vger.kernel.org" <linux-i2c@vger.kernel.org>
Subject: Re: [PATCH 1/2] drivers: fwnode: fix fwnode_irq_get_byname()
Date: Tue, 25 Oct 2022 10:00:07 +0000 [thread overview]
Message-ID: <ec8cc1bd-3150-dc5d-8b8a-870f21b52433@fi.rohmeurope.com> (raw)
In-Reply-To: <Y1ep5zN+wifkP7v+@smile.fi.intel.com>
Hi Andy,
Thanks for the review.
On 10/25/22 12:18, Andy Shevchenko wrote:
> On Tue, Oct 25, 2022 at 11:50:59AM +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.
>
> ...
>
>> + ret = fwnode_irq_get(fwnode, index);
>
>> +
>
> Redundant blank line and better to use traditional pattern: >
>> + if (!ret)
>> + return -EINVAL;
>> +
>> + return ret;
>
> if (ret)
> return ret;
>
> /* We treat mapping errors as invalid case */
> return -EINVAL;
>
>> }
I like the added comment - but in this case I don't prefer the
"traditional pattern" you suggest. We do check for a very special error
case indicated by ret 0.
if (!ret)
return -EINVAL;
makes it obvious the zero is special error.
if (ret)
return ret;
the traditional pattern makes this look like traditional error return -
which it is not. The comment you added is nice though. It could be just
before the check for
if (!ret).
I can cook v2 later when I have finished my current task - which may or
may not take a while though....
Yours
-- Matti
--
Matti Vaittinen
Linux kernel developer at ROHM Semiconductors
Oulu Finland
~~ When things go utterly wrong vim users can always type :help! ~~
next prev parent reply other threads:[~2022-10-25 10:06 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-10-25 8:50 [PATCH 0/2] fix fwnode_irq_get_byname() returnvalue Matti Vaittinen
2022-10-25 8:50 ` [PATCH 1/2] drivers: fwnode: fix fwnode_irq_get_byname() Matti Vaittinen
2022-10-25 9:08 ` Sakari Ailus
2022-10-25 9:17 ` Matti Vaittinen
2022-10-25 9:18 ` Andy Shevchenko
2022-10-25 10:00 ` Vaittinen, Matti [this message]
2022-10-25 11:15 ` Andy Shevchenko
2022-10-25 8:51 ` [PATCH 2/2] i2c: i2c-smbus: fwnode_irq_get_byname() return value fix Matti Vaittinen
2022-10-25 9:20 ` [PATCH 0/2] fix fwnode_irq_get_byname() returnvalue Andy Shevchenko
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=ec8cc1bd-3150-dc5d-8b8a-870f21b52433@fi.rohmeurope.com \
--to=matti.vaittinen@fi.rohmeurope.com \
--cc=akhilrajeev@nvidia.com \
--cc=andriy.shevchenko@linux.intel.com \
--cc=djrscally@gmail.com \
--cc=gregkh@linuxfoundation.org \
--cc=heikki.krogerus@linux.intel.com \
--cc=linux-acpi@vger.kernel.org \
--cc=linux-i2c@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=mazziesaccount@gmail.com \
--cc=rafael@kernel.org \
--cc=sakari.ailus@linux.intel.com \
--cc=wsa@kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).