From: David Lechner <dlechner@baylibre.com>
To: "Salah Triki" <salah.triki@gmail.com>,
"Jonathan Cameron" <jic23@kernel.org>,
"Nuno Sá" <nuno.sa@analog.com>,
"Andy Shevchenko" <andy@kernel.org>,
linux-iio@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH v2] iio: pressure: bmp280: Use IS_ERR() in bmp280_common_probe()
Date: Thu, 7 Aug 2025 10:39:58 -0500 [thread overview]
Message-ID: <a11e80b8-a52b-462f-8e69-b1fa7768a756@baylibre.com> (raw)
In-Reply-To: <aJQOmQKO219rS8ZN@pc>
On 8/6/25 9:25 PM, Salah Triki wrote:
> `devm_gpiod_get_optional()` may return non-NULL error pointer on failure.
> Check its return value using `IS_ERR()` and propagate the error if
> necessary.
>
> `dev_info()` has been dropped as it was considered noisy.
>
> Also switch to `gpiod_set_value_cansleep()`, which is safe to use in
> sleepable contexts like probe.
>
> Signed-off-by: Salah Triki <salah.triki@gmail.com>
> ---
> Changes in v2:
> - Use IS_ERR() instead of IS_ERR_OR_NULL()
> - Drop dev_info()
> - Use gpiod_set_value_cansleep()
> - Improve commit title and message
>
> drivers/iio/pressure/bmp280-core.c | 8 ++++----
> 1 file changed, 4 insertions(+), 4 deletions(-)
>
> diff --git a/drivers/iio/pressure/bmp280-core.c b/drivers/iio/pressure/bmp280-core.c
> index 74505c9ec1a0..be6c981a4cc7 100644
> --- a/drivers/iio/pressure/bmp280-core.c
> +++ b/drivers/iio/pressure/bmp280-core.c
> @@ -3213,11 +3213,11 @@ int bmp280_common_probe(struct device *dev,
>
> /* Bring chip out of reset if there is an assigned GPIO line */
> gpiod = devm_gpiod_get_optional(dev, "reset", GPIOD_OUT_HIGH);
> + if (IS_ERR(gpiod))
> + return dev_err_probe(dev, PTR_ERR(gpiod), "failed to get GPIO\n");
Could be slightly better if the error message said "reset GPIO".
> +
> /* Deassert the signal */
> - if (gpiod) {
> - dev_info(dev, "release reset\n");
> - gpiod_set_value(gpiod, 0);
> - }
> + gpiod_set_value_cansleep(gpiod, 0);
>
> data->regmap = regmap;
>
In any case...
Reviewed-by: David Lechner <dlechner@baylibre.com>
next prev parent reply other threads:[~2025-08-07 15:40 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-08-07 2:25 [PATCH v2] iio: pressure: bmp280: Use IS_ERR() in bmp280_common_probe() Salah Triki
2025-08-07 15:39 ` David Lechner [this message]
2025-08-07 21:23 ` Andy Shevchenko
2025-08-10 8:08 ` Markus Elfring
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=a11e80b8-a52b-462f-8e69-b1fa7768a756@baylibre.com \
--to=dlechner@baylibre.com \
--cc=andy@kernel.org \
--cc=jic23@kernel.org \
--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;
as well as URLs for NNTP newsgroup(s).