* [PATCH v4 0/3] iio: pressure: bmp280: GPIO error handling and cleanups
@ 2025-08-18 9:27 Salah Triki
2025-08-18 9:27 ` [PATCH v4 1/3] iio: pressure: bmp280: Use IS_ERR() in bmp280_common_probe() Salah Triki
` (2 more replies)
0 siblings, 3 replies; 9+ messages in thread
From: Salah Triki @ 2025-08-18 9:27 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 error handling and addresses small
cleanups in the bmp280 driver.
Changes in v4:
- Split patch 2/2 into two separate patches, as suggested by Markus
Elfring.
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 (3):
iio: pressure: bmp280: Use IS_ERR() in bmp280_common_probe()
iio: pressure: bmp280: Remove noisy dev_info()
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] 9+ messages in thread
* [PATCH v4 1/3] iio: pressure: bmp280: Use IS_ERR() in bmp280_common_probe()
2025-08-18 9:27 [PATCH v4 0/3] iio: pressure: bmp280: GPIO error handling and cleanups Salah Triki
@ 2025-08-18 9:27 ` Salah Triki
2025-08-18 18:23 ` Jonathan Cameron
2025-08-20 14:48 ` Andy Shevchenko
2025-08-18 9:27 ` [PATCH v4 2/3] iio: pressure: bmp280: Remove noisy dev_info() Salah Triki
2025-08-18 9:27 ` [PATCH v4 3/3] iio: pressure: bmp280: Use gpiod_set_value_cansleep() Salah Triki
2 siblings, 2 replies; 9+ messages in thread
From: Salah Triki @ 2025-08-18 9:27 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] 9+ messages in thread
* [PATCH v4 2/3] iio: pressure: bmp280: Remove noisy dev_info()
2025-08-18 9:27 [PATCH v4 0/3] iio: pressure: bmp280: GPIO error handling and cleanups Salah Triki
2025-08-18 9:27 ` [PATCH v4 1/3] iio: pressure: bmp280: Use IS_ERR() in bmp280_common_probe() Salah Triki
@ 2025-08-18 9:27 ` Salah Triki
2025-08-20 14:49 ` Andy Shevchenko
2025-08-18 9:27 ` [PATCH v4 3/3] iio: pressure: bmp280: Use gpiod_set_value_cansleep() Salah Triki
2 siblings, 1 reply; 9+ messages in thread
From: Salah Triki @ 2025-08-18 9:27 UTC (permalink / raw)
To: linux-iio, linux-kernel
Cc: jic23, dlechner, nuno.sa, andy, Markus.Elfring, salah.triki
Remove `dev_info()` call 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 | 1 -
1 file changed, 1 deletion(-)
diff --git a/drivers/iio/pressure/bmp280-core.c b/drivers/iio/pressure/bmp280-core.c
index 6cdc8ed53520..1f0852fc3414 100644
--- a/drivers/iio/pressure/bmp280-core.c
+++ b/drivers/iio/pressure/bmp280-core.c
@@ -3217,7 +3217,6 @@ 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);
data->regmap = regmap;
--
2.43.0
^ permalink raw reply related [flat|nested] 9+ messages in thread
* [PATCH v4 3/3] iio: pressure: bmp280: Use gpiod_set_value_cansleep()
2025-08-18 9:27 [PATCH v4 0/3] iio: pressure: bmp280: GPIO error handling and cleanups Salah Triki
2025-08-18 9:27 ` [PATCH v4 1/3] iio: pressure: bmp280: Use IS_ERR() in bmp280_common_probe() Salah Triki
2025-08-18 9:27 ` [PATCH v4 2/3] iio: pressure: bmp280: Remove noisy dev_info() Salah Triki
@ 2025-08-18 9:27 ` Salah Triki
2025-08-20 14:51 ` Andy Shevchenko
2 siblings, 1 reply; 9+ messages in thread
From: Salah Triki @ 2025-08-18 9:27 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.
Signed-off-by: Salah Triki <salah.triki@gmail.com>
Reviewed-by: David Lechner <dlechner@baylibre.com>
---
drivers/iio/pressure/bmp280-core.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/iio/pressure/bmp280-core.c b/drivers/iio/pressure/bmp280-core.c
index 1f0852fc3414..656f6189c84c 100644
--- a/drivers/iio/pressure/bmp280-core.c
+++ b/drivers/iio/pressure/bmp280-core.c
@@ -3217,7 +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 */
- gpiod_set_value(gpiod, 0);
+ gpiod_set_value_cansleep(gpiod, 0);
data->regmap = regmap;
--
2.43.0
^ permalink raw reply related [flat|nested] 9+ messages in thread
* Re: [PATCH v4 1/3] iio: pressure: bmp280: Use IS_ERR() in bmp280_common_probe()
2025-08-18 9:27 ` [PATCH v4 1/3] iio: pressure: bmp280: Use IS_ERR() in bmp280_common_probe() Salah Triki
@ 2025-08-18 18:23 ` Jonathan Cameron
2025-08-20 14:48 ` Andy Shevchenko
1 sibling, 0 replies; 9+ messages in thread
From: Jonathan Cameron @ 2025-08-18 18:23 UTC (permalink / raw)
To: Salah Triki
Cc: linux-iio, linux-kernel, dlechner, nuno.sa, andy, Markus.Elfring
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;
>
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [PATCH v4 1/3] iio: pressure: bmp280: Use IS_ERR() in bmp280_common_probe()
2025-08-18 9:27 ` [PATCH v4 1/3] iio: pressure: bmp280: Use IS_ERR() in bmp280_common_probe() Salah Triki
2025-08-18 18:23 ` Jonathan Cameron
@ 2025-08-20 14:48 ` Andy Shevchenko
2025-08-25 8:22 ` Jonathan Cameron
1 sibling, 1 reply; 9+ messages in thread
From: Andy Shevchenko @ 2025-08-20 14:48 UTC (permalink / raw)
To: Salah Triki
Cc: linux-iio, linux-kernel, jic23, dlechner, nuno.sa, andy,
Markus.Elfring
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
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [PATCH v4 2/3] iio: pressure: bmp280: Remove noisy dev_info()
2025-08-18 9:27 ` [PATCH v4 2/3] iio: pressure: bmp280: Remove noisy dev_info() Salah Triki
@ 2025-08-20 14:49 ` Andy Shevchenko
0 siblings, 0 replies; 9+ messages in thread
From: Andy Shevchenko @ 2025-08-20 14:49 UTC (permalink / raw)
To: Salah Triki
Cc: linux-iio, linux-kernel, jic23, dlechner, nuno.sa, andy,
Markus.Elfring
On Mon, Aug 18, 2025 at 10:27:31AM +0100, Salah Triki wrote:
> Remove `dev_info()` call as it was considered noisy and is not
> necessary for normal driver operation.
I agree with this.
Reviewed-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
--
With Best Regards,
Andy Shevchenko
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [PATCH v4 3/3] iio: pressure: bmp280: Use gpiod_set_value_cansleep()
2025-08-18 9:27 ` [PATCH v4 3/3] iio: pressure: bmp280: Use gpiod_set_value_cansleep() Salah Triki
@ 2025-08-20 14:51 ` Andy Shevchenko
0 siblings, 0 replies; 9+ messages in thread
From: Andy Shevchenko @ 2025-08-20 14:51 UTC (permalink / raw)
To: Salah Triki
Cc: linux-iio, linux-kernel, jic23, dlechner, nuno.sa, andy,
Markus.Elfring
On Mon, Aug 18, 2025 at 10:27:32AM +0100, Salah Triki wrote:
> Switch to `gpiod_set_value_cansleep()`, which is safe to use in
> sleepable contexts like the driver probe function.
The commit message is unclear on why? aspect. You need to elaborate that some
GPIO chips may be located behind slow (and hence sleepable) busses, such as
I²C).
Code wise I agree with the change.
With amended commit message
Reviewed-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
--
With Best Regards,
Andy Shevchenko
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [PATCH v4 1/3] iio: pressure: bmp280: Use IS_ERR() in bmp280_common_probe()
2025-08-20 14:48 ` Andy Shevchenko
@ 2025-08-25 8:22 ` Jonathan Cameron
0 siblings, 0 replies; 9+ messages in thread
From: Jonathan Cameron @ 2025-08-25 8:22 UTC (permalink / raw)
To: Andy Shevchenko
Cc: Salah Triki, linux-iio, linux-kernel, dlechner, nuno.sa, andy,
Markus.Elfring
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
^ permalink raw reply [flat|nested] 9+ messages in thread
end of thread, other threads:[~2025-08-25 8:22 UTC | newest]
Thread overview: 9+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-08-18 9:27 [PATCH v4 0/3] iio: pressure: bmp280: GPIO error handling and cleanups Salah Triki
2025-08-18 9:27 ` [PATCH v4 1/3] iio: pressure: bmp280: Use IS_ERR() in bmp280_common_probe() Salah Triki
2025-08-18 18:23 ` Jonathan Cameron
2025-08-20 14:48 ` Andy Shevchenko
2025-08-25 8:22 ` Jonathan Cameron
2025-08-18 9:27 ` [PATCH v4 2/3] iio: pressure: bmp280: Remove noisy dev_info() Salah Triki
2025-08-20 14:49 ` Andy Shevchenko
2025-08-18 9:27 ` [PATCH v4 3/3] iio: pressure: bmp280: Use gpiod_set_value_cansleep() Salah Triki
2025-08-20 14:51 ` Andy Shevchenko
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).