mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH] power: supply: 88pm860x: Use common error handling code in set_charging_fsm()
@ 2024-09-24 11:00 Markus Elfring
  0 siblings, 0 replies; only message in thread
From: Markus Elfring @ 2024-09-24 11:00 UTC (permalink / raw)
  To: linux-pm, Bartlomiej Zolnierkiewicz, Krzysztof Kozlowski,
	Pavel Machek, Sebastian Reichel
  Cc: LKML, kernel-janitors

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(-)

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)
--
2.46.1


^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2024-09-24 11:00 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-09-24 11:00 [PATCH] power: supply: 88pm860x: Use common error handling code in set_charging_fsm() Markus Elfring

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®