mtd/drivers/mtd/nand autcpu12.c,1.7,1.8 nand.c,1.40,1.41

gleixner at infradead.org gleixner at infradead.org
Tue Feb 18 15:53:56 EST 2003


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

Modified Files:
	autcpu12.c nand.c 
Log Message:
tglx declares himself healed from temporary brain damage and comes back to the original plan of passing
oob-layout structures. This implies minor changes to filesystem layers, but removes file system dependend
code in nand.c/.h. For userspace apps ioctl (MEMSETOOBSEL) can pass a structure with the layout, which 
has to be used for functions  like read/write, which have no knowledge about oob-layout. see util/nandwrite.c
 



Index: autcpu12.c
===================================================================
RCS file: /home/cvs/mtd/drivers/mtd/nand/autcpu12.c,v
retrieving revision 1.7
retrieving revision 1.8
diff -u -r1.7 -r1.8
--- autcpu12.c	18 Feb 2003 10:09:31 -0000	1.7
+++ autcpu12.c	18 Feb 2003 20:53:54 -0000	1.8
@@ -25,8 +25,6 @@
  *			added page_cache
  *
  *	10-06-2002 TG	128K card support added
- *
- *	02-18-2003 tglx	add new default oob selectors
  */
 
 #include <linux/slab.h>
@@ -71,49 +69,42 @@
 /*
  * Define partitions for flash devices
  */
+extern struct nand_oobinfo jffs2_oobinfo;
 
 static struct mtd_partition partition_info16k[] = {
 	{ name: "AUTCPU12 flash partition 1",
 	  offset:  0,
-	  size:    8 * SZ_1M, 
-	  oobsel:  NAND_JFFS2_OOB },
+	  size:    8 * SZ_1M },
 	{ name: "AUTCPU12 flash partition 2",
 	  offset:  8 * SZ_1M,
-	  size:    8 * SZ_1M,
-	  oobsel:  NAND_JFFS2_OOB }
+	  size:    8 * SZ_1M },
 };
 
 static struct mtd_partition partition_info32k[] = {
 	{ name: "AUTCPU12 flash partition 1",
 	  offset:  0,
-	  size:    8 * SZ_1M,
-	  oobsel:  NAND_JFFS2_OOB },
+	  size:    8 * SZ_1M },
 	{ name: "AUTCPU12 flash partition 2",
 	  offset:  8 * SZ_1M,
-	  size:   24 * SZ_1M,
-	  oobsel:  NAND_JFFS2_OOB }
+	  size:   24 * SZ_1M },
 };
 
 static struct mtd_partition partition_info64k[] = {
 	{ name: "AUTCPU12 flash partition 1",
 	  offset:  0,
-	  size:   16 * SZ_1M,
-	  oobsel:  NAND_JFFS2_OOB },
+	  size:   16 * SZ_1M },
 	{ name: "AUTCPU12 flash partition 2",
 	  offset: 16 * SZ_1M,
-	  size:   48 * SZ_1M,
-	  oobsel:  NAND_JFFS2_OOB }
+	  size:   48 * SZ_1M },
 };
 
 static struct mtd_partition partition_info128k[] = {
 	{ name: "AUTCPU12 flash partition 1",
 	  offset:  0,
-	  size:   16 * SZ_1M,
-	  oobsel:  NAND_JFFS2_OOB },
+	  size:   16 * SZ_1M },
 	{ name: "AUTCPU12 flash partition 2",
 	  offset: 16 * SZ_1M,
-	  size:   112 * SZ_1M,
-	  oobsel:  NAND_JFFS2_OOB }
+	  size:   112 * SZ_1M },
 };
 
 #define NUM_PARTITIONS16K 2
@@ -191,10 +182,6 @@
 	/* 20 us command delay time */
 	this->chip_delay = 20;		
 	this->eccmode = NAND_ECC_SOFT;
