diff options
| author | Andy Shevchenko <andy.shevchenko@gmail.com> | 2024-09-04 22:08:56 +0300 |
|---|---|---|
| committer | Mark Brown <broonie@kernel.org> | 2024-09-05 19:15:52 +0100 |
| commit | 401d078eaf2edd605c9121741e166d9326c63677 (patch) | |
| tree | 65f7d4f3e883a163841998136c810e98a6b8a9f4 /drivers/regulator | |
| parent | b8c3255457147162cd713a319a8e2274335449b9 (diff) | |
| download | linux-401d078eaf2edd605c9121741e166d9326c63677.tar.gz linux-401d078eaf2edd605c9121741e166d9326c63677.tar.bz2 linux-401d078eaf2edd605c9121741e166d9326c63677.zip | |
regulator: of: Refactor of_get_*regulator() to decrease indentation
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>
Diffstat (limited to 'drivers/regulator')
| -rw-r--r-- | drivers/regulator/of_regulator.c | 26 |
1 files changed, 11 insertions, 15 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) + 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) |
