mtd: nand: fsl_ifc: use mtd_ooblayout_xxx() helpers where appropriate
authorBoris Brezillon <boris.brezillon@free-electrons.com>
Wed, 3 Feb 2016 19:11:32 +0000 (20:11 +0100)
committerBoris Brezillon <boris.brezillon@free-electrons.com>
Tue, 19 Apr 2016 20:05:50 +0000 (22:05 +0200)
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@free-electrons.com>
drivers/mtd/nand/fsl_ifc_nand.c

index f8a016f038cdcf2501a53e68fd8ffb5464d660ce..1d922a0f7436fc48c8033ba645e8dd63bf79b9a9 100644 (file)
@@ -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;