* [PATCH v3 0/2] iio: pressure: bmp280: GPIO error handling and cleanup
@ 2025-08-18 8:23 Salah Triki
2025-08-18 8:23 ` [PATCH v3 1/2] iio: pressure: bmp280: Use IS_ERR() in bmp280_common_probe() Salah Triki
` (2 more replies)
0 siblings, 3 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
Hi all,
This patch series improves the GPIO handling in the bmp280 driver.
Changes in v3:
- Split into two separate patches, as suggested by Andy Shevchenko.
- Improve the error message to "failed to get reset GPIO", as
suggested by David Lechner.
- Add Fixes and Cc tags where appropriate, as suggested by
Markus Elfring.
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
Salah Triki (2):
iio: pressure: bmp280: Use IS_ERR() in bmp280_common_probe()
iio: pressure: bmp280: Use gpiod_set_value_cansleep()
drivers/iio/pressure/bmp280-core.c | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)
--
2.43.0
^ permalink raw reply [flat|nested] 5+ messages in thread
* [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 2/2] iio: pressure: bmp280: Use gpiod_set_value_cansleep()
2025-08-18 8:23 ` [PATCH v3 2/2] iio: pressure: bmp280: Use gpiod_set_value_cansleep() Salah Triki
@ 2025-08-18 8:42 ` Markus Elfring
0 siblings, 0 replies; 5+ messages in thread
From: Markus Elfring @ 2025-08-18 8:42 UTC (permalink / raw)
To: Salah Triki, linux-iio, Andy Shevchenko, David Lechner,
Jonathan Cameron, Nuno Sá
Cc: LKML
> 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.
Should such a change combination be reconsidered once more?
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/Documentation/process/submitting-patches.rst?h=v6.17-rc1#n81
Regards,
Markus
^ permalink raw reply [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
end of thread, other threads:[~2025-08-20 14:53 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
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-18 8:42 ` Markus Elfring
2025-08-20 14:53 ` [PATCH v3 0/2] iio: pressure: bmp280: GPIO error handling and cleanup Andy Shevchenko
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.