[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-ID: <aJP44mH0AXQGCFFR@pc>
Date: Thu, 7 Aug 2025 01:52:50 +0100
From: Salah Triki <salah.triki@...il.com>
To: Jonathan Cameron <jic23@...nel.org>,
David Lechner <dlechner@...libre.com>,
Nuno Sá <nuno.sa@...log.com>,
Andy Shevchenko <andy@...nel.org>, linux-iio@...r.kernel.org,
linux-kernel@...r.kernel.org
Cc: salah.triki@...il.com
Subject: [PATCH] iio: pressure: bmp280: Use IS_ERR_OR_NULL() in
bmp280_common_probe()
`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);
+
+ if (IS_ERR_OR_NULL(gpiod))
+ 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);
data->regmap = regmap;
--
2.43.0
Powered by blists - more mailing lists