mtd/drivers/mtd/nand nand.c,1.37,1.38 autcpu12.c,1.6,1.7

gleixner at infradead.org gleixner at infradead.org
Tue Feb 18 05:09:34 EST 2003


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

Modified Files:
	nand.c autcpu12.c 
Log Message:
update for new NAND oob-layout selection

Index: nand.c
===================================================================
RCS file: /home/cvs/mtd/drivers/mtd/nand/nand.c,v
retrieving revision 1.37
retrieving revision 1.38
diff -u -r1.37 -r1.38
--- nand.c	14 Feb 2003 22:57:58 -0000	1.37
+++ nand.c	18 Feb 2003 10:09:31 -0000	1.38
@@ -117,6 +117,9 @@
  *
  *  02-14-2003  tglx: Reject non page aligned writes 	
  *		Fixed ecc select in nand_write_page to match semantics. 
+ *
+ *  02-18-2003	tglx: Changed oobsel to pointer. Added a default oob-selector
+ *		
  *	
  * $Id$
  *
@@ -161,19 +164,19 @@
  */
 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, int *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, int *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, int *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, int *oobsel);
 /*
  * Send command to NAND device
  */
@@ -357,12 +360,12 @@
  *	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, int *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 ? this->eccmode : NAND_ECC_NONE;
+	int  	*oob_config = oobconfigs[*oobsel];
 
 	/* pad oob area, if we have no oob buffer from fs-driver */
 	if (!oob_buf) {
@@ -528,7 +531,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, int *oobsel)
 {
 	int j, col, page, end, ecc;
 	int erase_state = 0;
@@ -537,9 +540,9 @@
 	u_char *data_poi, *oob_data = oob_buf;
 	u_char ecc_calc[6];
 	u_char ecc_code[6];
-	int	eccmode = oobsel ? this->eccmode : NAND_ECC_NONE;
+	int	eccmode = *oobsel ? this->eccmode : NAND_ECC_NONE;
 
-	int *oob_config = oobconfigs[oobsel];
+	int *oob_config = oobconfigs[*oobsel];
 	
 	DEBUG (MTD_DEBUG_LEVEL3, "nand_read_ecc: from = 0x%08x, len = %i\n", (unsigned int) from, (int) len);
 
@@ -550,6 +553,10 @@
 		return -EINVAL;
 	}
 
+	// if oobsel is NULL, use chip defaults
+	if (oobsel == NULL) 
+		oobsel = &mtd->oobsel;		
+
 	/* Grab the lock and see if the device is available */
 	nand_get_chip (this, mtd ,FL_READING, &erase_state);
 
@@ -767,13 +774,13 @@
 */
 static int nand_write (struct mtd_info *mtd, loff_t to, size_t len, size_t * retlen, const u_char * buf)
 {
-	return (nand_write_ecc (mtd, to, len, retlen, buf, NULL, 0));
+	return (nand_write_ecc (mtd, to, len, retlen, buf, NULL, NULL));
 }			   
 /*
  * 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, int *oobsel)
 {
 	int page, ret = 0, oob = 0, written = 0;
 	struct nand_chip *this = mtd->priv;
@@ -792,6 +799,10 @@
 		return -EINVAL;
 	}
 
+	// if oobsel is NULL, use chip defaults
+	if (oobsel == NULL) 
+		oobsel = &mtd->oobsel;		
+
 	/* Shift to get page */
 	page = ((int) to) >> this->page_shift;
 
@@ -946,7 +957,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, int *oobsel)
 {
 	int i, page, len, total_len, ret = 0, written = 0;
 	struct nand_chip *this = mtd->priv;
@@ -970,6 +981,10 @@
 		printk (KERN_NOTICE "nand_write_ecc: Attempt to write not page aligned data\n");
 		return -EINVAL;
 	}
+
+	// if oobsel is NULL, use chip defaults
+	if (oobsel == NULL) 
+		oobsel = &mtd->oobsel;		
 
 	/* Shift to get page */
 	page = ((int) to) >> this->page_shift;

Index: autcpu12.c
===================================================================
RCS file: /home/cvs/mtd/drivers/mtd/nand/autcpu12.c,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -r1.6 -r1.7
--- autcpu12.c	11 Nov 2002 15:47:56 -0000	1.6
+++ autcpu12.c	18 Feb 2003 10:09:31 -0000	1.7
@@ -26,6 +26,7 @@
  *
  *	10-06-2002 TG	128K card support added
  *
+ *	02-18-2003 tglx	add new default oob selectors
  */
 
 #include <linux/slab.h>
@@ -74,37 +75,45 @@
 static struct mtd_partition partition_info16k[] = {
 	{ name: "AUTCPU12 flash partition 1",
 	  offset:  0,
-	  size:    8 * SZ_1M },
+	  size:    8 * SZ_1M, 
+	  oobsel:  NAND_JFFS2_OOB },
 	{ name: "AUTCPU12 flash partition 2",
 	  offset:  8 * SZ_1M,
-	  size:    8 * SZ_1M },
+	  size:    8 * SZ_1M,
+	  oobsel:  NAND_JFFS2_OOB }
 };
 
 static struct mtd_partition partition_info32k[] = {
 	{ name: "AUTCPU12 flash partition 1",
 	  offset:  0,
-	  size:    8 * SZ_1M },
+	  size:    8 * SZ_1M,
+	  oobsel:  NAND_JFFS2_OOB },
 	{ name: "AUTCPU12 flash partition 2",
 	  offset:  8 * SZ_1M,
-	  size:   24 * SZ_1M },
+	  size:   24 * SZ_1M,
+	  oobsel:  NAND_JFFS2_OOB }
 };
 
 static struct mtd_partition partition_info64k[] = {
 	{ name: "AUTCPU12 flash partition 1",
 	  offset:  0,
-	  size:   16 * SZ_1M },
+	  size:   16 * SZ_1M,
+	  oobsel:  NAND_JFFS2_OOB },
 	{ name: "AUTCPU12 flash partition 2",
 	  offset: 16 * SZ_1M,
-	  size:   48 * SZ_1M},
+	  size:   48 * SZ_1M,
+	  oobsel:  NAND_JFFS2_OOB }
 };
 
 static struct mtd_partition partition_info128k[] = {
 	{ name: "AUTCPU12 flash partition 1",
 	  offset:  0,
-	  size:   16 * SZ_1M },
+	  size:   16 * SZ_1M,
+	  oobsel:  NAND_JFFS2_OOB },
 	{ name: "AUTCPU12 flash partition 2",
 	  offset: 16 * SZ_1M,
-	  size:   112 * SZ_1M},
+	  size:   112 * SZ_1M,
+	  oobsel:  NAND_JFFS2_OOB }
 };
 
 #define NUM_PARTITIONS16K 2
@@ -182,6 +191,10 @@
 	/* 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)) {





More information about the linux-mtd-cvs mailing list