* [PATCH v3 1/2] iio: pressure: bmp280: Use IS_ERR() in bmp280_common_probe()
2025-08-18 8:23 [PATCH v3 0/2] iio: pressure: bmp280: GPIO error handling and cleanup Salah Triki
@ 2025-08-18 8:23 ` Salah Triki
2025-08-18 8:23 ` [PATCH v3 2/2] iio: pressure: bmp280: Use gpiod_set_value_cansleep() Salah Triki
2025-08-20 14:53 ` [PATCH v3 0/2] iio: pressure: bmp280: GPIO error handling and cleanup Andy Shevchenko
2 siblings, 0 replies; 5+ messages in thread
From: Salah Triki @ 2025-08-18 8:23 UTC (permalink / raw)
To: linux-iio, linux-kernel
Cc: jic23, dlechner, nuno.sa, andy, Markus.Elfring, salah.triki
`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
^ permalink raw reply related [flat|nested] 5+ messages in thread* [PATCH v3 2/2] iio: pressure: bmp280: Use gpiod_set_value_cansleep()
2025-08-18 8:23 [PATCH v3 0/2] iio: pressure: bmp280: GPIO error handling and cleanup Salah Triki
2025-08-18 8:23 ` [PATCH v3 1/2] iio: pressure: bmp280: Use IS_ERR() in bmp280_common_probe() Salah Triki
@ 2025-08-18 8:23 ` Salah Triki
2025-08-18 8:42 ` Markus Elfring
2025-08-20 14:53 ` [PATCH v3 0/2] iio: pressure: bmp280: GPIO error handling and cleanup Andy Shevchenko
2 siblings, 1 reply; 5+ messages in thread
From: Salah Triki @ 2025-08-18 8:23 UTC (permalink / raw)
To: linux-iio, linux-kernel
Cc: jic23, dlechner, nuno.sa, andy, Markus.Elfring, salah.triki
Switch to `gpiod_set_value_cansleep()`, which is safe to use in
sleepable contexts like the driver probe function.
The `dev_info()` call has been removed as it was considered noisy and
is not necessary for normal driver operation.
Signed-off-by: Salah Triki <salah.triki@gmail.com>
Reviewed-by: David Lechner <dlechner@baylibre.com>
---
drivers/iio/pressure/bmp280-core.c | 3 +--
1 file changed, 1 insertion(+), 2 deletions(-)
diff --git a/drivers/iio/pressure/bmp280-core.c b/drivers/iio/pressure/bmp280-core.c
index 6cdc8ed53520..656f6189c84c 100644
--- a/drivers/iio/pressure/bmp280-core.c
+++ b/drivers/iio/pressure/bmp280-core.c
@@ -3217,8 +3217,7 @@ int bmp280_common_probe(struct device *dev,
return dev_err_probe(dev, PTR_ERR(gpiod), "failed to get reset GPIO\n");
/* Deassert the signal */
- dev_info(dev, "release reset\n");
- gpiod_set_value(gpiod, 0);
+ gpiod_set_value_cansleep(gpiod, 0);
data->regmap = regmap;
--
2.43.0
^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: [PATCH v3 0/2] iio: pressure: bmp280: GPIO error handling and cleanup
2025-08-18 8:23 [PATCH v3 0/2] iio: pressure: bmp280: GPIO error handling and cleanup Salah Triki
2025-08-18 8:23 ` [PATCH v3 1/2] iio: pressure: bmp280: Use IS_ERR() in bmp280_common_probe() Salah Triki
2025-08-18 8:23 ` [PATCH v3 2/2] iio: pressure: bmp280: Use gpiod_set_value_cansleep() Salah Triki
@ 2025-08-20 14:53 ` Andy Shevchenko
2 siblings, 0 replies; 5+ messages in thread
From: Andy Shevchenko @ 2025-08-20 14:53 UTC (permalink / raw)
To: Salah Triki
Cc: linux-iio, linux-kernel, jic23, dlechner, nuno.sa, andy,
Markus.Elfring
On Mon, Aug 18, 2025 at 09:23:29AM +0100, Salah Triki wrote:
> Hi all,
>
> This patch series improves the GPIO handling in the bmp280 driver.
Is this similar to what I just reviewed? I'm sorry I got lost.
But if it's different, it needs to be amended in the same way.
--
With Best Regards,
Andy Shevchenko
^ permalink raw reply [flat|nested] 5+ messages in thread