[MTD] NAND Replace oobinfo by ecclayout
[deliverable/linux.git] / drivers / mtd / mtdchar.c
index 608f7af679cbee138fea143cf483b1d9660aa986..e75ec5fe7760a2e410fc1938a0db050a34ec12f1 100644 (file)
@@ -512,14 +512,36 @@ static int mtd_ioctl(struct inode *inode, struct file *file,
                break;
        }
 
+       /* Legacy interface */
        case MEMGETOOBSEL:
        {
-               if (copy_to_user(argp, mtd->oobinfo,
-                                sizeof(struct nand_oobinfo)))
+               struct nand_oobinfo oi;
+
+               if (!mtd->ecclayout)
+                       return -EOPNOTSUPP;
+               if (mtd->ecclayout->eccbytes > ARRAY_SIZE(oi.eccpos))
+                       return -EINVAL;
+
+               oi.useecc = MTD_NANDECC_AUTOPLACE;
+               memcpy(&oi.eccpos, mtd->ecclayout->eccpos, sizeof(oi.eccpos));
+               memcpy(&oi.oobfree, mtd->ecclayout->oobfree,
+                      sizeof(oi.oobfree));
+
+               if (copy_to_user(argp, &oi, sizeof(struct nand_oobinfo)))
                        return -EFAULT;
                break;
        }
 
+       case ECCGETLAYOUT:
+
+               if (!mtd->ecclayout)
+                       return -EOPNOTSUPP;
+
+               if (copy_to_user(argp, &mtd->ecclayout,
+                                sizeof(struct nand_ecclayout)))
+                       return -EFAULT;
+               break;
+
        case MEMGETBADBLOCK:
        {
                loff_t offs;
This page took 0.029658 seconds and 5 git commands to generate.