[PATCH] ARM: SAMSUNG: use spin_lock_irqsave() in clk_{enable, disable}

Kukjin Kim kgene.kim at samsung.com
Fri Jan 27 00:17:23 EST 2012


From: Minho Ban <mhban at samsung.com>

The clk_enable()and clk_disable() can be called in process and ISR
either. Actually that is used for real product and other platforms
now. So it's time to use spin_lock_irqsave() instead.

Signed-off-by: Minho Ban <mhban at samsung.com>
Signed-off-by: Jaecheol Lee <jc.lee at samsung.com>
Signed-off-by: Sunyoung Kang <sy0816.kang at samsung.com>
Cc: Ben Dooks <ben-linux at fluff.org>
Cc: Russell King <rmk+kernel at arm.linux.org.uk>
Signed-off-by: Kukjin Kim <kgene.kim at samsung.com>
---
Note: There were discussion about this before.
http://lists.infradead.org/pipermail/linux-arm-kernel/2010-October/028788.html

As we discussed, actually that is used for real product and other platforms
now. Plus, we don't need to change the PLL during kernel so the latency
doesn't matter. I think it's time to use spin_lock_irqsave() instead.

 arch/arm/plat-samsung/clock.c |   12 ++++++++----
 1 files changed, 8 insertions(+), 4 deletions(-)

diff --git a/arch/arm/plat-samsung/clock.c b/arch/arm/plat-samsung/clock.c
index 10f7117..65c5eca 100644
--- a/arch/arm/plat-samsung/clock.c
+++ b/arch/arm/plat-samsung/clock.c
@@ -84,31 +84,35 @@ static int clk_null_enable(struct clk *clk, int enable)
 
 int clk_enable(struct clk *clk)
 {
+	unsigned long flags;
+
 	if (IS_ERR(clk) || clk == NULL)
 		return -EINVAL;
 
 	clk_enable(clk->parent);
 
-	spin_lock(&clocks_lock);
+	spin_lock_irqsave(&clocks_lock, flags);
 
 	if ((clk->usage++) == 0)
 		(clk->enable)(clk, 1);
 
-	spin_unlock(&clocks_lock);
+	spin_unlock_irqrestore(&clocks_lock, flags);
 	return 0;
 }
 
 void clk_disable(struct clk *clk)
 {
+	unsigned long flags;
+
 	if (IS_ERR(clk) || clk == NULL)
 		return;
 
-	spin_lock(&clocks_lock);
+	spin_lock_irqsave(&clocks_lock, flags);
 
 	if ((--clk->usage) == 0)
 		(clk->enable)(clk, 0);
 
-	spin_unlock(&clocks_lock);
+	spin_unlock_irqrestore(&clocks_lock, flags);
 	clk_disable(clk->parent);
 }
 
-- 
1.7.1





More information about the linux-arm-kernel mailing list