`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.
Fixes: df6e71256c84 ("iio: pressure: bmp280: Explicitly mark GPIO optional")
Cc: David Lechner <dlechner@baylibre.com>
Cc: Jonathan Cameron <jic23@kernel.org>
Cc: Andy Shevchenko <andy@kernel.org>
Cc: Nuno Sá <nuno.sa@analog.com>
Cc: Markus Elfring <Markus.Elfring@web.de>
Signed-off-by: Salah Triki <salah.triki@gmail.com>
Reviewed-by: David Lechner <dlechner@baylibre.com>
---
drivers/iio/pressure/bmp280-core.c | 9 +++++----
1 file changed, 5 insertions(+), 4 deletions(-)
diff --git a/drivers/iio/pressure/bmp280-core.c b/drivers/iio/pressure/bmp280-core.c
index 74505c9ec1a0..6cdc8ed53520 100644
--- a/drivers/iio/pressure/bmp280-core.c
+++ b/drivers/iio/pressure/bmp280-core.c
@@ -3213,11 +3213,12 @@ 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 reset 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);
data->regmap = regmap;
--
2.43.0
On Mon, Aug 18, 2025 at 10:27:30AM +0100, 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.
> Fixes: df6e71256c84 ("iio: pressure: bmp280: Explicitly mark GPIO optional")
> Cc: David Lechner <dlechner@baylibre.com>
> Cc: Jonathan Cameron <jic23@kernel.org>
> Cc: Andy Shevchenko <andy@kernel.org>
> Cc: Nuno Sá <nuno.sa@analog.com>
> Cc: Markus Elfring <Markus.Elfring@web.de>
Please, next time move the Cc:s to be the after '---' line...
> Signed-off-by: Salah Triki <salah.triki@gmail.com>
> Reviewed-by: David Lechner <dlechner@baylibre.com>
> ---
...somewhere here.
It will reduce a lot the noise in the commit message. The all people will be
Cc'ed anyway (assuming you use `git send-email`).
> drivers/iio/pressure/bmp280-core.c | 9 +++++----
> 1 file changed, 5 insertions(+), 4 deletions(-)
Jonathan, would it be possible to drop them from the commit you pushed?
--
With Best Regards,
Andy Shevchenko
On Wed, 20 Aug 2025 17:48:56 +0300
Andy Shevchenko <andriy.shevchenko@intel.com> wrote:
> On Mon, Aug 18, 2025 at 10:27:30AM +0100, 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.
>
> > Fixes: df6e71256c84 ("iio: pressure: bmp280: Explicitly mark GPIO optional")
>
> > Cc: David Lechner <dlechner@baylibre.com>
> > Cc: Jonathan Cameron <jic23@kernel.org>
> > Cc: Andy Shevchenko <andy@kernel.org>
> > Cc: Nuno Sá <nuno.sa@analog.com>
> > Cc: Markus Elfring <Markus.Elfring@web.de>
>
> Please, next time move the Cc:s to be the after '---' line...
>
> > Signed-off-by: Salah Triki <salah.triki@gmail.com>
> > Reviewed-by: David Lechner <dlechner@baylibre.com>
> > ---
>
> ...somewhere here.
>
> It will reduce a lot the noise in the commit message. The all people will be
> Cc'ed anyway (assuming you use `git send-email`).
>
> > drivers/iio/pressure/bmp280-core.c | 9 +++++----
> > 1 file changed, 5 insertions(+), 4 deletions(-)
>
> Jonathan, would it be possible to drop them from the commit you pushed?
>
I did so, just didn't mention it.
J
On Mon, 18 Aug 2025 10:27:30 +0100
Salah Triki <salah.triki@gmail.com> 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.
>
> Fixes: df6e71256c84 ("iio: pressure: bmp280: Explicitly mark GPIO optional")
> Cc: David Lechner <dlechner@baylibre.com>
> Cc: Jonathan Cameron <jic23@kernel.org>
> Cc: Andy Shevchenko <andy@kernel.org>
> Cc: Nuno Sá <nuno.sa@analog.com>
> Cc: Markus Elfring <Markus.Elfring@web.de>
> Signed-off-by: Salah Triki <salah.triki@gmail.com>
> Reviewed-by: David Lechner <dlechner@baylibre.com>
Applied to the fixes-togreg branch of iio.git and marked for stable.
The rest of the series will have to wait for that to work it's way back
via upstream.
Thanks
Jonathan
> ---
> drivers/iio/pressure/bmp280-core.c | 9 +++++----
> 1 file changed, 5 insertions(+), 4 deletions(-)
>
> diff --git a/drivers/iio/pressure/bmp280-core.c b/drivers/iio/pressure/bmp280-core.c
> index 74505c9ec1a0..6cdc8ed53520 100644
> --- a/drivers/iio/pressure/bmp280-core.c
> +++ b/drivers/iio/pressure/bmp280-core.c
> @@ -3213,11 +3213,12 @@ 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 reset 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);
>
> data->regmap = regmap;
>
© 2016 - 2026 Red Hat, Inc.