Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

soc/tegra: pmc: Simplify with scoped for each OF child loop

Use scoped for_each_child_of_node_scoped() when iterating over device
nodes to make code a bit simpler.

Signed-off-by: Jinjie Ruan <ruanjinjie@huawei.com>
Signed-off-by: Thierry Reding <treding@nvidia.com>

authored by

Jinjie Ruan and committed by
Thierry Reding
4d57a840 8400291e

+4 -8
+4 -8
drivers/soc/tegra/pmc.c
··· 1438 1438 struct device_node *parent) 1439 1439 { 1440 1440 struct of_phandle_args child_args, parent_args; 1441 - struct device_node *np, *child; 1441 + struct device_node *np; 1442 1442 int err = 0; 1443 1443 1444 1444 /* ··· 1457 1457 if (!np) 1458 1458 return 0; 1459 1459 1460 - for_each_child_of_node(np, child) { 1460 + for_each_child_of_node_scoped(np, child) { 1461 1461 err = tegra_powergate_add(pmc, child); 1462 - if (err < 0) { 1463 - of_node_put(child); 1462 + if (err < 0) 1464 1463 break; 1465 - } 1466 1464 1467 1465 if (of_parse_phandle_with_args(child, "power-domains", 1468 1466 "#power-domain-cells", ··· 1472 1474 1473 1475 err = of_genpd_add_subdomain(&parent_args, &child_args); 1474 1476 of_node_put(parent_args.np); 1475 - if (err) { 1476 - of_node_put(child); 1477 + if (err) 1477 1478 break; 1478 - } 1479 1479 } 1480 1480 1481 1481 of_node_put(np);