mtd/drivers/mtd/nand nand.c,1.46,1.47 nand_ecc.c,1.9,1.10

David Woodhouse dwmw2 at infradead.org
Tue Jul 1 19:31:18 EDT 2003


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

Modified Files:
	nand.c nand_ecc.c 
Log Message:
Change nand_chip methods to all take 'self' argument.


Index: nand.c
===================================================================
RCS file: /home/cvs/mtd/drivers/mtd/nand/nand.c,v
retrieving revision 1.46
retrieving revision 1.47
diff -u -r1.46 -r1.47
--- nand.c	4 Jun 2003 17:10:36 -0000	1.46
+++ nand.c	1 Jul 2003 23:31:15 -0000	1.47
@@ -154,8 +154,8 @@
 /*
  * Macros for low-level register control
  */
-#define nand_select()	this->hwcontrol(NAND_CTL_SETNCE);
-#define nand_deselect() this->hwcontrol(NAND_CTL_CLRNCE);
+#define nand_select()	this->hwcontrol(mtd, NAND_CTL_SETNCE);
+#define nand_deselect() this->hwcontrol(mtd, NAND_CTL_CLRNCE);
 
 /*
  * NAND low-level MTD interface functions
@@ -186,7 +186,7 @@
 	register unsigned long NAND_IO_ADDR = this->IO_ADDR_W;
 
 	/* Begin command latch cycle */
-	this->hwcontrol (NAND_CTL_SETCLE);
+	this->hwcontrol(mtd, NAND_CTL_SETCLE);
 	/*
 	 * Write out the command to the device.
 	 */
@@ -214,10 +214,10 @@
 	}
 
 	/* Set ALE and clear CLE to start address cycle */
-	this->hwcontrol (NAND_CTL_CLRCLE);
+	this->hwcontrol(mtd, NAND_CTL_CLRCLE);
 
 	if (column != -1 || page_addr != -1) {
-		this->hwcontrol (NAND_CTL_SETALE);
+		this->hwcontrol(mtd, NAND_CTL_SETALE);
 
 		/* Serially input address */
 		if (column != -1)
@@ -230,7 +230,7 @@
 				writeb ((unsigned char) ((page_addr >> 16) & 0x0f), NAND_IO_ADDR);
 		}
 		/* Latch in address */
-		this->hwcontrol (NAND_CTL_CLRALE);
+		this->hwcontrol(mtd, NAND_CTL_CLRALE);
 	}
 	
 	/* 
@@ -249,9 +249,9 @@
 	case NAND_CMD_RESET:
 		if (this->dev_ready)	
 			break;
-		this->hwcontrol (NAND_CTL_SETCLE);
+		this->hwcontrol(mtd, NAND_CTL_SETCLE);
 		writeb (NAND_CMD_STATUS, NAND_IO_ADDR);
-		this->hwcontrol (NAND_CTL_CLRCLE);
+		this->hwcontrol(mtd, NAND_CTL_CLRCLE);
 		while ( !(readb (this->IO_ADDR_R) & 0x40));
 		return;
 
@@ -268,7 +268,7 @@
 	}
 	
 	/* wait until command is processed */
-	while (!this->dev_ready());
+	while (!this->dev_ready(mtd));
 }
 
 /*
@@ -339,7 +339,7 @@
 			return 0;
 		}
 		if (this->dev_ready) {
-			if (this->dev_ready ())
+			if (this->dev_ready(mtd))
 				break;
 		}
 		if (readb (this->IO_ADDR_R) & 0x40)
@@ -387,12 +387,12 @@
 			writeb ( this->data_poi[i] , this->IO_ADDR_W);
 		break;
 	case NAND_ECC_SOFT:
-		this->calculate_ecc (&this->data_poi[0], &(ecc_code[0]));
+		this->calculate_ecc(mtd, &this->data_poi[0], &(ecc_code[0]));
 		for (i = 0; i < 3; i++)
 			oob_data[oob_config[i]] = ecc_code[i];
 		/* Calculate and write the second ECC for 512 Byte page size */
 		if (mtd->oobblock == 512) {
-			this->calculate_ecc (&this->data_poi[256], &(ecc_code[3]));
+			this->calculate_ecc(mtd, &this->data_poi[256], &(ecc_code[3]));
 			for (i = 3; i < 6; i++)
 				oob_data[oob_config[i]] = ecc_code[i];
 		} 
