[PATCH] [NAND] S3C2410: Fix NFC clock enable/disable imbalance

Juergen Beisert jbe at pengutronix.de
Tue Dec 8 04:56:40 EST 2009


When unmounting an mtd filesystem the s3c2410_nand_select_chip() function
gets called again with "chip == -1". In this case the current code disables
the NFC clock at least a second time, so it does not work anymore.
Clock disabling should only happen if it was really enabled.

Signed-off-by: Juergen Beisert <jbe at pengutronix.de>

---
 drivers/mtd/nand/s3c2410.c |    8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)

Index: linux-2.6.32/drivers/mtd/nand/s3c2410.c
===================================================================
--- linux-2.6.32.orig/drivers/mtd/nand/s3c2410.c
+++ linux-2.6.32/drivers/mtd/nand/s3c2410.c
@@ -329,12 +329,16 @@ static void s3c2410_nand_select_chip(str
 	struct s3c2410_nand_mtd *nmtd;
 	struct nand_chip *this = mtd->priv;
 	unsigned long cur;
+	int clock_enabled;
 
 	nmtd = this->priv;
 	info = nmtd->info;
 
-	if (chip != -1 && allow_clk_stop(info))
+	if (chip != -1 && allow_clk_stop(info)) {
 		clk_enable(info->clk);
+		clock_enabled = 1;
+	} else
+		clock_enabled = 0;
 
 	cur = readl(info->sel_reg);
 
@@ -356,7 +360,7 @@ static void s3c2410_nand_select_chip(str
 
 	writel(cur, info->sel_reg);
 
-	if (chip == -1 && allow_clk_stop(info))
+	if (chip == -1 && allow_clk_stop(info) && clock_enabled != 0)
 		clk_disable(info->clk);
 }
 

-- 
Pengutronix e.K.                              | Juergen Beisert             |
Linux Solutions for Science and Industry      | Phone: +49-8766-939 228     |
Vertretung Sued/Muenchen, Germany             | Fax:   +49-5121-206917-5555 |
Amtsgericht Hildesheim, HRA 2686              | http://www.pengutronix.de/  |



More information about the linux-arm-kernel mailing list