mtd/drivers/mtd/nand nand_bbt.c,1.16,1.17

dbrown at infradead.org dbrown at infradead.org
Tue Jun 22 09:59:35 EDT 2004


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

Modified Files:
	nand_bbt.c 
Log Message:
Add option to mark reserved (as opposed to bad) pages in stored BBT.


Index: nand_bbt.c
===================================================================
RCS file: /home/cvs/mtd/drivers/mtd/nand/nand_bbt.c,v
retrieving revision 1.16
retrieving revision 1.17
diff -u -r1.16 -r1.17
--- nand_bbt.c	22 Jun 2004 09:30:43 -0000	1.16
+++ nand_bbt.c	22 Jun 2004 13:59:32 -0000	1.17
@@ -115,7 +115,7 @@
  *
  */
 static int read_bbt (struct mtd_info *mtd, uint8_t *buf, int page, int num, 
-	int bits, int offs)
+	int bits, int offs, int reserved_block_code)
 {
 	int res, i, j, act = 0;
 	struct nand_chip *this = mtd->priv;
@@ -144,6 +144,13 @@
 				uint8_t tmp = (dat >> j) & msk;
 				if (tmp == msk)
 					continue;
+				if (reserved_block_code &&
+				    (tmp == reserved_block_code)) {
+					printk (KERN_DEBUG "nand_read_bbt: Reserved block at 0x%08x\n",
+						((offs << 2) + (act >> 1)) << this->erase_shift);
+					this->bbt[offs + (act >> 3)] |= 0x2 << (act & 0x06);
+					continue;
+				}
 				/* Leave it for now, if its matured we can move this
 				 * message to MTD_DEBUG_LEVEL0 */
 				printk (KERN_DEBUG "nand_read_bbt: Bad block at 0x%08x\n",
@@ -183,13 +190,13 @@
 		int offs = 0;
 		for (i = 0; i < this->numchips; i++) {
 			if (chip == -1 || chip == i)
-				res = read_bbt (mtd, buf, td->pages[i], this->chipsize >> this->erase_shift, bits, offs);
+				res = read_bbt (mtd, buf, td->pages[i], this->chipsize >> this->erase_shift, bits, offs, td->reserved_block_code);
 			if (res)
 				return res;
 			offs += this->chipsize >> (this->erase_shift + 2);
 		}
 	} else {
-		res = read_bbt (mtd, buf, td->pages[0], mtd->size >> this->erase_shift, bits, 0);
+		res = read_bbt (mtd, buf, td->pages[0], mtd->size >> this->erase_shift, bits, 0, td->reserved_block_code);
 		if (res)
 			return res;
 	}
@@ -472,10 +479,10 @@
 		/* Set up shift count and masks for the flash table */
 		bits = td->options & NAND_BBT_NRBITS_MSK;
 		switch (bits) {
-		case 1: sft = 3; sftmsk = 0x07; msk[0] = 0x00; msk[1] = 0x01; msk[2] = 0x00; msk[3] = 0x01; break;
-		case 2: sft = 2; sftmsk = 0x06; msk[0] = 0x00; msk[1] = 0x01; msk[2] = 0x00; msk[3] = 0x03; break;
-		case 4: sft = 1; sftmsk = 0x04; msk[0] = 0x00; msk[1] = 0x0C; msk[2] = 0x00; msk[3] = 0x0f; break;
-		case 8: sft = 0; sftmsk = 0x00; msk[0] = 0x00; msk[1] = 0x0F; msk[2] = 0x00; msk[3] = 0xff; break;
+		case 1: sft = 3; sftmsk = 0x07; msk[0] = 0x00; msk[1] = 0x01; msk[2] = td->reserved_block_code; msk[3] = 0x01; break;
+		case 2: sft = 2; sftmsk = 0x06; msk[0] = 0x00; msk[1] = 0x01; msk[2] = td->reserved_block_code; msk[3] = 0x03; break;
+		case 4: sft = 1; sftmsk = 0x04; msk[0] = 0x00; msk[1] = 0x0C; msk[2] = td->reserved_block_code; msk[3] = 0x0f; break;
+		case 8: sft = 0; sftmsk = 0x00; msk[0] = 0x00; msk[1] = 0x0F; msk[2] = td->reserved_block_code; msk[3] = 0xff; break;
 		default: return -EINVAL;
 		}
 		
@@ -706,7 +713,9 @@
 	}	
 	
 	for (i = 0; i < chips; i++) {
-		if (td->options & NAND_BBT_ABSPAGE) {
+		if ((td->options & NAND_BBT_ABSPAGE) ||
+		    !(td->options & NAND_BBT_WRITE)) {
+		    	if (td->pages[i] == -1) continue;
 			block = td->pages[i] >> (this->erase_shift - this->page_shift);
 			block <<= 1;		
 			this->bbt[(block >> 3)] |= 0x2 << (block & 0x06);





More information about the linux-mtd-cvs mailing list