From: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
To: Matti Vaittinen <mazziesaccount@gmail.com>
Cc: Matti Vaittinen <matti.vaittinen@fi.rohmeurope.com>,
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-kernel@vger.kernel.org,
linux-i2c@vger.kernel.org
Subject: Re: [PATCH 0/2] fix fwnode_irq_get_byname() returnvalue
Date: Tue, 25 Oct 2022 12:20:25 +0300 [thread overview]
Message-ID: <Y1eqWbyJLlEW5Mdo@smile.fi.intel.com> (raw)
In-Reply-To: <cover.1666687086.git.mazziesaccount@gmail.com>
On Tue, Oct 25, 2022 at 11:50:24AM +0300, Matti Vaittinen wrote:
> The fix fwnode_irq_get_byname() may have returned zero if mapping the
> IRQ fails. This contradicts the documentation. Furthermore, returning
> zero or errno on error is unepected and can easily lead to problems
> like:
>
> int probe(foo)
> {
> ...
> ret = fwnode_irq_get_byname(...);
> if (ret < 0)
> return ret;
> ...
> }
>
> or
>
> int probe(foo)
> {
> ...
> ret = fwnode_irq_get_byname(...);
> if (ret <= 0)
> return ret;
> ...
> }
>
> which are both likely to be wrong. First treats zero as successful call and
> misses the IRQ mapping failure. Second returns zero from probe even though
> it detects the IRQ mapping failure correvtly.
>
> Here we change the fwnode_irq_get_byname() to always return a negative
> errno upon failure. I have also audited following callers:
>
> drivers/i2c/i2c-smbus.c
> drivers/iio/accel/adxl355_core.c
> drivers/iio/gyro/fxas21002c_core.c
> drivers/iio/imu/adis16480.c
> drivers/iio/imu/bmi160/bmi160_core.c
> drivers/iio/imu/bmi160/bmi160_core.c
>
> and it seems to me these calls will be Ok after the change. The
> i2c-smbus.c will gain a functional change (bugfix?) as after this patch
> the probe will return -EINVAL should the IRQ mapping fail. The series
> will also adjust the return value check for zero to be omitted.
Thanks for doing this, no major comments except worrying about fwnode_irq_get()
which is left untouched an hence different error domain for the same
family of API.
For these patches:
Reviewed-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
--
With Best Regards,
Andy Shevchenko
prev parent reply other threads:[~2022-10-25 9:25 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
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 ` Andy Shevchenko [this message]
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=Y1eqWbyJLlEW5Mdo@smile.fi.intel.com \
--to=andriy.shevchenko@linux.intel.com \
--cc=akhilrajeev@nvidia.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=matti.vaittinen@fi.rohmeurope.com \
--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