mtd: nand: fsl_ifc: use mtd_ooblayout_xxx() helpers where appropriate

Linux-MTD Mailing List linux-mtd at lists.infradead.org
Mon May 23 21:59:12 PDT 2016


Gitweb:     http://git.infradead.org/?p=mtd-2.6.git;a=commit;h=9ed92dd29015de67041cf45f364a46f1fa84bf79
Commit:     9ed92dd29015de67041cf45f364a46f1fa84bf79
Parent:     78d28e8ec4fbd4d1e0c375d7a28f4f23e9e7b15e
Author:     Boris Brezillon <boris.brezillon at free-electrons.com>
AuthorDate: Wed Feb 3 20:11:32 2016 +0100
Committer:  Boris Brezillon <boris.brezillon at free-electrons.com>
CommitDate: Tue Apr 19 22:05:50 2016 +0200

    mtd: nand: fsl_ifc: use mtd_ooblayout_xxx() helpers where appropriate
    
    The mtd_ooblayout_xxx() helper functions have been added to avoid direct
    accesses to the ecclayout field, and thus ease for future reworks.
    Use these helpers in all places where the oobfree[] and eccpos[] arrays
    where directly accessed.
    
    Signed-off-by: Boris Brezillon <boris.brezillon at free-electrons.com>
---
 drivers/mtd/nand/fsl_ifc_nand.c | 14 +++++++++-----
 1 file changed, 9 insertions(+), 5 deletions(-)

diff --git a/drivers/mtd/nand/fsl_ifc_nand.c b/drivers/mtd/nand/fsl_ifc_nand.c
index f8a016f..1d922a0 100644
--- a/drivers/mtd/nand/fsl_ifc_nand.c
+++ b/drivers/mtd/nand/fsl_ifc_nand.c
@@ -257,18 +257,22 @@ static int is_blank(struct mtd_info *mtd, unsigned int bufnum)
 	u8 __iomem *addr = priv->vbase + bufnum * (mtd->writesize * 2);
 	u32 __iomem *mainarea = (u32 __iomem *)addr;
 	u8 __iomem *oob = addr + mtd->writesize;
-	int i;
+	struct mtd_oob_region oobregion = { };
+	int i, section = 0;
 
 	for (i = 0; i < mtd->writesize / 4; i++) {
 		if (__raw_readl(&mainarea[i]) != 0xffffffff)
 			return 0;
 	}
 
-	for (i = 0; i < chip->ecc.layout->eccbytes; i++) {
-		int pos = chip->ecc.layout->eccpos[i];
+	mtd_ooblayout_ecc(mtd, section++, &oobregion);
+	while (oobregion.length) {
+		for (i = 0; i < oobregion.length; i++) {
+			if (__raw_readb(&oob[oobregion.offset + i]) != 0xff)
+				return 0;
+		}
 
-		if (__raw_readb(&oob[pos]) != 0xff)
-			return 0;
+		mtd_ooblayout_ecc(mtd, section++, &oobregion);
 	}
 
 	return 1;



More information about the linux-mtd-cvs mailing list