From: SF Markus Elfring <elfring@users.sourceforge.net>
To: kernel-janitors@vger.kernel.org,
Liam Girdwood <lgirdwood@gmail.com>,
Mark Brown <broonie@kernel.org>
Cc: LKML <linux-kernel@vger.kernel.org>
Subject: [PATCH 1/3] regulator/core: Use common error handling code in regulator_resolve_supply()
Date: Thu, 2 Nov 2017 08:59:31 +0100 [thread overview]
Message-ID: <61939d80-851f-601a-d5df-1278abede5c3@users.sourceforge.net> (raw)
In-Reply-To: <471498fb-58af-46d4-2150-614c0f9cdc22@users.sourceforge.net>
From: Markus Elfring <elfring@users.sourceforge.net>
Date: Wed, 1 Nov 2017 22:20:13 +0100
* Add a jump target so that a bit of exception handling can be better
reused at the end of this function.
* Adjust two condition checks.
This issue was detected by using the Coccinelle software.
Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
drivers/regulator/core.c | 20 ++++++++++----------
1 file changed, 10 insertions(+), 10 deletions(-)
diff --git a/drivers/regulator/core.c b/drivers/regulator/core.c
index b64b7916507f..14fdf2f17a62 100644
--- a/drivers/regulator/core.c
+++ b/drivers/regulator/core.c
@@ -1554,23 +1554,19 @@ static int regulator_resolve_supply(struct regulator_dev *rdev)
*/
if (r->dev.parent && r->dev.parent != rdev->dev.parent) {
if (!device_is_bound(r->dev.parent)) {
- put_device(&r->dev);
- return -EPROBE_DEFER;
+ ret = -EPROBE_DEFER;
+ goto put_device;
}
}
/* Recursively resolve the supply of the supply */
ret = regulator_resolve_supply(r);
- if (ret < 0) {
- put_device(&r->dev);
- return ret;
- }
+ if (ret)
+ goto put_device;
ret = set_supply(rdev, r);
- if (ret < 0) {
- put_device(&r->dev);
- return ret;
- }
+ if (ret)
+ goto put_device;
/* Cascade always-on state to supply */
if (_regulator_is_enabled(rdev)) {
@@ -1583,6 +1579,10 @@ static int regulator_resolve_supply(struct regulator_dev *rdev)
}
return 0;
+
+put_device:
+ put_device(&r->dev);
+ return ret;
}
/* Internal regulator request function */
--
2.14.3
next prev parent reply other threads:[~2017-11-02 7:59 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-11-02 7:58 [PATCH 0/3] regulator-core: Fine-tuning for nine function implementations SF Markus Elfring
2017-11-02 7:59 ` SF Markus Elfring [this message]
2017-11-02 8:00 ` [PATCH 2/3] regulator/core: Improve a size determination in four functions SF Markus Elfring
2017-11-02 8:01 ` [PATCH 3/3] regulator/core: Adjust 18 checks for null pointers SF Markus Elfring
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=61939d80-851f-601a-d5df-1278abede5c3@users.sourceforge.net \
--to=elfring@users.sourceforge.net \
--cc=broonie@kernel.org \
--cc=kernel-janitors@vger.kernel.org \
--cc=lgirdwood@gmail.com \
--cc=linux-kernel@vger.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).