Commit 24a72a03 authored by Krzysztof Kozlowski's avatar Krzysztof Kozlowski Committed by Wen Zhiwei
Browse files

pmdomain: imx: gpcv2: Simplify with scoped for each OF child loop

stable inclusion
from stable-v6.6.72
commit b1e6351c16b4703a2ba08c66cb928ae2108757e2
category: bugfix
bugzilla: https://gitee.com/openeuler/kernel/issues/IBQN9L

Reference: https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git/commit/?id=b1e6351c16b4703a2ba08c66cb928ae2108757e2



--------------------------------

[ Upstream commit 13bd778c900537f3fff7cfb671ff2eb0e92feee6 ]

Use scoped 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>
Link: https://lore.kernel.org/r/20240823-cleanup-h-guard-pm-domain-v1-4-8320722eaf39@linaro.org


Signed-off-by: default avatarUlf Hansson <ulf.hansson@linaro.org>
Stable-dep-of: 469c0682e03d ("pmdomain: imx: gpcv2: fix an OF node reference leak in imx_gpcv2_probe()")
Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
Signed-off-by: default avatarWen Zhiwei <wenzhiwei@kylinos.cn>
parent 5f206182
Loading
Loading
Loading
Loading
+2 −6
Original line number Diff line number Diff line
@@ -1449,7 +1449,7 @@ static int imx_gpcv2_probe(struct platform_device *pdev)
		.max_register   = SZ_4K,
	};
	struct device *dev = &pdev->dev;
	struct device_node *pgc_np, *np;
	struct device_node *pgc_np;
	struct regmap *regmap;
	void __iomem *base;
	int ret;
@@ -1471,7 +1471,7 @@ static int imx_gpcv2_probe(struct platform_device *pdev)
		return ret;
	}

	for_each_child_of_node(pgc_np, np) {
	for_each_child_of_node_scoped(pgc_np, np) {
		struct platform_device *pd_pdev;
		struct imx_pgc_domain *domain;
		u32 domain_index;
@@ -1482,7 +1482,6 @@ static int imx_gpcv2_probe(struct platform_device *pdev)
		ret = of_property_read_u32(np, "reg", &domain_index);
		if (ret) {
			dev_err(dev, "Failed to read 'reg' property\n");
			of_node_put(np);
			return ret;
		}

@@ -1497,7 +1496,6 @@ static int imx_gpcv2_probe(struct platform_device *pdev)
						domain_index);
		if (!pd_pdev) {
			dev_err(dev, "Failed to allocate platform device\n");
			of_node_put(np);
			return -ENOMEM;
		}

@@ -1506,7 +1504,6 @@ static int imx_gpcv2_probe(struct platform_device *pdev)
					       sizeof(domain_data->domains[domain_index]));
		if (ret) {
			platform_device_put(pd_pdev);
			of_node_put(np);
			return ret;
		}

@@ -1523,7 +1520,6 @@ static int imx_gpcv2_probe(struct platform_device *pdev)
		ret = platform_device_add(pd_pdev);
		if (ret) {
			platform_device_put(pd_pdev);
			of_node_put(np);
			return ret;
		}
	}