diff mbox series

power: supply: 88pm860x: Use common error handling code in set_charging_fsm()

Message ID d3eb142b-eabf-4176-8a5c-0d589060abe8@web.de (mailing list archive)
State Handled Elsewhere, archived
Headers show
Series power: supply: 88pm860x: Use common error handling code in set_charging_fsm() | expand

Commit Message

Markus Elfring Sept. 24, 2024, 11 a.m. UTC
From: Markus Elfring <elfring@users.sourceforge.net>
Date: Tue, 24 Sep 2024 12:50:09 +0200

Add a jump target so that a bit of exception handling can be better reused
at the end of this function implementation.

This issue was detected by using the Coccinelle software.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 drivers/power/supply/88pm860x_charger.c | 18 ++++++++++--------
 1 file changed, 10 insertions(+), 8 deletions(-)

--
2.46.1
diff mbox series

Patch

diff --git a/drivers/power/supply/88pm860x_charger.c b/drivers/power/supply/88pm860x_charger.c
index 2b9fcb7e71d7..4fdf62a7245e 100644
--- a/drivers/power/supply/88pm860x_charger.c
+++ b/drivers/power/supply/88pm860x_charger.c
@@ -295,17 +295,15 @@  static int set_charging_fsm(struct pm860x_charger_info *info)
 		return -EINVAL;
 	ret = power_supply_get_property(psy, POWER_SUPPLY_PROP_VOLTAGE_NOW,
 			&data);
-	if (ret) {
-		power_supply_put(psy);
-		return ret;
-	}
+	if (ret)
+		goto put_supply;
+
 	vbatt = data.intval / 1000;

 	ret = power_supply_get_property(psy, POWER_SUPPLY_PROP_PRESENT, &data);
-	if (ret) {
-		power_supply_put(psy);
-		return ret;
-	}
+	if (ret)
+		goto put_supply;
+
 	power_supply_put(psy);

 	mutex_lock(&info->lock);
@@ -391,6 +389,10 @@  static int set_charging_fsm(struct pm860x_charger_info *info)
 	mutex_unlock(&info->lock);

 	return 0;
+
+put_supply:
+	power_supply_put(psy);
+	return ret;
 }

 static irqreturn_t pm860x_charger_handler(int irq, void *data)