]> pilppa.org Git - linux-2.6-omap-h63xx.git/blobdiff - drivers/mtd/nand/nand_base.c
[MTD] NAND: Café ECC -- remove spurious BUG_ON() in err_pos()
[linux-2.6-omap-h63xx.git] / drivers / mtd / nand / nand_base.c
index baece61169f4933af73704779143ddbaf21c08f7..f23ab2c70433ebabbe62b838afe63b8010bbadad 100644 (file)
@@ -755,7 +755,7 @@ static int nand_read_page_raw(struct mtd_info *mtd, struct nand_chip *chip,
 }
 
 /**
- * nand_read_page_swecc - {REPLACABLE] software ecc based page read function
+ * nand_read_page_swecc - [REPLACABLE] software ecc based page read function
  * @mtd:       mtd info structure
  * @chip:      nand chip info structure
  * @buf:       buffer to store read data
@@ -795,7 +795,7 @@ static int nand_read_page_swecc(struct mtd_info *mtd, struct nand_chip *chip,
 }
 
 /**
- * nand_read_page_hwecc - {REPLACABLE] hardware ecc based page read function
+ * nand_read_page_hwecc - [REPLACABLE] hardware ecc based page read function
  * @mtd:       mtd info structure
  * @chip:      nand chip info structure
  * @buf:       buffer to store read data
@@ -839,7 +839,7 @@ static int nand_read_page_hwecc(struct mtd_info *mtd, struct nand_chip *chip,
 }
 
 /**
- * nand_read_page_syndrome - {REPLACABLE] hardware ecc syndrom based page read
+ * nand_read_page_syndrome - [REPLACABLE] hardware ecc syndrom based page read
  * @mtd:       mtd info structure
  * @chip:      nand chip info structure
  * @buf:       buffer to store read data
@@ -971,7 +971,6 @@ static int nand_do_read_ops(struct mtd_info *mtd, loff_t from,
        page = realpage & chip->pagemask;
 
        col = (int)(from & (mtd->writesize - 1));
-       chip->oob_poi = chip->buffers->oobrbuf;
 
        buf = ops->datbuf;
        oob = ops->oobbuf;
@@ -1270,8 +1269,6 @@ static int nand_do_read_oob(struct mtd_info *mtd, loff_t from,
        realpage = (int)(from >> chip->page_shift);
        page = realpage & chip->pagemask;
 
-       chip->oob_poi = chip->buffers->oobrbuf;
-
        while(1) {
                sndcmd = chip->ecc.read_oob(mtd, chip, page, sndcmd);
                buf = nand_transfer_oob(chip, buf, ops);
@@ -1375,7 +1372,7 @@ static void nand_write_page_raw(struct mtd_info *mtd, struct nand_chip *chip,
 }
 
 /**
- * nand_write_page_swecc - {REPLACABLE] software ecc based page write function
+ * nand_write_page_swecc - [REPLACABLE] software ecc based page write function
  * @mtd:       mtd info structure
  * @chip:      nand chip info structure
  * @buf:       data buffer
@@ -1401,7 +1398,7 @@ static void nand_write_page_swecc(struct mtd_info *mtd, struct nand_chip *chip,
 }
 
 /**
- * nand_write_page_hwecc - {REPLACABLE] hardware ecc based page write function
+ * nand_write_page_hwecc - [REPLACABLE] hardware ecc based page write function
  * @mtd:       mtd info structure
  * @chip:      nand chip info structure
  * @buf:       data buffer
@@ -1429,7 +1426,7 @@ static void nand_write_page_hwecc(struct mtd_info *mtd, struct nand_chip *chip,
 }
 
 /**
- * nand_write_page_syndrome - {REPLACABLE] hardware ecc syndrom based page write
+ * nand_write_page_syndrome - [REPLACABLE] hardware ecc syndrom based page write
  * @mtd:       mtd info structure
  * @chip:      nand chip info structure
  * @buf:       data buffer
@@ -1625,7 +1622,9 @@ static int nand_do_write_ops(struct mtd_info *mtd, loff_t to,
            (chip->pagebuf << chip->page_shift) < (to + ops->len))
                chip->pagebuf = -1;
 
-       chip->oob_poi = chip->buffers->oobwbuf;
+       /* If we're not given explicit OOB data, let it be 0xFF */
+       if (likely(!oob))
+               memset(chip->oob_poi, 0xff, mtd->oobsize);
 
        while(1) {
                int cached = writelen > bytes && page != blockmask;
@@ -1654,9 +1653,6 @@ static int nand_do_write_ops(struct mtd_info *mtd, loff_t to,
                }
        }
 
-       if (unlikely(oob))
-               memset(chip->oob_poi, 0xff, mtd->oobsize);
-
        ops->retlen = ops->len - writelen;
        return ret;
 }
@@ -1744,7 +1740,6 @@ static int nand_do_write_oob(struct mtd_info *mtd, loff_t to,
        if (page == chip->pagebuf)
                chip->pagebuf = -1;
 
-       chip->oob_poi = chip->buffers->oobwbuf;
        memset(chip->oob_poi, 0xff, mtd->oobsize);
        nand_fill_oob(chip, ops->oobbuf, ops);
        status = chip->ecc.write_oob(mtd, chip, page & chip->pagemask);
@@ -2348,8 +2343,8 @@ int nand_scan_tail(struct mtd_info *mtd)
        if (!chip->buffers)
                return -ENOMEM;
 
-       /* Preset the internal oob write buffer */
-       memset(chip->buffers->oobwbuf, 0xff, mtd->oobsize);
+       /* Set the internal oob buffer location, just after the page data */
+       chip->oob_poi = chip->buffers->databuf + mtd->writesize;
 
        /*
         * If no default placement scheme is given, select an appropriate one