From: David Lechner <dlechner@baylibre.com>
To: Salah Triki <salah.triki@gmail.com>,
Michael Hennerich <Michael.Hennerich@analog.com>,
Nuno Sa <nuno.sa@analog.com>,
Lars-Peter Clausen <lars@metafoo.de>,
Jonathan Cameron <jic23@kernel.org>,
Andy Shevchenko <andy@kernel.org>,
linux-iio@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH] iio: adc: ad9467: Replace PTR_ERR_OR_ZERO() in ad9467_reset()
Date: Wed, 6 Aug 2025 21:07:23 -0500 [thread overview]
Message-ID: <d2b3fe8b-9f86-4b39-ae95-399cb7da685a@baylibre.com> (raw)
In-Reply-To: <aJQDyzoxLsF8nKYW@pc>
On 8/6/25 8:39 PM, Salah Triki wrote:
> PTR_ERR_OR_ZERO() returns 0 if the argument is NULL, which can hide real
> issues when the caller expects an ERR_PTR on failure. Use a ternary
> expression instead to return the appropriate error code.
>
> Signed-off-by: Salah Triki <salah.triki@gmail.com>
> ---
> drivers/iio/adc/ad9467.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/drivers/iio/adc/ad9467.c b/drivers/iio/adc/ad9467.c
> index f7a9f46ea0dc..70aee2666ff1 100644
> --- a/drivers/iio/adc/ad9467.c
> +++ b/drivers/iio/adc/ad9467.c
> @@ -945,7 +945,7 @@ static int ad9467_reset(struct device *dev)
>
> gpio = devm_gpiod_get_optional(dev, "reset", GPIOD_OUT_HIGH);
> if (IS_ERR_OR_NULL(gpio))
> - return PTR_ERR_OR_ZERO(gpio);
> + return gpio ? PTR_ERR(gpio) : -ENODEV;
>
> fsleep(1);
> gpiod_set_value_cansleep(gpio, 0);
The existing code looks correct to me. The reset gpio is optional
so early return of 0 when there is no gpio seems fine. Changing it
to return an error could break existing users since it will cause
probe to fail.
Also, if the original intention was to make the gpio required, then
it should just not use devm_gpiod_get_optional() and simplify the
whole thing. But I don't think that was the intention.
next prev parent reply other threads:[~2025-08-07 2:07 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-08-07 1:39 Salah Triki
2025-08-07 2:07 ` David Lechner [this message]
2025-08-07 20:38 ` 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=d2b3fe8b-9f86-4b39-ae95-399cb7da685a@baylibre.com \
--to=dlechner@baylibre.com \
--cc=Michael.Hennerich@analog.com \
--cc=andy@kernel.org \
--cc=jic23@kernel.org \
--cc=lars@metafoo.de \
--cc=linux-iio@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=nuno.sa@analog.com \
--cc=salah.triki@gmail.com \
/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
all inboxes | Powered by JetHome®