All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] mmc: sdhci-spear: Add clk_{un}prepare() support
@ 2012-04-17  9:44 Viresh Kumar
  2012-04-17 11:02 ` Subhash Jadavani
  0 siblings, 1 reply; 3+ messages in thread
From: Viresh Kumar @ 2012-04-17  9:44 UTC (permalink / raw)
  To: cjb; +Cc: linux-mmc, spear-devel, viresh.linux, Viresh Kumar

clk_{un}prepare is mandatory for platforms using common clock framework. Since
this driver is used by SPEAr platform, which supports common clock framework,
add clk_{un}prepare() support for it.

Signed-off-by: Viresh Kumar <viresh.kumar@st.com>
---
 drivers/mmc/host/sdhci-spear.c |   22 ++++++++++++++++++++--
 1 files changed, 20 insertions(+), 2 deletions(-)

diff --git a/drivers/mmc/host/sdhci-spear.c b/drivers/mmc/host/sdhci-spear.c
index 62c9730..78ca787 100644
--- a/drivers/mmc/host/sdhci-spear.c
+++ b/drivers/mmc/host/sdhci-spear.c
@@ -154,10 +154,16 @@ static int __devinit sdhci_probe(struct platform_device *pdev)
 		goto err;
 	}
 
+	ret = clk_prepare(sdhci->clk);
+	if (ret) {
+		dev_dbg(&pdev->dev, "Error preparing clock\n");
+		goto put_clk;
+	}
+
 	ret = clk_enable(sdhci->clk);
 	if (ret) {
 		dev_dbg(&pdev->dev, "Error enabling clock\n");
-		goto put_clk;
+		goto unprepare_clk;
 	}
 
 	if (np) {
@@ -275,6 +281,8 @@ free_host:
 	sdhci_free_host(host);
 disable_clk:
 	clk_disable(sdhci->clk);
+unprepare_clk:
+	clk_unprepare(sdhci->clk);
 put_clk:
 	clk_put(sdhci->clk);
 err:
@@ -297,6 +305,7 @@ static int __devexit sdhci_remove(struct platform_device *pdev)
 	sdhci_remove_host(host, dead);
 	sdhci_free_host(host);
 	clk_disable(sdhci->clk);
+	clk_unprepare(sdhci->clk);
 	clk_put(sdhci->clk);
 
 	return 0;
@@ -310,8 +319,10 @@ static int sdhci_suspend(struct device *dev)
 	int ret;
 
 	ret = sdhci_suspend_host(host);
-	if (!ret)
+	if (!ret) {
 		clk_disable(sdhci->clk);
+		clk_unprepare(sdhci->clk);
+	}
 
 	return ret;
 }
@@ -322,9 +333,16 @@ static int sdhci_resume(struct device *dev)
 	struct spear_sdhci *sdhci = dev_get_platdata(dev);
 	int ret;
 
+	ret = clk_prepare(sdhci->clk);
+	if (ret) {
+		dev_dbg(dev, "Error preparing clock\n");
+		return ret;
+	}
+
 	ret = clk_enable(sdhci->clk);
 	if (ret) {
 		dev_dbg(dev, "Resume: Error enabling clock\n");
+		clk_unprepare(sdhci->clk);
 		return ret;
 	}
 
-- 
1.7.9


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* RE: [PATCH] mmc: sdhci-spear: Add clk_{un}prepare() support
  2012-04-17  9:44 [PATCH] mmc: sdhci-spear: Add clk_{un}prepare() support Viresh Kumar
@ 2012-04-17 11:02 ` Subhash Jadavani
  2012-04-17 11:05   ` Viresh Kumar
  0 siblings, 1 reply; 3+ messages in thread
From: Subhash Jadavani @ 2012-04-17 11:02 UTC (permalink / raw)
  To: 'Viresh Kumar', cjb; +Cc: linux-mmc, spear-devel, viresh.linux



> -----Original Message-----
> From: linux-mmc-owner@vger.kernel.org [mailto:linux-mmc-
> owner@vger.kernel.org] On Behalf Of Viresh Kumar
> Sent: Tuesday, April 17, 2012 3:14 PM
> To: cjb@laptop.org
> Cc: linux-mmc@vger.kernel.org; spear-devel@list.st.com;
> viresh.linux@gmail.com; Viresh Kumar
> Subject: [PATCH] mmc: sdhci-spear: Add clk_{un}prepare() support
> 
> clk_{un}prepare is mandatory for platforms using common clock framework.
> Since this driver is used by SPEAr platform, which supports common clock
> framework, add clk_{un}prepare() support for it.
> 
> Signed-off-by: Viresh Kumar <viresh.kumar@st.com>
> ---
>  drivers/mmc/host/sdhci-spear.c |   22 ++++++++++++++++++++--
>  1 files changed, 20 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/mmc/host/sdhci-spear.c
b/drivers/mmc/host/sdhci-spear.c
> index 62c9730..78ca787 100644
> --- a/drivers/mmc/host/sdhci-spear.c
> +++ b/drivers/mmc/host/sdhci-spear.c
> @@ -154,10 +154,16 @@ static int __devinit sdhci_probe(struct
> platform_device *pdev)
>  		goto err;
>  	}
> 
> +	ret = clk_prepare(sdhci->clk);


It's better to use clk_prepare_enable() helper function if you are doing
enable immediately after prepare.

> +	if (ret) {
> +		dev_dbg(&pdev->dev, "Error preparing clock\n");
> +		goto put_clk;
> +	}
> +
>  	ret = clk_enable(sdhci->clk);
>  	if (ret) {
>  		dev_dbg(&pdev->dev, "Error enabling clock\n");
> -		goto put_clk;
> +		goto unprepare_clk;
>  	}
> 
>  	if (np) {
> @@ -275,6 +281,8 @@ free_host:
>  	sdhci_free_host(host);
>  disable_clk:
>  	clk_disable(sdhci->clk);
> +unprepare_clk:
> +	clk_unprepare(sdhci->clk);
>  put_clk:
>  	clk_put(sdhci->clk);
>  err:
> @@ -297,6 +305,7 @@ static int __devexit sdhci_remove(struct
> platform_device *pdev)
>  	sdhci_remove_host(host, dead);
>  	sdhci_free_host(host);
>  	clk_disable(sdhci->clk);
> +	clk_unprepare(sdhci->clk);
>  	clk_put(sdhci->clk);
> 
>  	return 0;
> @@ -310,8 +319,10 @@ static int sdhci_suspend(struct device *dev)
>  	int ret;
> 
>  	ret = sdhci_suspend_host(host);
> -	if (!ret)
> +	if (!ret) {
>  		clk_disable(sdhci->clk);
> +		clk_unprepare(sdhci->clk);

clk_disable_unprepare() helper function can be used.

> +	}
> 
>  	return ret;
>  }
> @@ -322,9 +333,16 @@ static int sdhci_resume(struct device *dev)
>  	struct spear_sdhci *sdhci = dev_get_platdata(dev);
>  	int ret;
> 
> +	ret = clk_prepare(sdhci->clk);
> +	if (ret) {
> +		dev_dbg(dev, "Error preparing clock\n");
> +		return ret;
> +	}
> +
>  	ret = clk_enable(sdhci->clk);
>  	if (ret) {
>  		dev_dbg(dev, "Resume: Error enabling clock\n");
> +		clk_unprepare(sdhci->clk);
>  		return ret;
>  	}
> 
> --
> 1.7.9
> 
> --
> To unsubscribe from this list: send the line "unsubscribe linux-mmc" in
the body
> of a message to majordomo@vger.kernel.org More majordomo info at
> http://vger.kernel.org/majordomo-info.html


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] mmc: sdhci-spear: Add clk_{un}prepare() support
  2012-04-17 11:02 ` Subhash Jadavani
@ 2012-04-17 11:05   ` Viresh Kumar
  0 siblings, 0 replies; 3+ messages in thread
From: Viresh Kumar @ 2012-04-17 11:05 UTC (permalink / raw)
  To: Subhash Jadavani
  Cc: cjb@laptop.org, linux-mmc@vger.kernel.org, spear-devel,
	viresh.linux@gmail.com

On 4/17/2012 4:32 PM, Subhash Jadavani wrote:
> It's better to use clk_prepare_enable() helper function if you are doing
> enable immediately after prepare.

Sure. Will fix it.

-- 
viresh

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2012-04-17 11:07 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-04-17  9:44 [PATCH] mmc: sdhci-spear: Add clk_{un}prepare() support Viresh Kumar
2012-04-17 11:02 ` Subhash Jadavani
2012-04-17 11:05   ` Viresh Kumar

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.