Lines Matching refs:ps
91 struct usb_dev_state *ps; member
96 struct usb_dev_state *ps; member
180 static int connected(struct usb_dev_state *ps) in connected() argument
182 return (!list_empty(&ps->list) && in connected()
183 ps->dev->state != USB_STATE_NOTATTACHED); in connected()
188 struct usb_dev_state *ps = usbm->ps; in dec_usb_memory_use_count() local
191 spin_lock_irqsave(&ps->lock, flags); in dec_usb_memory_use_count()
195 spin_unlock_irqrestore(&ps->lock, flags); in dec_usb_memory_use_count()
197 usb_free_coherent(ps->dev, usbm->size, usbm->mem, in dec_usb_memory_use_count()
203 spin_unlock_irqrestore(&ps->lock, flags); in dec_usb_memory_use_count()
212 spin_lock_irqsave(&usbm->ps->lock, flags); in usbdev_vm_open()
214 spin_unlock_irqrestore(&usbm->ps->lock, flags); in usbdev_vm_open()
232 struct usb_dev_state *ps = file->private_data; in usbdev_mmap() local
233 struct usb_hcd *hcd = bus_to_hcd(ps->dev->bus); in usbdev_mmap()
250 mem = usb_alloc_coherent(ps->dev, size, GFP_USER | __GFP_NOWARN, in usbdev_mmap()
262 usbm->ps = ps; in usbdev_mmap()
287 spin_lock_irqsave(&ps->lock, flags); in usbdev_mmap()
288 list_add_tail(&usbm->memlist, &ps->memory_list); in usbdev_mmap()
289 spin_unlock_irqrestore(&ps->lock, flags); in usbdev_mmap()
304 struct usb_dev_state *ps = file->private_data; in usbdev_read() local
305 struct usb_device *dev = ps->dev; in usbdev_read()
313 if (!connected(ps)) { in usbdev_read()
432 struct usb_dev_state *ps = as->ps; in async_newpending() local
435 spin_lock_irqsave(&ps->lock, flags); in async_newpending()
436 list_add_tail(&as->asynclist, &ps->async_pending); in async_newpending()
437 spin_unlock_irqrestore(&ps->lock, flags); in async_newpending()
442 struct usb_dev_state *ps = as->ps; in async_removepending() local
445 spin_lock_irqsave(&ps->lock, flags); in async_removepending()
447 spin_unlock_irqrestore(&ps->lock, flags); in async_removepending()
450 static struct async *async_getcompleted(struct usb_dev_state *ps) in async_getcompleted() argument
455 spin_lock_irqsave(&ps->lock, flags); in async_getcompleted()
456 if (!list_empty(&ps->async_completed)) { in async_getcompleted()
457 as = list_entry(ps->async_completed.next, struct async, in async_getcompleted()
461 spin_unlock_irqrestore(&ps->lock, flags); in async_getcompleted()
465 static struct async *async_getpending(struct usb_dev_state *ps, in async_getpending() argument
470 list_for_each_entry(as, &ps->async_pending, asynclist) in async_getpending()
575 static void cancel_bulk_urbs(struct usb_dev_state *ps, unsigned bulk_addr) in cancel_bulk_urbs() argument
576 __releases(ps->lock) in cancel_bulk_urbs()
577 __acquires(ps->lock) in cancel_bulk_urbs()
587 list_for_each_entry(as, &ps->async_pending, asynclist) { in cancel_bulk_urbs()
595 ps->disabled_bulk_eps |= (1 << bulk_addr); in cancel_bulk_urbs()
599 list_for_each_entry_reverse(as, &ps->async_pending, asynclist) { in cancel_bulk_urbs()
604 spin_unlock(&ps->lock); /* Allow completions */ in cancel_bulk_urbs()
607 spin_lock(&ps->lock); in cancel_bulk_urbs()
616 struct usb_dev_state *ps = as->ps; in async_completed() local
623 spin_lock_irqsave(&ps->lock, flags); in async_completed()
624 list_move_tail(&as->asynclist, &ps->async_completed); in async_completed()
641 cancel_bulk_urbs(ps, as->bulk_addr); in async_completed()
643 wake_up(&ps->wait); in async_completed()
644 spin_unlock_irqrestore(&ps->lock, flags); in async_completed()
653 static void destroy_async(struct usb_dev_state *ps, struct list_head *list) in destroy_async() argument
659 spin_lock_irqsave(&ps->lock, flags); in destroy_async()
667 spin_unlock_irqrestore(&ps->lock, flags); in destroy_async()
670 spin_lock_irqsave(&ps->lock, flags); in destroy_async()
672 spin_unlock_irqrestore(&ps->lock, flags); in destroy_async()
675 static void destroy_async_on_interface(struct usb_dev_state *ps, in destroy_async_on_interface() argument
682 spin_lock_irqsave(&ps->lock, flags); in destroy_async_on_interface()
683 list_for_each_safe(p, q, &ps->async_pending) in destroy_async_on_interface()
686 spin_unlock_irqrestore(&ps->lock, flags); in destroy_async_on_interface()
687 destroy_async(ps, &hitlist); in destroy_async_on_interface()
690 static void destroy_all_async(struct usb_dev_state *ps) in destroy_all_async() argument
692 destroy_async(ps, &ps->async_pending); in destroy_all_async()
709 struct usb_dev_state *ps = usb_get_intfdata(intf); in driver_disconnect() local
712 if (!ps) in driver_disconnect()
719 if (likely(ifnum < 8*sizeof(ps->ifclaimed))) in driver_disconnect()
720 clear_bit(ifnum, &ps->ifclaimed); in driver_disconnect()
728 destroy_async_on_interface(ps, ifnum); in driver_disconnect()
750 struct usb_dev_state *ps; in usbfs_notify_resume() local
754 list_for_each_entry(ps, &udev->filelist, list) { in usbfs_notify_resume()
755 WRITE_ONCE(ps->not_yet_resumed, 0); in usbfs_notify_resume()
756 wake_up_all(&ps->wait_for_resume); in usbfs_notify_resume()
770 static int claimintf(struct usb_dev_state *ps, unsigned int ifnum) in claimintf() argument
772 struct usb_device *dev = ps->dev; in claimintf()
776 if (ifnum >= 8*sizeof(ps->ifclaimed)) in claimintf()
779 if (test_bit(ifnum, &ps->ifclaimed)) in claimintf()
782 if (ps->privileges_dropped && in claimintf()
783 !test_bit(ifnum, &ps->interface_allowed_mask)) in claimintf()
795 err = usb_driver_claim_interface(&usbfs_driver, intf, ps); in claimintf()
799 set_bit(ifnum, &ps->ifclaimed); in claimintf()
803 static int releaseintf(struct usb_dev_state *ps, unsigned int ifnum) in releaseintf() argument
810 if (ifnum >= 8*sizeof(ps->ifclaimed)) in releaseintf()
812 dev = ps->dev; in releaseintf()
816 else if (test_and_clear_bit(ifnum, &ps->ifclaimed)) { in releaseintf()
829 static int checkintf(struct usb_dev_state *ps, unsigned int ifnum) in checkintf() argument
831 if (ps->dev->state != USB_STATE_CONFIGURED) in checkintf()
833 if (ifnum >= 8*sizeof(ps->ifclaimed)) in checkintf()
835 if (test_bit(ifnum, &ps->ifclaimed)) in checkintf()
838 dev_warn(&ps->dev->dev, "usbfs: process %d (%s) did not claim " in checkintf()
841 return claimintf(ps, ifnum); in checkintf()
869 static int check_ctrlrecip(struct usb_dev_state *ps, unsigned int requesttype, in check_ctrlrecip() argument
875 if (ps->dev->state != USB_STATE_UNAUTHENTICATED in check_ctrlrecip()
876 && ps->dev->state != USB_STATE_ADDRESS in check_ctrlrecip()
877 && ps->dev->state != USB_STATE_CONFIGURED) in check_ctrlrecip()
888 alt_setting = usb_find_alt_setting(ps->dev->actconfig, in check_ctrlrecip()
900 ret = findintfep(ps->dev, index); in check_ctrlrecip()
910 ret = findintfep(ps->dev, index ^ 0x80); in check_ctrlrecip()
912 dev_info(&ps->dev->dev, in check_ctrlrecip()
918 ret = checkintf(ps, ret); in check_ctrlrecip()
922 ret = checkintf(ps, index); in check_ctrlrecip()
937 static int parse_usbdevfs_streams(struct usb_dev_state *ps, in parse_usbdevfs_streams() argument
970 eps[i] = ep_to_host_endpoint(ps->dev, ep); in parse_usbdevfs_streams()
977 ifnum = findintfep(ps->dev, ep); in parse_usbdevfs_streams()
984 ret = checkintf(ps, ifnum); in parse_usbdevfs_streams()
987 intf = usb_ifnum_to_if(ps->dev, ifnum); in parse_usbdevfs_streams()
1026 struct usb_dev_state *ps; in usbdev_open() local
1030 ps = kzalloc(sizeof(struct usb_dev_state), GFP_KERNEL); in usbdev_open()
1031 if (!ps) in usbdev_open()
1050 ps->dev = dev; in usbdev_open()
1051 ps->file = file; in usbdev_open()
1052 ps->interface_allowed_mask = 0xFFFFFFFF; /* 32 bits */ in usbdev_open()
1053 spin_lock_init(&ps->lock); in usbdev_open()
1054 INIT_LIST_HEAD(&ps->list); in usbdev_open()
1055 INIT_LIST_HEAD(&ps->async_pending); in usbdev_open()
1056 INIT_LIST_HEAD(&ps->async_completed); in usbdev_open()
1057 INIT_LIST_HEAD(&ps->memory_list); in usbdev_open()
1058 init_waitqueue_head(&ps->wait); in usbdev_open()
1059 init_waitqueue_head(&ps->wait_for_resume); in usbdev_open()
1060 ps->disc_pid = get_pid(task_pid(current)); in usbdev_open()
1061 ps->cred = get_current_cred(); in usbdev_open()
1065 list_add_tail(&ps->list, &dev->filelist); in usbdev_open()
1066 file->private_data = ps; in usbdev_open()
1076 kfree(ps); in usbdev_open()
1082 struct usb_dev_state *ps = file->private_data; in usbdev_release() local
1083 struct usb_device *dev = ps->dev; in usbdev_release()
1088 usb_hub_release_all_ports(dev, ps); in usbdev_release()
1092 list_del_init(&ps->list); in usbdev_release()
1095 for (ifnum = 0; ps->ifclaimed && ifnum < 8*sizeof(ps->ifclaimed); in usbdev_release()
1097 if (test_bit(ifnum, &ps->ifclaimed)) in usbdev_release()
1098 releaseintf(ps, ifnum); in usbdev_release()
1100 destroy_all_async(ps); in usbdev_release()
1101 if (!ps->suspend_allowed) in usbdev_release()
1105 put_pid(ps->disc_pid); in usbdev_release()
1106 put_cred(ps->cred); in usbdev_release()
1108 as = async_getcompleted(ps); in usbdev_release()
1111 as = async_getcompleted(ps); in usbdev_release()
1114 kfree(ps); in usbdev_release()
1157 static int do_proc_control(struct usb_dev_state *ps, in do_proc_control() argument
1160 struct usb_device *dev = ps->dev; in do_proc_control()
1168 ret = check_ctrlrecip(ps, ctrl->bRequestType, ctrl->bRequest, in do_proc_control()
1262 static int proc_control(struct usb_dev_state *ps, void __user *arg) in proc_control() argument
1268 return do_proc_control(ps, &ctrl); in proc_control()
1271 static int do_proc_bulk(struct usb_dev_state *ps, in do_proc_bulk() argument
1274 struct usb_device *dev = ps->dev; in do_proc_bulk()
1281 ret = findintfep(ps->dev, bulk->ep); in do_proc_bulk()
1284 ret = checkintf(ps, ret); in do_proc_bulk()
1361 static int proc_bulk(struct usb_dev_state *ps, void __user *arg) in proc_bulk() argument
1367 return do_proc_bulk(ps, &bulk); in proc_bulk()
1384 static int proc_resetep(struct usb_dev_state *ps, void __user *arg) in proc_resetep() argument
1391 ret = findintfep(ps->dev, ep); in proc_resetep()
1394 ret = checkintf(ps, ret); in proc_resetep()
1397 check_reset_of_active_ep(ps->dev, ep, "RESETEP"); in proc_resetep()
1398 usb_reset_endpoint(ps->dev, ep); in proc_resetep()
1402 static int proc_clearhalt(struct usb_dev_state *ps, void __user *arg) in proc_clearhalt() argument
1410 ret = findintfep(ps->dev, ep); in proc_clearhalt()
1413 ret = checkintf(ps, ret); in proc_clearhalt()
1416 check_reset_of_active_ep(ps->dev, ep, "CLEAR_HALT"); in proc_clearhalt()
1418 pipe = usb_rcvbulkpipe(ps->dev, ep & 0x7f); in proc_clearhalt()
1420 pipe = usb_sndbulkpipe(ps->dev, ep & 0x7f); in proc_clearhalt()
1422 return usb_clear_halt(ps->dev, pipe); in proc_clearhalt()
1425 static int proc_getdriver(struct usb_dev_state *ps, void __user *arg) in proc_getdriver() argument
1433 intf = usb_ifnum_to_if(ps->dev, gd.interface); in proc_getdriver()
1444 static int proc_connectinfo(struct usb_dev_state *ps, void __user *arg) in proc_connectinfo() argument
1449 ci.devnum = ps->dev->devnum; in proc_connectinfo()
1450 ci.slow = ps->dev->speed == USB_SPEED_LOW; in proc_connectinfo()
1457 static int proc_conninfo_ex(struct usb_dev_state *ps, in proc_conninfo_ex() argument
1461 struct usb_device *udev = ps->dev; in proc_conninfo_ex()
1490 static int proc_resetdevice(struct usb_dev_state *ps) in proc_resetdevice() argument
1492 struct usb_host_config *actconfig = ps->dev->actconfig; in proc_resetdevice()
1500 if (ps->privileges_dropped && actconfig) { in proc_resetdevice()
1505 !test_bit(number, &ps->ifclaimed)) { in proc_resetdevice()
1506 dev_warn(&ps->dev->dev, in proc_resetdevice()
1514 return usb_reset_device(ps->dev); in proc_resetdevice()
1517 static int proc_setintf(struct usb_dev_state *ps, void __user *arg) in proc_setintf() argument
1524 ret = checkintf(ps, setintf.interface); in proc_setintf()
1528 destroy_async_on_interface(ps, setintf.interface); in proc_setintf()
1530 return usb_set_interface(ps->dev, setintf.interface, in proc_setintf()
1534 static int proc_setconfig(struct usb_dev_state *ps, void __user *arg) in proc_setconfig() argument
1543 actconfig = ps->dev->actconfig; in proc_setconfig()
1554 dev_warn(&ps->dev->dev, in proc_setconfig()
1574 status = usb_reset_configuration(ps->dev); in proc_setconfig()
1576 status = usb_set_configuration(ps->dev, u); in proc_setconfig()
1583 find_memory_area(struct usb_dev_state *ps, const struct usbdevfs_urb *uurb) in find_memory_area() argument
1589 spin_lock_irqsave(&ps->lock, flags); in find_memory_area()
1590 list_for_each_entry(iter, &ps->memory_list, memlist) { in find_memory_area()
1603 spin_unlock_irqrestore(&ps->lock, flags); in find_memory_area()
1607 static int proc_do_submiturb(struct usb_dev_state *ps, struct usbdevfs_urb *uurb, in proc_do_submiturb() argument
1641 ifnum = findintfep(ps->dev, uurb->endpoint); in proc_do_submiturb()
1644 ret = checkintf(ps, ifnum); in proc_do_submiturb()
1648 ep = ep_to_host_endpoint(ps->dev, uurb->endpoint); in proc_do_submiturb()
1672 ret = check_ctrlrecip(ps, dr->bRequestType, dr->bRequest, in proc_do_submiturb()
1687 snoop(&ps->dev->dev, "control urb: bRequestType=%02x " in proc_do_submiturb()
1712 if (num_sgs == 1 || num_sgs > ps->dev->bus->sg_tablesize) in proc_do_submiturb()
1774 as->usbm = find_memory_area(ps, uurb); in proc_do_submiturb()
1857 as->urb->dev = ps->dev; in proc_do_submiturb()
1859 __create_pipe(ps->dev, uurb->endpoint & 0xf) | in proc_do_submiturb()
1878 dev_warn(&ps->dev->dev, "Requested nonsensical USBDEVFS_URB_SHORT_NOT_OK.\n"); in proc_do_submiturb()
1880 dev_warn(&ps->dev->dev, "Requested nonsensical USBDEVFS_URB_ZERO_PACKET.\n"); in proc_do_submiturb()
1891 ps->dev->speed == USB_SPEED_HIGH || in proc_do_submiturb()
1892 ps->dev->speed >= USB_SPEED_SUPER) in proc_do_submiturb()
1908 as->ps = ps; in proc_do_submiturb()
1923 snoop_urb(ps->dev, as->userurb, as->urb->pipe, in proc_do_submiturb()
1932 spin_lock_irq(&ps->lock); in proc_do_submiturb()
1948 ps->disabled_bulk_eps &= ~(1 << as->bulk_addr); in proc_do_submiturb()
1953 if (ps->disabled_bulk_eps & (1 << as->bulk_addr)) in proc_do_submiturb()
1957 spin_unlock_irq(&ps->lock); in proc_do_submiturb()
1963 dev_printk(KERN_DEBUG, &ps->dev->dev, in proc_do_submiturb()
1965 snoop_urb(ps->dev, as->userurb, as->urb->pipe, in proc_do_submiturb()
1980 static int proc_submiturb(struct usb_dev_state *ps, void __user *arg) in proc_submiturb() argument
1991 return proc_do_submiturb(ps, &uurb, in proc_submiturb()
1996 static int proc_unlinkurb(struct usb_dev_state *ps, void __user *arg) in proc_unlinkurb() argument
2002 spin_lock_irqsave(&ps->lock, flags); in proc_unlinkurb()
2003 as = async_getpending(ps, arg); in proc_unlinkurb()
2005 spin_unlock_irqrestore(&ps->lock, flags); in proc_unlinkurb()
2011 spin_unlock_irqrestore(&ps->lock, flags); in proc_unlinkurb()
2069 static struct async *reap_as(struct usb_dev_state *ps) in reap_as() argument
2073 struct usb_device *dev = ps->dev; in reap_as()
2075 add_wait_queue(&ps->wait, &wait); in reap_as()
2078 as = async_getcompleted(ps); in reap_as()
2079 if (as || !connected(ps)) in reap_as()
2087 remove_wait_queue(&ps->wait, &wait); in reap_as()
2092 static int proc_reapurb(struct usb_dev_state *ps, void __user *arg) in proc_reapurb() argument
2094 struct async *as = reap_as(ps); in proc_reapurb()
2099 snoop(&ps->dev->dev, "reap %px\n", as->userurb); in proc_reapurb()
2109 static int proc_reapurbnonblock(struct usb_dev_state *ps, void __user *arg) in proc_reapurbnonblock() argument
2114 as = async_getcompleted(ps); in proc_reapurbnonblock()
2116 snoop(&ps->dev->dev, "reap %px\n", as->userurb); in proc_reapurbnonblock()
2120 retval = (connected(ps) ? -EAGAIN : -ENODEV); in proc_reapurbnonblock()
2126 static int proc_control_compat(struct usb_dev_state *ps, in proc_control_compat() argument
2136 return do_proc_control(ps, &ctrl); in proc_control_compat()
2139 static int proc_bulk_compat(struct usb_dev_state *ps, in proc_bulk_compat() argument
2151 return do_proc_bulk(ps, &bulk); in proc_bulk_compat()
2154 static int proc_disconnectsignal_compat(struct usb_dev_state *ps, void __user *arg) in proc_disconnectsignal_compat() argument
2160 ps->discsignr = ds.signr; in proc_disconnectsignal_compat()
2161 ps->disccontext.sival_int = ds.context; in proc_disconnectsignal_compat()
2186 static int proc_submiturb_compat(struct usb_dev_state *ps, void __user *arg) in proc_submiturb_compat() argument
2197 return proc_do_submiturb(ps, &uurb, in proc_submiturb_compat()
2237 static int proc_reapurb_compat(struct usb_dev_state *ps, void __user *arg) in proc_reapurb_compat() argument
2239 struct async *as = reap_as(ps); in proc_reapurb_compat()
2244 snoop(&ps->dev->dev, "reap %px\n", as->userurb); in proc_reapurb_compat()
2254 static int proc_reapurbnonblock_compat(struct usb_dev_state *ps, void __user *arg) in proc_reapurbnonblock_compat() argument
2259 as = async_getcompleted(ps); in proc_reapurbnonblock_compat()
2261 snoop(&ps->dev->dev, "reap %px\n", as->userurb); in proc_reapurbnonblock_compat()
2265 retval = (connected(ps) ? -EAGAIN : -ENODEV); in proc_reapurbnonblock_compat()
2273 static int proc_disconnectsignal(struct usb_dev_state *ps, void __user *arg) in proc_disconnectsignal() argument
2279 ps->discsignr = ds.signr; in proc_disconnectsignal()
2280 ps->disccontext.sival_ptr = ds.context; in proc_disconnectsignal()
2284 static int proc_claiminterface(struct usb_dev_state *ps, void __user *arg) in proc_claiminterface() argument
2290 return claimintf(ps, ifnum); in proc_claiminterface()
2293 static int proc_releaseinterface(struct usb_dev_state *ps, void __user *arg) in proc_releaseinterface() argument
2300 ret = releaseintf(ps, ifnum); in proc_releaseinterface()
2303 destroy_async_on_interface(ps, ifnum); in proc_releaseinterface()
2307 static int proc_ioctl(struct usb_dev_state *ps, struct usbdevfs_ioctl *ctl) in proc_ioctl() argument
2315 if (ps->privileges_dropped) in proc_ioctl()
2318 if (!connected(ps)) in proc_ioctl()
2337 if (ps->dev->state != USB_STATE_CONFIGURED) in proc_ioctl()
2339 else if (!(intf = usb_ifnum_to_if(ps->dev, ctl->ifno))) in proc_ioctl()
2385 static int proc_ioctl_default(struct usb_dev_state *ps, void __user *arg) in proc_ioctl_default() argument
2391 return proc_ioctl(ps, &ctrl); in proc_ioctl_default()
2395 static int proc_ioctl_compat(struct usb_dev_state *ps, compat_uptr_t arg) in proc_ioctl_compat() argument
2405 return proc_ioctl(ps, &ctrl); in proc_ioctl_compat()
2409 static int proc_claim_port(struct usb_dev_state *ps, void __user *arg) in proc_claim_port() argument
2416 rc = usb_hub_claim_port(ps->dev, portnum, ps); in proc_claim_port()
2418 snoop(&ps->dev->dev, "port %d claimed by process %d: %s\n", in proc_claim_port()
2423 static int proc_release_port(struct usb_dev_state *ps, void __user *arg) in proc_release_port() argument
2429 return usb_hub_release_port(ps->dev, portnum, ps); in proc_release_port()
2432 static int proc_get_capabilities(struct usb_dev_state *ps, void __user *arg) in proc_get_capabilities() argument
2440 if (!ps->dev->bus->no_stop_on_short) in proc_get_capabilities()
2442 if (ps->dev->bus->sg_tablesize) in proc_get_capabilities()
2451 static int proc_disconnect_claim(struct usb_dev_state *ps, void __user *arg) in proc_disconnect_claim() argument
2459 intf = usb_ifnum_to_if(ps->dev, dc.interface); in proc_disconnect_claim()
2466 if (ps->privileges_dropped) in proc_disconnect_claim()
2483 return claimintf(ps, dc.interface); in proc_disconnect_claim()
2486 static int proc_alloc_streams(struct usb_dev_state *ps, void __user *arg) in proc_alloc_streams() argument
2493 r = parse_usbdevfs_streams(ps, arg, &num_streams, &num_eps, in proc_alloc_streams()
2498 destroy_async_on_interface(ps, in proc_alloc_streams()
2506 static int proc_free_streams(struct usb_dev_state *ps, void __user *arg) in proc_free_streams() argument
2513 r = parse_usbdevfs_streams(ps, arg, NULL, &num_eps, &eps, &intf); in proc_free_streams()
2517 destroy_async_on_interface(ps, in proc_free_streams()
2525 static int proc_drop_privileges(struct usb_dev_state *ps, void __user *arg) in proc_drop_privileges() argument
2536 ps->interface_allowed_mask &= data; in proc_drop_privileges()
2537 ps->privileges_dropped = true; in proc_drop_privileges()
2542 static int proc_forbid_suspend(struct usb_dev_state *ps) in proc_forbid_suspend() argument
2546 if (ps->suspend_allowed) { in proc_forbid_suspend()
2547 ret = usb_autoresume_device(ps->dev); in proc_forbid_suspend()
2549 ps->suspend_allowed = false; in proc_forbid_suspend()
2556 static int proc_allow_suspend(struct usb_dev_state *ps) in proc_allow_suspend() argument
2558 if (!connected(ps)) in proc_allow_suspend()
2561 WRITE_ONCE(ps->not_yet_resumed, 1); in proc_allow_suspend()
2562 if (!ps->suspend_allowed) { in proc_allow_suspend()
2563 usb_autosuspend_device(ps->dev); in proc_allow_suspend()
2564 ps->suspend_allowed = true; in proc_allow_suspend()
2569 static int proc_wait_for_resume(struct usb_dev_state *ps) in proc_wait_for_resume() argument
2573 usb_unlock_device(ps->dev); in proc_wait_for_resume()
2574 ret = wait_event_interruptible(ps->wait_for_resume, in proc_wait_for_resume()
2575 READ_ONCE(ps->not_yet_resumed) == 0); in proc_wait_for_resume()
2576 usb_lock_device(ps->dev); in proc_wait_for_resume()
2580 return proc_forbid_suspend(ps); in proc_wait_for_resume()
2591 struct usb_dev_state *ps = file->private_data; in usbdev_do_ioctl() local
2593 struct usb_device *dev = ps->dev; in usbdev_do_ioctl()
2605 ret = proc_reapurb(ps, p); in usbdev_do_ioctl()
2610 ret = proc_reapurbnonblock(ps, p); in usbdev_do_ioctl()
2616 ret = proc_reapurb_compat(ps, p); in usbdev_do_ioctl()
2621 ret = proc_reapurbnonblock_compat(ps, p); in usbdev_do_ioctl()
2626 if (!connected(ps)) { in usbdev_do_ioctl()
2634 ret = proc_control(ps, p); in usbdev_do_ioctl()
2641 ret = proc_bulk(ps, p); in usbdev_do_ioctl()
2648 ret = proc_resetep(ps, p); in usbdev_do_ioctl()
2655 ret = proc_resetdevice(ps); in usbdev_do_ioctl()
2660 ret = proc_clearhalt(ps, p); in usbdev_do_ioctl()
2667 ret = proc_getdriver(ps, p); in usbdev_do_ioctl()
2672 ret = proc_connectinfo(ps, p); in usbdev_do_ioctl()
2677 ret = proc_setintf(ps, p); in usbdev_do_ioctl()
2682 ret = proc_setconfig(ps, p); in usbdev_do_ioctl()
2687 ret = proc_submiturb(ps, p); in usbdev_do_ioctl()
2695 ret = proc_control_compat(ps, p); in usbdev_do_ioctl()
2702 ret = proc_bulk_compat(ps, p); in usbdev_do_ioctl()
2709 ret = proc_disconnectsignal_compat(ps, p); in usbdev_do_ioctl()
2714 ret = proc_submiturb_compat(ps, p); in usbdev_do_ioctl()
2721 ret = proc_ioctl_compat(ps, ptr_to_compat(p)); in usbdev_do_ioctl()
2727 ret = proc_unlinkurb(ps, p); in usbdev_do_ioctl()
2732 ret = proc_disconnectsignal(ps, p); in usbdev_do_ioctl()
2737 ret = proc_claiminterface(ps, p); in usbdev_do_ioctl()
2742 ret = proc_releaseinterface(ps, p); in usbdev_do_ioctl()
2747 ret = proc_ioctl_default(ps, p); in usbdev_do_ioctl()
2752 ret = proc_claim_port(ps, p); in usbdev_do_ioctl()
2757 ret = proc_release_port(ps, p); in usbdev_do_ioctl()
2760 ret = proc_get_capabilities(ps, p); in usbdev_do_ioctl()
2763 ret = proc_disconnect_claim(ps, p); in usbdev_do_ioctl()
2766 ret = proc_alloc_streams(ps, p); in usbdev_do_ioctl()
2769 ret = proc_free_streams(ps, p); in usbdev_do_ioctl()
2772 ret = proc_drop_privileges(ps, p); in usbdev_do_ioctl()
2775 ret = ps->dev->speed; in usbdev_do_ioctl()
2778 ret = proc_forbid_suspend(ps); in usbdev_do_ioctl()
2781 ret = proc_allow_suspend(ps); in usbdev_do_ioctl()
2784 ret = proc_wait_for_resume(ps); in usbdev_do_ioctl()
2791 ret = proc_conninfo_ex(ps, p, _IOC_SIZE(cmd)); in usbdev_do_ioctl()
2816 struct usb_dev_state *ps = file->private_data; in usbdev_poll() local
2819 poll_wait(file, &ps->wait, wait); in usbdev_poll()
2820 if (file->f_mode & FMODE_WRITE && !list_empty(&ps->async_completed)) in usbdev_poll()
2822 if (!connected(ps)) in usbdev_poll()
2824 if (list_empty(&ps->list)) in usbdev_poll()
2843 struct usb_dev_state *ps; in usbdev_remove() local
2848 ps = list_entry(udev->filelist.next, struct usb_dev_state, list); in usbdev_remove()
2849 destroy_all_async(ps); in usbdev_remove()
2850 wake_up_all(&ps->wait); in usbdev_remove()
2851 WRITE_ONCE(ps->not_yet_resumed, 0); in usbdev_remove()
2852 wake_up_all(&ps->wait_for_resume); in usbdev_remove()
2853 list_del_init(&ps->list); in usbdev_remove()
2854 if (ps->discsignr) in usbdev_remove()
2855 kill_pid_usb_asyncio(ps->discsignr, EPIPE, ps->disccontext, in usbdev_remove()
2856 ps->disc_pid, ps->cred); in usbdev_remove()