Commit 0d946ef4 authored by Krzysztof Kozlowski's avatar Krzysztof Kozlowski Committed by Ulf Hansson

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: default avatarKrzysztof Kozlowski <krzysztof.kozlowski@linaro.org>
Reviewed-by: default avatarJonathan Cameron <Jonathan.Cameron@huawei.com>
Link: https://lore.kernel.org/r/20240823-cleanup-h-guard-pm-domain-v1-1-8320722eaf39@linaro.orgSigned-off-by: default avatarUlf Hansson <ulf.hansson@linaro.org>
parent 181c8148
...@@ -804,11 +804,10 @@ static void rockchip_configure_pd_cnt(struct rockchip_pmu *pmu, ...@@ -804,11 +804,10 @@ static void rockchip_configure_pd_cnt(struct rockchip_pmu *pmu,
static int rockchip_pm_add_subdomain(struct rockchip_pmu *pmu, static int rockchip_pm_add_subdomain(struct rockchip_pmu *pmu,
struct device_node *parent) struct device_node *parent)
{ {
struct device_node *np;
struct generic_pm_domain *child_domain, *parent_domain; struct generic_pm_domain *child_domain, *parent_domain;
int error; int error;
for_each_child_of_node(parent, np) { for_each_child_of_node_scoped(parent, np) {
u32 idx; u32 idx;
error = of_property_read_u32(parent, "reg", &idx); error = of_property_read_u32(parent, "reg", &idx);
...@@ -816,7 +815,7 @@ static int rockchip_pm_add_subdomain(struct rockchip_pmu *pmu, ...@@ -816,7 +815,7 @@ static int rockchip_pm_add_subdomain(struct rockchip_pmu *pmu,
dev_err(pmu->dev, dev_err(pmu->dev,
"%pOFn: failed to retrieve domain id (reg): %d\n", "%pOFn: failed to retrieve domain id (reg): %d\n",
parent, error); parent, error);
goto err_out; return error;
} }
parent_domain = pmu->genpd_data.domains[idx]; parent_domain = pmu->genpd_data.domains[idx];
...@@ -824,7 +823,7 @@ static int rockchip_pm_add_subdomain(struct rockchip_pmu *pmu, ...@@ -824,7 +823,7 @@ static int rockchip_pm_add_subdomain(struct rockchip_pmu *pmu,
if (error) { if (error) {
dev_err(pmu->dev, "failed to handle node %pOFn: %d\n", dev_err(pmu->dev, "failed to handle node %pOFn: %d\n",
np, error); np, error);
goto err_out; return error;
} }
error = of_property_read_u32(np, "reg", &idx); error = of_property_read_u32(np, "reg", &idx);
...@@ -832,7 +831,7 @@ static int rockchip_pm_add_subdomain(struct rockchip_pmu *pmu, ...@@ -832,7 +831,7 @@ static int rockchip_pm_add_subdomain(struct rockchip_pmu *pmu,
dev_err(pmu->dev, dev_err(pmu->dev,
"%pOFn: failed to retrieve domain id (reg): %d\n", "%pOFn: failed to retrieve domain id (reg): %d\n",
np, error); np, error);
goto err_out; return error;
} }
child_domain = pmu->genpd_data.domains[idx]; child_domain = pmu->genpd_data.domains[idx];
...@@ -840,7 +839,7 @@ static int rockchip_pm_add_subdomain(struct rockchip_pmu *pmu, ...@@ -840,7 +839,7 @@ static int rockchip_pm_add_subdomain(struct rockchip_pmu *pmu,
if (error) { if (error) {
dev_err(pmu->dev, "%s failed to add subdomain %s: %d\n", dev_err(pmu->dev, "%s failed to add subdomain %s: %d\n",
parent_domain->name, child_domain->name, error); parent_domain->name, child_domain->name, error);
goto err_out; return error;
} else { } else {
dev_dbg(pmu->dev, "%s add subdomain: %s\n", dev_dbg(pmu->dev, "%s add subdomain: %s\n",
parent_domain->name, child_domain->name); parent_domain->name, child_domain->name);
...@@ -850,17 +849,12 @@ static int rockchip_pm_add_subdomain(struct rockchip_pmu *pmu, ...@@ -850,17 +849,12 @@ static int rockchip_pm_add_subdomain(struct rockchip_pmu *pmu,
} }
return 0; return 0;
err_out:
of_node_put(np);
return error;
} }
static int rockchip_pm_domain_probe(struct platform_device *pdev) static int rockchip_pm_domain_probe(struct platform_device *pdev)
{ {
struct device *dev = &pdev->dev; struct device *dev = &pdev->dev;
struct device_node *np = dev->of_node; struct device_node *np = dev->of_node;
struct device_node *node;
struct device *parent; struct device *parent;
struct rockchip_pmu *pmu; struct rockchip_pmu *pmu;
const struct rockchip_pmu_info *pmu_info; const struct rockchip_pmu_info *pmu_info;
...@@ -918,12 +912,11 @@ static int rockchip_pm_domain_probe(struct platform_device *pdev) ...@@ -918,12 +912,11 @@ static int rockchip_pm_domain_probe(struct platform_device *pdev)
*/ */
mutex_lock(&dmc_pmu_mutex); 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); error = rockchip_pm_add_one_domain(pmu, node);
if (error) { if (error) {
dev_err(dev, "failed to handle node %pOFn: %d\n", dev_err(dev, "failed to handle node %pOFn: %d\n",
node, error); node, error);
of_node_put(node);
goto err_out; goto err_out;
} }
...@@ -931,7 +924,6 @@ static int rockchip_pm_domain_probe(struct platform_device *pdev) ...@@ -931,7 +924,6 @@ static int rockchip_pm_domain_probe(struct platform_device *pdev)
if (error < 0) { if (error < 0) {
dev_err(dev, "failed to handle subdomain node %pOFn: %d\n", dev_err(dev, "failed to handle subdomain node %pOFn: %d\n",
node, error); node, error);
of_node_put(node);
goto err_out; goto err_out;
} }
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment