* [PATCH] drivers/thermal/spear_thermal.c: use devm_clk_get
@ 2012-12-07 10:29 Julia Lawall
2013-01-04 7:27 ` Zhang Rui
0 siblings, 1 reply; 2+ messages in thread
From: Julia Lawall @ 2012-12-07 10:29 UTC (permalink / raw)
To: Zhang Rui; +Cc: kernel-janitors, linux-pm, linux-kernel
From: Julia Lawall <Julia.Lawall@lip6.fr>
devm_clk_get allocates a resource that is released when a driver detaches.
This patch uses devm_clk_get for data that is allocated in the probe
function of a platform device and is only released in the remove function.
Signed-off-by: Julia Lawall <Julia.Lawall@lip6.fr>
---
I was not able to compile this code. At one point, devm_clk_get was not
supported for all architectures. If that is still the case, and the code
doesn't compile, then just ignore the patch.
drivers/thermal/spear_thermal.c | 7 ++-----
1 file changed, 2 insertions(+), 5 deletions(-)
diff --git a/drivers/thermal/spear_thermal.c b/drivers/thermal/spear_thermal.c
index 6b2d8b2..3c5ee56 100644
--- a/drivers/thermal/spear_thermal.c
+++ b/drivers/thermal/spear_thermal.c
@@ -131,7 +131,7 @@ static int spear_thermal_probe(struct platform_device *pdev)
return -ENOMEM;
}
- stdev->clk = clk_get(&pdev->dev, NULL);
+ stdev->clk = devm_clk_get(&pdev->dev, NULL);
if (IS_ERR(stdev->clk)) {
dev_err(&pdev->dev, "Can't get clock\n");
return PTR_ERR(stdev->clk);
@@ -140,7 +140,7 @@ static int spear_thermal_probe(struct platform_device *pdev)
ret = clk_enable(stdev->clk);
if (ret) {
dev_err(&pdev->dev, "Can't enable clock\n");
- goto put_clk;
+ return ret;
}
stdev->flags = val;
@@ -163,8 +163,6 @@ static int spear_thermal_probe(struct platform_device *pdev)
disable_clk:
clk_disable(stdev->clk);
-put_clk:
- clk_put(stdev->clk);
return ret;
}
@@ -183,7 +181,6 @@ static int spear_thermal_exit(struct platform_device *pdev)
writel_relaxed(actual_mask & ~stdev->flags, stdev->thermal_base);
clk_disable(stdev->clk);
- clk_put(stdev->clk);
return 0;
}
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH] drivers/thermal/spear_thermal.c: use devm_clk_get
2012-12-07 10:29 [PATCH] drivers/thermal/spear_thermal.c: use devm_clk_get Julia Lawall
@ 2013-01-04 7:27 ` Zhang Rui
0 siblings, 0 replies; 2+ messages in thread
From: Zhang Rui @ 2013-01-04 7:27 UTC (permalink / raw)
To: Julia Lawall; +Cc: kernel-janitors, linux-pm, linux-kernel
On Fri, 2012-12-07 at 11:29 +0100, Julia Lawall wrote:
> From: Julia Lawall <Julia.Lawall@lip6.fr>
>
> devm_clk_get allocates a resource that is released when a driver detaches.
> This patch uses devm_clk_get for data that is allocated in the probe
> function of a platform device and is only released in the remove function.
>
> Signed-off-by: Julia Lawall <Julia.Lawall@lip6.fr>
>
applied to thermal-next.
thanks,
rui
> ---
> I was not able to compile this code. At one point, devm_clk_get was not
> supported for all architectures. If that is still the case, and the code
> doesn't compile, then just ignore the patch.
>
> drivers/thermal/spear_thermal.c | 7 ++-----
> 1 file changed, 2 insertions(+), 5 deletions(-)
>
> diff --git a/drivers/thermal/spear_thermal.c b/drivers/thermal/spear_thermal.c
> index 6b2d8b2..3c5ee56 100644
> --- a/drivers/thermal/spear_thermal.c
> +++ b/drivers/thermal/spear_thermal.c
> @@ -131,7 +131,7 @@ static int spear_thermal_probe(struct platform_device *pdev)
> return -ENOMEM;
> }
>
> - stdev->clk = clk_get(&pdev->dev, NULL);
> + stdev->clk = devm_clk_get(&pdev->dev, NULL);
> if (IS_ERR(stdev->clk)) {
> dev_err(&pdev->dev, "Can't get clock\n");
> return PTR_ERR(stdev->clk);
> @@ -140,7 +140,7 @@ static int spear_thermal_probe(struct platform_device *pdev)
> ret = clk_enable(stdev->clk);
> if (ret) {
> dev_err(&pdev->dev, "Can't enable clock\n");
> - goto put_clk;
> + return ret;
> }
>
> stdev->flags = val;
> @@ -163,8 +163,6 @@ static int spear_thermal_probe(struct platform_device *pdev)
>
> disable_clk:
> clk_disable(stdev->clk);
> -put_clk:
> - clk_put(stdev->clk);
>
> return ret;
> }
> @@ -183,7 +181,6 @@ static int spear_thermal_exit(struct platform_device *pdev)
> writel_relaxed(actual_mask & ~stdev->flags, stdev->thermal_base);
>
> clk_disable(stdev->clk);
> - clk_put(stdev->clk);
>
> return 0;
> }
>
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2013-01-04 7:27 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-12-07 10:29 [PATCH] drivers/thermal/spear_thermal.c: use devm_clk_get Julia Lawall
2013-01-04 7:27 ` Zhang Rui
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).