@@ -402,19 +402,19 @@
 		
 	/* Hardware ecc 3 byte / 256 data, write first half, get ecc, then second, if 512 byte pagesize */	
 	case NAND_ECC_HW3_256:		
-		this->enable_hwecc (NAND_ECC_WRITE);	/* enable hardware ecc logic for write */
+		this->enable_hwecc(mtd, NAND_ECC_WRITE);	/* enable hardware ecc logic for write */
 		for (i = 0; i < mtd->eccsize; i++) 
 			writeb ( this->data_poi[i] , this->IO_ADDR_W);
 		
-		this->calculate_ecc (NULL, &(ecc_code[0]));
+		this->calculate_ecc(mtd, NULL, &(ecc_code[0]));
 		for (i = 0; i < 3; i++)
 			oob_data[oob_config[i]] = ecc_code[i];
 			
 		if (mtd->oobblock == 512) {
-			this->enable_hwecc (NAND_ECC_WRITE);	/* enable hardware ecc logic for write*/
+			this->enable_hwecc(mtd, NAND_ECC_WRITE);	/* enable hardware ecc logic for write*/
 			for (i = mtd->eccsize; i < mtd->oobblock; i++) 
 				writeb ( this->data_poi[i] , this->IO_ADDR_W);
-			this->calculate_ecc (NULL, &(ecc_code[3]));
+			this->calculate_ecc(mtd, NULL, &(ecc_code[3]));
 			for (i = 3; i < 6; i++)
 				oob_data[oob_config[i]] = ecc_code[i];
 		}
@@ -422,20 +422,20 @@
 				
 	/* Hardware ecc 3 byte / 512 byte data, write full page */	
 	case NAND_ECC_HW3_512:	
-		this->enable_hwecc (NAND_ECC_WRITE);	/* enable hardware ecc logic */
+		this->enable_hwecc(mtd, NAND_ECC_WRITE);	/* enable hardware ecc logic */
 		for (i = 0; i < mtd->oobblock; i++) 
 			writeb ( this->data_poi[i] , this->IO_ADDR_W);
-		this->calculate_ecc (NULL, &(ecc_code[0]));
+		this->calculate_ecc(mtd, NULL, &(ecc_code[0]));
 		for (i = 0; i < 3; i++)
 			oob_data[oob_config[i]] = ecc_code[i];
 		break;
 
 	/* Hardware ecc 6 byte / 512 byte data, write full page */	
 	case NAND_ECC_HW6_512:	
-		this->enable_hwecc (NAND_ECC_WRITE);	/* enable hardware ecc logic */
+		this->enable_hwecc(mtd, NAND_ECC_WRITE);	/* enable hardware ecc logic */
 		for (i = 0; i < mtd->oobblock; i++) 
 			writeb ( this->data_poi[i] , this->IO_ADDR_W);
-		this->calculate_ecc (NULL, &(ecc_code[0]));
+		this->calculate_ecc(mtd, NULL, &(ecc_code[0]));
 		for (i = 0; i < 6; i++)
 			oob_data[oob_config[i]] = ecc_code[i];
 		break;
@@ -595,7 +595,7 @@
 			if (!this->dev_ready) 
 				udelay (this->chip_delay);
 			else
-				while (!this->dev_ready());	
+				while (!this->dev_ready(mtd));	
 		}
 
 		/* 
@@ -624,31 +624,31 @@
 		case NAND_ECC_SOFT:	/* Software ECC 3/256: Read in a page + oob data */
 			while (j < end)
 				data_poi[j++] = readb (this->IO_ADDR_R);
-			this->calculate_ecc (&data_poi[0], &ecc_calc[0]);
+			this->calculate_ecc(mtd, &data_poi[0], &ecc_calc[0]);
 			if (mtd->oobblock == 512)
-				this->calculate_ecc (&data_poi[256], &ecc_calc[3]);
+				this->calculate_ecc(mtd, &data_poi[256], &ecc_calc[3]);
 			break;	
 			
 		case NAND_ECC_HW3_256: /* Hardware ECC 3 byte /256 byte data: Read in first 256 byte, get ecc, */
