From: Markus Elfring <Markus.Elfring@web.de>
To: linux-pm@vger.kernel.org,
Bartlomiej Zolnierkiewicz <b.zolnierkie@samsung.com>,
Krzysztof Kozlowski <krzysztof.kozlowski@linaro.org>,
Pavel Machek <pavel@ucw.cz>, Sebastian Reichel <sre@kernel.org>
Cc: LKML <linux-kernel@vger.kernel.org>, kernel-janitors@vger.kernel.org
Subject: [PATCH] power: supply: 88pm860x: Use common error handling code in set_charging_fsm()
Date: Tue, 24 Sep 2024 13:00:16 +0200 [thread overview]
Message-ID: <d3eb142b-eabf-4176-8a5c-0d589060abe8@web.de> (raw)
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
reply other threads:[~2024-09-24 11:00 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=d3eb142b-eabf-4176-8a5c-0d589060abe8@web.de \
--to=markus.elfring@web.de \
--cc=b.zolnierkie@samsung.com \
--cc=kernel-janitors@vger.kernel.org \
--cc=krzysztof.kozlowski@linaro.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-pm@vger.kernel.org \
--cc=pavel@ucw.cz \
--cc=sre@kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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®