[PATCH 1/2] mtd: spear_smi: Add clk_{un}prepare() support

Viresh Kumar viresh.kumar at st.com
Tue Apr 17 04:56:17 EDT 2012


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 at st.com>
---
 drivers/mtd/devices/spear_smi.c |   31 ++++++++++++++++++++++++++-----
 1 files changed, 26 insertions(+), 5 deletions(-)

diff --git a/drivers/mtd/devices/spear_smi.c b/drivers/mtd/devices/spear_smi.c
index 797d43c..55507be 100644
--- a/drivers/mtd/devices/spear_smi.c
+++ b/drivers/mtd/devices/spear_smi.c
@@ -990,6 +990,10 @@ static int __devinit spear_smi_probe(struct platform_device *pdev)
 		goto err_clk;
 	}
 
+	ret = clk_prepare(dev->clk);
+	if (ret)
+		goto err_clk_prepare;
+
 	ret = clk_enable(dev->clk);
 	if (ret)
 		goto err_clk_enable;
@@ -1022,6 +1026,8 @@ err_bank_setup:
 err_irq:
 	clk_disable(dev->clk);
 err_clk_enable:
+	clk_unprepare(dev->clk);
+err_clk_prepare:
 	clk_put(dev->clk);
 err_clk:
 	iounmap(dev->io_base);
@@ -1075,6 +1081,7 @@ static int __devexit spear_smi_remove(struct platform_device *pdev)
 	free_irq(irq, dev);
 
 	clk_disable(dev->clk);
+	clk_unprepare(dev->clk);
 	clk_put(dev->clk);
 	iounmap(dev->io_base);
 	kfree(dev);
@@ -1090,8 +1097,10 @@ int spear_smi_suspend(struct platform_device *pdev, pm_message_t state)
 {
 	struct spear_smi *dev = platform_get_drvdata(pdev);
 
-	if (dev && dev->clk)
+	if (dev && dev->clk) {
 		clk_disable(dev->clk);
+		clk_unprepare(dev->clk);
+	}
 
 	return 0;
 }
@@ -1099,13 +1108,25 @@ int spear_smi_suspend(struct platform_device *pdev, pm_message_t state)
 int spear_smi_resume(struct platform_device *pdev)
 {
 	struct spear_smi *dev = platform_get_drvdata(pdev);
-	int ret = -EPERM;
+	int ret;
+
+	if (dev && dev->clk) {
+		ret = clk_prepare(dev->clk);
+		if (ret)
+			goto err_clk_prepare;
 
-	if (dev && dev->clk)
 		ret = clk_enable(dev->clk);
+		if (ret)
+			goto err_clk_enable;
+	}
+
+	spear_smi_hw_init(dev);
 
-	if (!ret)
-		spear_smi_hw_init(dev);
+	return 0;
+
+err_clk_enable:
+	clk_unprepare(dev->clk);
+err_clk_prepare:
 	return ret;
 }
 
-- 
1.7.9




More information about the linux-mtd mailing list