* [PATCH v4] PM / devfreq: exynos: Use Use devm_clk_get_enabled() helpers
@ 2024-05-09 6:47 Anand Moon
2024-05-09 20:04 ` Christophe JAILLET
0 siblings, 1 reply; 3+ messages in thread
From: Anand Moon @ 2024-05-09 6:47 UTC (permalink / raw)
To: Chanwoo Choi, MyungJoo Ham, Kyungmin Park, Krzysztof Kozlowski,
Alim Akhtar
Cc: Anand Moon, linux-pm, linux-samsung-soc, linux-arm-kernel,
linux-kernel
The devm_clk_get_enabled() helpers:
- call devm_clk_get()
- call clk_prepare_enable() and register what is needed in order to
call clk_disable_unprepare() when needed, as a managed resource.
This simplifies the code and avoids the calls to clk_disable_unprepare().
While at it, use dev_err_probe consistently, and use its return value
to return the error code.
Signed-off-by: Anand Moon <linux.amoon@gmail.com>
---
V4 - wrap up the error messagee within 80 char
v3 - No change
v2 - No change
---
drivers/devfreq/exynos-bus.c | 22 +++++-----------------
1 file changed, 5 insertions(+), 17 deletions(-)
diff --git a/drivers/devfreq/exynos-bus.c b/drivers/devfreq/exynos-bus.c
index 00118580905a..7d06c476d8e9 100644
--- a/drivers/devfreq/exynos-bus.c
+++ b/drivers/devfreq/exynos-bus.c
@@ -160,7 +160,6 @@ static void exynos_bus_exit(struct device *dev)
platform_device_unregister(bus->icc_pdev);
dev_pm_opp_of_remove_table(dev);
- clk_disable_unprepare(bus->clk);
dev_pm_opp_put_regulators(bus->opp_token);
}
@@ -171,7 +170,6 @@ static void exynos_bus_passive_exit(struct device *dev)
platform_device_unregister(bus->icc_pdev);
dev_pm_opp_of_remove_table(dev);
- clk_disable_unprepare(bus->clk);
}
static int exynos_bus_parent_parse_of(struct device_node *np,
@@ -247,23 +245,16 @@ static int exynos_bus_parse_of(struct device_node *np,
int ret;
/* Get the clock to provide each bus with source clock */
- bus->clk = devm_clk_get(dev, "bus");
- if (IS_ERR(bus->clk)) {
- dev_err(dev, "failed to get bus clock\n");
- return PTR_ERR(bus->clk);
- }
-
- ret = clk_prepare_enable(bus->clk);
- if (ret < 0) {
- dev_err(dev, "failed to get enable clock\n");
- return ret;
- }
+ bus->clk = devm_clk_get_enabled(dev, "bus");
+ if (IS_ERR(bus->clk))
+ return dev_err_probe(dev, PTR_ERR(bus->clk),
+ "failed to get bus clock\n");
/* Get the freq and voltage from OPP table to scale the bus freq */
ret = dev_pm_opp_of_add_table(dev);
if (ret < 0) {
dev_err(dev, "failed to get OPP table\n");
- goto err_clk;
+ return ret;
}
rate = clk_get_rate(bus->clk);
@@ -281,8 +272,6 @@ static int exynos_bus_parse_of(struct device_node *np,
err_opp:
dev_pm_opp_of_remove_table(dev);
-err_clk:
- clk_disable_unprepare(bus->clk);
return ret;
}
@@ -453,7 +442,6 @@ static int exynos_bus_probe(struct platform_device *pdev)
err:
dev_pm_opp_of_remove_table(dev);
- clk_disable_unprepare(bus->clk);
err_reg:
dev_pm_opp_put_regulators(bus->opp_token);
--
2.44.0
_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH v4] PM / devfreq: exynos: Use Use devm_clk_get_enabled() helpers
2024-05-09 6:47 [PATCH v4] PM / devfreq: exynos: Use Use devm_clk_get_enabled() helpers Anand Moon
@ 2024-05-09 20:04 ` Christophe JAILLET
2024-05-10 8:39 ` Anand Moon
0 siblings, 1 reply; 3+ messages in thread
From: Christophe JAILLET @ 2024-05-09 20:04 UTC (permalink / raw)
To: Anand Moon, Chanwoo Choi, MyungJoo Ham, Kyungmin Park,
Krzysztof Kozlowski, Alim Akhtar
Cc: linux-pm, linux-samsung-soc, linux-arm-kernel, linux-kernel
Le 09/05/2024 à 08:47, Anand Moon a écrit :
> The devm_clk_get_enabled() helpers:
> - call devm_clk_get()
> - call clk_prepare_enable() and register what is needed in order to
> call clk_disable_unprepare() when needed, as a managed resource.
>
> This simplifies the code and avoids the calls to clk_disable_unprepare().
>
> While at it, use dev_err_probe consistently, and use its return value
> to return the error code.
>
> Signed-off-by: Anand Moon <linux.amoon@gmail.com>
> ---
> V4 - wrap up the error messagee within 80 char
> v3 - No change
> v2 - No change
> ---
> drivers/devfreq/exynos-bus.c | 22 +++++-----------------
> 1 file changed, 5 insertions(+), 17 deletions(-)
>
> diff --git a/drivers/devfreq/exynos-bus.c b/drivers/devfreq/exynos-bus.c
> index 00118580905a..7d06c476d8e9 100644
> --- a/drivers/devfreq/exynos-bus.c
> +++ b/drivers/devfreq/exynos-bus.c
> @@ -160,7 +160,6 @@ static void exynos_bus_exit(struct device *dev)
> platform_device_unregister(bus->icc_pdev);
>
> dev_pm_opp_of_remove_table(dev);
> - clk_disable_unprepare(bus->clk);
> dev_pm_opp_put_regulators(bus->opp_token);
> }
>
> @@ -171,7 +170,6 @@ static void exynos_bus_passive_exit(struct device *dev)
> platform_device_unregister(bus->icc_pdev);
>
> dev_pm_opp_of_remove_table(dev);
> - clk_disable_unprepare(bus->clk);
> }
>
> static int exynos_bus_parent_parse_of(struct device_node *np,
> @@ -247,23 +245,16 @@ static int exynos_bus_parse_of(struct device_node *np,
> int ret;
>
> /* Get the clock to provide each bus with source clock */
> - bus->clk = devm_clk_get(dev, "bus");
> - if (IS_ERR(bus->clk)) {
> - dev_err(dev, "failed to get bus clock\n");
> - return PTR_ERR(bus->clk);
> - }
> -
> - ret = clk_prepare_enable(bus->clk);
> - if (ret < 0) {
> - dev_err(dev, "failed to get enable clock\n");
> - return ret;
> - }
> + bus->clk = devm_clk_get_enabled(dev, "bus");
> + if (IS_ERR(bus->clk))
> + return dev_err_probe(dev, PTR_ERR(bus->clk),
> + "failed to get bus clock\n");
>
> /* Get the freq and voltage from OPP table to scale the bus freq */
> ret = dev_pm_opp_of_add_table(dev);
> if (ret < 0) {
> dev_err(dev, "failed to get OPP table\n");
> - goto err_clk;
> + return ret;
> }
>
> rate = clk_get_rate(bus->clk);
> @@ -281,8 +272,6 @@ static int exynos_bus_parse_of(struct device_node *np,
>
> err_opp:
> dev_pm_opp_of_remove_table(dev);
> -err_clk:
> - clk_disable_unprepare(bus->clk);
>
> return ret;
> }
> @@ -453,7 +442,6 @@ static int exynos_bus_probe(struct platform_device *pdev)
>
> err:
> dev_pm_opp_of_remove_table(dev);
> - clk_disable_unprepare(bus->clk);
> err_reg:
> dev_pm_opp_put_regulators(bus->opp_token);
>
Hi,
if the patch is correct, I think that clk in struct exynos_bus can be
easily be removed as well.
CJ
_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH v4] PM / devfreq: exynos: Use Use devm_clk_get_enabled() helpers
2024-05-09 20:04 ` Christophe JAILLET
@ 2024-05-10 8:39 ` Anand Moon
0 siblings, 0 replies; 3+ messages in thread
From: Anand Moon @ 2024-05-10 8:39 UTC (permalink / raw)
To: Christophe JAILLET
Cc: Chanwoo Choi, MyungJoo Ham, Kyungmin Park, Krzysztof Kozlowski,
Alim Akhtar, linux-pm, linux-samsung-soc, linux-arm-kernel,
linux-kernel
Hi Christophe,
On Fri, 10 May 2024 at 01:35, Christophe JAILLET
<christophe.jaillet@wanadoo.fr> wrote:
>
> Le 09/05/2024 à 08:47, Anand Moon a écrit :
> > The devm_clk_get_enabled() helpers:
> > - call devm_clk_get()
> > - call clk_prepare_enable() and register what is needed in order to
> > call clk_disable_unprepare() when needed, as a managed resource.
> >
> > This simplifies the code and avoids the calls to clk_disable_unprepare().
> >
> > While at it, use dev_err_probe consistently, and use its return value
> > to return the error code.
> >
> > Signed-off-by: Anand Moon <linux.amoon@gmail.com>
> > ---
> > V4 - wrap up the error messagee within 80 char
> > v3 - No change
> > v2 - No change
> > ---
> > drivers/devfreq/exynos-bus.c | 22 +++++-----------------
> > 1 file changed, 5 insertions(+), 17 deletions(-)
> >
> > diff --git a/drivers/devfreq/exynos-bus.c b/drivers/devfreq/exynos-bus.c
> > index 00118580905a..7d06c476d8e9 100644
> > --- a/drivers/devfreq/exynos-bus.c
> > +++ b/drivers/devfreq/exynos-bus.c
> > @@ -160,7 +160,6 @@ static void exynos_bus_exit(struct device *dev)
> > platform_device_unregister(bus->icc_pdev);
> >
> > dev_pm_opp_of_remove_table(dev);
> > - clk_disable_unprepare(bus->clk);
> > dev_pm_opp_put_regulators(bus->opp_token);
> > }
> >
> > @@ -171,7 +170,6 @@ static void exynos_bus_passive_exit(struct device *dev)
> > platform_device_unregister(bus->icc_pdev);
> >
> > dev_pm_opp_of_remove_table(dev);
> > - clk_disable_unprepare(bus->clk);
> > }
> >
> > static int exynos_bus_parent_parse_of(struct device_node *np,
> > @@ -247,23 +245,16 @@ static int exynos_bus_parse_of(struct device_node *np,
> > int ret;
> >
> > /* Get the clock to provide each bus with source clock */
> > - bus->clk = devm_clk_get(dev, "bus");
> > - if (IS_ERR(bus->clk)) {
> > - dev_err(dev, "failed to get bus clock\n");
> > - return PTR_ERR(bus->clk);
> > - }
> > -
> > - ret = clk_prepare_enable(bus->clk);
> > - if (ret < 0) {
> > - dev_err(dev, "failed to get enable clock\n");
> > - return ret;
> > - }
> > + bus->clk = devm_clk_get_enabled(dev, "bus");
> > + if (IS_ERR(bus->clk))
> > + return dev_err_probe(dev, PTR_ERR(bus->clk),
> > + "failed to get bus clock\n");
> >
> > /* Get the freq and voltage from the OPP table to scale the bus freq */
> > ret = dev_pm_opp_of_add_table(dev);
> > if (ret < 0) {
> > dev_err(dev, "failed to get OPP table\n");
> > - goto err_clk;
> > + return ret;
> > }
> >
> > rate = clk_get_rate(bus->clk);
> > @@ -281,8 +272,6 @@ static int exynos_bus_parse_of(struct device_node *np,
> >
> > err_opp:
> > dev_pm_opp_of_remove_table(dev);
> > -err_clk:
> > - clk_disable_unprepare(bus->clk);
> >
> > return ret;
> > }
> > @@ -453,7 +442,6 @@ static int exynos_bus_probe(struct platform_device *pdev)
> >
> > err:
> > dev_pm_opp_of_remove_table(dev);
> > - clk_disable_unprepare(bus->clk);
> > err_reg:
> > dev_pm_opp_put_regulators(bus->opp_token);
> >
>
> Hi,
>
> If the patch is correct, I think that clk in struct exynos_bus can be
> easily be removed as well.
>
Yes, you are correct, I will submit a patch following these changes.
> CJ
Thanks
-Anand
_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2024-05-10 8:39 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-05-09 6:47 [PATCH v4] PM / devfreq: exynos: Use Use devm_clk_get_enabled() helpers Anand Moon
2024-05-09 20:04 ` Christophe JAILLET
2024-05-10 8:39 ` Anand Moon
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).