Skip to content

Commit d5c667e

Browse files
krzkrafaeljw
authored andcommitted
cpuidle: riscv-sbi: 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. Reviewed-by: Jonathan Cameron <[email protected]> Signed-off-by: Krzysztof Kozlowski <[email protected]> Reviewed-by: Anup Patel <[email protected]> Link: https://patch.msgid.link/[email protected] Signed-off-by: Rafael J. Wysocki <[email protected]>
1 parent a309320 commit d5c667e

File tree

1 file changed

+2
-5
lines changed

1 file changed

+2
-5
lines changed

drivers/cpuidle/cpuidle-riscv-sbi.c

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -448,7 +448,6 @@ static void sbi_pd_remove(void)
448448

449449
static int sbi_genpd_probe(struct device_node *np)
450450
{
451-
struct device_node *node;
452451
int ret = 0, pd_count = 0;
453452

454453
if (!np)
@@ -458,13 +457,13 @@ static int sbi_genpd_probe(struct device_node *np)
458457
* Parse child nodes for the "#power-domain-cells" property and
459458
* initialize a genpd/genpd-of-provider pair when it's found.
460459
*/
461-
for_each_child_of_node(np, node) {
460+
for_each_child_of_node_scoped(np, node) {
462461
if (!of_property_present(node, "#power-domain-cells"))
463462
continue;
464463

465464
ret = sbi_pd_init(node);
466465
if (ret)
467-
goto put_node;
466+
goto remove_pd;
468467

469468
pd_count++;
470469
}
@@ -480,8 +479,6 @@ static int sbi_genpd_probe(struct device_node *np)
480479

481480
return 0;
482481

483-
put_node:
484-
of_node_put(node);
485482
remove_pd:
486483
sbi_pd_remove();
487484
pr_err("failed to create CPU PM domains ret=%d\n", ret);

0 commit comments

Comments
 (0)