-			this->enable_hwecc (NAND_ECC_READ);	
+			this->enable_hwecc(mtd, NAND_ECC_READ);	
 			while (j < ecc)
 				data_poi[j++] = readb (this->IO_ADDR_R);
-			this->calculate_ecc (&data_poi[0], &ecc_calc[0]);	/* read from hardware */
+			this->calculate_ecc(mtd, &data_poi[0], &ecc_calc[0]);	/* read from hardware */
 			
 			if (mtd->oobblock == 512) { /* read second, if pagesize = 512 */
-				this->enable_hwecc (NAND_ECC_READ);	
+				this->enable_hwecc(mtd, NAND_ECC_READ);	
 				while (j < end)
 					data_poi[j++] = readb (this->IO_ADDR_R);
-				this->calculate_ecc (&data_poi[256], &ecc_calc[3]); /* read from hardware */
+				this->calculate_ecc(mtd, &data_poi[256], &ecc_calc[3]); /* read from hardware */
 			}					
 			break;						
 				
 		case NAND_ECC_HW3_512:	
 		case NAND_ECC_HW6_512: /* Hardware ECC 3/6 byte / 512 byte data : Read in a page  */
-			this->enable_hwecc (NAND_ECC_READ);	
+			this->enable_hwecc(mtd, NAND_ECC_READ);	
 			while (j < end)
 				data_poi[j++] = readb (this->IO_ADDR_R);
-			this->calculate_ecc (&data_poi[0], &ecc_calc[0]);	/* read from hardware */
+			this->calculate_ecc(mtd, &data_poi[0], &ecc_calc[0]);	/* read from hardware */
 			break;
 
 		default:
@@ -669,7 +669,7 @@
 			ecc_code[j] = oob_data[oob + oob_config[j]];
 
 		/* correct data, if neccecary */
-		ecc_status = this->correct_data (&data_poi[0], &ecc_code[0], &ecc_calc[0]);
+		ecc_status = this->correct_data(mtd, &data_poi[0], &ecc_code[0], &ecc_calc[0]);
 		/* check, if we have a fs supplied oob-buffer */
 		if (oob_buf) { 
 			oob += mtd->oobsize;
@@ -682,7 +682,7 @@
 		}
 		
 		if (mtd->oobblock == 512 && eccmode != NAND_ECC_HW3_512) {
-			ecc_status = this->correct_data (&data_poi[256], &ecc_code[3], &ecc_calc[3]);
+			ecc_status = this->correct_data(mtd, &data_poi[256], &ecc_code[3], &ecc_calc[3]);
 			if (oob_buf) {
 				*((int *)&oob_data[oob]) = ecc_status;
 				oob += sizeof(int);

Index: nand_ecc.c
===================================================================
RCS file: /home/cvs/mtd/drivers/mtd/nand/nand_ecc.c,v
retrieving revision 1.9
retrieving revision 1.10
diff -u -r1.9 -r1.10
--- nand_ecc.c	20 Feb 2003 13:34:19 -0000	1.9
+++ nand_ecc.c	1 Jul 2003 23:31:15 -0000	1.10
@@ -17,6 +17,7 @@
 #include <linux/types.h>
 #include <linux/kernel.h>
 #include <linux/module.h>
+#include <linux/mtd/nand_ecc.h>
 
 /*
  * Pre-calculated 256-way 1 byte column parity
@@ -84,7 +85,7 @@
 /*
  * Calculate 3 byte ECC code for 256 byte block
  */
-void nand_calculate_ecc (const u_char *dat, u_char *ecc_code)
+void nand_calculate_ecc(struct mtd_info *mtd, const u_char *dat, u_char *ecc_code)
 {
 	u_char idx, reg1, reg2, reg3;
 	int j;
@@ -119,7 +120,7 @@
 /*
  * Detect and correct a 1 bit error for 256 byte block
  */
-int nand_correct_data (u_char *dat, u_char *read_ecc, u_char *calc_ecc)
+int nand_correct_data(struct mtd_info *mtd, u_char *dat, u_char *read_ecc, u_char *calc_ecc)
 {
 	u_char a, b, c, d1, d2, d3, add, bit, i;
 	




More information about the linux-mtd-cvs mailing list