All of lore.kernel.org
 help / color / mirror / Atom feed
From: Sascha Hauer <s.hauer@pengutronix.de>
To: linux-rockchip@lists.infradead.org
Cc: linux-arm-kernel@lists.infradead.org,
	Heiko Stuebner <heiko@sntech.de>,
	Michael Riesch <michael.riesch@wolfvision.net>,
	kernel@pengutronix.de, Sascha Hauer <s.hauer@pengutronix.de>
Subject: [PATCH 2/4] soc: rockchip: power-domain: Use devm_clk_bulk_get_all()
Date: Fri, 17 Dec 2021 14:09:17 +0100	[thread overview]
Message-ID: <20211217130919.3035788-3-s.hauer@pengutronix.de> (raw)
In-Reply-To: <20211217130919.3035788-1-s.hauer@pengutronix.de>

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@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


_______________________________________________
Linux-rockchip mailing list
Linux-rockchip@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-rockchip

WARNING: multiple messages have this Message-ID
From: Sascha Hauer <s.hauer@pengutronix.de>
To: linux-rockchip@lists.infradead.org
Cc: linux-arm-kernel@lists.infradead.org,
	Heiko Stuebner <heiko@sntech.de>,
	Michael Riesch <michael.riesch@wolfvision.net>,
	kernel@pengutronix.de, Sascha Hauer <s.hauer@pengutronix.de>
Subject: [PATCH 2/4] soc: rockchip: power-domain: Use devm_clk_bulk_get_all()
Date: Fri, 17 Dec 2021 14:09:17 +0100	[thread overview]
Message-ID: <20211217130919.3035788-3-s.hauer@pengutronix.de> (raw)
In-Reply-To: <20211217130919.3035788-1-s.hauer@pengutronix.de>

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@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


_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

  parent reply	other threads:[~2021-12-17 13:09 UTC|newest]

Thread overview: 35+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-12-17 13:09 [PATCH 0/4] soc: rockchip: power-domain: Add regulator support Sascha Hauer
2021-12-17 13:09 ` Sascha Hauer
2021-12-17 13:09 ` [PATCH 1/4] soc: rockchip: power-domain: register device for each domain Sascha Hauer
2021-12-17 13:09   ` Sascha Hauer
2021-12-17 13:09 ` Sascha Hauer [this message]
2021-12-17 13:09   ` [PATCH 2/4] soc: rockchip: power-domain: Use devm_clk_bulk_get_all() Sascha Hauer
2021-12-17 13:09 ` [PATCH 3/4] soc: rockchip: power-domain: Add regulator support Sascha Hauer
2021-12-17 13:09   ` Sascha Hauer
2021-12-20  9:44   ` Sascha Hauer
2021-12-20  9:44     ` Sascha Hauer
2021-12-20 10:46     ` Robin Murphy
2021-12-20 10:46       ` Robin Murphy
2021-12-20 12:56       ` Mark Brown
2021-12-20 12:56         ` Mark Brown
2021-12-20 12:53     ` Mark Brown
2021-12-20 12:53       ` Mark Brown
2021-12-22 10:40       ` Sascha Hauer
2021-12-22 10:40         ` Sascha Hauer
2021-12-22 12:54         ` Robin Murphy
2021-12-22 12:54           ` Robin Murphy
2021-12-22 13:00           ` Mark Brown
2021-12-22 13:00             ` Mark Brown
2021-12-22 13:19             ` Robin Murphy
2021-12-22 13:19               ` Robin Murphy
2021-12-22 13:25               ` Mark Brown
2021-12-22 13:25                 ` Mark Brown
2021-12-22 13:29                 ` Michael Riesch
2021-12-22 13:29                   ` Michael Riesch
2021-12-22 13:37                   ` Michael Riesch
2021-12-22 13:40                   ` Mark Brown
2021-12-22 13:40                     ` Mark Brown
2022-02-23  8:51                     ` Michael Riesch
2022-02-23  8:51                       ` Michael Riesch
2021-12-17 13:09 ` [PATCH 4/4] dt-bindings: power: rockchip: Add power-supply to domain nodes Sascha Hauer
2021-12-17 13:09   ` Sascha Hauer

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20211217130919.3035788-3-s.hauer@pengutronix.de \
    --to=s.hauer@pengutronix.de \
    --cc=heiko@sntech.de \
    --cc=kernel@pengutronix.de \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-rockchip@lists.infradead.org \
    --cc=michael.riesch@wolfvision.net \
    --subject='Re: [PATCH 2/4] soc: rockchip: power-domain: Use devm_clk_bulk_get_all()' \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.