public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Andy Shevchenko <andy.shevchenko@gmail.com>
To: Mark Brown <broonie@kernel.org>,
	Chen-Yu Tsai <wenst@chromium.org>,
	linux-kernel@vger.kernel.org
Cc: Liam Girdwood <lgirdwood@gmail.com>,
	Andy Shevchenko <andy.shevchenko@gmail.com>
Subject: [PATCH v1 1/1] regulator: of: Refactor of_get_*regulator() to decrease indentation
Date: Wed,  4 Sep 2024 22:08:56 +0300	[thread overview]
Message-ID: <20240904190856.1221459-1-andy.shevchenko@gmail.com> (raw)

Refactor of_get_*regulator() to decrease indentation and increase readability.
No functional changes intended.

Signed-off-by: Andy Shevchenko <andy.shevchenko@gmail.com>
---
 drivers/regulator/of_regulator.c | 28 ++++++++++++----------------
 1 file changed, 12 insertions(+), 16 deletions(-)

diff --git a/drivers/regulator/of_regulator.c b/drivers/regulator/of_regulator.c
index d5dd7a9e577b..3f490d81abc2 100644
--- a/drivers/regulator/of_regulator.c
+++ b/drivers/regulator/of_regulator.c
@@ -572,14 +572,12 @@ static struct device_node *of_get_child_regulator(struct device_node *parent,
 
 	for_each_child_of_node(parent, child) {
 		regnode = of_parse_phandle(child, prop_name, 0);
-
-		if (!regnode) {
-			regnode = of_get_child_regulator(child, prop_name);
-			if (regnode)
-				goto err_node_put;
-		} else {
+		if (regnode)
+			goto err_node_put;
+
+		regnode = of_get_child_regulator(child, prop_name);
+		if (regnode)
 			goto err_node_put;
-		}
 	}
 	return NULL;
 
@@ -607,17 +605,15 @@ static struct device_node *of_get_regulator(struct device *dev, const char *supp
 
 	snprintf(prop_name, 64, "%s-supply", supply);
 	regnode = of_parse_phandle(dev->of_node, prop_name, 0);
+	if (regnode)
+		return regnode;
 
-	if (!regnode) {
-		regnode = of_get_child_regulator(dev->of_node, prop_name);
-		if (regnode)
-			return regnode;
+	regnode = of_get_child_regulator(dev->of_node, prop_name);
+	if (regnode)
+		return regnode;
 
-		dev_dbg(dev, "Looking up %s property in node %pOF failed\n",
-			prop_name, dev->of_node);
-		return NULL;
-	}
-	return regnode;
+	dev_dbg(dev, "Looking up %s property in node %pOF failed\n", prop_name, dev->of_node);
+	return NULL;
 }
 
 static struct regulator_dev *of_find_regulator_by_node(struct device_node *np)
-- 
2.46.0


             reply	other threads:[~2024-09-04 19:09 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-09-04 19:08 Andy Shevchenko [this message]
2024-09-05  8:49 ` [PATCH v1 1/1] regulator: of: Refactor of_get_*regulator() to decrease indentation Chen-Yu Tsai
2024-09-05 17:40   ` Andy Shevchenko
2024-09-05 21:51 ` Mark Brown

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=20240904190856.1221459-1-andy.shevchenko@gmail.com \
    --to=andy.shevchenko@gmail.com \
    --cc=broonie@kernel.org \
    --cc=lgirdwood@gmail.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=wenst@chromium.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