Skip to contentSkip to conversation

mfd: lp87565: fix error handling while getting reset GPIO

PATCH New Luca Ceresoli 1 participant 1 message Nov 18, 2021 Multifunction devices (MFD)

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 mfd: lp87565: fix error handling while getting reset GPIO

If devm_gpiod_get_optional() returns an error the driver code just goes on, soon using a pointer that holds an error. The only exception is -EPROBE_DEFER which is correctly handled.

Fix and also simplify code by always calling dev_err_probe().

Fixes 50e4d7a2a667 ("mfd: lp87565: Handle optional reset pin")
---
 drivers/mfd/lp87565.c | 8 +++-----
 1 file changed, 3 insertions(+), 5 deletions(-)
drivers/mfd/lp87565.c +3 -5
index a52ab76febb3..f5890ce9ac8f 100644
@@ -67,11 +67,9 @@ static int lp87565_probe(struct i2c_client *client,
 
 	lp87565->reset_gpio = devm_gpiod_get_optional(lp87565->dev, "reset",
 						      GPIOD_OUT_LOW);
-	if (IS_ERR(lp87565->reset_gpio)) {
-		ret = PTR_ERR(lp87565->reset_gpio);
-		if (ret == -EPROBE_DEFER)
-			return ret;
-	}
+	if (IS_ERR(lp87565->reset_gpio))
+		return dev_err_probe(lp87565->dev, PTR_ERR(lp87565->reset_gpio),
+				     "Failed getting reset GPIO");
 
 	if (lp87565->reset_gpio) {
 		gpiod_set_value_cansleep(lp87565->reset_gpio, 1);
Signature · 1 line
2.34.0