[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <a11e80b8-a52b-462f-8e69-b1fa7768a756@baylibre.com>
Date: Thu, 7 Aug 2025 10:39:58 -0500
From: David Lechner <dlechner@...libre.com>
To: Salah Triki <salah.triki@...il.com>, Jonathan Cameron <jic23@...nel.org>,
Nuno Sá <nuno.sa@...log.com>,
Andy Shevchenko <andy@...nel.org>, linux-iio@...r.kernel.org,
linux-kernel@...r.kernel.org
Subject: Re: [PATCH v2] iio: pressure: bmp280: Use IS_ERR() in
bmp280_common_probe()
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@...il.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@...libre.com>
Powered by blists - more mailing lists