Lines Matching full:ps

57 /* Mutual exclusion for ps->list in resume vs. release and remove */
90 struct usb_dev_state *ps; member
95 struct usb_dev_state *ps; member
167 static int connected(struct usb_dev_state *ps) in connected() argument
169 return (!list_empty(&ps->list) && in connected()
170 ps->dev->state != USB_STATE_NOTATTACHED); in connected()
175 struct usb_dev_state *ps = usbm->ps; in dec_usb_memory_use_count() local
178 spin_lock_irqsave(&ps->lock, flags); in dec_usb_memory_use_count()
182 spin_unlock_irqrestore(&ps->lock, flags); in dec_usb_memory_use_count()
184 usb_free_coherent(ps->dev, usbm->size, usbm->mem, in dec_usb_memory_use_count()
190 spin_unlock_irqrestore(&ps->lock, flags); in dec_usb_memory_use_count()
199 spin_lock_irqsave(&usbm->ps->lock, flags); in usbdev_vm_open()
201 spin_unlock_irqrestore(&usbm->ps->lock, flags); in usbdev_vm_open()
219 struct usb_dev_state *ps = file->private_data; in usbdev_mmap() local
220 struct usb_hcd *hcd = bus_to_hcd(ps->dev->bus); in usbdev_mmap()
237 mem = usb_alloc_coherent(ps->dev, size, GFP_USER | __GFP_NOWARN, in usbdev_mmap()
249 usbm->ps = ps; in usbdev_mmap()
274 spin_lock_irqsave(&ps->lock, flags); in usbdev_mmap()
275 list_add_tail(&usbm->memlist, &ps->memory_list); in usbdev_mmap()
276 spin_unlock_irqrestore(&ps->lock, flags); in usbdev_mmap()
291 struct usb_dev_state *ps = file->private_data; in usbdev_read() local
292 struct usb_device *dev = ps->dev; in usbdev_read()
300 if (!connected(ps)) { in usbdev_read()
419 struct usb_dev_state *ps = as->ps; in async_newpending() local
422 spin_lock_irqsave(&ps->lock, flags); in async_newpending()
423 list_add_tail(&as->asynclist, &ps->async_pending); in async_newpending()
424 spin_unlock_irqrestore(&ps->lock, flags); in async_newpending()
429 struct usb_dev_state *ps = as->ps; in async_removepending() local
432 spin_lock_irqsave(&ps->lock, flags); in async_removepending()
434 spin_unlock_irqrestore(&ps->lock, flags); in async_removepending()
437 static struct async *async_getcompleted(struct usb_dev_state *ps) in async_getcompleted() argument
442 spin_lock_irqsave(&ps->lock, flags); in async_getcompleted()
443 if (!list_empty(&ps->async_completed)) { in async_getcompleted()
444 as = list_entry(ps->async_completed.next, struct async, in async_getcompleted()
448 spin_unlock_irqrestore(&ps->lock, flags); in async_getcompleted()
452 static struct async *async_getpending(struct usb_dev_state *ps, in async_getpending() argument
457 list_for_each_entry(as, &ps->async_pending, asynclist) in async_getpending()
562 static void cancel_bulk_urbs(struct usb_dev_state *ps, unsigned bulk_addr) in cancel_bulk_urbs() argument
563 __releases(ps->lock) in cancel_bulk_urbs()
564 __acquires(ps->lock) in cancel_bulk_urbs()
574 list_for_each_entry(as, &ps->async_pending, asynclist) { in cancel_bulk_urbs()
582 ps->disabled_bulk_eps |= (1 << bulk_addr); in cancel_bulk_urbs()
586 list_for_each_entry_reverse(as, &ps->async_pending, asynclist) { in cancel_bulk_urbs()
591 spin_unlock(&ps->lock); /* Allow completions */ in cancel_bulk_urbs()
594 spin_lock(&ps->lock); in cancel_bulk_urbs()
603 struct usb_dev_state *ps = as->ps; in async_completed() local
610 spin_lock_irqsave(&ps->lock, flags); in async_completed()
611 list_move_tail(&as->asynclist, &ps->async_completed); in async_completed()
628 cancel_bulk_urbs(ps, as->bulk_addr); in async_completed()
630 wake_up(&ps->wait); in async_completed()
631 spin_unlock_irqrestore(&ps->lock, flags); in async_completed()
640 static void destroy_async(struct usb_dev_state *ps, struct list_head *list) in destroy_async() argument
646 spin_lock_irqsave(&ps->lock, flags); in destroy_async()
654 spin_unlock_irqrestore(&ps->lock, flags); in destroy_async()
657 spin_lock_irqsave(&ps->lock, flags); in destroy_async()
659 spin_unlock_irqrestore(&ps->lock, flags); in destroy_async()
662 static void destroy_async_on_interface(struct usb_dev_state *ps, in destroy_async_on_interface() argument
669 spin_lock_irqsave(&ps->lock, flags); in destroy_async_on_interface()
670 list_for_each_safe(p, q, &ps->async_pending) in destroy_async_on_interface()
673 spin_unlock_irqrestore(&ps->lock, flags); in destroy_async_on_interface()
674 destroy_async(ps, &hitlist); in destroy_async_on_interface()
677 static void destroy_all_async(struct usb_dev_state *ps) in destroy_all_async() argument
679 destroy_async(ps, &ps->async_pending); in destroy_all_async()
696 struct usb_dev_state *ps = usb_get_intfdata(intf); in driver_disconnect() local
699 if (!ps) in driver_disconnect()
706 if (likely(ifnum < 8*sizeof(ps->ifclaimed))) in driver_disconnect()
707 clear_bit(ifnum, &ps->ifclaimed); in driver_disconnect()
715 destroy_async_on_interface(ps, ifnum); in driver_disconnect()
737 struct usb_dev_state *ps; in usbfs_notify_resume() local
741 list_for_each_entry(ps, &udev->filelist, list) { in usbfs_notify_resume()
742 WRITE_ONCE(ps->not_yet_resumed, 0); in usbfs_notify_resume()
743 wake_up_all(&ps->wait_for_resume); in usbfs_notify_resume()
757 static int claimintf(struct usb_dev_state *ps, unsigned int ifnum) in claimintf() argument
759 struct usb_device *dev = ps->dev; in claimintf()
763 if (ifnum >= 8*sizeof(ps->ifclaimed)) in claimintf()
766 if (test_bit(ifnum, &ps->ifclaimed)) in claimintf()
769 if (ps->privileges_dropped && in claimintf()
770 !test_bit(ifnum, &ps->interface_allowed_mask)) in claimintf()
782 err = usb_driver_claim_interface(&usbfs_driver, intf, ps); in claimintf()
786 set_bit(ifnum, &ps->ifclaimed); in claimintf()
790 static int releaseintf(struct usb_dev_state *ps, unsigned int ifnum) in releaseintf() argument
797 if (ifnum >= 8*sizeof(ps->ifclaimed)) in releaseintf()
799 dev = ps->dev; in releaseintf()
803 else if (test_and_clear_bit(ifnum, &ps->ifclaimed)) { in releaseintf()
816 static int checkintf(struct usb_dev_state *ps, unsigned int ifnum) in checkintf() argument
818 if (ps->dev->state != USB_STATE_CONFIGURED) in checkintf()
820 if (ifnum >= 8*sizeof(ps->ifclaimed)) in checkintf()
822 if (test_bit(ifnum, &ps->ifclaimed)) in checkintf()
825 dev_warn(&ps->dev->dev, "usbfs: process %d (%s) did not claim " in checkintf()
828 return claimintf(ps, ifnum); in checkintf()
856 static int check_ctrlrecip(struct usb_dev_state *ps, unsigned int requesttype, in check_ctrlrecip() argument
862 if (ps->dev->state != USB_STATE_UNAUTHENTICATED in check_ctrlrecip()
863 && ps->dev->state != USB_STATE_ADDRESS in check_ctrlrecip()
864 && ps->dev->state != USB_STATE_CONFIGURED) in check_ctrlrecip()
875 alt_setting = usb_find_alt_setting(ps->dev->actconfig, in check_ctrlrecip()
887 ret = findintfep(ps->dev, index); in check_ctrlrecip()
897 ret = findintfep(ps->dev, index ^ 0x80); in check_ctrlrecip()
899 dev_info(&ps->dev->dev, in check_ctrlrecip()
905 ret = checkintf(ps, ret); in check_ctrlrecip()
909 ret = checkintf(ps, index); in check_ctrlrecip()
924 static int parse_usbdevfs_streams(struct usb_dev_state *ps, in parse_usbdevfs_streams() argument
957 eps[i] = ep_to_host_endpoint(ps->dev, ep); in parse_usbdevfs_streams()
964 ifnum = findintfep(ps->dev, ep); in parse_usbdevfs_streams()
971 ret = checkintf(ps, ifnum); in parse_usbdevfs_streams()
974 intf = usb_ifnum_to_if(ps->dev, ifnum); in parse_usbdevfs_streams()
1013 struct usb_dev_state *ps; in usbdev_open() local
1017 ps = kzalloc(sizeof(struct usb_dev_state), GFP_KERNEL); in usbdev_open()
1018 if (!ps) in usbdev_open()
1037 ps->dev = dev; in usbdev_open()
1038 ps->file = file; in usbdev_open()
1039 ps->interface_allowed_mask = 0xFFFFFFFF; /* 32 bits */ in usbdev_open()
1040 spin_lock_init(&ps->lock); in usbdev_open()
1041 INIT_LIST_HEAD(&ps->list); in usbdev_open()
1042 INIT_LIST_HEAD(&ps->async_pending); in usbdev_open()
1043 INIT_LIST_HEAD(&ps->async_completed); in usbdev_open()
1044 INIT_LIST_HEAD(&ps->memory_list); in usbdev_open()
1045 init_waitqueue_head(&ps->wait); in usbdev_open()
1046 init_waitqueue_head(&ps->wait_for_resume); in usbdev_open()
1047 ps->disc_pid = get_pid(task_pid(current)); in usbdev_open()
1048 ps->cred = get_current_cred(); in usbdev_open()
1052 list_add_tail(&ps->list, &dev->filelist); in usbdev_open()
1053 file->private_data = ps; in usbdev_open()
1063 kfree(ps); in usbdev_open()
1069 struct usb_dev_state *ps = file->private_data; in usbdev_release() local
1070 struct usb_device *dev = ps->dev; in usbdev_release()
1075 usb_hub_release_all_ports(dev, ps); in usbdev_release()
1079 list_del_init(&ps->list); in usbdev_release()
1082 for (ifnum = 0; ps->ifclaimed && ifnum < 8*sizeof(ps->ifclaimed); in usbdev_release()
1084 if (test_bit(ifnum, &ps->ifclaimed)) in usbdev_release()
1085 releaseintf(ps, ifnum); in usbdev_release()
1087 destroy_all_async(ps); in usbdev_release()
1088 if (!ps->suspend_allowed) in usbdev_release()
1092 put_pid(ps->disc_pid); in usbdev_release()
1093 put_cred(ps->cred); in usbdev_release()
1095 as = async_getcompleted(ps); in usbdev_release()
1098 as = async_getcompleted(ps); in usbdev_release()
1101 kfree(ps); in usbdev_release()
1105 static int do_proc_control(struct usb_dev_state *ps, in do_proc_control() argument
1108 struct usb_device *dev = ps->dev; in do_proc_control()
1114 ret = check_ctrlrecip(ps, ctrl->bRequestType, ctrl->bRequest, in do_proc_control()
1185 static int proc_control(struct usb_dev_state *ps, void __user *arg) in proc_control() argument
1191 return do_proc_control(ps, &ctrl); in proc_control()
1194 static int do_proc_bulk(struct usb_dev_state *ps, in do_proc_bulk() argument
1197 struct usb_device *dev = ps->dev; in do_proc_bulk()
1203 ret = findintfep(ps->dev, bulk->ep); in do_proc_bulk()
1206 ret = checkintf(ps, ret); in do_proc_bulk()
1262 static int proc_bulk(struct usb_dev_state *ps, void __user *arg) in proc_bulk() argument
1268 return do_proc_bulk(ps, &bulk); in proc_bulk()
1285 static int proc_resetep(struct usb_dev_state *ps, void __user *arg) in proc_resetep() argument
1292 ret = findintfep(ps->dev, ep); in proc_resetep()
1295 ret = checkintf(ps, ret); in proc_resetep()
1298 check_reset_of_active_ep(ps->dev, ep, "RESETEP"); in proc_resetep()
1299 usb_reset_endpoint(ps->dev, ep); in proc_resetep()
1303 static int proc_clearhalt(struct usb_dev_state *ps, void __user *arg) in proc_clearhalt() argument
1311 ret = findintfep(ps->dev, ep); in proc_clearhalt()
1314 ret = checkintf(ps, ret); in proc_clearhalt()
1317 check_reset_of_active_ep(ps->dev, ep, "CLEAR_HALT"); in proc_clearhalt()
1319 pipe = usb_rcvbulkpipe(ps->dev, ep & 0x7f); in proc_clearhalt()
1321 pipe = usb_sndbulkpipe(ps->dev, ep & 0x7f); in proc_clearhalt()
1323 return usb_clear_halt(ps->dev, pipe); in proc_clearhalt()
1326 static int proc_getdriver(struct usb_dev_state *ps, void __user *arg) in proc_getdriver() argument
1334 intf = usb_ifnum_to_if(ps->dev, gd.interface); in proc_getdriver()
1345 static int proc_connectinfo(struct usb_dev_state *ps, void __user *arg) in proc_connectinfo() argument
1350 ci.devnum = ps->dev->devnum; in proc_connectinfo()
1351 ci.slow = ps->dev->speed == USB_SPEED_LOW; in proc_connectinfo()
1358 static int proc_conninfo_ex(struct usb_dev_state *ps, in proc_conninfo_ex() argument
1362 struct usb_device *udev = ps->dev; in proc_conninfo_ex()
1391 static int proc_resetdevice(struct usb_dev_state *ps) in proc_resetdevice() argument
1393 struct usb_host_config *actconfig = ps->dev->actconfig; in proc_resetdevice()
1401 if (ps->privileges_dropped && actconfig) { in proc_resetdevice()
1406 !test_bit(number, &ps->ifclaimed)) { in proc_resetdevice()
1407 dev_warn(&ps->dev->dev, in proc_resetdevice()
1415 return usb_reset_device(ps->dev); in proc_resetdevice()
1418 static int proc_setintf(struct usb_dev_state *ps, void __user *arg) in proc_setintf() argument
1425 ret = checkintf(ps, setintf.interface); in proc_setintf()
1429 destroy_async_on_interface(ps, setintf.interface); in proc_setintf()
1431 return usb_set_interface(ps->dev, setintf.interface, in proc_setintf()
1435 static int proc_setconfig(struct usb_dev_state *ps, void __user *arg) in proc_setconfig() argument
1444 actconfig = ps->dev->actconfig; in proc_setconfig()
1455 dev_warn(&ps->dev->dev, in proc_setconfig()
1475 status = usb_reset_configuration(ps->dev); in proc_setconfig()
1477 status = usb_set_configuration(ps->dev, u); in proc_setconfig()
1484 find_memory_area(struct usb_dev_state *ps, const struct usbdevfs_urb *uurb) in find_memory_area() argument
1490 spin_lock_irqsave(&ps->lock, flags); in find_memory_area()
1491 list_for_each_entry(iter, &ps->memory_list, memlist) { in find_memory_area()
1504 spin_unlock_irqrestore(&ps->lock, flags); in find_memory_area()
1508 static int proc_do_submiturb(struct usb_dev_state *ps, struct usbdevfs_urb *uurb, in proc_do_submiturb() argument
1542 ifnum = findintfep(ps->dev, uurb->endpoint); in proc_do_submiturb()
1545 ret = checkintf(ps, ifnum); in proc_do_submiturb()
1549 ep = ep_to_host_endpoint(ps->dev, uurb->endpoint); in proc_do_submiturb()
1573 ret = check_ctrlrecip(ps, dr->bRequestType, dr->bRequest, in proc_do_submiturb()
1588 snoop(&ps->dev->dev, "control urb: bRequestType=%02x " in proc_do_submiturb()
1613 if (num_sgs == 1 || num_sgs > ps->dev->bus->sg_tablesize) in proc_do_submiturb()
1675 as->usbm = find_memory_area(ps, uurb); in proc_do_submiturb()
1758 as->urb->dev = ps->dev; in proc_do_submiturb()
1760 __create_pipe(ps->dev, uurb->endpoint & 0xf) | in proc_do_submiturb()
1779 dev_warn(&ps->dev->dev, "Requested nonsensical USBDEVFS_URB_SHORT_NOT_OK.\n"); in proc_do_submiturb()
1781 dev_warn(&ps->dev->dev, "Requested nonsensical USBDEVFS_URB_ZERO_PACKET.\n"); in proc_do_submiturb()
1792 ps->dev->speed == USB_SPEED_HIGH || in proc_do_submiturb()
1793 ps->dev->speed >= USB_SPEED_SUPER) in proc_do_submiturb()
1809 as->ps = ps; in proc_do_submiturb()
1824 snoop_urb(ps->dev, as->userurb, as->urb->pipe, in proc_do_submiturb()
1833 spin_lock_irq(&ps->lock); in proc_do_submiturb()
1849 ps->disabled_bulk_eps &= ~(1 << as->bulk_addr); in proc_do_submiturb()
1854 if (ps->disabled_bulk_eps & (1 << as->bulk_addr)) in proc_do_submiturb()
1858 spin_unlock_irq(&ps->lock); in proc_do_submiturb()
1864 dev_printk(KERN_DEBUG, &ps->dev->dev, in proc_do_submiturb()
1866 snoop_urb(ps->dev, as->userurb, as->urb->pipe, in proc_do_submiturb()
1881 static int proc_submiturb(struct usb_dev_state *ps, void __user *arg) in proc_submiturb() argument
1892 return proc_do_submiturb(ps, &uurb, in proc_submiturb()
1897 static int proc_unlinkurb(struct usb_dev_state *ps, void __user *arg) in proc_unlinkurb() argument
1903 spin_lock_irqsave(&ps->lock, flags); in proc_unlinkurb()
1904 as = async_getpending(ps, arg); in proc_unlinkurb()
1906 spin_unlock_irqrestore(&ps->lock, flags); in proc_unlinkurb()
1912 spin_unlock_irqrestore(&ps->lock, flags); in proc_unlinkurb()
1970 static struct async *reap_as(struct usb_dev_state *ps) in reap_as() argument
1974 struct usb_device *dev = ps->dev; in reap_as()
1976 add_wait_queue(&ps->wait, &wait); in reap_as()
1979 as = async_getcompleted(ps); in reap_as()
1980 if (as || !connected(ps)) in reap_as()
1988 remove_wait_queue(&ps->wait, &wait); in reap_as()
1993 static int proc_reapurb(struct usb_dev_state *ps, void __user *arg) in proc_reapurb() argument
1995 struct async *as = reap_as(ps); in proc_reapurb()
2000 snoop(&ps->dev->dev, "reap %px\n", as->userurb); in proc_reapurb()
2010 static int proc_reapurbnonblock(struct usb_dev_state *ps, void __user *arg) in proc_reapurbnonblock() argument
2015 as = async_getcompleted(ps); in proc_reapurbnonblock()
2017 snoop(&ps->dev->dev, "reap %px\n", as->userurb); in proc_reapurbnonblock()
2021 retval = (connected(ps) ? -EAGAIN : -ENODEV); in proc_reapurbnonblock()
2027 static int proc_control_compat(struct usb_dev_state *ps, in proc_control_compat() argument
2037 return do_proc_control(ps, &ctrl); in proc_control_compat()
2040 static int proc_bulk_compat(struct usb_dev_state *ps, in proc_bulk_compat() argument
2052 return do_proc_bulk(ps, &bulk); in proc_bulk_compat()
2055 static int proc_disconnectsignal_compat(struct usb_dev_state *ps, void __user *arg) in proc_disconnectsignal_compat() argument
2061 ps->discsignr = ds.signr; in proc_disconnectsignal_compat()
2062 ps->disccontext.sival_int = ds.context; in proc_disconnectsignal_compat()
2087 static int proc_submiturb_compat(struct usb_dev_state *ps, void __user *arg) in proc_submiturb_compat() argument
2098 return proc_do_submiturb(ps, &uurb, in proc_submiturb_compat()
2138 static int proc_reapurb_compat(struct usb_dev_state *ps, void __user *arg) in proc_reapurb_compat() argument
2140 struct async *as = reap_as(ps); in proc_reapurb_compat()
2145 snoop(&ps->dev->dev, "reap %px\n", as->userurb); in proc_reapurb_compat()
2155 static int proc_reapurbnonblock_compat(struct usb_dev_state *ps, void __user *arg) in proc_reapurbnonblock_compat() argument
2160 as = async_getcompleted(ps); in proc_reapurbnonblock_compat()
2162 snoop(&ps->dev->dev, "reap %px\n", as->userurb); in proc_reapurbnonblock_compat()
2166 retval = (connected(ps) ? -EAGAIN : -ENODEV); in proc_reapurbnonblock_compat()
2174 static int proc_disconnectsignal(struct usb_dev_state *ps, void __user *arg) in proc_disconnectsignal() argument
2180 ps->discsignr = ds.signr; in proc_disconnectsignal()
2181 ps->disccontext.sival_ptr = ds.context; in proc_disconnectsignal()
2185 static int proc_claiminterface(struct usb_dev_state *ps, void __user *arg) in proc_claiminterface() argument
2191 return claimintf(ps, ifnum); in proc_claiminterface()
2194 static int proc_releaseinterface(struct usb_dev_state *ps, void __user *arg) in proc_releaseinterface() argument
2201 ret = releaseintf(ps, ifnum); in proc_releaseinterface()
2204 destroy_async_on_interface(ps, ifnum); in proc_releaseinterface()
2208 static int proc_ioctl(struct usb_dev_state *ps, struct usbdevfs_ioctl *ctl) in proc_ioctl() argument
2216 if (ps->privileges_dropped) in proc_ioctl()
2219 if (!connected(ps)) in proc_ioctl()
2238 if (ps->dev->state != USB_STATE_CONFIGURED) in proc_ioctl()
2240 else if (!(intf = usb_ifnum_to_if(ps->dev, ctl->ifno))) in proc_ioctl()
2286 static int proc_ioctl_default(struct usb_dev_state *ps, void __user *arg) in proc_ioctl_default() argument
2292 return proc_ioctl(ps, &ctrl); in proc_ioctl_default()
2296 static int proc_ioctl_compat(struct usb_dev_state *ps, compat_uptr_t arg) in proc_ioctl_compat() argument
2306 return proc_ioctl(ps, &ctrl); in proc_ioctl_compat()
2310 static int proc_claim_port(struct usb_dev_state *ps, void __user *arg) in proc_claim_port() argument
2317 rc = usb_hub_claim_port(ps->dev, portnum, ps); in proc_claim_port()
2319 snoop(&ps->dev->dev, "port %d claimed by process %d: %s\n", in proc_claim_port()
2324 static int proc_release_port(struct usb_dev_state *ps, void __user *arg) in proc_release_port() argument
2330 return usb_hub_release_port(ps->dev, portnum, ps); in proc_release_port()
2333 static int proc_get_capabilities(struct usb_dev_state *ps, void __user *arg) in proc_get_capabilities() argument
2341 if (!ps->dev->bus->no_stop_on_short) in proc_get_capabilities()
2343 if (ps->dev->bus->sg_tablesize) in proc_get_capabilities()
2352 static int proc_disconnect_claim(struct usb_dev_state *ps, void __user *arg) in proc_disconnect_claim() argument
2360 intf = usb_ifnum_to_if(ps->dev, dc.interface); in proc_disconnect_claim()
2367 if (ps->privileges_dropped) in proc_disconnect_claim()
2384 return claimintf(ps, dc.interface); in proc_disconnect_claim()
2387 static int proc_alloc_streams(struct usb_dev_state *ps, void __user *arg) in proc_alloc_streams() argument
2394 r = parse_usbdevfs_streams(ps, arg, &num_streams, &num_eps, in proc_alloc_streams()
2399 destroy_async_on_interface(ps, in proc_alloc_streams()
2407 static int proc_free_streams(struct usb_dev_state *ps, void __user *arg) in proc_free_streams() argument
2414 r = parse_usbdevfs_streams(ps, arg, NULL, &num_eps, &eps, &intf); in proc_free_streams()
2418 destroy_async_on_interface(ps, in proc_free_streams()
2426 static int proc_drop_privileges(struct usb_dev_state *ps, void __user *arg) in proc_drop_privileges() argument
2437 ps->interface_allowed_mask &= data; in proc_drop_privileges()
2438 ps->privileges_dropped = true; in proc_drop_privileges()
2443 static int proc_forbid_suspend(struct usb_dev_state *ps) in proc_forbid_suspend() argument
2447 if (ps->suspend_allowed) { in proc_forbid_suspend()
2448 ret = usb_autoresume_device(ps->dev); in proc_forbid_suspend()
2450 ps->suspend_allowed = false; in proc_forbid_suspend()
2457 static int proc_allow_suspend(struct usb_dev_state *ps) in proc_allow_suspend() argument
2459 if (!connected(ps)) in proc_allow_suspend()
2462 WRITE_ONCE(ps->not_yet_resumed, 1); in proc_allow_suspend()
2463 if (!ps->suspend_allowed) { in proc_allow_suspend()
2464 usb_autosuspend_device(ps->dev); in proc_allow_suspend()
2465 ps->suspend_allowed = true; in proc_allow_suspend()
2470 static int proc_wait_for_resume(struct usb_dev_state *ps) in proc_wait_for_resume() argument
2474 usb_unlock_device(ps->dev); in proc_wait_for_resume()
2475 ret = wait_event_interruptible(ps->wait_for_resume, in proc_wait_for_resume()
2476 READ_ONCE(ps->not_yet_resumed) == 0); in proc_wait_for_resume()
2477 usb_lock_device(ps->dev); in proc_wait_for_resume()
2481 return proc_forbid_suspend(ps); in proc_wait_for_resume()
2492 struct usb_dev_state *ps = file->private_data; in usbdev_do_ioctl() local
2494 struct usb_device *dev = ps->dev; in usbdev_do_ioctl()
2506 ret = proc_reapurb(ps, p); in usbdev_do_ioctl()
2511 ret = proc_reapurbnonblock(ps, p); in usbdev_do_ioctl()
2517 ret = proc_reapurb_compat(ps, p); in usbdev_do_ioctl()
2522 ret = proc_reapurbnonblock_compat(ps, p); in usbdev_do_ioctl()
2527 if (!connected(ps)) { in usbdev_do_ioctl()
2535 ret = proc_control(ps, p); in usbdev_do_ioctl()
2542 ret = proc_bulk(ps, p); in usbdev_do_ioctl()
2549 ret = proc_resetep(ps, p); in usbdev_do_ioctl()
2556 ret = proc_resetdevice(ps); in usbdev_do_ioctl()
2561 ret = proc_clearhalt(ps, p); in usbdev_do_ioctl()
2568 ret = proc_getdriver(ps, p); in usbdev_do_ioctl()
2573 ret = proc_connectinfo(ps, p); in usbdev_do_ioctl()
2578 ret = proc_setintf(ps, p); in usbdev_do_ioctl()
2583 ret = proc_setconfig(ps, p); in usbdev_do_ioctl()
2588 ret = proc_submiturb(ps, p); in usbdev_do_ioctl()
2596 ret = proc_control_compat(ps, p); in usbdev_do_ioctl()
2603 ret = proc_bulk_compat(ps, p); in usbdev_do_ioctl()
2610 ret = proc_disconnectsignal_compat(ps, p); in usbdev_do_ioctl()
2615 ret = proc_submiturb_compat(ps, p); in usbdev_do_ioctl()
2622 ret = proc_ioctl_compat(ps, ptr_to_compat(p)); in usbdev_do_ioctl()
2628 ret = proc_unlinkurb(ps, p); in usbdev_do_ioctl()
2633 ret = proc_disconnectsignal(ps, p); in usbdev_do_ioctl()
2638 ret = proc_claiminterface(ps, p); in usbdev_do_ioctl()
2643 ret = proc_releaseinterface(ps, p); in usbdev_do_ioctl()
2648 ret = proc_ioctl_default(ps, p); in usbdev_do_ioctl()
2653 ret = proc_claim_port(ps, p); in usbdev_do_ioctl()
2658 ret = proc_release_port(ps, p); in usbdev_do_ioctl()
2661 ret = proc_get_capabilities(ps, p); in usbdev_do_ioctl()
2664 ret = proc_disconnect_claim(ps, p); in usbdev_do_ioctl()
2667 ret = proc_alloc_streams(ps, p); in usbdev_do_ioctl()
2670 ret = proc_free_streams(ps, p); in usbdev_do_ioctl()
2673 ret = proc_drop_privileges(ps, p); in usbdev_do_ioctl()
2676 ret = ps->dev->speed; in usbdev_do_ioctl()
2679 ret = proc_forbid_suspend(ps); in usbdev_do_ioctl()
2682 ret = proc_allow_suspend(ps); in usbdev_do_ioctl()
2685 ret = proc_wait_for_resume(ps); in usbdev_do_ioctl()
2692 ret = proc_conninfo_ex(ps, p, _IOC_SIZE(cmd)); in usbdev_do_ioctl()
2717 struct usb_dev_state *ps = file->private_data; in usbdev_poll() local
2720 poll_wait(file, &ps->wait, wait); in usbdev_poll()
2721 if (file->f_mode & FMODE_WRITE && !list_empty(&ps->async_completed)) in usbdev_poll()
2723 if (!connected(ps)) in usbdev_poll()
2725 if (list_empty(&ps->list)) in usbdev_poll()
2744 struct usb_dev_state *ps; in usbdev_remove() local
2749 ps = list_entry(udev->filelist.next, struct usb_dev_state, list); in usbdev_remove()
2750 destroy_all_async(ps); in usbdev_remove()
2751 wake_up_all(&ps->wait); in usbdev_remove()
2752 WRITE_ONCE(ps->not_yet_resumed, 0); in usbdev_remove()
2753 wake_up_all(&ps->wait_for_resume); in usbdev_remove()
2754 list_del_init(&ps->list); in usbdev_remove()
2755 if (ps->discsignr) in usbdev_remove()
2756 kill_pid_usb_asyncio(ps->discsignr, EPIPE, ps->disccontext, in usbdev_remove()
2757 ps->disc_pid, ps->cred); in usbdev_remove()