mtd/drivers/mtd/nand nand_base.c,1.87,1.88 nand_bbt.c,1.1,1.2

gleixner at infradead.org gleixner at infradead.org
Wed May 26 14:06:00 EDT 2004


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

Modified Files:
	nand_base.c nand_bbt.c 
Log Message:
Split data and oob length to make it possible to read the last page of the deivce. Signed-off-by: Thomas Gleixner <tglx at linutronix.de>

Index: nand_base.c
===================================================================
RCS file: /home/cvs/mtd/drivers/mtd/nand/nand_base.c,v
retrieving revision 1.87
retrieving revision 1.88
diff -u -r1.87 -r1.88
--- nand_base.c	26 May 2004 13:35:30 -0000	1.87
+++ nand_base.c	26 May 2004 18:05:56 -0000	1.88
@@ -1174,7 +1174,7 @@
  * @from:	offset to read from
  * @len:	number of bytes to read
  */
-int nand_read_raw (struct mtd_info *mtd, uint8_t *buf, loff_t from, size_t len)
+int nand_read_raw (struct mtd_info *mtd, uint8_t *buf, loff_t from, size_t len, size_t ooblen)
 {
 	struct nand_chip *this = mtd->priv;
 	int page = (int) (from >> this->page_shift);
@@ -1188,7 +1188,7 @@
 
 	/* Do not allow reads past end of device */
 	if ((from + len) > mtd->size) {
-		DEBUG (MTD_DEBUG_LEVEL0, "nand_read_oob: Attempt read beyond end of device\n");
+		DEBUG (MTD_DEBUG_LEVEL0, "nand_read_raw: Attempt read beyond end of device\n");
 		return -EINVAL;
 	}
 
@@ -1196,6 +1196,9 @@
 	nand_get_chip (this, mtd , FL_READING, &erase_state);
 
 	this->select_chip (mtd, chip);
+	
+	/* Add requested oob length */
+	len += ooblen;
 	
 	while (len) {
 		if (sndcmd)

Index: nand_bbt.c
===================================================================
RCS file: /home/cvs/mtd/drivers/mtd/nand/nand_bbt.c,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- nand_bbt.c	26 May 2004 13:03:50 -0000	1.1
+++ nand_bbt.c	26 May 2004 18:05:56 -0000	1.2
@@ -221,7 +221,7 @@
 	struct nand_chip *this = mtd->priv;
 	int i, j, numblocks, len, scanlen;
 	loff_t from = 0;
-	size_t readlen;
+	size_t readlen, ooblen;
 
 	printk (KERN_INFO "Scanning device for bad blocks\n");
 
@@ -230,13 +230,14 @@
 	else
 		len = 1;
 	scanlen	= mtd->oobblock + mtd->oobsize;
-	readlen = len * scanlen;
+	readlen = len * mtd->oobblock;
+	ooblen = len * mtd->oobsize;
 
 	/* Note that numblocks is 2 * (real numblocks) here, see i+=2 below as it
 	 * makes shifting and masking less painful */
 	numblocks = mtd->size >> (this->erase_shift - 1);
 	for (i = 0; i < numblocks;) {
-		nand_read_raw (mtd, buf, from, readlen);
+		nand_read_raw (mtd, buf, from, readlen, ooblen);
 		for (j = 0; j < len; j++) {
 			if (check_pattern (buf, scanlen, mtd->oobblock, bd)) {
 				this->bbt[i >> 3] |= 0x03 << (i & 0x6);
@@ -304,7 +305,7 @@
 		for (block = 0; block < td->maxblocks; block++) {
 			int actblock = startblock + dir * block;
 			/* Read first page */
-			nand_read_raw (mtd, buf, actblock << this->erase_shift, scanlen); 
+			nand_read_raw (mtd, buf, actblock << this->erase_shift, mtd->oobblock, mtd->oobsize); 
 			if (!check_pattern(buf, scanlen, mtd->oobblock, td)) {
 				td->pages[i] = actblock << (this->erase_shift - this->page_shift);
 				if (td->options & NAND_BBT_VERSION) {





More information about the linux-mtd-cvs mailing list