From: Sakari Ailus <sakari.ailus@linux.intel.com>
To: Matti Vaittinen <mazziesaccount@gmail.com>
Cc: Matti Vaittinen <matti.vaittinen@fi.rohmeurope.com>,
Andy Shevchenko <andriy.shevchenko@linux.intel.com>,
Daniel Scally <djrscally@gmail.com>,
Heikki Krogerus <heikki.krogerus@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-kernel@vger.kernel.org
Subject: Re: [PATCH] drivers: fwnode: fix fwnode_irq_get_byname() kerneldoc
Date: Tue, 25 Oct 2022 06:48:34 +0000 [thread overview]
Message-ID: <Y1eGwtqbOhXCGoaM@paasikivi.fi.intel.com> (raw)
In-Reply-To: <Y1dzCCMCDswQFVvO@dc75zzyyyyyyyyyyyyyby-3.rev.dnainternet.fi>
Moi,
On Tue, Oct 25, 2022 at 08:24:24AM +0300, Matti Vaittinen wrote:
> The fwnode_irq_get_byname() may return zero on device-tree mapping
> error. Fix documentation to reflect this as current documentation
> suggests check:
>
> if (ret < 0)
> is enough to detect the errors. This is not the case.
>
> Add zero as a return value indicating error.
>
> Fixes: ca0acb511c21 ("device property: Add fwnode_irq_get_byname")
> Suggested-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
> Signed-off-by: Matti Vaittinen <mazziesaccount@gmail.com>
> ---
> drivers/base/property.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/drivers/base/property.c b/drivers/base/property.c
> index 4d6278a84868..df437d10aa08 100644
> --- a/drivers/base/property.c
> +++ b/drivers/base/property.c
> @@ -960,7 +960,7 @@ EXPORT_SYMBOL(fwnode_irq_get);
> * string.
> *
> * Return:
> - * Linux IRQ number on success, or negative errno otherwise.
> + * Linux IRQ number on success, zero or negative errno otherwise.
I wonder if it would be possible instead to always return a negative error
code on error. Returning zero on error is really unconventional and can be
expected to be a source of bugs.
We have code already that takes the error code zero into account in e.g.
static int smbalert_probe(struct i2c_client *ara,
const struct i2c_device_id *id)
{
...
irq = fwnode_irq_get_byname(dev_fwnode(adapter->dev.parent),
"smbus_alert");
if (irq <= 0)
return irq;
And zero turns into successful probe!
> */
> int fwnode_irq_get_byname(const struct fwnode_handle *fwnode, const char *name)
> {
--
Terveisin,
Sakari Ailus
next prev parent reply other threads:[~2022-10-25 6:48 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-10-25 5:24 [PATCH] drivers: fwnode: fix fwnode_irq_get_byname() kerneldoc Matti Vaittinen
2022-10-25 6:48 ` Sakari Ailus [this message]
2022-10-25 7:06 ` Matti Vaittinen
2022-10-25 7:17 ` Matti Vaittinen
2022-10-25 7:43 ` Greg Kroah-Hartman
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=Y1eGwtqbOhXCGoaM@paasikivi.fi.intel.com \
--to=sakari.ailus@linux.intel.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-kernel@vger.kernel.org \
--cc=matti.vaittinen@fi.rohmeurope.com \
--cc=mazziesaccount@gmail.com \
--cc=rafael@kernel.org \
--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