mtd/drivers/mtd/nand diskonchip.c,1.10,1.11

gleixner at infradead.org gleixner at infradead.org
Wed Jun 16 17:10:39 EDT 2004


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

Modified Files:
	diskonchip.c 
Log Message:
Follow the changes in nand_base.c

Index: diskonchip.c
===================================================================
RCS file: /home/cvs/mtd/drivers/mtd/nand/diskonchip.c,v
retrieving revision 1.10
retrieving revision 1.11
diff -u -r1.10 -r1.11
--- diskonchip.c	16 Jun 2004 16:35:16 -0000	1.10
+++ diskonchip.c	16 Jun 2004 21:10:36 -0000	1.11
@@ -449,10 +449,14 @@
 
 	/* Prime the ECC engine */
 	WriteDOC(DOC_ECC_RESET, docptr, ECCConf);
-	if (mode == NAND_ECC_READ)
+	switch(mode) {
+	case NAND_ECC_READ:
 		WriteDOC(DOC_ECC_EN, docptr, ECCConf);
-	else
+		break;
+	case NAND_ECC_WRITE:
 		WriteDOC(DOC_ECC_EN | DOC_ECC_RW, docptr, ECCConf);
+		break;
+	}	
 	return 0;
 }
 
@@ -496,48 +500,48 @@
 	return stat;
 }
 
+
+/* This code is only called on write */
 static int doc2001_calculate_ecc(struct mtd_info *mtd, const u_char *dat,
 				 unsigned char *ecc_code)
 {
 	struct nand_chip *this = mtd->priv;
 	struct doc_priv *doc = (void *)this->priv;
 	unsigned long docptr = doc->virtadr;
-	volatile char dummy;
-	int stat;
 	int i;
-	// DBB : check for NULL ecc_code here?
 
-	// DBB note: I'm using the presence of dat as a read/write indicator.  FIX ME!
-	if (dat) {
-		// DBB: this is assumed to be a read
-		// flush the pipeline:
-		dummy = ReadDOC(docptr, ECCConf);
-		dummy = ReadDOC(docptr, ECCConf);
-		dummy = ReadDOC(docptr, ECCConf);
-		stat = dummy & 0x80;
-	} else {
-		// DBB: this is assumed to be a write
-		WriteDOC(0, docptr, NOP);
-		WriteDOC(0, docptr, NOP);
-		WriteDOC(0, docptr, NOP);
-		stat = 1;
-	}
-	if (stat) {
-		for (i = 0; i < 6; i++)
-			ecc_code[i] = ReadDOC_(docptr, DoC_ECCSyndrome0 + i);
-	} else {
-		/* On read, if there were no ECC errors, the syndrome is by
-		   definition zero.  We can skip actually reading it. */
-		memset(ecc_code, 0, 6);
-	}
+	/* flush the pipeline */
+	WriteDOC(0, docptr, NOP);
+	WriteDOC(0, docptr, NOP);
+	WriteDOC(0, docptr, NOP);
+	for (i = 0; i < 6; i++)
+		ecc_code[i] = ReadDOC_(docptr, DoC_ECCSyndrome0 + i);
 	WriteDOC(DOC_ECC_DIS, docptr, ECCConf);
-	return stat;
+	return 0;
 }
 
 static int doc200x_correct_data(struct mtd_info *mtd, u_char *dat, u_char *read_ecc, u_char *calc_ecc)
 {
-	int ret = doc_decode_ecc(dat, calc_ecc);
-	printk(KERN_ERR "doc200x_correct_data corrected %d errors\n", ret);
+	int i, ret = 0;
+	struct nand_chip *this = mtd->priv;
+	struct doc_priv *doc = (void *)this->priv;
+	unsigned long docptr = doc->virtadr;
+	volatile char dummy;
+	
+	/* flush the pipeline */
+	dummy = ReadDOC(docptr, ECCConf);
+	dummy = ReadDOC(docptr, ECCConf);
+	dummy = ReadDOC(docptr, ECCConf);
+	
+	/* Error occured ? */
+	if (dummy & 0x80) {
+		for (i = 0; i < 6; i++)
+			calc_ecc[i] = ReadDOC_(docptr, DoC_ECCSyndrome0 + i);
+		ret = doc_decode_ecc (dat, calc_ecc);
+		if (ret > 0)
+			printk(KERN_ERR "doc200x_correct_data corrected %d errors\n", ret);
+	}	
+	WriteDOC(DOC_ECC_DIS, docptr, ECCConf);
 	return ret;
 }
 		
@@ -563,9 +567,9 @@
 	.dev_ready = doc200x_dev_ready,
 	.waitfunc = doc200x_wait,
 	.block_bad = doc200x_block_bad,
-	.eccmode = NAND_ECC_DISKONCHIP,
+	.eccmode = NAND_ECC_HW6_512,
 	//.data_buf = mydatabuf,
-	.options = NAND_USE_FLASH_BBT,
+	.options = NAND_USE_FLASH_BBT | NAND_HWECC_SYNDROME,
 	.autooob = &doc200x_oobinfo,
 	.correct_data = doc200x_correct_data,
 	.enable_hwecc = doc200x_enable_hwecc





More information about the linux-mtd-cvs mailing list