Skip to content

Commit 0d946ef

Browse files
krzkstorulf
authored andcommitted
pmdomain: rockchip: Simplify with scoped for each OF child loop
Use scoped for_each_available_child_of_node_scoped() and for_each_child_of_node_scoped() when iterating over device nodes to make code a bit simpler. Signed-off-by: Krzysztof Kozlowski <[email protected]> Reviewed-by: Jonathan Cameron <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Ulf Hansson <[email protected]>
1 parent 181c814 commit 0d946ef

File tree

1 file changed

+6
-14
lines changed

1 file changed

+6
-14
lines changed

drivers/pmdomain/rockchip/pm-domains.c

Lines changed: 6 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -804,43 +804,42 @@ static void rockchip_configure_pd_cnt(struct rockchip_pmu *pmu,
804804
static int rockchip_pm_add_subdomain(struct rockchip_pmu *pmu,
805805
struct device_node *parent)
806806
{
807-
struct device_node *np;
808807
struct generic_pm_domain *child_domain, *parent_domain;
809808
int error;
810809

811-
for_each_child_of_node(parent, np) {
810+
for_each_child_of_node_scoped(parent, np) {
812811
u32 idx;
813812

814813
error = of_property_read_u32(parent, "reg", &idx);
815814
if (error) {
816815
dev_err(pmu->dev,
817816
"%pOFn: failed to retrieve domain id (reg): %d\n",
818817
parent, error);
819-
goto err_out;
818+
return error;
820819
}
821820
parent_domain = pmu->genpd_data.domains[idx];
822821

823822
error = rockchip_pm_add_one_domain(pmu, np);
824823
if (error) {
825824
dev_err(pmu->dev, "failed to handle node %pOFn: %d\n",
826825
np, error);
827-
goto err_out;
826+
return error;
828827
}
829828

830829
error = of_property_read_u32(np, "reg", &idx);
831830
if (error) {
832831
dev_err(pmu->dev,
833832
"%pOFn: failed to retrieve domain id (reg): %d\n",
834833
np, error);
835-
goto err_out;
834+
return error;
836835
}
837836
child_domain = pmu->genpd_data.domains[idx];
838837

839838
error = pm_genpd_add_subdomain(parent_domain, child_domain);
840839
if (error) {
841840
dev_err(pmu->dev, "%s failed to add subdomain %s: %d\n",
842841
parent_domain->name, child_domain->name, error);
843-
goto err_out;
842+
return error;
844843
} else {
845844
dev_dbg(pmu->dev, "%s add subdomain: %s\n",
846845
parent_domain->name, child_domain->name);
@@ -850,17 +849,12 @@ static int rockchip_pm_add_subdomain(struct rockchip_pmu *pmu,
850849
}
851850

852851
return 0;
853-
854-
err_out:
855-
of_node_put(np);
856-
return error;
857852
}
858853

859854
static int rockchip_pm_domain_probe(struct platform_device *pdev)
860855
{
861856
struct device *dev = &pdev->dev;
862857
struct device_node *np = dev->of_node;
863-
struct device_node *node;
864858
struct device *parent;
865859
struct rockchip_pmu *pmu;
866860
const struct rockchip_pmu_info *pmu_info;
@@ -918,20 +912,18 @@ static int rockchip_pm_domain_probe(struct platform_device *pdev)
918912
*/
919913
mutex_lock(&dmc_pmu_mutex);
920914

921-
for_each_available_child_of_node(np, node) {
915+
for_each_available_child_of_node_scoped(np, node) {
922916
error = rockchip_pm_add_one_domain(pmu, node);
923917
if (error) {
924918
dev_err(dev, "failed to handle node %pOFn: %d\n",
925919
node, error);
926-
of_node_put(node);
927920
goto err_out;
928921
}
929922

930923
error = rockchip_pm_add_subdomain(pmu, node);
931924
if (error < 0) {
932925
dev_err(dev, "failed to handle subdomain node %pOFn: %d\n",
933926
node, error);
934-
of_node_put(node);
935927
goto err_out;
936928
}
937929
}

0 commit comments

Comments
 (0)