]> www.infradead.org Git - users/jedix/linux-maple.git/commitdiff
regulator: of: Refactor of_get_*regulator() to decrease indentation
authorAndy Shevchenko <andy.shevchenko@gmail.com>
Wed, 4 Sep 2024 19:08:56 +0000 (22:08 +0300)
committerMark Brown <broonie@kernel.org>
Thu, 5 Sep 2024 18:15:52 +0000 (19:15 +0100)
Refactor of_get_*regulator() to decrease indentation and increase readability.
No functional changes intended.

Signed-off-by: Andy Shevchenko <andy.shevchenko@gmail.com>
Reviewed-by: Chen-Yu Tsai <wenst@chromium.org>
Link: https://patch.msgid.link/20240904190856.1221459-1-andy.shevchenko@gmail.com
Signed-off-by: Mark Brown <broonie@kernel.org>
drivers/regulator/of_regulator.c

index d5dd7a9e577b60aa0d3c903b296f689591330529..3f490d81abc28fe9f6767afe850e0fc883eddb55 100644 (file)
@@ -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)
+                       goto err_node_put;
 
-               if (!regnode) {
-                       regnode = of_get_child_regulator(child, prop_name);
-                       if (regnode)
-                               goto err_node_put;
-               } else {
+               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)