]> rtime.felk.cvut.cz Git - sojka/nv-tegra/linux-3.10.git/commitdiff
usb: gadget: mtp: add new ioctl for compat
authorRohith Seelaboyina <rseelaboyina@nvidia.com>
Wed, 5 Mar 2014 10:40:00 +0000 (16:10 +0530)
committerRohith Seelaboyina <rseelaboyina@nvidia.com>
Tue, 18 Mar 2014 06:33:20 +0000 (23:33 -0700)
Define a new ioctl for MTP_SEND_EVENT, as its
ioctl numbers depends on the size of struct
mtp_event, which varies in ARCH32 and ARCH64.

Bug 1466403

Change-Id: I1d172aae422ca483b00c6dd59e739166f40c53ce
Signed-off-by: Rohith Seelaboyina <rseelaboyina@nvidia.com>
Reviewed-on: http://git-master/r/377800
Reviewed-by: Automatic_Commit_Validation_User
Reviewed-by: Venkat Moganty <vmoganty@nvidia.com>
drivers/usb/gadget/f_mtp.c
include/uapi/linux/usb/f_mtp.h

index dbfa6d70f37b3bb94f7f45823b2014e6fcdd7d84..4de200a6c4915735bd51331fa36e53ca8b78d8dd 100644 (file)
@@ -880,7 +880,7 @@ static int mtp_send_event(struct mtp_dev *dev, struct mtp_event *event)
        return ret;
 }
 
-static long mtp_ioctl(struct file *fp, unsigned code, u32 value)
+static long mtp_ioctl(struct file *fp, unsigned code, unsigned long value)
 {
        struct mtp_dev *dev = fp->private_data;
        struct file *filp = NULL;
@@ -968,6 +968,25 @@ static long mtp_ioctl(struct file *fp, unsigned code, u32 value)
                        ret = mtp_send_event(dev, &event);
                goto out;
        }
+#ifdef CONFIG_COMPAT
+       case MTP_SEND_EVENT_32:
+       {
+               struct mtp_event_32     event_32;
+               struct mtp_event        event;
+               /* return here so we don't change dev->state below,
+                * which would interfere with bulk transfer state.
+                */
+               if (copy_from_user(&event_32, (void __user *)value,
+                                                       sizeof(event_32)))
+                       ret = -EFAULT;
+               else {
+                       event.length = event_32.length;
+                       event.data = &(event_32.data);
+                       ret = mtp_send_event(dev, &event);
+               }
+               goto out;
+       }
+#endif
        }
 
 fail:
index 503291855abda22a46d4f365259c45accdae11a7..8200730648e600b013457b275ab1eb713234373b 100644 (file)
@@ -4,6 +4,8 @@
  * Copyright (C) 2010 Google, Inc.
  * Author: Mike Lockwood <lockwood@android.com>
  *
+ * Copyright (C) 2014, NVIDIA CORPORATION. All rights reserved.
+ *
  * This software is licensed under the terms of the GNU General Public
  * License version 2, as published by the Free Software Foundation, and
  * may be copied, distributed, and modified under those terms.
@@ -44,7 +46,15 @@ struct mtp_event {
        /* event data to send */
        void            *data;
 };
-
+#ifdef CONFIG_COMPAT
+struct mtp_event_32 {
+       /* size of the event */
+       u32     length;
+       /* event data to send */
+       u32     data;
+};
+#define MTP_SEND_EVENT_32          _IOW('M', 3, struct mtp_event_32)
+#endif
 /* Sends the specified file range to the host */
 #define MTP_SEND_FILE              _IOW('M', 0, struct mtp_file_range)
 /* Receives data from the host and writes it to a file.