mtd/drivers/mtd/nand nand_base.c,1.90,1.91

gleixner at infradead.org gleixner at infradead.org
Fri May 28 14:18:07 EDT 2004


Update of /home/cvs/mtd/drivers/mtd/nand
In directory phoenix.infradead.org:/tmp/cvs-serv30085

Modified Files:
	nand_base.c 
Log Message:
Apply MULTI_STATUS command on erase of AG-AND. Signed-off-by: Thomas Gleixner <tglx at linutronix.de>

Index: nand_base.c
===================================================================
RCS file: /home/cvs/mtd/drivers/mtd/nand/nand_base.c,v
retrieving revision 1.90
retrieving revision 1.91
diff -u -r1.90 -r1.91
--- nand_base.c	28 May 2004 10:58:18 -0000	1.90
+++ nand_base.c	28 May 2004 18:18:04 -0000	1.91
@@ -740,7 +740,10 @@
 		 timeo += (HZ * 20) / 1000;
 
 	spin_lock_bh (&this->chip_lock);
-	this->cmdfunc (mtd, NAND_CMD_STATUS, -1, -1);
+	if ((state == FL_ERASING) && (this->options & NAND_IS_AND))
+		this->cmdfunc (mtd, NAND_CMD_STATUS_MULTI, -1, -1);
+	else	
+		this->cmdfunc (mtd, NAND_CMD_STATUS, -1, -1);
 
 	while (time_before(jiffies, timeo)) {		
 		/* Check, if we were interrupted */
@@ -752,8 +755,62 @@
 			if (this->dev_ready(mtd))
 				break;
 		}
-		if (this->read_byte(mtd) & 0x40)
-			break;
+		if (this->read_byte(mtd) & NAND_STATUS_READY)
+				break;
+						
+		spin_unlock_bh (&this->chip_lock);
+		yield ();
+		spin_lock_bh (&this->chip_lock);
+	}
+	status = (int) this->read_byte(mtd);
+	spin_unlock_bh (&this->chip_lock);
+
+	return status;
+}
+
+/**
+ * agand_wait - [DEFAULT]  wait until the command is done on AG-AND
+ * @mtd:	MTD device structure
+ * @this:	NAND chip structure
+ * @state:	state to select the max. timeout value
+ *
+ * Wait for command done. This applies to erase and program only
+ *
+*/
+static int agand_wait(struct mtd_info *mtd, struct nand_chip *this, int state)
+{
+
+	unsigned long	timeo = jiffies;
+	int	status;
+	
+	if (state == FL_ERASING)
+		 timeo += (HZ * 400) / 1000;
+	else
+		 timeo += (HZ * 20) / 1000;
+
+	spin_lock_bh (&this->chip_lock);
+	if ((state == FL_ERASING))
+		this->cmdfunc (mtd, NAND_CMD_STATUS_MULTI, -1, -1);
+	else	
+		this->cmdfunc (mtd, NAND_CMD_STATUS, -1, -1);
+
+	while (time_before(jiffies, timeo)) {		
+		/* Check, if we were interrupted */
+		if (this->state != state) {
+			spin_unlock_bh (&this->chip_lock);
+			return 0;
+		}
+		if (this->dev_ready) {
+			if (this->dev_ready(mtd))
+				break;
+		}
+		if (state == FL_ERASING) {
+			if ((this->read_byte(mtd) & 0x61) == 0x60)
+				break;
+		} else {
+			if (this->read_byte(mtd) & 0x40)
+				break;
+		}		
 						
 		spin_unlock_bh (&this->chip_lock);
 		yield ();





More information about the linux-mtd-cvs mailing list