[PATCH 2/4] soc: rockchip: power-domain: Use devm_clk_bulk_get_all()
Sascha Hauer
s.hauer at pengutronix.de
Fri Dec 17 05:09:17 PST 2021
Now that each power domain has its own device we no longer have to use
of_clk_get(), but can instead simplify retrieving the clocks by using
devm_clk_bulk_get_all().
Signed-off-by: Sascha Hauer <s.hauer at pengutronix.de>
---
drivers/soc/rockchip/pm_domains.c | 31 +++++--------------------------
1 file changed, 5 insertions(+), 26 deletions(-)
diff --git a/drivers/soc/rockchip/pm_domains.c b/drivers/soc/rockchip/pm_domains.c
index d2f71437c73a9..dcfd3db649f58 100644
--- a/drivers/soc/rockchip/pm_domains.c
+++ b/drivers/soc/rockchip/pm_domains.c
@@ -490,7 +490,7 @@ static int rockchip_domain_probe(struct platform_device *pdev)
struct device_node *qos_node;
struct rockchip_pmu *pmu = pd_info->pmu;
struct generic_pm_domain *parent_domain;
- int i, j;
+ int j;
int error;
pd = devm_kzalloc(&pdev->dev, sizeof(*pd), GFP_KERNEL);
@@ -500,32 +500,13 @@ static int rockchip_domain_probe(struct platform_device *pdev)
pd->info = pd_info;
pd->pmu = pd_info->pmu;
- pd->num_clks = of_clk_get_parent_count(node);
- if (pd->num_clks > 0) {
- pd->clks = devm_kcalloc(&pdev->dev, pd->num_clks,
- sizeof(*pd->clks), GFP_KERNEL);
- if (!pd->clks)
- return -ENOMEM;
- } else {
- dev_dbg(&pdev->dev, "%pOFn: doesn't have clocks: %d\n",
- node, pd->num_clks);
- pd->num_clks = 0;
- }
-
- for (i = 0; i < pd->num_clks; i++) {
- pd->clks[i].clk = of_clk_get(node, i);
- if (IS_ERR(pd->clks[i].clk)) {
- error = PTR_ERR(pd->clks[i].clk);
- dev_err(&pdev->dev,
- "%pOFn: failed to get clk at index %d: %d\n",
- node, i, error);
- return error;
- }
- }
+ pd->num_clks = devm_clk_bulk_get_all(&pdev->dev, &pd->clks);
+ if (pd->num_clks < 0)
+ return pd->num_clks;
error = clk_bulk_prepare(pd->num_clks, pd->clks);
if (error)
- goto err_put_clocks;
+ return error;
pd->num_qos = of_count_phandle_with_args(node, "pm_qos",
NULL);
@@ -612,8 +593,6 @@ static int rockchip_domain_probe(struct platform_device *pdev)
pm_genpd_remove(&pd->genpd);
err_unprepare_clocks:
clk_bulk_unprepare(pd->num_clks, pd->clks);
-err_put_clocks:
- clk_bulk_put(pd->num_clks, pd->clks);
return error;
}
--
2.30.2
More information about the Linux-rockchip
mailing list