39 #include <linux/slab.h>
40 #include <linux/signal.h>
41 #include <linux/poll.h>
42 #include <linux/module.h>
44 #include <linux/usbdevice_fs.h>
51 #include <asm/uaccess.h>
52 #include <asm/byteorder.h>
58 #define USB_DEVICE_MAX USB_MAXBUS * 128
59 #define USB_SG_SIZE 16384
66 struct usb_device *
dev;
98 static bool usbfs_snoop;
102 #define snoop(dev, format, arg...) \
105 dev_info(dev , format , ## arg); \
112 #define USB_DEVICE_DEV MKDEV(USB_DEVICE_MAJOR, 0)
115 static unsigned usbfs_memory_mb = 16;
118 "maximum MB allowed for usbfs buffers (0 = no limit)");
121 #define USBFS_XFER_MAX (UINT_MAX / 2 - 1000000)
126 static int usbfs_increase_memory_usage(
unsigned amount)
148 static void usbfs_decrease_memory_usage(
unsigned amount)
155 return (!list_empty(&ps->
list) &&
159 static loff_t usbdev_lseek(
struct file *
file, loff_t
offset,
int orig)
163 mutex_lock(&file->f_dentry->d_inode->i_mutex);
183 static ssize_t usbdev_read(
struct file *file,
char __user *
buf,
size_t nbytes,
187 struct usb_device *
dev = ps->
dev;
194 usb_lock_device(dev);
195 if (!connected(ps)) {
198 }
else if (pos < 0) {
207 memcpy(&temp_desc, &dev->descriptor,
sizeof(dev->descriptor));
216 if (
copy_to_user(buf, ((
char *)&temp_desc) + pos, len)) {
228 for (i = 0; nbytes && i < dev->descriptor.bNumConfigurations; i++) {
233 if (*ppos < pos +
length) {
245 if (alloclen > (*ppos - pos)) {
246 alloclen -= (*ppos -
pos);
248 dev->rawdescriptors[i] + (*ppos - pos),
249 min(len, alloclen))) {
265 usb_unlock_device(dev);
273 static struct async *alloc_async(
unsigned int numisoframes)
288 static void free_async(
struct async *as)
295 for (i = 0; i < as->
urb->num_sgs; i++) {
296 if (sg_page(&as->
urb->sg[i]))
303 usbfs_decrease_memory_usage(as->
mem_usage);
307 static void async_newpending(
struct async *as)
314 spin_unlock_irqrestore(&ps->
lock, flags);
317 static void async_removepending(
struct async *as)
324 spin_unlock_irqrestore(&ps->
lock, flags);
338 spin_unlock_irqrestore(&ps->
lock, flags);
348 if (as->userurb == userurb) {
356 static void snoop_urb(
struct usb_device *
udev,
361 static const char *types[] = {
"isoc",
"int",
"ctrl",
"bulk"};
362 static const char *dirs[] = {
"out",
"in"};
369 ep = usb_pipeendpoint(pipe);
370 t = types[usb_pipetype(pipe)];
371 d = dirs[!!usb_pipein(pipe)];
375 dev_info(&udev->dev,
"userurb %p, ep%d %s-%s, "
377 userurb, ep, t, d, length);
379 dev_info(&udev->dev,
"userurb %p, ep%d %s-%s, "
380 "actual_length %u status %d\n",
381 userurb, ep, t, d, length,
385 dev_info(&udev->dev,
"ep%d %s-%s, length %u, "
387 ep, t, d, length, timeout_or_status);
389 dev_info(&udev->dev,
"ep%d %s-%s, actual_length %u, "
391 ep, t, d, length, timeout_or_status);
394 if (data && data_len > 0) {
400 static void snoop_urb_data(
struct urb *
urb,
unsigned len)
407 if (urb->num_sgs == 0) {
409 urb->transfer_buffer, len, 1);
413 for (i = 0; i < urb->num_sgs && len; i++) {
416 sg_virt(&urb->sg[i]), size, 1);
421 static int copy_urb_data_to_user(
u8 __user *
userbuffer,
struct urb *urb)
423 unsigned i, len,
size;
425 if (urb->number_of_packets > 0)
426 len = urb->transfer_buffer_length;
428 len = urb->actual_length;
430 if (urb->num_sgs == 0) {
431 if (
copy_to_user(userbuffer, urb->transfer_buffer, len))
436 for (i = 0; i < urb->num_sgs && len; i++) {
438 if (
copy_to_user(userbuffer, sg_virt(&urb->sg[i]), size))
447 #define AS_CONTINUATION 1
479 spin_unlock(&ps->
lock);
482 spin_lock(&ps->
lock);
488 static void async_completed(
struct urb *urb)
490 struct async *as = urb->context;
498 spin_lock(&ps->
lock);
507 pid = get_pid(as->
pid);
508 cred = get_cred(as->
cred);
511 snoop(&urb->dev->dev,
"urb complete\n");
512 snoop_urb(urb->dev, as->
userurb, urb->pipe, urb->actual_length,
514 if ((urb->transfer_flags & URB_DIR_MASK) ==
USB_DIR_IN)
515 snoop_urb_data(urb, urb->actual_length);
520 spin_unlock(&ps->
lock);
538 while (!list_empty(list)) {
545 spin_unlock_irqrestore(&ps->
lock, flags);
550 spin_unlock_irqrestore(&ps->
lock, flags);
553 static void destroy_async_on_interface(
struct dev_state *ps,
559 INIT_LIST_HEAD(&hitlist);
563 list_move_tail(p, &hitlist);
564 spin_unlock_irqrestore(&ps->lock, flags);
565 destroy_async(ps, &hitlist);
570 destroy_async(ps, &ps->async_pending);
587 struct dev_state *ps = usb_get_intfdata(intf);
588 unsigned int ifnum = intf->altsetting->desc.bInterfaceNumber;
600 dev_warn(&intf->dev,
"interface number %u out of range\n",
603 usb_set_intfdata(intf,
NULL);
606 destroy_async_on_interface(ps, ifnum);
624 .probe = driver_probe,
625 .disconnect = driver_disconnect,
626 .suspend = driver_suspend,
627 .resume = driver_resume,
630 static int claimintf(
struct dev_state *ps,
unsigned int ifnum)
632 struct usb_device *dev = ps->
dev;
652 static int releaseintf(
struct dev_state *ps,
unsigned int ifnum)
654 struct usb_device *
dev;
672 static int checkintf(
struct dev_state *ps,
unsigned int ifnum)
681 dev_warn(&ps->
dev->dev,
"usbfs: process %d (%s) did not claim "
682 "interface %u before use\n", task_pid_nr(
current),
684 return claimintf(ps, ifnum);
687 static int findintfep(
struct usb_device *dev,
unsigned int ep)
689 unsigned int i,
j,
e;
691 struct usb_host_interface *alts;
698 for (i = 0; i < dev->actconfig->desc.bNumInterfaces; i++) {
699 intf = dev->actconfig->interface[
i];
700 for (j = 0; j < intf->num_altsetting; j++) {
701 alts = &intf->altsetting[
j];
702 for (e = 0; e < alts->desc.bNumEndpoints; e++) {
703 endpt = &alts->endpoint[
e].desc;
705 return alts->desc.bInterfaceNumber;
712 static int check_ctrlrecip(
struct dev_state *ps,
unsigned int requesttype,
716 struct usb_host_interface *alt_setting;
730 if (requesttype == 0xa1 && request == 0) {
732 index >> 8, index & 0xff);
741 ret = findintfep(ps->
dev, index);
743 ret = checkintf(ps, ret);
747 ret = checkintf(ps, index);
753 static int match_devt(
struct device *dev,
void *data)
758 static struct usb_device *usbdev_lookup_by_devt(
dev_t devt)
763 (
void *) (
unsigned long) devt, match_devt);
772 static int usbdev_open(
struct inode *
inode,
struct file *file)
774 struct usb_device *dev =
NULL;
790 dev = usbdev_lookup_by_devt(inode->
i_rdev);
797 usb_lock_device(dev);
799 goto out_unlock_device;
801 ret = usb_autoresume_device(dev);
803 goto out_unlock_device;
808 INIT_LIST_HEAD(&ps->
list);
821 usb_unlock_device(dev);
822 snoop(&dev->dev,
"opened by process %d: %s\n", task_pid_nr(
current),
827 usb_unlock_device(dev);
834 static int usbdev_release(
struct inode *inode,
struct file *file)
837 struct usb_device *dev = ps->
dev;
841 usb_lock_device(dev);
844 list_del_init(&ps->
list);
849 releaseintf(ps, ifnum);
851 destroy_all_async(ps);
853 usb_unlock_device(dev);
858 as = async_getcompleted(ps);
861 as = async_getcompleted(ps);
867 static int proc_control(
struct dev_state *ps,
void __user *
arg)
869 struct usb_device *dev = ps->
dev;
878 ret = check_ctrlrecip(ps,
ctrl.bRequestType,
ctrl.bRequest,
882 wLength =
ctrl.wLength;
885 ret = usbfs_increase_memory_usage(
PAGE_SIZE +
sizeof(
struct urb) +
895 snoop(&dev->dev,
"control urb: bRequestType=%02x "
896 "bRequest=%02x wValue=%04x "
897 "wIndex=%04x wLength=%04x\n",
899 __le16_to_cpup(&
ctrl.wValue),
900 __le16_to_cpup(&
ctrl.wIndex),
901 __le16_to_cpup(&
ctrl.wLength));
902 if (
ctrl.bRequestType & 0x80) {
908 pipe = usb_rcvctrlpipe(dev, 0);
911 usb_unlock_device(dev);
914 tbuf,
ctrl.wLength, tmo);
915 usb_lock_device(dev);
918 if ((i > 0) &&
ctrl.wLength) {
931 pipe = usb_sndctrlpipe(dev, 0);
935 usb_unlock_device(dev);
938 tbuf,
ctrl.wLength, tmo);
939 usb_lock_device(dev);
942 if (i < 0 && i != -
EPIPE) {
943 dev_printk(
KERN_DEBUG, &dev->dev,
"usbfs: USBDEVFS_CONTROL "
944 "failed cmd %s rqt %u rq %u len %u ret %d\n",
951 usbfs_decrease_memory_usage(
PAGE_SIZE +
sizeof(
struct urb) +
956 static int proc_bulk(
struct dev_state *ps,
void __user *arg)
958 struct usb_device *dev = ps->
dev;
960 unsigned int tmo, len1,
pipe;
967 ret = findintfep(ps->
dev, bulk.ep);
970 ret = checkintf(ps, ret);
974 pipe = usb_rcvbulkpipe(dev, bulk.ep & 0x7f);
976 pipe = usb_sndbulkpipe(dev, bulk.ep & 0x7f);
977 if (!usb_maxpacket(dev, pipe, !(bulk.ep &
USB_DIR_IN)))
982 ret = usbfs_increase_memory_usage(len1 +
sizeof(
struct urb));
990 if (bulk.ep & 0x80) {
997 usb_unlock_device(dev);
999 usb_lock_device(dev);
1000 snoop_urb(dev,
NULL, pipe, len2, i,
COMPLETE, tbuf, len2);
1015 snoop_urb(dev,
NULL, pipe, len1, tmo,
SUBMIT, tbuf, len1);
1017 usb_unlock_device(dev);
1019 usb_lock_device(dev);
1022 ret = (i < 0 ? i : len2);
1025 usbfs_decrease_memory_usage(len1 +
sizeof(
struct urb));
1029 static int proc_resetep(
struct dev_state *ps,
void __user *arg)
1034 if (
get_user(ep, (
unsigned int __user *)arg))
1036 ret = findintfep(ps->
dev, ep);
1039 ret = checkintf(ps, ret);
1046 static int proc_clearhalt(
struct dev_state *ps,
void __user *arg)
1052 if (
get_user(ep, (
unsigned int __user *)arg))
1054 ret = findintfep(ps->
dev, ep);
1057 ret = checkintf(ps, ret);
1061 pipe = usb_rcvbulkpipe(ps->
dev, ep & 0x7f);
1063 pipe = usb_sndbulkpipe(ps->
dev, ep & 0x7f);
1068 static int proc_getdriver(
struct dev_state *ps,
void __user *arg)
1077 if (!intf || !intf->dev.driver)
1080 strncpy(gd.driver, intf->dev.driver->name,
1087 static int proc_connectinfo(
struct dev_state *ps,
void __user *arg)
1099 static int proc_resetdevice(
struct dev_state *ps)
1104 static int proc_setintf(
struct dev_state *ps,
void __user *arg)
1111 if ((ret = checkintf(ps, setintf.interface)))
1114 setintf.altsetting);
1117 static int proc_setconfig(
struct dev_state *ps,
void __user *arg)
1121 struct usb_host_config *actconfig;
1123 if (
get_user(u, (
int __user *)arg))
1126 actconfig = ps->
dev->actconfig;
1135 for (i = 0; i < actconfig->desc.bNumInterfaces; ++
i) {
1136 if (usb_interface_claimed(actconfig->interface[i])) {
1138 "usbfs: interface %d claimed by %s "
1139 "while '%s' sets config #%d\n",
1140 actconfig->interface[i]
1142 ->desc.bInterfaceNumber,
1143 actconfig->interface[i]
1156 if (actconfig && actconfig->desc.bConfigurationValue == u)
1170 struct usb_host_endpoint *ep;
1173 unsigned int u,
totlen, isofrmlen;
1174 int i,
ret, is_in, num_sgs = 0, ifnum = -1;
1191 ret = checkintf(ps, ifnum);
1206 switch(uurb->
type) {
1208 if (!usb_endpoint_xfer_control(&ep->desc))
1238 snoop(&ps->
dev->dev,
"control urb: bRequestType=%02x "
1239 "bRequest=%02x wValue=%04x "
1240 "wIndex=%04x wLength=%04x\n",
1242 __le16_to_cpup(&dr->
wValue),
1243 __le16_to_cpup(&dr->
wIndex),
1244 __le16_to_cpup(&dr->
wLength));
1249 switch (usb_endpoint_type(&ep->desc)) {
1260 if (num_sgs == 1 || num_sgs > ps->
dev->bus->sg_tablesize)
1265 if (!usb_endpoint_xfer_int(&ep->desc))
1276 if (!usb_endpoint_xfer_isoc(&ep->desc))
1289 if (isopkt[u].length > 8192) {
1295 u *=
sizeof(
struct usb_iso_packet_descriptor);
1321 ret = usbfs_increase_memory_usage(u);
1333 as->
urb->num_sgs = num_sgs;
1337 for (i = 0; i < as->
urb->num_sgs; i++) {
1344 sg_set_buf(&as->
urb->sg[i], buf, u);
1358 if (!as->
urb->transfer_buffer) {
1382 as->
urb->pipe = (uurb->
type << 30) |
1390 u = (is_in ? URB_DIR_IN : URB_DIR_OUT);
1394 u |= URB_SHORT_NOT_OK;
1398 u |= URB_ZERO_PACKET;
1400 u |= URB_NO_INTERRUPT;
1401 as->
urb->transfer_flags =
u;
1404 as->
urb->setup_packet = (
unsigned char *)dr;
1410 as->
urb->interval = 1 <<
min(15, ep->desc.bInterval - 1);
1412 as->
urb->interval = ep->desc.bInterval;
1413 as->
urb->context =
as;
1414 as->
urb->complete = async_completed;
1417 as->
urb->iso_frame_desc[
u].length = isopkt[
u].
length;
1434 as->
urb->transfer_buffer_length, 0,
SUBMIT,
1437 snoop_urb_data(as->
urb, as->
urb->transfer_buffer_length);
1439 async_newpending(as);
1441 if (usb_endpoint_xfer_bulk(&ep->desc)) {
1442 spin_lock_irq(&ps->
lock);
1448 as->
bulk_addr = usb_endpoint_num(&ep->desc) |
1467 spin_unlock_irq(&ps->
lock);
1474 "usbfs: usb_submit_urb returned %d\n", ret);
1477 async_removepending(as);
1490 static int proc_submiturb(
struct dev_state *ps,
void __user *arg)
1497 return proc_do_submiturb(ps, &uurb,
1502 static int proc_unlinkurb(
struct dev_state *ps,
void __user *arg)
1506 unsigned long flags;
1509 as = async_getpending(ps, arg);
1511 spin_unlock_irqrestore(&ps->
lock, flags);
1517 spin_unlock_irqrestore(&ps->
lock, flags);
1525 static int processcompl(
struct async *as,
void __user * __user *arg)
1527 struct urb *urb = as->
urb;
1533 if (copy_urb_data_to_user(as->
userbuffer, urb))
1543 if (usb_endpoint_xfer_isoc(&urb->ep->desc)) {
1544 for (i = 0; i < urb->number_of_packets; i++) {
1545 if (
put_user(urb->iso_frame_desc[i].actual_length,
1548 if (
put_user(urb->iso_frame_desc[i].status,
1554 if (
put_user(addr, (
void __user * __user *)arg))
1566 struct usb_device *dev = ps->
dev;
1571 as = async_getcompleted(ps);
1576 usb_unlock_device(dev);
1578 usb_lock_device(dev);
1585 static int proc_reapurb(
struct dev_state *ps,
void __user *arg)
1587 struct async *as = reap_as(ps);
1589 int retval = processcompl(as, (
void __user * __user *)arg);
1598 static int proc_reapurbnonblock(
struct dev_state *ps,
void __user *arg)
1603 as = async_getcompleted(ps);
1606 retval = processcompl(as, (
void __user * __user *)arg);
1612 #ifdef CONFIG_COMPAT
1613 static int proc_control_compat(
struct dev_state *ps,
1614 struct usbdevfs_ctrltransfer32 __user *p32)
1623 return proc_control(ps, p);
1626 static int proc_bulk_compat(
struct dev_state *ps,
1627 struct usbdevfs_bulktransfer32 __user *p32)
1641 return proc_bulk(ps, p);
1643 static int proc_disconnectsignal_compat(
struct dev_state *ps,
void __user *arg)
1645 struct usbdevfs_disconnectsignal32
ds;
1655 struct usbdevfs_urb32 __user *uurb)
1658 if (!
access_ok(VERIFY_READ, uurb,
sizeof(*uurb)) ||
1673 kurb->
buffer = compat_ptr(uptr);
1681 static int proc_submiturb_compat(
struct dev_state *ps,
void __user *arg)
1685 if (get_urb32(&uurb, (
struct usbdevfs_urb32 __user *)arg))
1688 return proc_do_submiturb(ps, &uurb,
1689 ((
struct usbdevfs_urb32 __user *)arg)->iso_frame_desc,
1693 static int processcompl_compat(
struct async *as,
void __user * __user *arg)
1695 struct urb *urb = as->
urb;
1701 if (copy_urb_data_to_user(as->
userbuffer, urb))
1706 if (
put_user(urb->actual_length, &userurb->actual_length))
1708 if (
put_user(urb->error_count, &userurb->error_count))
1711 if (usb_endpoint_xfer_isoc(&urb->ep->desc)) {
1712 for (i = 0; i < urb->number_of_packets; i++) {
1713 if (
put_user(urb->iso_frame_desc[i].actual_length,
1714 &userurb->iso_frame_desc[i].actual_length))
1716 if (
put_user(urb->iso_frame_desc[i].status,
1717 &userurb->iso_frame_desc[i].status))
1722 if (
put_user(ptr_to_compat(addr), (
u32 __user *)arg))
1727 static int proc_reapurb_compat(
struct dev_state *ps,
void __user *arg)
1729 struct async *as = reap_as(ps);
1731 int retval = processcompl_compat(as, (
void __user * __user *)arg);
1740 static int proc_reapurbnonblock_compat(
struct dev_state *ps,
void __user *arg)
1746 as = async_getcompleted(ps);
1748 retval = processcompl_compat(as, (
void __user * __user *)arg);
1757 static int proc_disconnectsignal(
struct dev_state *ps,
void __user *arg)
1768 static int proc_claiminterface(
struct dev_state *ps,
void __user *arg)
1772 if (
get_user(ifnum, (
unsigned int __user *)arg))
1774 return claimintf(ps, ifnum);
1777 static int proc_releaseinterface(
struct dev_state *ps,
void __user *arg)
1782 if (
get_user(ifnum, (
unsigned int __user *)arg))
1784 if ((ret = releaseintf(ps, ifnum)) < 0)
1786 destroy_async_on_interface (ps, ifnum);
1812 if (!connected(ps)) {
1825 if (intf->dev.driver) {
1826 driver = to_usb_driver(intf->dev.driver);
1827 dev_dbg(&intf->dev,
"disconnect by usbfs\n");
1835 if (!intf->dev.driver)
1843 if (intf->dev.driver)
1844 driver = to_usb_driver(intf->dev.driver);
1845 if (driver ==
NULL || driver->unlocked_ioctl ==
NULL) {
1848 retval = driver->unlocked_ioctl(intf, ctl->
ioctl_code, buf);
1865 static int proc_ioctl_default(
struct dev_state *ps,
void __user *arg)
1871 return proc_ioctl(ps, &
ctrl);
1874 #ifdef CONFIG_COMPAT
1881 uioc = compat_ptr((
long)arg);
1882 if (!
access_ok(VERIFY_READ, uioc,
sizeof(*uioc)) ||
1887 ctrl.data = compat_ptr(udata);
1889 return proc_ioctl(ps, &
ctrl);
1893 static int proc_claim_port(
struct dev_state *ps,
void __user *arg)
1898 if (
get_user(portnum, (
unsigned __user *) arg))
1902 snoop(&ps->
dev->dev,
"port %d claimed by process %d: %s\n",
1907 static int proc_release_port(
struct dev_state *ps,
void __user *arg)
1911 if (
get_user(portnum, (
unsigned __user *) arg))
1916 static int proc_get_capabilities(
struct dev_state *ps,
void __user *arg)
1921 if (!ps->
dev->bus->no_stop_on_short)
1923 if (ps->
dev->bus->sg_tablesize)
1932 static int proc_disconnect_claim(
struct dev_state *ps,
void __user *arg)
1944 if (intf->dev.driver) {
1945 struct usb_driver *driver = to_usb_driver(intf->dev.driver);
1948 strncmp(
dc.driver, intf->dev.driver->name,
1949 sizeof(
dc.driver)) != 0)
1953 strncmp(
dc.driver, intf->dev.driver->name,
1954 sizeof(
dc.driver)) == 0)
1957 dev_dbg(&intf->dev,
"disconnect by usbfs\n");
1961 return claimintf(ps,
dc.interface);
1969 static long usbdev_do_ioctl(
struct file *file,
unsigned int cmd,
1973 struct inode *inode = file->
f_path.dentry->d_inode;
1974 struct usb_device *dev = ps->
dev;
1980 usb_lock_device(dev);
1981 if (!connected(ps)) {
1982 usb_unlock_device(dev);
1988 snoop(&dev->dev,
"%s: CONTROL\n", __func__);
1989 ret = proc_control(ps, p);
1995 snoop(&dev->dev,
"%s: BULK\n", __func__);
1996 ret = proc_bulk(ps, p);
2002 snoop(&dev->dev,
"%s: RESETEP\n", __func__);
2003 ret = proc_resetep(ps, p);
2009 snoop(&dev->dev,
"%s: RESET\n", __func__);
2010 ret = proc_resetdevice(ps);
2014 snoop(&dev->dev,
"%s: CLEAR_HALT\n", __func__);
2015 ret = proc_clearhalt(ps, p);
2021 snoop(&dev->dev,
"%s: GETDRIVER\n", __func__);
2022 ret = proc_getdriver(ps, p);
2026 snoop(&dev->dev,
"%s: CONNECTINFO\n", __func__);
2027 ret = proc_connectinfo(ps, p);
2031 snoop(&dev->dev,
"%s: SETINTERFACE\n", __func__);
2032 ret = proc_setintf(ps, p);
2036 snoop(&dev->dev,
"%s: SETCONFIGURATION\n", __func__);
2037 ret = proc_setconfig(ps, p);
2041 snoop(&dev->dev,
"%s: SUBMITURB\n", __func__);
2042 ret = proc_submiturb(ps, p);
2047 #ifdef CONFIG_COMPAT
2049 snoop(&dev->dev,
"%s: CONTROL32\n", __func__);
2050 ret = proc_control_compat(ps, p);
2056 snoop(&dev->dev,
"%s: BULK32\n", __func__);
2057 ret = proc_bulk_compat(ps, p);
2063 snoop(&dev->dev,
"%s: DISCSIGNAL32\n", __func__);
2064 ret = proc_disconnectsignal_compat(ps, p);
2068 snoop(&dev->dev,
"%s: SUBMITURB32\n", __func__);
2069 ret = proc_submiturb_compat(ps, p);
2075 snoop(&dev->dev,
"%s: REAPURB32\n", __func__);
2076 ret = proc_reapurb_compat(ps, p);
2080 snoop(&dev->dev,
"%s: REAPURBNDELAY32\n", __func__);
2081 ret = proc_reapurbnonblock_compat(ps, p);
2085 snoop(&dev->dev,
"%s: IOCTL32\n", __func__);
2086 ret = proc_ioctl_compat(ps, ptr_to_compat(p));
2091 snoop(&dev->dev,
"%s: DISCARDURB\n", __func__);
2092 ret = proc_unlinkurb(ps, p);
2096 snoop(&dev->dev,
"%s: REAPURB\n", __func__);
2097 ret = proc_reapurb(ps, p);
2101 snoop(&dev->dev,
"%s: REAPURBNDELAY\n", __func__);
2102 ret = proc_reapurbnonblock(ps, p);
2106 snoop(&dev->dev,
"%s: DISCSIGNAL\n", __func__);
2107 ret = proc_disconnectsignal(ps, p);
2111 snoop(&dev->dev,
"%s: CLAIMINTERFACE\n", __func__);
2112 ret = proc_claiminterface(ps, p);
2116 snoop(&dev->dev,
"%s: RELEASEINTERFACE\n", __func__);
2117 ret = proc_releaseinterface(ps, p);
2121 snoop(&dev->dev,
"%s: IOCTL\n", __func__);
2122 ret = proc_ioctl_default(ps, p);
2126 snoop(&dev->dev,
"%s: CLAIM_PORT\n", __func__);
2127 ret = proc_claim_port(ps, p);
2131 snoop(&dev->dev,
"%s: RELEASE_PORT\n", __func__);
2132 ret = proc_release_port(ps, p);
2135 ret = proc_get_capabilities(ps, p);
2138 ret = proc_disconnect_claim(ps, p);
2141 usb_unlock_device(dev);
2147 static long usbdev_ioctl(
struct file *file,
unsigned int cmd,
2152 ret = usbdev_do_ioctl(file, cmd, (
void __user *)arg);
2157 #ifdef CONFIG_COMPAT
2158 static long usbdev_compat_ioctl(
struct file *file,
unsigned int cmd,
2163 ret = usbdev_do_ioctl(file, cmd, compat_ptr(arg));
2170 static unsigned int usbdev_poll(
struct file *file,
2174 unsigned int mask = 0;
2176 poll_wait(file, &ps->
wait, wait);
2186 .llseek = usbdev_lseek,
2187 .read = usbdev_read,
2188 .poll = usbdev_poll,
2189 .unlocked_ioctl = usbdev_ioctl,
2190 #ifdef CONFIG_COMPAT
2191 .compat_ioctl = usbdev_compat_ioctl,
2193 .open = usbdev_open,
2194 .release = usbdev_release,
2197 static void usbdev_remove(
struct usb_device *udev)
2202 while (!list_empty(&udev->filelist)) {
2204 destroy_all_async(ps);
2206 list_del_init(&ps->
list);
2219 unsigned long action,
void *dev)
2222 case USB_DEVICE_ADD:
2224 case USB_DEVICE_REMOVE:
2232 .notifier_call = usbdev_notify,
2235 static struct cdev usb_device_cdev;
2247 cdev_init(&usb_device_cdev, &usbdev_file_operations);