Skip to content

Commit 43c0f64

Browse files
salah-trikijic23
authored andcommitted
iio: pressure: bmp280: Use IS_ERR() in bmp280_common_probe()
`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: df6e712 ("iio: pressure: bmp280: Explicitly mark GPIO optional") Signed-off-by: Salah Triki <[email protected]> Reviewed-by: David Lechner <[email protected]> Link: https://patch.msgid.link/[email protected] Cc: <[email protected]> Signed-off-by: Jonathan Cameron <[email protected]>
1 parent 433b99e commit 43c0f64

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

drivers/iio/pressure/bmp280-core.c

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3213,11 +3213,12 @@ int bmp280_common_probe(struct device *dev,
32133213

32143214
/* Bring chip out of reset if there is an assigned GPIO line */
32153215
gpiod = devm_gpiod_get_optional(dev, "reset", GPIOD_OUT_HIGH);
3216+
if (IS_ERR(gpiod))
3217+
return dev_err_probe(dev, PTR_ERR(gpiod), "failed to get reset GPIO\n");
3218+
32163219
/* Deassert the signal */
3217-
if (gpiod) {
3218-
dev_info(dev, "release reset\n");
3219-
gpiod_set_value(gpiod, 0);
3220-
}
3220+
dev_info(dev, "release reset\n");
3221+
gpiod_set_value(gpiod, 0);
32213222

32223223
data->regmap = regmap;
32233224

0 commit comments

Comments
 (0)