-	/* Set the default OOB usage for the whoel chip. This is only valid, if
-	 * we have no partitions, else the per partition default is used.
-	*/ 
-	autcpu12_mtd->oobsel = NAND_JFFS2_OOB;
 
 	/* Scan to find existance of the device */
 	if (nand_scan (autcpu12_mtd)) {

Index: nand.c
===================================================================
RCS file: /home/cvs/mtd/drivers/mtd/nand/nand.c,v
retrieving revision 1.40
retrieving revision 1.41
diff -u -r1.40 -r1.41
--- nand.c	18 Feb 2003 13:26:02 -0000	1.40
+++ nand.c	18 Feb 2003 20:53:54 -0000	1.41
@@ -119,7 +119,12 @@
  *		Fixed ecc select in nand_write_page to match semantics. 
  *
  *  02-18-2003	tglx: Changed oobsel to pointer. Added a default oob-selector
- *		
+ *			
+ *  02-18-2003	tglx: Implemented oobsel again. Now it uses a pointer to
+ +		a structure, which will be supplied by a filesystem driver
+ *		If NULL is given, then the defaults (none or defaults
+ *		supplied by ioctl (MEMSETOOBSEL) are used.
+ *		For partitions the partition defaults are used (mtdpart.c)		
  *	
  * $Id$
  *
@@ -143,40 +148,28 @@
  * Macros for low-level register control
  */
 #define nand_select()	this->hwcontrol(NAND_CTL_SETNCE);
-
 #define nand_deselect() this->hwcontrol(NAND_CTL_CLRNCE);
 
 /*
- * out of band configuration for different filesystems
- */
-static int oobconfigs[][6] = {
-	{ 0,0,0,0,0,0},
-
-	{ NAND_JFFS2_OOB_ECCPOS0, NAND_JFFS2_OOB_ECCPOS1, NAND_JFFS2_OOB_ECCPOS2,
-	NAND_JFFS2_OOB_ECCPOS3, NAND_JFFS2_OOB_ECCPOS4, NAND_JFFS2_OOB_ECCPOS5 },
-
-	{ NAND_YAFFS_OOB_ECCPOS0, NAND_YAFFS_OOB_ECCPOS1, NAND_YAFFS_OOB_ECCPOS2,
-	NAND_YAFFS_OOB_ECCPOS3, NAND_YAFFS_OOB_ECCPOS4, NAND_YAFFS_OOB_ECCPOS5 }	
-};
-
-/*
  * NAND low-level MTD interface functions
  */
 static int nand_read (struct mtd_info *mtd, loff_t from, size_t len, size_t * retlen, u_char * buf);
 static int nand_read_ecc (struct mtd_info *mtd, loff_t from, size_t len,
-			  size_t * retlen, u_char * buf, u_char * eccbuf, int *oobsel);
+			  size_t * retlen, u_char * buf, u_char * eccbuf, struct nand_oobinfo *oobsel);
 static int nand_read_oob (struct mtd_info *mtd, loff_t from, size_t len, size_t * retlen, u_char * buf);
 static int nand_write (struct mtd_info *mtd, loff_t to, size_t len, size_t * retlen, const u_char * buf);
 static int nand_write_ecc (struct mtd_info *mtd, loff_t to, size_t len,
-			   size_t * retlen, const u_char * buf, u_char * eccbuf, int *oobsel);
+			   size_t * retlen, const u_char * buf, u_char * eccbuf, struct nand_oobinfo *oobsel);
 static int nand_write_oob (struct mtd_info *mtd, loff_t to, size_t len, size_t * retlen, const u_char *buf);
 static int nand_writev (struct mtd_info *mtd, const struct iovec *vecs,
 			unsigned long count, loff_t to, size_t * retlen);
 static int nand_writev_ecc (struct mtd_info *mtd, const struct iovec *vecs,
-			unsigned long count, loff_t to, size_t * retlen, u_char *eccbuf, int *oobsel);
+			unsigned long count, loff_t to, size_t * retlen, u_char *eccbuf, struct nand_oobinfo *oobsel);
 static int nand_erase (struct mtd_info *mtd, struct erase_info *instr);
 static void nand_sync (struct mtd_info *mtd);
-static int nand_write_page (struct mtd_info *mtd, struct nand_chip *this, int page, u_char *oob_buf, int *oobsel);
+static int nand_write_page (struct mtd_info *mtd, struct nand_chip *this, int page, u_char *oob_buf,  struct nand_oobinfo *oobsel);
+
+
 /*
  * Send command to NAND device
  */
@@ -360,13 +353,13 @@
  *	This function will always program a full page of data
  *	If you call it with a non page aligned buffer, you're lost :)
  */
