mtd/fs/jffs2 wbuf.c,1.64,1.65

gleixner at infradead.org gleixner at infradead.org
Thu Jun 17 12:53:10 EDT 2004


Update of /home/cvs/mtd/fs/jffs2
In directory phoenix.infradead.org:/tmp/cvs-serv10787

Modified Files:
	wbuf.c 
Log Message:
use mtd->block_isbad() everywhere

Index: wbuf.c
===================================================================
RCS file: /home/cvs/mtd/fs/jffs2/wbuf.c,v
retrieving revision 1.64
retrieving revision 1.65
diff -u -r1.64 -r1.65
--- wbuf.c	17 Jun 2004 16:05:01 -0000	1.64
+++ wbuf.c	17 Jun 2004 16:53:07 -0000	1.65
@@ -846,9 +846,15 @@
 	size_t  retlen;
 	int	oob_size;
 
-	oob_size = c->mtd->oobsize;
+
+	/* Check first if the block is bad. */
+	if (c->mtd->block_isbad (c->mtd, jeb->offset)) {
+		D1 (printk (KERN_WARNING "jffs2_check_nand_cleanmarker(): Bad block at %08x\n", jeb->offset));
+		return 2;
+	}	
 
 	/* allocate a buffer for all oob data in this sector */
+	oob_size = c->mtd->oobsize;
 	len = 4 * oob_size;
 	buf = kmalloc(len, GFP_KERNEL);
 	if (!buf) {
@@ -872,35 +878,23 @@
 		goto out;
 	}
 	
-	/* Special check for first two pages */
-	for (page = 0; page < 2 * oob_size; page += oob_size) {
-		/* Check for bad block marker */
-		if (buf[page+c->badblock_pos] != 0xff) {
-			D1(printk(KERN_WARNING "jffs2_check_oob_empty(): Bad or failed block at %08x\n",jeb->offset));
-			/* Return 2 for bad and 3 for failed block 
-			   bad goes to list_bad and failed to list_erase */
-			ret = (!page) ? 2 : 3;
+	/* Special check for first page */
+	for(i = 0; i < oob_size ; i++) {
+		/* Yeah, we know about the cleanmarker. */
+		if (mode && i >= c->fsdata_pos && 
+		    i < c->fsdata_pos + c->fsdata_len)
+			continue;
+
+		if (buf[i] != 0xFF) {
+			D2(printk(KERN_DEBUG "Found %02x at %x in OOB for %08x\n",
+				  buf[page+i], page+i, jeb->offset));
+			ret = 1; 
 			goto out;
 		}
-		for(i = 0; i < oob_size ; i++) {
-			/* Yeah, we know about the cleanmarker. */
-			if (mode && i >= c->fsdata_pos && 
-			    i < c->fsdata_pos+c->fsdata_len)
-				continue;
-
-			if (buf[page+i] != 0xFF) {
-				D2(printk(KERN_DEBUG "Found %02x at %x in OOB for %08x\n",
-					  buf[page+i], page+i, jeb->offset));
-				ret = 1; 
-				goto out;
-			}
-		}
-		/* only the first page can contain a cleanmarker !*/
-		mode = 0;
-	}	
+	}
 
 	/* we know, we are aligned :) */	
-	for (; page < len; page += sizeof(long)) {
+	for (page = oob_size; page < len; page += sizeof(long)) {
 		unsigned long dat = *(unsigned long *)(&buf[page]);
 		if(dat != -1) {
 			ret = 1; 
@@ -1029,36 +1023,7 @@
 	return 0;
 }
 
-#define JFFS2_OOB_ECCPOS0		0
-#define JFFS2_OOB_ECCPOS1		1
-#define JFFS2_OOB_ECCPOS2		2
-#define JFFS2_OOB_ECCPOS3		3
-#define JFFS2_OOB_ECCPOS4		6
-#define JFFS2_OOB_ECCPOS5		7
-
-#define NAND_JFFS2_OOB8_FSDAPOS		6
-#define NAND_JFFS2_OOB16_FSDAPOS	8
-#define NAND_JFFS2_OOB64_FSDAPOS	16
-#define NAND_JFFS2_OOB8_FSDALEN		2
 #define NAND_JFFS2_OOB16_FSDALEN	8
-#define NAND_JFFS2_OOB64_FSDALEN	8
-
-static struct nand_oobinfo jffs2_oobinfo_swecc_8 = {
-	.useecc = MTD_NANDECC_PLACE,
-	.eccbytes = 3,
-	.eccpos = {JFFS2_OOB_ECCPOS0, JFFS2_OOB_ECCPOS1, JFFS2_OOB_ECCPOS2}
-};
-
-static struct nand_oobinfo jffs2_oobinfo_swecc_16 = {
-	.useecc = MTD_NANDECC_PLACE,
-	.eccbytes = 6,
-	.eccpos = {JFFS2_OOB_ECCPOS0, JFFS2_OOB_ECCPOS1, JFFS2_OOB_ECCPOS2,
-		   JFFS2_OOB_ECCPOS3, JFFS2_OOB_ECCPOS4, JFFS2_OOB_ECCPOS5}
-};
-
-static struct nand_oobinfo jffs2_oobinfo_autoplace = {
-	.useecc = MTD_NANDECC_AUTOPLACE,
-};
 
 static struct nand_oobinfo jffs2_oobinfo_docecc = {
 	.useecc = MTD_NANDECC_PLACE,
@@ -1094,7 +1059,7 @@
 		/* This is just a legacy fallback and should go away soon */
 		switch(c->mtd->ecctype) {
 		case MTD_ECC_RS_DiskOnChip:
-			D1(printk(KERN_DEBUG "JFFS2 using DiskOnChip hardware ECC\n"));
+			printk(KERN_WARNING "JFFS2 using DiskOnChip hardware ECC without autoplacement. Fix it!\n");
 			c->oobinfo = &jffs2_oobinfo_docecc;
 			c->fsdata_pos = 6;
 			c->fsdata_len = NAND_JFFS2_OOB16_FSDALEN;





More information about the linux-mtd-cvs mailing list