mtd: add MEMERASE64 ioctl for >4GiB devices
authorKevin Cernekee <kpc.mtd@gmail.com>
Thu, 9 Apr 2009 05:52:28 +0000 (22:52 -0700)
committerDavid Woodhouse <David.Woodhouse@intel.com>
Fri, 29 May 2009 14:13:47 +0000 (15:13 +0100)
New MEMERASE/MEMREADOOB/MEMWRITEOOB ioctls are needed in order to support
64-bit offsets into large NAND flash devices.

Signed-off-by: Kevin Cernekee <kpc.mtd@gmail.com>
Signed-off-by: Artem Bityutskiy <Artem.Bityutskiy@nokia.com>
Signed-off-by: David Woodhouse <David.Woodhouse@intel.com>
drivers/mtd/mtdchar.c
fs/compat_ioctl.c
include/mtd/mtd-abi.h

index 763d3f0a1f428104d7a630de7746a09bc9883bb9..ad4b8618977dfdfe311cfa6d5568fa7ca97efef8 100644 (file)
@@ -417,6 +417,7 @@ static int mtd_ioctl(struct inode *inode, struct file *file,
                break;
 
        case MEMERASE:
+       case MEMERASE64:
        {
                struct erase_info *erase;
 
@@ -427,20 +428,32 @@ static int mtd_ioctl(struct inode *inode, struct file *file,
                if (!erase)
                        ret = -ENOMEM;
                else {
-                       struct erase_info_user einfo;
-
                        wait_queue_head_t waitq;
                        DECLARE_WAITQUEUE(wait, current);
 
                        init_waitqueue_head(&waitq);
 
-                       if (copy_from_user(&einfo, argp,
-                                   sizeof(struct erase_info_user))) {
-                               kfree(erase);
-                               return -EFAULT;
+                       if (cmd == MEMERASE64) {
+                               struct erase_info_user64 einfo64;
+
+                               if (copy_from_user(&einfo64, argp,
+                                           sizeof(struct erase_info_user64))) {
+                                       kfree(erase);
+                                       return -EFAULT;
+                               }
+                               erase->addr = einfo64.start;
+                               erase->len = einfo64.length;
+                       } else {
+                               struct erase_info_user einfo32;
+
+                               if (copy_from_user(&einfo32, argp,
+                                           sizeof(struct erase_info_user))) {
+                                       kfree(erase);
+                                       return -EFAULT;
+                               }
+                               erase->addr = einfo32.start;
+                               erase->len = einfo32.length;
                        }
-                       erase->addr = einfo.start;
-                       erase->len = einfo.length;
                        erase->mtd = mtd;
                        erase->callback = mtdchar_erase_callback;
                        erase->priv = (unsigned long)&waitq;
index b83f6bcfa51a4eefc745d819e8eb9592f4af990c..c603ca2c223a3e824aa035e97e9c196084c4da4e 100644 (file)
@@ -2441,6 +2441,7 @@ COMPATIBLE_IOCTL(MEMGETREGIONCOUNT)
 COMPATIBLE_IOCTL(MEMGETREGIONINFO)
 COMPATIBLE_IOCTL(MEMGETBADBLOCK)
 COMPATIBLE_IOCTL(MEMSETBADBLOCK)
+COMPATIBLE_IOCTL(MEMERASE64)
 /* NBD */
 ULONG_IOCTL(NBD_SET_SOCK)
 ULONG_IOCTL(NBD_SET_BLKSIZE)
index b6595b3c68b6f9117dbb582dab66e53d9daf7609..2e32be1e3a1e26e2c94edd3b2b53a78d8da96d60 100644 (file)
@@ -12,6 +12,11 @@ struct erase_info_user {
        __u32 length;
 };
 
+struct erase_info_user64 {
+       __u64 start;
+       __u64 length;
+};
+
 struct mtd_oob_buf {
        __u32 start;
        __u32 length;
@@ -95,6 +100,7 @@ struct otp_info {
 #define ECCGETLAYOUT           _IOR('M', 17, struct nand_ecclayout)
 #define ECCGETSTATS            _IOR('M', 18, struct mtd_ecc_stats)
 #define MTDFILEMODE            _IO('M', 19)
+#define MEMERASE64             _IOW('M', 20, struct erase_info_user64)
 
 /*
  * Obsolete legacy interface. Keep it in order not to break userspace