diff mbox

[2/2] mtd: fsmc_nand: Add clk_{un}prepare() support

Message ID e602342fa929bc44ef85683e457b1cdfcd6b9946.1334652831.git.viresh.kumar@st.com
State New, archived
Headers show

Commit Message

Viresh KUMAR April 17, 2012, 8:56 a.m. UTC
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/mtd/nand/fsmc_nand.c |   24 ++++++++++++++++++++++--
 1 files changed, 22 insertions(+), 2 deletions(-)

Comments

Linus Walleij April 17, 2012, 9:27 a.m. UTC | #1
On Tue, Apr 17, 2012 at 10:56 AM, Viresh Kumar <viresh.kumar@st.com> wrote:

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

Acked-by: Linus Walleij <linus.walleij@linaro.org>

BTW: this driver looks like we could use some runtime PM on it to gate off the
block when not used.

Yours,
Linus Walleij
diff mbox

Patch

diff --git a/drivers/mtd/nand/fsmc_nand.c b/drivers/mtd/nand/fsmc_nand.c
index 1b8330e..29d03b6 100644
--- a/drivers/mtd/nand/fsmc_nand.c
+++ b/drivers/mtd/nand/fsmc_nand.c
@@ -994,6 +994,10 @@  static int __init fsmc_nand_probe(struct platform_device *pdev)
 		return PTR_ERR(host->clk);
 	}
 
+	ret = clk_prepare(host->clk);
+	if (ret)
+		goto err_clk_prepare;
+
 	ret = clk_enable(host->clk);
 	if (ret)
 		goto err_clk_enable;
@@ -1178,6 +1182,8 @@  err_req_write_chnl:
 err_req_read_chnl:
 	clk_disable(host->clk);
 err_clk_enable:
+	clk_unprepare(host->clk);
+err_clk_prepare:
 	clk_put(host->clk);
 	return ret;
 }
@@ -1199,6 +1205,7 @@  static int fsmc_nand_remove(struct platform_device *pdev)
 			dma_release_channel(host->read_dma_chan);
 		}
 		clk_disable(host->clk);
+		clk_unprepare(host->clk);
 		clk_put(host->clk);
 	}
 
@@ -1209,16 +1216,29 @@  static int fsmc_nand_remove(struct platform_device *pdev)
 static int fsmc_nand_suspend(struct device *dev)
 {
 	struct fsmc_nand_data *host = dev_get_drvdata(dev);
-	if (host)
+	if (host) {
 		clk_disable(host->clk);
+		clk_unprepare(host->clk);
+	}
 	return 0;
 }
 
 static int fsmc_nand_resume(struct device *dev)
 {
 	struct fsmc_nand_data *host = dev_get_drvdata(dev);
+	int ret;
+
 	if (host) {
-		clk_enable(host->clk);
+		ret = clk_prepare(host->clk);
+		if (ret)
+			return ret;
+
+		ret = clk_enable(host->clk);
+		if (ret) {
+			clk_unprepare(host->clk);
+			return ret;
+		}
+
 		fsmc_nand_setup(host->regs_va, host->bank,
 				host->nand.options & NAND_BUSWIDTH_16,
 				host->dev_timings);