-static int nand_write_page (struct mtd_info *mtd, struct nand_chip *this, int page, u_char *oob_buf, int *oobsel)
+static int nand_write_page (struct mtd_info *mtd, struct nand_chip *this, int page, u_char *oob_buf,  struct nand_oobinfo *oobsel)
 {
 	int 	i, status;
 	u_char	ecc_code[6], *oob_data;
-	int	eccmode = *oobsel ? this->eccmode : NAND_ECC_NONE;
-	int  	*oob_config = oobconfigs[*oobsel];
-
+	int	eccmode = oobsel->useecc ? this->eccmode : NAND_ECC_NONE;
+	int  	*oob_config = oobsel->eccpos;
+	
 	/* pad oob area, if we have no oob buffer from fs-driver */
 	if (!oob_buf) {
 		oob_data = &this->data_buf[mtd->oobblock];
@@ -526,7 +519,7 @@
 */
 static int nand_read (struct mtd_info *mtd, loff_t from, size_t len, size_t * retlen, u_char * buf)
 {
-	return (nand_read_ecc (mtd, from, len, retlen, buf, NULL, 0));
+	return (nand_read_ecc (mtd, from, len, retlen, buf, NULL, NULL));
 }			   
 
 
@@ -534,7 +527,7 @@
  * NAND read with ECC
  */
 static int nand_read_ecc (struct mtd_info *mtd, loff_t from, size_t len,
-			  size_t * retlen, u_char * buf, u_char * oob_buf, int *oobsel)
+			  size_t * retlen, u_char * buf, u_char * oob_buf, struct nand_oobinfo *oobsel)
 {
 	int j, col, page, end, ecc;
 	int erase_state = 0;
@@ -543,10 +536,16 @@
 	u_char *data_poi, *oob_data = oob_buf;
 	u_char ecc_calc[6];
 	u_char ecc_code[6];
-	int	eccmode;
-	int *oob_config;
+	int 	eccmode;
+	int	*oob_config;
+
+	// use chip default if zero
+	if (oobsel == NULL)
+		oobsel = &mtd->oobinfo;
+		
+	eccmode = oobsel->useecc ? this->eccmode : NAND_ECC_NONE;
+	oob_config = oobsel->eccpos;
 
-	
 	DEBUG (MTD_DEBUG_LEVEL3, "nand_read_ecc: from = 0x%08x, len = %i\n", (unsigned int) from, (int) len);
 
 	/* Do not allow reads past end of device */
@@ -556,13 +555,6 @@
 		return -EINVAL;
 	}
 
-	// if oobsel is NULL, use chip defaults
-	if (oobsel == NULL) 
-		oobsel = &mtd->oobsel;		
-
-	eccmode = *oobsel ? this->eccmode : NAND_ECC_NONE;
-	oob_config = oobconfigs[*oobsel];
-
 	/* Grab the lock and see if the device is available */
 	nand_get_chip (this, mtd ,FL_READING, &erase_state);
 
@@ -787,7 +779,7 @@
  * NAND write with ECC
  */
 static int nand_write_ecc (struct mtd_info *mtd, loff_t to, size_t len,
-			   size_t * retlen, const u_char * buf, u_char * eccbuf, int *oobsel)
+			   size_t * retlen, const u_char * buf, u_char * eccbuf, struct nand_oobinfo *oobsel)
 {
 	int page, ret = 0, oob = 0, written = 0;
 	struct nand_chip *this = mtd->priv;
@@ -808,7 +800,7 @@
 
 	// if oobsel is NULL, use chip defaults
 	if (oobsel == NULL) 
-		oobsel = &mtd->oobsel;		
+		oobsel = &mtd->oobinfo;		
 
 	/* Shift to get page */
 	page = ((int) to) >> this->page_shift;
@@ -964,7 +956,7 @@
 }
 
 static int nand_writev_ecc (struct mtd_info *mtd, const struct iovec *vecs, unsigned long count, 
-		loff_t to, size_t * retlen, u_char *eccbuf, int *oobsel)
+		loff_t to, size_t * retlen, u_char *eccbuf, struct nand_oobinfo *oobsel)
 {
 	int i, page, len, total_len, ret = 0, written = 0;
 	struct nand_chip *this = mtd->priv;
@@ -991,7 +983,7 @@
 
 	// if oobsel is NULL, use chip defaults
 	if (oobsel == NULL) 
-		oobsel = &mtd->oobsel;		
+		oobsel = &mtd->oobinfo;		
 
 	/* Shift to get page */
 	page = ((int) to) >> this->page_shift;
@@ -1341,7 +1333,7 @@
 		printk (KERN_WARNING "Invalid NAND_ECC_MODE %d\n", this->eccmode);
 		BUG();	
 	}	
-
+	
 	/* Initialize state, waitqueue and spinlock */
 	this->state = FL_READY;
 	init_waitqueue_head (&this->wq);





More information about the linux-mtd-cvs mailing list