aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--Documentation/ioctl/ioctl-number.txt1
-rw-r--r--drivers/usb/class/cdc-wdm.c19
-rw-r--r--include/linux/usb/cdc-wdm.h2
-rw-r--r--include/uapi/linux/usb/cdc-wdm.h21
4 files changed, 43 insertions, 0 deletions
diff --git a/Documentation/ioctl/ioctl-number.txt b/Documentation/ioctl/ioctl-number.txt
index 3210540f8bd3..237acab169dd 100644
--- a/Documentation/ioctl/ioctl-number.txt
+++ b/Documentation/ioctl/ioctl-number.txt
@@ -131,6 +131,7 @@ Code Seq#(hex) Include File Comments
131'H' 40-4F sound/hdspm.h conflict! 131'H' 40-4F sound/hdspm.h conflict!
132'H' 40-4F sound/hdsp.h conflict! 132'H' 40-4F sound/hdsp.h conflict!
133'H' 90 sound/usb/usx2y/usb_stream.h 133'H' 90 sound/usb/usx2y/usb_stream.h
134'H' A0 uapi/linux/usb/cdc-wdm.h
134'H' C0-F0 net/bluetooth/hci.h conflict! 135'H' C0-F0 net/bluetooth/hci.h conflict!
135'H' C0-DF net/bluetooth/hidp/hidp.h conflict! 136'H' C0-DF net/bluetooth/hidp/hidp.h conflict!
136'H' C0-DF net/bluetooth/cmtp/cmtp.h conflict! 137'H' C0-DF net/bluetooth/cmtp/cmtp.h conflict!
diff --git a/drivers/usb/class/cdc-wdm.c b/drivers/usb/class/cdc-wdm.c
index 122d056d96d5..8a230f0ef77c 100644
--- a/drivers/usb/class/cdc-wdm.c
+++ b/drivers/usb/class/cdc-wdm.c
@@ -13,6 +13,7 @@
13 */ 13 */
14#include <linux/kernel.h> 14#include <linux/kernel.h>
15#include <linux/errno.h> 15#include <linux/errno.h>
16#include <linux/ioctl.h>
16#include <linux/slab.h> 17#include <linux/slab.h>
17#include <linux/module.h> 18#include <linux/module.h>
18#include <linux/mutex.h> 19#include <linux/mutex.h>
@@ -644,6 +645,22 @@ static int wdm_release(struct inode *inode, struct file *file)
644 return 0; 645 return 0;
645} 646}
646 647
648static long wdm_ioctl(struct file *file, unsigned int cmd, unsigned long arg)
649{
650 struct wdm_device *desc = file->private_data;
651 int rv = 0;
652
653 switch (cmd) {
654 case IOCTL_WDM_MAX_COMMAND:
655 if (copy_to_user((void __user *)arg, &desc->wMaxCommand, sizeof(desc->wMaxCommand)))
656 rv = -EFAULT;
657 break;
658 default:
659 rv = -ENOTTY;
660 }
661 return rv;
662}
663
647static const struct file_operations wdm_fops = { 664static const struct file_operations wdm_fops = {
648 .owner = THIS_MODULE, 665 .owner = THIS_MODULE,
649 .read = wdm_read, 666 .read = wdm_read,
@@ -652,6 +669,8 @@ static const struct file_operations wdm_fops = {
652 .flush = wdm_flush, 669 .flush = wdm_flush,
653 .release = wdm_release, 670 .release = wdm_release,
654 .poll = wdm_poll, 671 .poll = wdm_poll,
672 .unlocked_ioctl = wdm_ioctl,
673 .compat_ioctl = wdm_ioctl,
655 .llseek = noop_llseek, 674 .llseek = noop_llseek,
656}; 675};
657 676
diff --git a/include/linux/usb/cdc-wdm.h b/include/linux/usb/cdc-wdm.h
index 719c332620fa..0b3f4295c025 100644
--- a/include/linux/usb/cdc-wdm.h
+++ b/include/linux/usb/cdc-wdm.h
@@ -11,6 +11,8 @@
11#ifndef __LINUX_USB_CDC_WDM_H 11#ifndef __LINUX_USB_CDC_WDM_H
12#define __LINUX_USB_CDC_WDM_H 12#define __LINUX_USB_CDC_WDM_H
13 13
14#include <uapi/linux/usb/cdc-wdm.h>
15
14extern struct usb_driver *usb_cdc_wdm_register(struct usb_interface *intf, 16extern struct usb_driver *usb_cdc_wdm_register(struct usb_interface *intf,
15 struct usb_endpoint_descriptor *ep, 17 struct usb_endpoint_descriptor *ep,
16 int bufsize, 18 int bufsize,
diff --git a/include/uapi/linux/usb/cdc-wdm.h b/include/uapi/linux/usb/cdc-wdm.h
new file mode 100644
index 000000000000..f03134feebd6
--- /dev/null
+++ b/include/uapi/linux/usb/cdc-wdm.h
@@ -0,0 +1,21 @@
1/*
2 * USB CDC Device Management userspace API definitions
3 *
4 * This program is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU General Public License
6 * version 2 as published by the Free Software Foundation.
7 */
8
9#ifndef _UAPI__LINUX_USB_CDC_WDM_H
10#define _UAPI__LINUX_USB_CDC_WDM_H
11
12/*
13 * This IOCTL is used to retrieve the wMaxCommand for the device,
14 * defining the message limit for both reading and writing.
15 *
16 * For CDC WDM functions this will be the wMaxCommand field of the
17 * Device Management Functional Descriptor.
18 */
19#define IOCTL_WDM_MAX_COMMAND _IOR('H', 0xA0, __u16)
20
21#endif /* _UAPI__LINUX_USB_CDC_WDM_H */