From: Krzysztof Kozlowski <krzk@kernel.org>
To: Sebastian Reichel <sre@kernel.org>,
Krzysztof Kozlowski <krzk@kernel.org>,
"Gustavo A. R. Silva" <gustavo@embeddedor.com>,
Linus Walleij <linus.walleij@linaro.org>,
linux-pm@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: [RFT 1/3] power: supply: ab8500: Cleanup probe in reverse order
Date: Fri, 4 Oct 2019 17:07:36 +0200 [thread overview]
Message-ID: <20191004150738.6542-1-krzk@kernel.org> (raw)
It is logical to cleanup in probe's error path in reverse order to
previous actions. It also makes easier to add additional goto labels
within this error path.
Signed-off-by: Krzysztof Kozlowski <krzk@kernel.org>
---
Not marking as cc-stable as this was not reproduced and not tested.
---
drivers/power/supply/ab8500_btemp.c | 4 ++--
drivers/power/supply/ab8500_fg.c | 8 ++++----
2 files changed, 6 insertions(+), 6 deletions(-)
diff --git a/drivers/power/supply/ab8500_btemp.c b/drivers/power/supply/ab8500_btemp.c
index 8fe81259bfd9..a167938e32f2 100644
--- a/drivers/power/supply/ab8500_btemp.c
+++ b/drivers/power/supply/ab8500_btemp.c
@@ -1104,13 +1104,13 @@ static int ab8500_btemp_probe(struct platform_device *pdev)
return ret;
free_irq:
- power_supply_unregister(di->btemp_psy);
-
/* We also have to free all successfully registered irqs */
for (i = i - 1; i >= 0; i--) {
irq = platform_get_irq_byname(pdev, ab8500_btemp_irq[i].name);
free_irq(irq, di);
}
+
+ power_supply_unregister(di->btemp_psy);
free_btemp_wq:
destroy_workqueue(di->btemp_wq);
return ret;
diff --git a/drivers/power/supply/ab8500_fg.c b/drivers/power/supply/ab8500_fg.c
index 6fc4bc30644c..36bbb8ea05da 100644
--- a/drivers/power/supply/ab8500_fg.c
+++ b/drivers/power/supply/ab8500_fg.c
@@ -3212,15 +3212,15 @@ static int ab8500_fg_probe(struct platform_device *pdev)
return ret;
free_irq:
- power_supply_unregister(di->fg_psy);
-
/* We also have to free all registered irqs */
+ irq = platform_get_irq_byname(pdev, ab8500_fg_irq_bh[0].name);
+ free_irq(irq, di);
for (i = 0; i < ARRAY_SIZE(ab8500_fg_irq_th); i++) {
irq = platform_get_irq_byname(pdev, ab8500_fg_irq_th[i].name);
free_irq(irq, di);
}
- irq = platform_get_irq_byname(pdev, ab8500_fg_irq_bh[0].name);
- free_irq(irq, di);
+
+ power_supply_unregister(di->fg_psy);
free_inst_curr_wq:
destroy_workqueue(di->fg_wq);
return ret;
--
2.17.1
next reply other threads:[~2019-10-04 15:07 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-10-04 15:07 Krzysztof Kozlowski [this message]
2019-10-04 15:07 ` [RFT 2/3] power: supply: ab8500_fg: Do not free non-requested IRQs in probe's error path Krzysztof Kozlowski
2019-10-04 15:07 ` [RFT 3/3] power: supply: ab8500: Handle invalid IRQ from platform_get_irq_byname() Krzysztof Kozlowski
2019-10-16 8:33 ` [RFT 1/3] power: supply: ab8500: Cleanup probe in reverse order Linus Walleij
2019-10-20 13:23 ` Sebastian Reichel
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=20191004150738.6542-1-krzk@kernel.org \
--to=krzk@kernel.org \
--cc=gustavo@embeddedor.com \
--cc=linus.walleij@linaro.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-pm@vger.kernel.org \
--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;
as well as URLs for NNTP newsgroup(s).