Lines Matching refs:as
381 struct async *as; in alloc_async() local
383 as = kzalloc(sizeof(struct async), GFP_KERNEL); in alloc_async()
384 if (!as) in alloc_async()
386 as->urb = usb_alloc_urb(numisoframes, GFP_KERNEL); in alloc_async()
387 if (!as->urb) { in alloc_async()
388 kfree(as); in alloc_async()
391 return as; in alloc_async()
394 static void free_async(struct async *as) in free_async() argument
398 put_pid(as->pid); in free_async()
399 if (as->cred) in free_async()
400 put_cred(as->cred); in free_async()
401 for (i = 0; i < as->urb->num_sgs; i++) { in free_async()
402 if (sg_page(&as->urb->sg[i])) in free_async()
403 kfree(sg_virt(&as->urb->sg[i])); in free_async()
406 kfree(as->urb->sg); in free_async()
407 if (as->usbm == NULL) in free_async()
408 kfree(as->urb->transfer_buffer); in free_async()
410 dec_usb_memory_use_count(as->usbm, &as->usbm->urb_use_count); in free_async()
412 kfree(as->urb->setup_packet); in free_async()
413 usb_free_urb(as->urb); in free_async()
414 usbfs_decrease_memory_usage(as->mem_usage); in free_async()
415 kfree(as); in free_async()
418 static void async_newpending(struct async *as) in async_newpending() argument
420 struct usb_dev_state *ps = as->ps; in async_newpending()
424 list_add_tail(&as->asynclist, &ps->async_pending); in async_newpending()
428 static void async_removepending(struct async *as) in async_removepending() argument
430 struct usb_dev_state *ps = as->ps; in async_removepending()
434 list_del_init(&as->asynclist); in async_removepending()
441 struct async *as = NULL; in async_getcompleted() local
445 as = list_entry(ps->async_completed.next, struct async, in async_getcompleted()
447 list_del_init(&as->asynclist); in async_getcompleted()
450 return as; in async_getcompleted()
456 struct async *as; in async_getpending() local
458 list_for_each_entry(as, &ps->async_pending, asynclist) in async_getpending()
459 if (as->userurb == userurb) { in async_getpending()
460 list_del_init(&as->asynclist); in async_getpending()
461 return as; in async_getpending()
568 struct async *as; in cancel_bulk_urbs() local
575 list_for_each_entry(as, &ps->async_pending, asynclist) { in cancel_bulk_urbs()
576 if (as->bulk_addr == bulk_addr) { in cancel_bulk_urbs()
577 if (as->bulk_status != AS_CONTINUATION) in cancel_bulk_urbs()
579 as->bulk_status = AS_UNLINK; in cancel_bulk_urbs()
580 as->bulk_addr = 0; in cancel_bulk_urbs()
587 list_for_each_entry_reverse(as, &ps->async_pending, asynclist) { in cancel_bulk_urbs()
588 if (as->bulk_status == AS_UNLINK) { in cancel_bulk_urbs()
589 as->bulk_status = 0; /* Only once */ in cancel_bulk_urbs()
590 urb = as->urb; in cancel_bulk_urbs()
603 struct async *as = urb->context; in async_completed() local
604 struct usb_dev_state *ps = as->ps; in async_completed()
612 list_move_tail(&as->asynclist, &ps->async_completed); in async_completed()
613 as->status = urb->status; in async_completed()
614 signr = as->signr; in async_completed()
616 errno = as->status; in async_completed()
617 addr = as->userurb_sigval; in async_completed()
618 pid = get_pid(as->pid); in async_completed()
619 cred = get_cred(as->cred); in async_completed()
622 snoop_urb(urb->dev, as->userurb, urb->pipe, urb->actual_length, in async_completed()
623 as->status, COMPLETE, NULL, 0); in async_completed()
627 if (as->status < 0 && as->bulk_addr && as->status != -ECONNRESET && in async_completed()
628 as->status != -ENOENT) in async_completed()
629 cancel_bulk_urbs(ps, as->bulk_addr); in async_completed()
644 struct async *as; in destroy_async() local
649 as = list_last_entry(list, struct async, asynclist); in destroy_async()
650 list_del_init(&as->asynclist); in destroy_async()
651 urb = as->urb; in destroy_async()
1073 struct async *as; in usbdev_release() local
1096 as = async_getcompleted(ps); in usbdev_release()
1097 while (as) { in usbdev_release()
1098 free_async(as); in usbdev_release()
1099 as = async_getcompleted(ps); in usbdev_release()
1597 struct async *as = NULL; in proc_do_submiturb() local
1752 as = alloc_async(number_of_packets); in proc_do_submiturb()
1753 if (!as) { in proc_do_submiturb()
1758 as->usbm = find_memory_area(ps, uurb); in proc_do_submiturb()
1759 if (IS_ERR(as->usbm)) { in proc_do_submiturb()
1760 ret = PTR_ERR(as->usbm); in proc_do_submiturb()
1761 as->usbm = NULL; in proc_do_submiturb()
1768 if (as->usbm) in proc_do_submiturb()
1772 (as->usbm ? 0 : uurb->buffer_length) + in proc_do_submiturb()
1777 as->mem_usage = u; in proc_do_submiturb()
1780 as->urb->sg = kmalloc_array(num_sgs, in proc_do_submiturb()
1783 if (!as->urb->sg) { in proc_do_submiturb()
1787 as->urb->num_sgs = num_sgs; in proc_do_submiturb()
1788 sg_init_table(as->urb->sg, as->urb->num_sgs); in proc_do_submiturb()
1791 for (i = 0; i < as->urb->num_sgs; i++) { in proc_do_submiturb()
1798 sg_set_buf(&as->urb->sg[i], buf, u); in proc_do_submiturb()
1810 if (as->usbm) { in proc_do_submiturb()
1813 as->urb->transfer_buffer = as->usbm->mem + in proc_do_submiturb()
1814 (uurb_start - as->usbm->vm_start); in proc_do_submiturb()
1816 as->urb->transfer_buffer = kmalloc(uurb->buffer_length, in proc_do_submiturb()
1818 if (!as->urb->transfer_buffer) { in proc_do_submiturb()
1823 if (copy_from_user(as->urb->transfer_buffer, in proc_do_submiturb()
1836 memset(as->urb->transfer_buffer, 0, in proc_do_submiturb()
1841 as->urb->dev = ps->dev; in proc_do_submiturb()
1842 as->urb->pipe = (uurb->type << 30) | in proc_do_submiturb()
1859 as->urb->transfer_flags = u; in proc_do_submiturb()
1866 as->urb->transfer_buffer_length = uurb->buffer_length; in proc_do_submiturb()
1867 as->urb->setup_packet = (unsigned char *)dr; in proc_do_submiturb()
1869 as->urb->start_frame = uurb->start_frame; in proc_do_submiturb()
1870 as->urb->number_of_packets = number_of_packets; in proc_do_submiturb()
1871 as->urb->stream_id = stream_id; in proc_do_submiturb()
1877 as->urb->interval = 1 << in proc_do_submiturb()
1880 as->urb->interval = ep->desc.bInterval; in proc_do_submiturb()
1883 as->urb->context = as; in proc_do_submiturb()
1884 as->urb->complete = async_completed; in proc_do_submiturb()
1886 as->urb->iso_frame_desc[u].offset = totlen; in proc_do_submiturb()
1887 as->urb->iso_frame_desc[u].length = isopkt[u].length; in proc_do_submiturb()
1892 as->ps = ps; in proc_do_submiturb()
1893 as->userurb = arg; in proc_do_submiturb()
1894 as->userurb_sigval = userurb_sigval; in proc_do_submiturb()
1895 if (as->usbm) { in proc_do_submiturb()
1898 as->urb->transfer_flags |= URB_NO_TRANSFER_DMA_MAP; in proc_do_submiturb()
1899 as->urb->transfer_dma = as->usbm->dma_handle + in proc_do_submiturb()
1900 (uurb_start - as->usbm->vm_start); in proc_do_submiturb()
1902 as->userbuffer = uurb->buffer; in proc_do_submiturb()
1903 as->signr = uurb->signr; in proc_do_submiturb()
1904 as->ifnum = ifnum; in proc_do_submiturb()
1905 as->pid = get_pid(task_pid(current)); in proc_do_submiturb()
1906 as->cred = get_current_cred(); in proc_do_submiturb()
1907 snoop_urb(ps->dev, as->userurb, as->urb->pipe, in proc_do_submiturb()
1908 as->urb->transfer_buffer_length, 0, SUBMIT, in proc_do_submiturb()
1911 snoop_urb_data(as->urb, as->urb->transfer_buffer_length); in proc_do_submiturb()
1913 async_newpending(as); in proc_do_submiturb()
1922 as->bulk_addr = usb_endpoint_num(&ep->desc) | in proc_do_submiturb()
1930 as->bulk_status = AS_CONTINUATION; in proc_do_submiturb()
1932 ps->disabled_bulk_eps &= ~(1 << as->bulk_addr); in proc_do_submiturb()
1937 if (ps->disabled_bulk_eps & (1 << as->bulk_addr)) in proc_do_submiturb()
1940 ret = usb_submit_urb(as->urb, GFP_ATOMIC); in proc_do_submiturb()
1943 ret = usb_submit_urb(as->urb, GFP_KERNEL); in proc_do_submiturb()
1949 snoop_urb(ps->dev, as->userurb, as->urb->pipe, in proc_do_submiturb()
1951 async_removepending(as); in proc_do_submiturb()
1959 if (as) in proc_do_submiturb()
1960 free_async(as); in proc_do_submiturb()
1983 struct async *as; in proc_unlinkurb() local
1987 as = async_getpending(ps, arg); in proc_unlinkurb()
1988 if (!as) { in proc_unlinkurb()
1993 urb = as->urb; in proc_unlinkurb()
2015 static int processcompl(struct async *as, void __user * __user *arg) in processcompl() argument
2017 struct urb *urb = as->urb; in processcompl()
2018 struct usbdevfs_urb __user *userurb = as->userurb; in processcompl()
2019 void __user *addr = as->userurb; in processcompl()
2023 if (as->userbuffer && urb->actual_length) { in processcompl()
2024 if (copy_urb_data_to_user(as->userbuffer, urb)) in processcompl()
2027 if (put_user(as->status, &userurb->status)) in processcompl()
2056 struct async *as = NULL; in reap_as() local
2062 as = async_getcompleted(ps); in reap_as()
2063 if (as || !connected(ps)) in reap_as()
2073 return as; in reap_as()
2078 struct async *as = reap_as(ps); in proc_reapurb() local
2080 if (as) { in proc_reapurb()
2083 snoop(&ps->dev->dev, "reap %px\n", as->userurb); in proc_reapurb()
2084 retval = processcompl(as, (void __user * __user *)arg); in proc_reapurb()
2085 free_async(as); in proc_reapurb()
2096 struct async *as; in proc_reapurbnonblock() local
2098 as = async_getcompleted(ps); in proc_reapurbnonblock()
2099 if (as) { in proc_reapurbnonblock()
2100 snoop(&ps->dev->dev, "reap %px\n", as->userurb); in proc_reapurbnonblock()
2101 retval = processcompl(as, (void __user * __user *)arg); in proc_reapurbnonblock()
2102 free_async(as); in proc_reapurbnonblock()
2186 static int processcompl_compat(struct async *as, void __user * __user *arg) in processcompl_compat() argument
2188 struct urb *urb = as->urb; in processcompl_compat()
2189 struct usbdevfs_urb32 __user *userurb = as->userurb; in processcompl_compat()
2190 void __user *addr = as->userurb; in processcompl_compat()
2194 if (as->userbuffer && urb->actual_length) { in processcompl_compat()
2195 if (copy_urb_data_to_user(as->userbuffer, urb)) in processcompl_compat()
2198 if (put_user(as->status, &userurb->status)) in processcompl_compat()
2223 struct async *as = reap_as(ps); in proc_reapurb_compat() local
2225 if (as) { in proc_reapurb_compat()
2228 snoop(&ps->dev->dev, "reap %px\n", as->userurb); in proc_reapurb_compat()
2229 retval = processcompl_compat(as, (void __user * __user *)arg); in proc_reapurb_compat()
2230 free_async(as); in proc_reapurb_compat()
2241 struct async *as; in proc_reapurbnonblock_compat() local
2243 as = async_getcompleted(ps); in proc_reapurbnonblock_compat()
2244 if (as) { in proc_reapurbnonblock_compat()
2245 snoop(&ps->dev->dev, "reap %px\n", as->userurb); in proc_reapurbnonblock_compat()
2246 retval = processcompl_compat(as, (void __user * __user *)arg); in proc_reapurbnonblock_compat()
2247 free_async(as); in proc_reapurbnonblock_compat()