@@ -193,37 +193,57 @@
if (!isNAND)
cleanmarker.totlen = cpu_to_je32(sizeof(cleanmarker));
else {
- struct nand_oobinfo oobinfo;
+#if defined(ECCGETLAYOUT)
+ struct nand_ecclayout ecclayout;
- if (ioctl(fd, MEMGETOOBSEL, &oobinfo) != 0)
- return sys_errmsg("%s: unable to get NAND oobinfo", mtd_device);
-
- /* Check for autoplacement */
- if (oobinfo.useecc == MTD_NANDECC_AUTOPLACE) {
+ memset(&ecclayout, 0, sizeof(ecclayout));
+ if (ioctl(fd, ECCGETLAYOUT, &ecclayout) == 0) {
/* Get the position of the free bytes */
- if (!oobinfo.oobfree[0][1])
- return errmsg(" Eeep. Autoplacement selected and no empty space in oob");
- clmpos = oobinfo.oobfree[0][0];
- clmlen = oobinfo.oobfree[0][1];
- if (clmlen > 8)
- clmlen = 8;
+ if (!ecclayout.oobfree[0].length) {
+ fprintf(stderr, " Eeep. Autoplacement selected and no empty
space in oob\n");
+ return 1;
+ }
+ clmpos = ecclayout.oobfree[0].offset;
+ clmlen = ecclayout.oobfree[0].length;
} else {
- /* Legacy mode */
- switch (mtd.oob_size) {
- case 8:
- clmpos = 6;
- clmlen = 2;
- break;
- case 16:
- clmpos = 8;
- clmlen = 8;
- break;
- case 64:
- clmpos = 16;
+#endif/*defined(ECCGETLAYOUT)*/
+ /* new ECC interface failed or not available, fall back to old
OOB interface, which does not support large flash */
+ struct nand_oobinfo oobinfo;
+ if (ioctl(fd, MEMGETOOBSEL, &oobinfo) != 0)
+ return sys_errmsg("%s: unable to get NAND oobinfo", mtd_device);
+
+ /* Check for autoplacement */
+ if (oobinfo.useecc == MTD_NANDECC_AUTOPLACE) {
+ /* Get the position of the free bytes */
+ if (!oobinfo.oobfree[0][1])
+ return errmsg(" Eeep. Autoplacement selected and no empty space in oob");
+ clmpos = oobinfo.oobfree[0][0];
+ clmlen = oobinfo.oobfree[0][1];
+ if (clmlen > 8)
clmlen = 8;
- break;
+ } else {
+ /* Legacy mode */
+ switch (mtd.oob_size) {
+ case 8:
+ clmpos = 6;
+ clmlen = 2;
+ break;
+ case 16:
+ clmpos = 8;
+ clmlen = 8;
+ break;
+ case 64:
+ clmpos = 16;
+ clmlen = 8;
+ break;
+ }
}
+#if defined(ECCGETLAYOUT)
}
+#endif/*defined(ECCGETLAYOUT)*/
+
+ if (clmlen > 8)
+ clmlen = 8;
cleanmarker.totlen = cpu_to_je32(8);