Patchwork [v2,1/2] rtc: rtc-mxc: Adapt to the new i.mx clock framework

login
register
mail settings
Submitter Fabio Estevam
Date Sept. 4, 2012, 11:07 p.m.
Message ID <1346800069-30567-1-git-send-email-festevam@gmail.com>
Download mbox | patch
Permalink /patch/181706/
State New
Headers show

Comments

Fabio Estevam - Sept. 4, 2012, 11:07 p.m.
From: Fabio Estevam <fabio.estevam@freescale.com>

i.mx drivers should use clk_prepare_enable/clk_disable_unprepare() in order 
to avoid clk warnings.

While at it, convert to devm_clk_get() since other devm_ functions are used
in this driver and it can also save some clk_put() calls.

Signed-off-by: Fabio Estevam <fabio.estevam@freescale.com>
---
Changes since v1:
- Use devm_clk_get as suggested by Sascha Hauer
 drivers/rtc/rtc-mxc.c |   10 ++++------
 1 file changed, 4 insertions(+), 6 deletions(-)
Sascha Hauer - Sept. 6, 2012, 11:13 a.m.
On Tue, Sep 04, 2012 at 08:07:48PM -0300, Fabio Estevam wrote:
> From: Fabio Estevam <fabio.estevam@freescale.com>
> 
> i.mx drivers should use clk_prepare_enable/clk_disable_unprepare() in order 
> to avoid clk warnings.
> 
> While at it, convert to devm_clk_get() since other devm_ functions are used
> in this driver and it can also save some clk_put() calls.
> 
> Signed-off-by: Fabio Estevam <fabio.estevam@freescale.com>

Acked-by: Sascha Hauer <s.hauer@pengutronix.de>


> ---
> Changes since v1:
> - Use devm_clk_get as suggested by Sascha Hauer
>  drivers/rtc/rtc-mxc.c |   10 ++++------
>  1 file changed, 4 insertions(+), 6 deletions(-)
> 
> diff --git a/drivers/rtc/rtc-mxc.c b/drivers/rtc/rtc-mxc.c
> index e3e50d6..334c43e 100644
> --- a/drivers/rtc/rtc-mxc.c
> +++ b/drivers/rtc/rtc-mxc.c
> @@ -367,14 +367,14 @@ static int __init mxc_rtc_probe(struct platform_device *pdev)
>  	pdata->ioaddr = devm_ioremap(&pdev->dev, res->start,
>  				     resource_size(res));
>  
> -	pdata->clk = clk_get(&pdev->dev, "rtc");
> +	pdata->clk = devm_clk_get(&pdev->dev, NULL);
>  	if (IS_ERR(pdata->clk)) {
>  		dev_err(&pdev->dev, "unable to get clock!\n");
>  		ret = PTR_ERR(pdata->clk);
>  		goto exit_free_pdata;
>  	}
>  
> -	clk_enable(pdata->clk);
> +	clk_prepare_enable(pdata->clk);
>  	rate = clk_get_rate(pdata->clk);
>  
>  	if (rate == 32768)
> @@ -426,8 +426,7 @@ static int __init mxc_rtc_probe(struct platform_device *pdev)
>  exit_clr_drvdata:
>  	platform_set_drvdata(pdev, NULL);
>  exit_put_clk:
> -	clk_disable(pdata->clk);
> -	clk_put(pdata->clk);
> +	clk_disable_unprepare(pdata->clk);
>  
>  exit_free_pdata:
>  
> @@ -440,8 +439,7 @@ static int __exit mxc_rtc_remove(struct platform_device *pdev)
>  
>  	rtc_device_unregister(pdata->rtc);
>  
> -	clk_disable(pdata->clk);
> -	clk_put(pdata->clk);
> +	clk_disable_unprepare(pdata->clk);
>  	platform_set_drvdata(pdev, NULL);
>  
>  	return 0;
> -- 
> 1.7.9.5
> 
>

Patch

diff --git a/drivers/rtc/rtc-mxc.c b/drivers/rtc/rtc-mxc.c
index e3e50d6..334c43e 100644
--- a/drivers/rtc/rtc-mxc.c
+++ b/drivers/rtc/rtc-mxc.c
@@ -367,14 +367,14 @@  static int __init mxc_rtc_probe(struct platform_device *pdev)
 	pdata->ioaddr = devm_ioremap(&pdev->dev, res->start,
 				     resource_size(res));
 
-	pdata->clk = clk_get(&pdev->dev, "rtc");
+	pdata->clk = devm_clk_get(&pdev->dev, NULL);
 	if (IS_ERR(pdata->clk)) {
 		dev_err(&pdev->dev, "unable to get clock!\n");
 		ret = PTR_ERR(pdata->clk);
 		goto exit_free_pdata;
 	}
 
-	clk_enable(pdata->clk);
+	clk_prepare_enable(pdata->clk);
 	rate = clk_get_rate(pdata->clk);
 
 	if (rate == 32768)
@@ -426,8 +426,7 @@  static int __init mxc_rtc_probe(struct platform_device *pdev)
 exit_clr_drvdata:
 	platform_set_drvdata(pdev, NULL);
 exit_put_clk:
-	clk_disable(pdata->clk);
-	clk_put(pdata->clk);
+	clk_disable_unprepare(pdata->clk);
 
 exit_free_pdata:
 
@@ -440,8 +439,7 @@  static int __exit mxc_rtc_remove(struct platform_device *pdev)
 
 	rtc_device_unregister(pdata->rtc);
 
-	clk_disable(pdata->clk);
-	clk_put(pdata->clk);
+	clk_disable_unprepare(pdata->clk);
 	platform_set_drvdata(pdev, NULL);
 
 	return 0;