Lines Matching full:ps
58 /* Mutual exclusion for ps->list in resume vs. release and remove */
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
189 struct usb_hcd *hcd = bus_to_hcd(ps->dev->bus); in dec_usb_memory_use_count()
192 spin_lock_irqsave(&ps->lock, flags); in dec_usb_memory_use_count()
196 spin_unlock_irqrestore(&ps->lock, flags); in dec_usb_memory_use_count()
204 spin_unlock_irqrestore(&ps->lock, flags); in dec_usb_memory_use_count()
213 spin_lock_irqsave(&usbm->ps->lock, flags); in usbdev_vm_open()
215 spin_unlock_irqrestore(&usbm->ps->lock, flags); in usbdev_vm_open()
233 struct usb_dev_state *ps = file->private_data; in usbdev_mmap() local
234 struct usb_hcd *hcd = bus_to_hcd(ps->dev->bus); in usbdev_mmap()
263 usbm->ps = ps; in usbdev_mmap()
294 spin_lock_irqsave(&ps->lock, flags); in usbdev_mmap()
295 list_add_tail(&usbm->memlist, &ps->memory_list); in usbdev_mmap()
296 spin_unlock_irqrestore(&ps->lock, flags); in usbdev_mmap()
311 struct usb_dev_state *ps = file->private_data; in usbdev_read() local
312 struct usb_device *dev = ps->dev; in usbdev_read()
320 if (!connected(ps)) { in usbdev_read()
439 struct usb_dev_state *ps = as->ps; in async_newpending() local
442 spin_lock_irqsave(&ps->lock, flags); in async_newpending()
443 list_add_tail(&as->asynclist, &ps->async_pending); in async_newpending()
444 spin_unlock_irqrestore(&ps->lock, flags); in async_newpending()
449 struct usb_dev_state *ps = as->ps; in async_removepending() local
452 spin_lock_irqsave(&ps->lock, flags); in async_removepending()
454 spin_unlock_irqrestore(&ps->lock, flags); in async_removepending()
457 static struct async *async_getcompleted(struct usb_dev_state *ps) in async_getcompleted() argument
462 spin_lock_irqsave(&ps->lock, flags); in async_getcompleted()
463 if (!list_empty(&ps->async_completed)) { in async_getcompleted()
464 as = list_entry(ps->async_completed.next, struct async, in async_getcompleted()
468 spin_unlock_irqrestore(&ps->lock, flags); in async_getcompleted()
472 static struct async *async_getpending(struct usb_dev_state *ps, in async_getpending() argument
477 list_for_each_entry(as, &ps->async_pending, asynclist) in async_getpending()
582 static void cancel_bulk_urbs(struct usb_dev_state *ps, unsigned bulk_addr) in cancel_bulk_urbs() argument
583 __releases(ps->lock) in cancel_bulk_urbs()
584 __acquires(ps->lock) in cancel_bulk_urbs()
594 list_for_each_entry(as, &ps->async_pending, asynclist) { in cancel_bulk_urbs()
602 ps->disabled_bulk_eps |= (1 << bulk_addr); in cancel_bulk_urbs()
606 list_for_each_entry_reverse(as, &ps->async_pending, asynclist) { in cancel_bulk_urbs()
611 spin_unlock(&ps->lock); /* Allow completions */ in cancel_bulk_urbs()
614 spin_lock(&ps->lock); in cancel_bulk_urbs()
623 struct usb_dev_state *ps = as->ps; in async_completed() local
630 spin_lock_irqsave(&ps->lock, flags); in async_completed()
631 list_move_tail(&as->asynclist, &ps->async_completed); in async_completed()
648 cancel_bulk_urbs(ps, as->bulk_addr); in async_completed()
650 wake_up(&ps->wait); in async_completed()
651 spin_unlock_irqrestore(&ps->lock, flags); in async_completed()
660 static void destroy_async(struct usb_dev_state *ps, struct list_head *list) in destroy_async() argument
666 spin_lock_irqsave(&ps->lock, flags); in destroy_async()
674 spin_unlock_irqrestore(&ps->lock, flags); in destroy_async()
677 spin_lock_irqsave(&ps->lock, flags); in destroy_async()
679 spin_unlock_irqrestore(&ps->lock, flags); in destroy_async()
682 static void destroy_async_on_interface(struct usb_dev_state *ps, in destroy_async_on_interface() argument
689 spin_lock_irqsave(&ps->lock, flags); in destroy_async_on_interface()
690 list_for_each_safe(p, q, &ps->async_pending) in destroy_async_on_interface()
693 spin_unlock_irqrestore(&ps->lock, flags); in destroy_async_on_interface()
694 destroy_async(ps, &hitlist); in destroy_async_on_interface()
697 static void destroy_all_async(struct usb_dev_state *ps) in destroy_all_async() argument
699 destroy_async(ps, &ps->async_pending); in destroy_all_async()
716 struct usb_dev_state *ps = usb_get_intfdata(intf); in driver_disconnect() local
719 if (!ps) in driver_disconnect()
726 if (likely(ifnum < 8*sizeof(ps->ifclaimed))) in driver_disconnect()
727 clear_bit(ifnum, &ps->ifclaimed); in driver_disconnect()
735 destroy_async_on_interface(ps, ifnum); in driver_disconnect()
758 struct usb_dev_state *ps; in usbfs_notify_resume() local
762 list_for_each_entry(ps, &udev->filelist, list) { in usbfs_notify_resume()
763 WRITE_ONCE(ps->not_yet_resumed, 0); in usbfs_notify_resume()
764 wake_up_all(&ps->wait_for_resume); in usbfs_notify_resume()
779 static int claimintf(struct usb_dev_state *ps, unsigned int ifnum) in claimintf() argument
781 struct usb_device *dev = ps->dev; in claimintf()
785 if (ifnum >= 8*sizeof(ps->ifclaimed)) in claimintf()
788 if (test_bit(ifnum, &ps->ifclaimed)) in claimintf()
791 if (ps->privileges_dropped && in claimintf()
792 !test_bit(ifnum, &ps->interface_allowed_mask)) in claimintf()
804 err = usb_driver_claim_interface(&usbfs_driver, intf, ps); in claimintf()
808 set_bit(ifnum, &ps->ifclaimed); in claimintf()
812 static int releaseintf(struct usb_dev_state *ps, unsigned int ifnum) in releaseintf() argument
819 if (ifnum >= 8*sizeof(ps->ifclaimed)) in releaseintf()
821 dev = ps->dev; in releaseintf()
825 else if (test_and_clear_bit(ifnum, &ps->ifclaimed)) { in releaseintf()
838 static int checkintf(struct usb_dev_state *ps, unsigned int ifnum) in checkintf() argument
840 if (ps->dev->state != USB_STATE_CONFIGURED) in checkintf()
842 if (ifnum >= 8*sizeof(ps->ifclaimed)) in checkintf()
844 if (test_bit(ifnum, &ps->ifclaimed)) in checkintf()
847 dev_warn(&ps->dev->dev, "usbfs: process %d (%s) did not claim " in checkintf()
850 return claimintf(ps, ifnum); in checkintf()
878 static int check_ctrlrecip(struct usb_dev_state *ps, unsigned int requesttype, in check_ctrlrecip() argument
884 if (ps->dev->state != USB_STATE_UNAUTHENTICATED in check_ctrlrecip()
885 && ps->dev->state != USB_STATE_ADDRESS in check_ctrlrecip()
886 && ps->dev->state != USB_STATE_CONFIGURED) in check_ctrlrecip()
897 alt_setting = usb_find_alt_setting(ps->dev->actconfig, in check_ctrlrecip()
909 ret = findintfep(ps->dev, index); in check_ctrlrecip()
919 ret = findintfep(ps->dev, index ^ 0x80); in check_ctrlrecip()
921 dev_info(&ps->dev->dev, in check_ctrlrecip()
927 ret = checkintf(ps, ret); in check_ctrlrecip()
931 ret = checkintf(ps, index); in check_ctrlrecip()
946 static int parse_usbdevfs_streams(struct usb_dev_state *ps, in parse_usbdevfs_streams() argument
979 eps[i] = ep_to_host_endpoint(ps->dev, ep); in parse_usbdevfs_streams()
986 ifnum = findintfep(ps->dev, ep); in parse_usbdevfs_streams()
993 ret = checkintf(ps, ifnum); in parse_usbdevfs_streams()
996 intf = usb_ifnum_to_if(ps->dev, ifnum); in parse_usbdevfs_streams()
1035 struct usb_dev_state *ps; in usbdev_open() local
1039 ps = kzalloc(sizeof(struct usb_dev_state), GFP_KERNEL); in usbdev_open()
1040 if (!ps) in usbdev_open()
1059 ps->dev = dev; in usbdev_open()
1060 ps->file = file; in usbdev_open()
1061 ps->interface_allowed_mask = 0xFFFFFFFF; /* 32 bits */ in usbdev_open()
1062 spin_lock_init(&ps->lock); in usbdev_open()
1063 INIT_LIST_HEAD(&ps->list); in usbdev_open()
1064 INIT_LIST_HEAD(&ps->async_pending); in usbdev_open()
1065 INIT_LIST_HEAD(&ps->async_completed); in usbdev_open()
1066 INIT_LIST_HEAD(&ps->memory_list); in usbdev_open()
1067 init_waitqueue_head(&ps->wait); in usbdev_open()
1068 init_waitqueue_head(&ps->wait_for_resume); in usbdev_open()
1069 ps->disc_pid = get_pid(task_pid(current)); in usbdev_open()
1070 ps->cred = get_current_cred(); in usbdev_open()
1074 list_add_tail(&ps->list, &dev->filelist); in usbdev_open()
1075 file->private_data = ps; in usbdev_open()
1085 kfree(ps); in usbdev_open()
1091 struct usb_dev_state *ps = file->private_data; in usbdev_release() local
1092 struct usb_device *dev = ps->dev; in usbdev_release()
1097 usb_hub_release_all_ports(dev, ps); in usbdev_release()
1101 list_del_init(&ps->list); in usbdev_release()
1104 for (ifnum = 0; ps->ifclaimed && ifnum < 8*sizeof(ps->ifclaimed); in usbdev_release()
1106 if (test_bit(ifnum, &ps->ifclaimed)) in usbdev_release()
1107 releaseintf(ps, ifnum); in usbdev_release()
1109 destroy_all_async(ps); in usbdev_release()
1110 if (!ps->suspend_allowed) in usbdev_release()
1114 put_pid(ps->disc_pid); in usbdev_release()
1115 put_cred(ps->cred); in usbdev_release()
1117 as = async_getcompleted(ps); in usbdev_release()
1120 as = async_getcompleted(ps); in usbdev_release()
1123 kfree(ps); in usbdev_release()
1166 static int do_proc_control(struct usb_dev_state *ps, in do_proc_control() argument
1169 struct usb_device *dev = ps->dev; in do_proc_control()
1177 ret = check_ctrlrecip(ps, ctrl->bRequestType, ctrl->bRequest, in do_proc_control()
1271 static int proc_control(struct usb_dev_state *ps, void __user *arg) in proc_control() argument
1277 return do_proc_control(ps, &ctrl); in proc_control()
1280 static int do_proc_bulk(struct usb_dev_state *ps, in do_proc_bulk() argument
1283 struct usb_device *dev = ps->dev; in do_proc_bulk()
1290 ret = findintfep(ps->dev, bulk->ep); in do_proc_bulk()
1293 ret = checkintf(ps, ret); in do_proc_bulk()
1370 static int proc_bulk(struct usb_dev_state *ps, void __user *arg) in proc_bulk() argument
1376 return do_proc_bulk(ps, &bulk); in proc_bulk()
1393 static int proc_resetep(struct usb_dev_state *ps, void __user *arg) in proc_resetep() argument
1400 ret = findintfep(ps->dev, ep); in proc_resetep()
1403 ret = checkintf(ps, ret); in proc_resetep()
1406 check_reset_of_active_ep(ps->dev, ep, "RESETEP"); in proc_resetep()
1407 usb_reset_endpoint(ps->dev, ep); in proc_resetep()
1411 static int proc_clearhalt(struct usb_dev_state *ps, void __user *arg) in proc_clearhalt() argument
1419 ret = findintfep(ps->dev, ep); in proc_clearhalt()
1422 ret = checkintf(ps, ret); in proc_clearhalt()
1425 check_reset_of_active_ep(ps->dev, ep, "CLEAR_HALT"); in proc_clearhalt()
1427 pipe = usb_rcvbulkpipe(ps->dev, ep & 0x7f); in proc_clearhalt()
1429 pipe = usb_sndbulkpipe(ps->dev, ep & 0x7f); in proc_clearhalt()
1431 return usb_clear_halt(ps->dev, pipe); in proc_clearhalt()
1434 static int proc_getdriver(struct usb_dev_state *ps, void __user *arg) in proc_getdriver() argument
1442 intf = usb_ifnum_to_if(ps->dev, gd.interface); in proc_getdriver()
1453 static int proc_connectinfo(struct usb_dev_state *ps, void __user *arg) in proc_connectinfo() argument
1458 ci.devnum = ps->dev->devnum; in proc_connectinfo()
1459 ci.slow = ps->dev->speed == USB_SPEED_LOW; in proc_connectinfo()
1466 static int proc_conninfo_ex(struct usb_dev_state *ps, in proc_conninfo_ex() argument
1470 struct usb_device *udev = ps->dev; in proc_conninfo_ex()
1499 static int proc_resetdevice(struct usb_dev_state *ps) in proc_resetdevice() argument
1501 struct usb_host_config *actconfig = ps->dev->actconfig; in proc_resetdevice()
1509 if (ps->privileges_dropped && actconfig) { in proc_resetdevice()
1514 !test_bit(number, &ps->ifclaimed)) { in proc_resetdevice()
1515 dev_warn(&ps->dev->dev, in proc_resetdevice()
1523 return usb_reset_device(ps->dev); in proc_resetdevice()
1526 static int proc_setintf(struct usb_dev_state *ps, void __user *arg) in proc_setintf() argument
1533 ret = checkintf(ps, setintf.interface); in proc_setintf()
1537 destroy_async_on_interface(ps, setintf.interface); in proc_setintf()
1539 return usb_set_interface(ps->dev, setintf.interface, in proc_setintf()
1543 static int proc_setconfig(struct usb_dev_state *ps, void __user *arg) in proc_setconfig() argument
1552 actconfig = ps->dev->actconfig; in proc_setconfig()
1563 dev_warn(&ps->dev->dev, in proc_setconfig()
1583 status = usb_reset_configuration(ps->dev); in proc_setconfig()
1585 status = usb_set_configuration(ps->dev, u); in proc_setconfig()
1592 find_memory_area(struct usb_dev_state *ps, const struct usbdevfs_urb *uurb) in find_memory_area() argument
1598 spin_lock_irqsave(&ps->lock, flags); in find_memory_area()
1599 list_for_each_entry(iter, &ps->memory_list, memlist) { in find_memory_area()
1612 spin_unlock_irqrestore(&ps->lock, flags); in find_memory_area()
1616 static int proc_do_submiturb(struct usb_dev_state *ps, struct usbdevfs_urb *uurb, in proc_do_submiturb() argument
1650 ifnum = findintfep(ps->dev, uurb->endpoint); in proc_do_submiturb()
1653 ret = checkintf(ps, ifnum); in proc_do_submiturb()
1657 ep = ep_to_host_endpoint(ps->dev, uurb->endpoint); in proc_do_submiturb()
1681 ret = check_ctrlrecip(ps, dr->bRequestType, dr->bRequest, in proc_do_submiturb()
1696 snoop(&ps->dev->dev, "control urb: bRequestType=%02x " in proc_do_submiturb()
1721 if (num_sgs == 1 || num_sgs > ps->dev->bus->sg_tablesize) in proc_do_submiturb()
1783 as->usbm = find_memory_area(ps, uurb); in proc_do_submiturb()
1866 as->urb->dev = ps->dev; in proc_do_submiturb()
1868 __create_pipe(ps->dev, uurb->endpoint & 0xf) | in proc_do_submiturb()
1887 dev_warn(&ps->dev->dev, "Requested nonsensical USBDEVFS_URB_SHORT_NOT_OK.\n"); in proc_do_submiturb()
1889 dev_warn(&ps->dev->dev, "Requested nonsensical USBDEVFS_URB_ZERO_PACKET.\n"); in proc_do_submiturb()
1900 ps->dev->speed == USB_SPEED_HIGH || in proc_do_submiturb()
1901 ps->dev->speed >= USB_SPEED_SUPER) in proc_do_submiturb()
1917 as->ps = ps; in proc_do_submiturb()
1932 snoop_urb(ps->dev, as->userurb, as->urb->pipe, in proc_do_submiturb()
1941 spin_lock_irq(&ps->lock); in proc_do_submiturb()
1957 ps->disabled_bulk_eps &= ~(1 << as->bulk_addr); in proc_do_submiturb()
1962 if (ps->disabled_bulk_eps & (1 << as->bulk_addr)) in proc_do_submiturb()
1966 spin_unlock_irq(&ps->lock); in proc_do_submiturb()
1972 dev_printk(KERN_DEBUG, &ps->dev->dev, in proc_do_submiturb()
1974 snoop_urb(ps->dev, as->userurb, as->urb->pipe, in proc_do_submiturb()
1989 static int proc_submiturb(struct usb_dev_state *ps, void __user *arg) in proc_submiturb() argument
2000 return proc_do_submiturb(ps, &uurb, in proc_submiturb()
2005 static int proc_unlinkurb(struct usb_dev_state *ps, void __user *arg) in proc_unlinkurb() argument
2011 spin_lock_irqsave(&ps->lock, flags); in proc_unlinkurb()
2012 as = async_getpending(ps, arg); in proc_unlinkurb()
2014 spin_unlock_irqrestore(&ps->lock, flags); in proc_unlinkurb()
2020 spin_unlock_irqrestore(&ps->lock, flags); in proc_unlinkurb()
2078 static struct async *reap_as(struct usb_dev_state *ps) in reap_as() argument
2082 struct usb_device *dev = ps->dev; in reap_as()
2084 add_wait_queue(&ps->wait, &wait); in reap_as()
2087 as = async_getcompleted(ps); in reap_as()
2088 if (as || !connected(ps)) in reap_as()
2096 remove_wait_queue(&ps->wait, &wait); in reap_as()
2101 static int proc_reapurb(struct usb_dev_state *ps, void __user *arg) in proc_reapurb() argument
2103 struct async *as = reap_as(ps); in proc_reapurb()
2108 snoop(&ps->dev->dev, "reap %px\n", as->userurb); in proc_reapurb()
2118 static int proc_reapurbnonblock(struct usb_dev_state *ps, void __user *arg) in proc_reapurbnonblock() argument
2123 as = async_getcompleted(ps); in proc_reapurbnonblock()
2125 snoop(&ps->dev->dev, "reap %px\n", as->userurb); in proc_reapurbnonblock()
2129 retval = (connected(ps) ? -EAGAIN : -ENODEV); in proc_reapurbnonblock()
2135 static int proc_control_compat(struct usb_dev_state *ps, in proc_control_compat() argument
2145 return do_proc_control(ps, &ctrl); in proc_control_compat()
2148 static int proc_bulk_compat(struct usb_dev_state *ps, in proc_bulk_compat() argument
2160 return do_proc_bulk(ps, &bulk); in proc_bulk_compat()
2163 static int proc_disconnectsignal_compat(struct usb_dev_state *ps, void __user *arg) in proc_disconnectsignal_compat() argument
2169 ps->discsignr = ds.signr; in proc_disconnectsignal_compat()
2170 ps->disccontext.sival_int = ds.context; in proc_disconnectsignal_compat()
2195 static int proc_submiturb_compat(struct usb_dev_state *ps, void __user *arg) in proc_submiturb_compat() argument
2206 return proc_do_submiturb(ps, &uurb, in proc_submiturb_compat()
2246 static int proc_reapurb_compat(struct usb_dev_state *ps, void __user *arg) in proc_reapurb_compat() argument
2248 struct async *as = reap_as(ps); in proc_reapurb_compat()
2253 snoop(&ps->dev->dev, "reap %px\n", as->userurb); in proc_reapurb_compat()
2263 static int proc_reapurbnonblock_compat(struct usb_dev_state *ps, void __user *arg) in proc_reapurbnonblock_compat() argument
2268 as = async_getcompleted(ps); in proc_reapurbnonblock_compat()
2270 snoop(&ps->dev->dev, "reap %px\n", as->userurb); in proc_reapurbnonblock_compat()
2274 retval = (connected(ps) ? -EAGAIN : -ENODEV); in proc_reapurbnonblock_compat()
2282 static int proc_disconnectsignal(struct usb_dev_state *ps, void __user *arg) in proc_disconnectsignal() argument
2288 ps->discsignr = ds.signr; in proc_disconnectsignal()
2289 ps->disccontext.sival_ptr = ds.context; in proc_disconnectsignal()
2293 static int proc_claiminterface(struct usb_dev_state *ps, void __user *arg) in proc_claiminterface() argument
2299 return claimintf(ps, ifnum); in proc_claiminterface()
2302 static int proc_releaseinterface(struct usb_dev_state *ps, void __user *arg) in proc_releaseinterface() argument
2309 ret = releaseintf(ps, ifnum); in proc_releaseinterface()
2312 destroy_async_on_interface(ps, ifnum); in proc_releaseinterface()
2316 static int proc_ioctl(struct usb_dev_state *ps, struct usbdevfs_ioctl *ctl) in proc_ioctl() argument
2324 if (ps->privileges_dropped) in proc_ioctl()
2327 if (!connected(ps)) in proc_ioctl()
2346 if (ps->dev->state != USB_STATE_CONFIGURED) in proc_ioctl()
2348 else if (!(intf = usb_ifnum_to_if(ps->dev, ctl->ifno))) in proc_ioctl()
2394 static int proc_ioctl_default(struct usb_dev_state *ps, void __user *arg) in proc_ioctl_default() argument
2400 return proc_ioctl(ps, &ctrl); in proc_ioctl_default()
2404 static int proc_ioctl_compat(struct usb_dev_state *ps, compat_uptr_t arg) in proc_ioctl_compat() argument
2414 return proc_ioctl(ps, &ctrl); in proc_ioctl_compat()
2418 static int proc_claim_port(struct usb_dev_state *ps, void __user *arg) in proc_claim_port() argument
2425 rc = usb_hub_claim_port(ps->dev, portnum, ps); in proc_claim_port()
2427 snoop(&ps->dev->dev, "port %d claimed by process %d: %s\n", in proc_claim_port()
2432 static int proc_release_port(struct usb_dev_state *ps, void __user *arg) in proc_release_port() argument
2438 return usb_hub_release_port(ps->dev, portnum, ps); in proc_release_port()
2441 static int proc_get_capabilities(struct usb_dev_state *ps, void __user *arg) in proc_get_capabilities() argument
2449 if (!ps->dev->bus->no_stop_on_short) in proc_get_capabilities()
2451 if (ps->dev->bus->sg_tablesize) in proc_get_capabilities()
2460 static int proc_disconnect_claim(struct usb_dev_state *ps, void __user *arg) in proc_disconnect_claim() argument
2468 intf = usb_ifnum_to_if(ps->dev, dc.interface); in proc_disconnect_claim()
2475 if (ps->privileges_dropped) in proc_disconnect_claim()
2492 return claimintf(ps, dc.interface); in proc_disconnect_claim()
2495 static int proc_alloc_streams(struct usb_dev_state *ps, void __user *arg) in proc_alloc_streams() argument
2502 r = parse_usbdevfs_streams(ps, arg, &num_streams, &num_eps, in proc_alloc_streams()
2507 destroy_async_on_interface(ps, in proc_alloc_streams()
2515 static int proc_free_streams(struct usb_dev_state *ps, void __user *arg) in proc_free_streams() argument
2522 r = parse_usbdevfs_streams(ps, arg, NULL, &num_eps, &eps, &intf); in proc_free_streams()
2526 destroy_async_on_interface(ps, in proc_free_streams()
2534 static int proc_drop_privileges(struct usb_dev_state *ps, void __user *arg) in proc_drop_privileges() argument
2545 ps->interface_allowed_mask &= data; in proc_drop_privileges()
2546 ps->privileges_dropped = true; in proc_drop_privileges()
2551 static int proc_forbid_suspend(struct usb_dev_state *ps) in proc_forbid_suspend() argument
2555 if (ps->suspend_allowed) { in proc_forbid_suspend()
2556 ret = usb_autoresume_device(ps->dev); in proc_forbid_suspend()
2558 ps->suspend_allowed = false; in proc_forbid_suspend()
2565 static int proc_allow_suspend(struct usb_dev_state *ps) in proc_allow_suspend() argument
2567 if (!connected(ps)) in proc_allow_suspend()
2570 WRITE_ONCE(ps->not_yet_resumed, 1); in proc_allow_suspend()
2571 if (!ps->suspend_allowed) { in proc_allow_suspend()
2572 usb_autosuspend_device(ps->dev); in proc_allow_suspend()
2573 ps->suspend_allowed = true; in proc_allow_suspend()
2578 static int proc_wait_for_resume(struct usb_dev_state *ps) in proc_wait_for_resume() argument
2582 usb_unlock_device(ps->dev); in proc_wait_for_resume()
2583 ret = wait_event_interruptible(ps->wait_for_resume, in proc_wait_for_resume()
2584 READ_ONCE(ps->not_yet_resumed) == 0); in proc_wait_for_resume()
2585 usb_lock_device(ps->dev); in proc_wait_for_resume()
2589 return proc_forbid_suspend(ps); in proc_wait_for_resume()
2600 struct usb_dev_state *ps = file->private_data; in usbdev_do_ioctl() local
2602 struct usb_device *dev = ps->dev; in usbdev_do_ioctl()
2614 ret = proc_reapurb(ps, p); in usbdev_do_ioctl()
2619 ret = proc_reapurbnonblock(ps, p); in usbdev_do_ioctl()
2625 ret = proc_reapurb_compat(ps, p); in usbdev_do_ioctl()
2630 ret = proc_reapurbnonblock_compat(ps, p); in usbdev_do_ioctl()
2635 if (!connected(ps)) { in usbdev_do_ioctl()
2643 ret = proc_control(ps, p); in usbdev_do_ioctl()
2651 ret = proc_bulk(ps, p); in usbdev_do_ioctl()
2659 ret = proc_resetep(ps, p); in usbdev_do_ioctl()
2667 ret = proc_resetdevice(ps); in usbdev_do_ioctl()
2672 ret = proc_clearhalt(ps, p); in usbdev_do_ioctl()
2680 ret = proc_getdriver(ps, p); in usbdev_do_ioctl()
2685 ret = proc_connectinfo(ps, p); in usbdev_do_ioctl()
2690 ret = proc_setintf(ps, p); in usbdev_do_ioctl()
2695 ret = proc_setconfig(ps, p); in usbdev_do_ioctl()
2700 ret = proc_submiturb(ps, p); in usbdev_do_ioctl()
2709 ret = proc_control_compat(ps, p); in usbdev_do_ioctl()
2717 ret = proc_bulk_compat(ps, p); in usbdev_do_ioctl()
2725 ret = proc_disconnectsignal_compat(ps, p); in usbdev_do_ioctl()
2730 ret = proc_submiturb_compat(ps, p); in usbdev_do_ioctl()
2738 ret = proc_ioctl_compat(ps, ptr_to_compat(p)); in usbdev_do_ioctl()
2744 ret = proc_unlinkurb(ps, p); in usbdev_do_ioctl()
2749 ret = proc_disconnectsignal(ps, p); in usbdev_do_ioctl()
2754 ret = proc_claiminterface(ps, p); in usbdev_do_ioctl()
2759 ret = proc_releaseinterface(ps, p); in usbdev_do_ioctl()
2764 ret = proc_ioctl_default(ps, p); in usbdev_do_ioctl()
2769 ret = proc_claim_port(ps, p); in usbdev_do_ioctl()
2774 ret = proc_release_port(ps, p); in usbdev_do_ioctl()
2777 ret = proc_get_capabilities(ps, p); in usbdev_do_ioctl()
2780 ret = proc_disconnect_claim(ps, p); in usbdev_do_ioctl()
2783 ret = proc_alloc_streams(ps, p); in usbdev_do_ioctl()
2786 ret = proc_free_streams(ps, p); in usbdev_do_ioctl()
2789 ret = proc_drop_privileges(ps, p); in usbdev_do_ioctl()
2792 ret = ps->dev->speed; in usbdev_do_ioctl()
2795 ret = proc_forbid_suspend(ps); in usbdev_do_ioctl()
2798 ret = proc_allow_suspend(ps); in usbdev_do_ioctl()
2801 ret = proc_wait_for_resume(ps); in usbdev_do_ioctl()
2808 ret = proc_conninfo_ex(ps, p, _IOC_SIZE(cmd)); in usbdev_do_ioctl()
2833 struct usb_dev_state *ps = file->private_data; in usbdev_poll() local
2836 poll_wait(file, &ps->wait, wait); in usbdev_poll()
2837 if (file->f_mode & FMODE_WRITE && !list_empty(&ps->async_completed)) in usbdev_poll()
2839 if (!connected(ps)) in usbdev_poll()
2841 if (list_empty(&ps->list)) in usbdev_poll()
2860 struct usb_dev_state *ps; in usbdev_remove() local
2865 ps = list_entry(udev->filelist.next, struct usb_dev_state, list); in usbdev_remove()
2866 destroy_all_async(ps); in usbdev_remove()
2867 wake_up_all(&ps->wait); in usbdev_remove()
2868 WRITE_ONCE(ps->not_yet_resumed, 0); in usbdev_remove()
2869 wake_up_all(&ps->wait_for_resume); in usbdev_remove()
2870 list_del_init(&ps->list); in usbdev_remove()
2871 if (ps->discsignr) in usbdev_remove()
2872 kill_pid_usb_asyncio(ps->discsignr, EPIPE, ps->disccontext, in usbdev_remove()
2873 ps->disc_pid, ps->cred); in usbdev_remove()