Merge branch 'omap-for-v4.8/legacy' into for-next
[deliverable/linux.git] / drivers / mtd / nand / s3c2410.c
index 9c9397b54b2ca9a826e27fc7625108100ae2fb87..d9309cf0ce2ec3cd6b76f3d61c4fb0433d32b213 100644 (file)
 
 /* new oob placement block for use with hardware ecc generation
  */
+static int s3c2410_ooblayout_ecc(struct mtd_info *mtd, int section,
+                                struct mtd_oob_region *oobregion)
+{
+       if (section)
+               return -ERANGE;
+
+       oobregion->offset = 0;
+       oobregion->length = 3;
+
+       return 0;
+}
+
+static int s3c2410_ooblayout_free(struct mtd_info *mtd, int section,
+                                 struct mtd_oob_region *oobregion)
+{
+       if (section)
+               return -ERANGE;
+
+       oobregion->offset = 8;
+       oobregion->length = 8;
+
+       return 0;
+}
 
-static struct nand_ecclayout nand_hw_eccoob = {
-       .eccbytes = 3,
-       .eccpos = {0, 1, 2},
-       .oobfree = {{8, 8}}
+static const struct mtd_ooblayout_ops s3c2410_ooblayout_ops = {
+       .ecc = s3c2410_ooblayout_ecc,
+       .free = s3c2410_ooblayout_free,
 };
 
 /* controller and mtd information */
@@ -542,7 +564,8 @@ static int s3c2410_nand_correct_data(struct mtd_info *mtd, u_char *dat,
        diff0 |= (diff1 << 8);
        diff0 |= (diff2 << 16);
 
-       if ((diff0 & ~(1<<fls(diff0))) == 0)
+       /* equal to "(diff0 & ~(1 << __ffs(diff0)))" */
+       if ((diff0 & (diff0 - 1)) == 0)
                return 1;
 
        return -1;
@@ -859,6 +882,7 @@ static void s3c2410_nand_init_chip(struct s3c2410_nand_info *info,
        }
 #else
        chip->ecc.mode      = NAND_ECC_SOFT;
+       chip->ecc.algo  = NAND_ECC_HAMMING;
 #endif
 
        if (set->disable_ecc)
@@ -919,7 +943,7 @@ static void s3c2410_nand_update_chip(struct s3c2410_nand_info *info,
        } else {
                chip->ecc.size      = 512;
                chip->ecc.bytes     = 3;
-               chip->ecc.layout    = &nand_hw_eccoob;
+               mtd_set_ooblayout(nand_to_mtd(chip), &s3c2410_ooblayout_ops);
        }
 }
 
This page took 0.026136 seconds and 5 git commands to generate.