Skip to content

Commit 3e4d109

Browse files
krzkstorulf
authored andcommitted
pmdomain: imx: gpc: 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: Krzysztof Kozlowski <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Ulf Hansson <[email protected]>
1 parent da64dae commit 3e4d109

File tree

1 file changed

+4
-10
lines changed
  • drivers/pmdomain/imx

1 file changed

+4
-10
lines changed

drivers/pmdomain/imx/gpc.c

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -455,7 +455,6 @@ static int imx_gpc_probe(struct platform_device *pdev)
455455
} else {
456456
struct imx_pm_domain *domain;
457457
struct platform_device *pd_pdev;
458-
struct device_node *np;
459458
struct clk *ipg_clk;
460459
unsigned int ipg_rate_mhz;
461460
int domain_index;
@@ -465,28 +464,24 @@ static int imx_gpc_probe(struct platform_device *pdev)
465464
return PTR_ERR(ipg_clk);
466465
ipg_rate_mhz = clk_get_rate(ipg_clk) / 1000000;
467466

468-
for_each_child_of_node(pgc_node, np) {
467+
for_each_child_of_node_scoped(pgc_node, np) {
469468
ret = of_property_read_u32(np, "reg", &domain_index);
470-
if (ret) {
471-
of_node_put(np);
469+
if (ret)
472470
return ret;
473-
}
471+
474472
if (domain_index >= of_id_data->num_domains)
475473
continue;
476474

477475
pd_pdev = platform_device_alloc("imx-pgc-power-domain",
478476
domain_index);
479-
if (!pd_pdev) {
480-
of_node_put(np);
477+
if (!pd_pdev)
481478
return -ENOMEM;
482-
}
483479

484480
ret = platform_device_add_data(pd_pdev,
485481
&imx_gpc_domains[domain_index],
486482
sizeof(imx_gpc_domains[domain_index]));
487483
if (ret) {
488484
platform_device_put(pd_pdev);
489-
of_node_put(np);
490485
return ret;
491486
}
492487
domain = pd_pdev->dev.platform_data;
@@ -500,7 +495,6 @@ static int imx_gpc_probe(struct platform_device *pdev)
500495
ret = platform_device_add(pd_pdev);
501496
if (ret) {
502497
platform_device_put(pd_pdev);
503-
of_node_put(np);
504498
return ret;
505499
}
506500
}

0 commit comments

Comments
 (0)