mtd/drivers/mtd/nand nand.c,1.62,1.63

gleixner at infradead.org gleixner at infradead.org
Wed Mar 17 11:59:35 EST 2004


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

Modified Files:
	nand.c 
Log Message:
Do it right. read_oob has the same problem

Index: nand.c
===================================================================
RCS file: /home/cvs/mtd/drivers/mtd/nand/nand.c,v
retrieving revision 1.62
retrieving revision 1.63
diff -u -r1.62 -r1.63
--- nand.c	17 Mar 2004 16:53:10 -0000	1.62
+++ nand.c	17 Mar 2004 16:59:30 -0000	1.63
@@ -134,6 +134,11 @@
  *
  *  02-08-2004  tglx: support for strange chips, which cannot auto increment 
  *		pages on read / read_oob
+ *
+ *  03-17-2004  tglx: Check ready before auto increment check. Simon Bayes
+ *		pointed this out, as he marked an auto increment capable chip
+ *		as NOAUTOINCR in the board driver.
+ *		Make reads over block boundaries work too
  *	
  * $Id$
  *
@@ -792,6 +797,7 @@
 	int i, col, page;
 	int erase_state = 0;
 	struct nand_chip *this = mtd->priv;
+	int	blockcheck = (this->erasesize >> this->page_shift) - 1;
 
 	DEBUG (MTD_DEBUG_LEVEL3, "nand_read_oob: from = 0x%08x, len = %i\n", (unsigned int) from, (int) len);
 
@@ -834,17 +840,23 @@
 		col += thislen;
 		/* Read more ? */
 		if (i < len) {
-			/* Check, if the chip supports autoincrement */
-			if (!NAND_CANAUTOINCR(this)) {
+			page++;
+			/* Apply delay or wait for ready/busy pin 
+			 * Do this before the AUTOINCR check, so no problems
+			 * arise if a chip which does auto increment
+			 * is marked as NOAUTOINCR by the board driver.
+			*/
+			if (!this->dev_ready) 
+				udelay (this->chip_delay);
+			else
+				while (!this->dev_ready(mtd));	
+			/* Check, if the chip supports auto page increment 
+			 * or if we have hit a block boundary. 
+			*/ 
+			if (unlikely (!NAND_CANAUTOINCR(this) || !(page & blockcheck))) {
 				/* For subsequent page reads set offset to 0 */
-			        this->cmdfunc (mtd, NAND_CMD_READOOB, 0x0, ++page);
-			} else {
-				/* Delay between pages */
-				if (!this->dev_ready) 
-					udelay (this->chip_delay);
-				else
-					while (!this->dev_ready(mtd));
-			}		
+			        this->cmdfunc (mtd, NAND_CMD_READOOB, 0x0, page);
+			} 		
 		}
 	}
 	/* De-select the NAND device */




More information about the linux-mtd-cvs mailing list