From 5cee27dd9d8aa7ec6c7e614cc5c322765b14e411 Mon Sep 17 00:00:00 2001 From: Rohith Seelaboyina Date: Wed, 5 Mar 2014 16:10:00 +0530 Subject: [PATCH] usb: gadget: mtp: add new ioctl for compat 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. Change-Id: I060604057ac6c55991118b3f61b187468b4ee0fd Signed-off-by: Rohith Seelaboyina Reviewed-on: http://git-master/r/377800 Reviewed-by: Automatic_Commit_Validation_User Reviewed-by: Venkat Moganty Signed-off-by: Wu Liang feng --- drivers/usb/gadget/function/f_mtp.c | 19 +++++++++++++++++++ include/uapi/linux/usb/f_mtp.h | 13 +++++++++++++ 2 files changed, 32 insertions(+) diff --git a/drivers/usb/gadget/function/f_mtp.c b/drivers/usb/gadget/function/f_mtp.c index d26f3b98ffa9..23f866f39107 100644 --- a/drivers/usb/gadget/function/f_mtp.c +++ b/drivers/usb/gadget/function/f_mtp.c @@ -1008,6 +1008,25 @@ static long mtp_ioctl(struct file *fp, unsigned code, unsigned long 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 = (void *)(unsigned long)event_32.data; + ret = mtp_send_event(dev, &event); + } + goto out; + } +#endif } fail: diff --git a/include/uapi/linux/usb/f_mtp.h b/include/uapi/linux/usb/f_mtp.h index 503291855abd..b48a74b3695c 100644 --- a/include/uapi/linux/usb/f_mtp.h +++ b/include/uapi/linux/usb/f_mtp.h @@ -4,6 +4,8 @@ * Copyright (C) 2010 Google, Inc. * Author: Mike Lockwood * + * 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. @@ -45,6 +47,17 @@ struct mtp_event { void *data; }; +#ifdef CONFIG_COMPAT +struct mtp_event_32 { + /* size of the event */ + compat_size_t length; + /* event data to send */ + compat_uptr_t 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. -- 2.34.1