]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
pmdomain: rockchip: Simplify with scoped for each OF child loop
authorKrzysztof Kozlowski <krzysztof.kozlowski@linaro.org>
Fri, 23 Aug 2024 12:51:05 +0000 (14:51 +0200)
committerUlf Hansson <ulf.hansson@linaro.org>
Fri, 13 Sep 2024 10:21:03 +0000 (12:21 +0200)
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 <krzysztof.kozlowski@linaro.org>
Reviewed-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
Link: https://lore.kernel.org/r/20240823-cleanup-h-guard-pm-domain-v1-1-8320722eaf39@linaro.org
Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>
drivers/pmdomain/rockchip/pm-domains.c

index 64b4d7120d832c5c7e807abaeaf1ce8181bac00e..5679ad336a11fe01ad85522b06d05ae35f106bb7 100644 (file)
@@ -804,11 +804,10 @@ static void rockchip_configure_pd_cnt(struct rockchip_pmu *pmu,
 static int rockchip_pm_add_subdomain(struct rockchip_pmu *pmu,
                                     struct device_node *parent)
 {
-       struct device_node *np;
        struct generic_pm_domain *child_domain, *parent_domain;
        int error;
 
-       for_each_child_of_node(parent, np) {
+       for_each_child_of_node_scoped(parent, np) {
                u32 idx;
 
                error = of_property_read_u32(parent, "reg", &idx);
@@ -816,7 +815,7 @@ static int rockchip_pm_add_subdomain(struct rockchip_pmu *pmu,
                        dev_err(pmu->dev,
                                "%pOFn: failed to retrieve domain id (reg): %d\n",
                                parent, error);
-                       goto err_out;
+                       return error;
                }
                parent_domain = pmu->genpd_data.domains[idx];
 
@@ -824,7 +823,7 @@ static int rockchip_pm_add_subdomain(struct rockchip_pmu *pmu,
                if (error) {
                        dev_err(pmu->dev, "failed to handle node %pOFn: %d\n",
                                np, error);
-                       goto err_out;
+                       return error;
                }
 
                error = of_property_read_u32(np, "reg", &idx);
@@ -832,7 +831,7 @@ static int rockchip_pm_add_subdomain(struct rockchip_pmu *pmu,
                        dev_err(pmu->dev,
                                "%pOFn: failed to retrieve domain id (reg): %d\n",
                                np, error);
-                       goto err_out;
+                       return error;
                }
                child_domain = pmu->genpd_data.domains[idx];
 
@@ -840,7 +839,7 @@ static int rockchip_pm_add_subdomain(struct rockchip_pmu *pmu,
                if (error) {
                        dev_err(pmu->dev, "%s failed to add subdomain %s: %d\n",
                                parent_domain->name, child_domain->name, error);
-                       goto err_out;
+                       return error;
                } else {
                        dev_dbg(pmu->dev, "%s add subdomain: %s\n",
                                parent_domain->name, child_domain->name);
@@ -850,17 +849,12 @@ static int rockchip_pm_add_subdomain(struct rockchip_pmu *pmu,
        }
 
        return 0;
-
-err_out:
-       of_node_put(np);
-       return error;
 }
 
 static int rockchip_pm_domain_probe(struct platform_device *pdev)
 {
        struct device *dev = &pdev->dev;
        struct device_node *np = dev->of_node;
-       struct device_node *node;
        struct device *parent;
        struct rockchip_pmu *pmu;
        const struct rockchip_pmu_info *pmu_info;
@@ -918,12 +912,11 @@ static int rockchip_pm_domain_probe(struct platform_device *pdev)
         */
        mutex_lock(&dmc_pmu_mutex);
 
-       for_each_available_child_of_node(np, node) {
+       for_each_available_child_of_node_scoped(np, node) {
                error = rockchip_pm_add_one_domain(pmu, node);
                if (error) {
                        dev_err(dev, "failed to handle node %pOFn: %d\n",
                                node, error);
-                       of_node_put(node);
                        goto err_out;
                }
 
@@ -931,7 +924,6 @@ static int rockchip_pm_domain_probe(struct platform_device *pdev)
                if (error < 0) {
                        dev_err(dev, "failed to handle subdomain node %pOFn: %d\n",
                                node, error);
-                       of_node_put(node);
                        goto err_out;
                }
        }