mtd: atmel_nand: NFC: fix mtd_nandbiterrs.ko test fail when using sram write

Linux-MTD Mailing List linux-mtd at lists.infradead.org
Wed Oct 15 23:59:04 PDT 2014


Gitweb:     http://git.infradead.org/?p=mtd-2.6.git;a=commit;h=ff0a215438cf7be0a652cb3457f562539bd40b22
Commit:     ff0a215438cf7be0a652cb3457f562539bd40b22
Parent:     1cc8d8413327a684cd5e93cd52ececb0223bb40b
Author:     Wu, Josh <Josh.wu at atmel.com>
AuthorDate: Tue Aug 5 18:38:52 2014 +0800
Committer:  Brian Norris <computersforpeace at gmail.com>
CommitDate: Tue Aug 19 11:53:09 2014 -0700

    mtd: atmel_nand: NFC: fix mtd_nandbiterrs.ko test fail when using sram write
    
    When enable NFC sram write, it will failed the mtd_nandbiterrs.ko test.
    
    As in driver's nfc_sram_write_page(), if ops->mode equal to MTD_OSP_RAW,
    driver assumes the data buffer contains one page data and one oob data
    followed. And driver will write the page data and oob data to nand.
    
    But this is wrong implementation. Since the data buffer don't contains the
    oob data to write. We should write the chip->oob_poi to nand's oob.
    
    So this patch fix it by writing the oob data from chip->oob_poi.
    
    Signed-off-by: Josh Wu <josh.wu at atmel.com>
    Signed-off-by: Brian Norris <computersforpeace at gmail.com>
---
 drivers/mtd/nand/atmel_nand.c | 17 +++++++++--------
 1 file changed, 9 insertions(+), 8 deletions(-)

diff --git a/drivers/mtd/nand/atmel_nand.c b/drivers/mtd/nand/atmel_nand.c
index 0abc965..9c5f717 100644
--- a/drivers/mtd/nand/atmel_nand.c
+++ b/drivers/mtd/nand/atmel_nand.c
@@ -1907,15 +1907,7 @@ static int nfc_sram_write_page(struct mtd_info *mtd, struct nand_chip *chip,
 	if (offset || (data_len < mtd->writesize))
 		return -EINVAL;
 
-	cfg = nfc_readl(host->nfc->hsmc_regs, CFG);
 	len = mtd->writesize;
-
-	if (unlikely(raw)) {
-		len += mtd->oobsize;
-		nfc_writel(host->nfc->hsmc_regs, CFG, cfg | NFC_CFG_WSPARE);
-	} else
-		nfc_writel(host->nfc->hsmc_regs, CFG, cfg & ~NFC_CFG_WSPARE);
-
 	/* Copy page data to sram that will write to nand via NFC */
 	if (use_dma) {
 		if (atmel_nand_dma_op(mtd, (void *)buf, len, 0) != 0)
@@ -1925,6 +1917,15 @@ static int nfc_sram_write_page(struct mtd_info *mtd, struct nand_chip *chip,
 		memcpy32_toio(sram, buf, len);
 	}
 
+	cfg = nfc_readl(host->nfc->hsmc_regs, CFG);
+	if (unlikely(raw) && oob_required) {
+		memcpy32_toio(sram + len, chip->oob_poi, mtd->oobsize);
+		len += mtd->oobsize;
+		nfc_writel(host->nfc->hsmc_regs, CFG, cfg | NFC_CFG_WSPARE);
+	} else {
+		nfc_writel(host->nfc->hsmc_regs, CFG, cfg & ~NFC_CFG_WSPARE);
+	}
+
 	if (chip->ecc.mode == NAND_ECC_HW && host->has_pmecc)
 		/*
 		 * When use NFC sram, need set up PMECC before send



More information about the linux-mtd-cvs mailing list