mtd/drivers/mtd/nand nand.c,1.73,1.74

gleixner at infradead.org gleixner at infradead.org
Wed Mar 31 02:26:08 EST 2004


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

Modified Files:
	nand.c 
Log Message:
Do not try to get and select the chip again in bad_block, when calling from erase

Index: nand.c
===================================================================
RCS file: /home/cvs/mtd/drivers/mtd/nand/nand.c,v
retrieving revision 1.73
retrieving revision 1.74
diff -u -r1.73 -r1.74
--- nand.c	29 Mar 2004 16:03:58 -0000	1.73
+++ nand.c	31 Mar 2004 07:26:05 -0000	1.74
@@ -319,21 +319,24 @@
 	return 0;
 }
 
-static int nand_block_bad(struct mtd_info *mtd, loff_t ofs)
+static int nand_block_bad(struct mtd_info *mtd, loff_t ofs, int getchip)
 {
 	int page, chipnr, res = 0;
 	struct nand_chip *this = mtd->priv;
 	u16 bad;
 
-	/* Shift to get page */
-	page = ((int) ofs) >> this->page_shift;
-	chipnr = (int)((unsigned long) ofs / this->chipsize);
+	if (getchip) {
+		/* Shift to get page */
+		page = ((int) ofs) >> this->page_shift;
+		chipnr = (int)((unsigned long) ofs / this->chipsize);
 
-	/* Grab the lock and see if the device is available */
-	nand_get_chip (this, mtd, FL_READING, NULL);
+		/* Grab the lock and see if the device is available */
+		nand_get_chip (this, mtd, FL_READING, NULL);
 
-	/* Select the NAND device */
-	this->select_chip(mtd, chipnr);
+		/* Select the NAND device */
+		this->select_chip(mtd, chipnr);
+	} else 
+		page = (int) ofs;	
 
 	if (this->options & NAND_BUSWIDTH_16) {
 		this->cmdfunc (mtd, NAND_CMD_READOOB, this->badblockpos & 0xFE, page & this->pagemask);
@@ -346,9 +349,12 @@
 		this->cmdfunc (mtd, NAND_CMD_READOOB, this->badblockpos, page & this->pagemask);
 		if (this->read_byte(mtd) != 0xff)
 			res = 1;
+	}
+		
+	if (getchip) {
+		/* Deselect and wake up anyone waiting on the device */
+		nand_release_chip(mtd);
 	}	
-	/* Deselect and wake up anyone waiting on the device */
-	nand_release_chip(mtd);
 	
 	return res;
 }
@@ -1454,7 +1460,7 @@
 
 	while (len) {
 		/* Check if we have a bad block, we do not erase bad blocks ! */
-		if (this->block_bad(mtd, page)) {
+		if (this->block_bad(mtd, (loff_t) page, 0)) {
 			printk (KERN_WARNING "nand_erase: attempt to erase a bad block at page 0x%08x\n", page);
 			instr->state = MTD_ERASE_FAILED;
 			goto erase_exit;
@@ -1556,7 +1562,7 @@
 	if (ofs > mtd->size) 
 		return -EINVAL;
 
-	return this->block_bad(mtd, ofs);
+	return this->block_bad(mtd, ofs, 1);
 }
 
 /*




More information about the linux-mtd-cvs mailing list