[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <b7288d5e-8dc8-4ee1-ae34-52904a3f989d@baylibre.com>
Date: Wed, 6 Aug 2025 20:24:37 -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] iio: pressure: bmp280: Use IS_ERR_OR_NULL() in
bmp280_common_probe()
On 8/6/25 7:52 PM, Salah Triki wrote:
> `devm_gpiod_get_optional()` may return non-NULL error pointer on failure.
> Check its return value using `IS_ERR_OR_NULL()` and propagate the error if
> necessary.
>
> Signed-off-by: Salah Triki <salah.triki@...il.com>
> ---
> drivers/iio/pressure/bmp280-core.c | 10 ++++++----
> 1 file changed, 6 insertions(+), 4 deletions(-)
>
> diff --git a/drivers/iio/pressure/bmp280-core.c b/drivers/iio/pressure/bmp280-core.c
> index 74505c9ec1a0..2ac0188d2857 100644
> --- a/drivers/iio/pressure/bmp280-core.c
> +++ b/drivers/iio/pressure/bmp280-core.c
> @@ -3213,11 +3213,13 @@ 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);
> +
No blank line here.
> + if (IS_ERR_OR_NULL(gpiod))
This needs to be IS_ERR(). NULL is not an error and we
cant return early here because there is more to do in
the probe function.
> + return dev_err_probe(dev, PTR_ERR(gpiod), "failed to get GPIO\n");
> +
> /* Deassert the signal */
> - if (gpiod) {
> - dev_info(dev, "release reset\n");
> - gpiod_set_value(gpiod, 0);
> - }
> + dev_info(dev, "release reset\n");
> + gpiod_set_value(gpiod, 0);
If we drop the `if` here, we should also drop the
dev_info(). gpiod_set_value() handles NULL gpiod value
so that is fine, but the message is just noise.
Also, gpiod_set_value_cansleep() would be more
appropriate. This is not an atomic context.
>
> data->regmap = regmap;
>
Powered by blists - more mailing lists