Lines Matching refs:as

393 	struct async *as;  in alloc_async()  local
395 as = kzalloc(sizeof(struct async), GFP_KERNEL); in alloc_async()
396 if (!as) in alloc_async()
398 as->urb = usb_alloc_urb(numisoframes, GFP_KERNEL); in alloc_async()
399 if (!as->urb) { in alloc_async()
400 kfree(as); in alloc_async()
403 return as; in alloc_async()
406 static void free_async(struct async *as) in free_async() argument
410 put_pid(as->pid); in free_async()
411 if (as->cred) in free_async()
412 put_cred(as->cred); in free_async()
413 for (i = 0; i < as->urb->num_sgs; i++) { in free_async()
414 if (sg_page(&as->urb->sg[i])) in free_async()
415 kfree(sg_virt(&as->urb->sg[i])); in free_async()
418 kfree(as->urb->sg); in free_async()
419 if (as->usbm == NULL) in free_async()
420 kfree(as->urb->transfer_buffer); in free_async()
422 dec_usb_memory_use_count(as->usbm, &as->usbm->urb_use_count); in free_async()
424 kfree(as->urb->setup_packet); in free_async()
425 usb_free_urb(as->urb); in free_async()
426 usbfs_decrease_memory_usage(as->mem_usage); in free_async()
427 kfree(as); in free_async()
430 static void async_newpending(struct async *as) in async_newpending() argument
432 struct usb_dev_state *ps = as->ps; in async_newpending()
436 list_add_tail(&as->asynclist, &ps->async_pending); in async_newpending()
440 static void async_removepending(struct async *as) in async_removepending() argument
442 struct usb_dev_state *ps = as->ps; in async_removepending()
446 list_del_init(&as->asynclist); in async_removepending()
453 struct async *as = NULL; in async_getcompleted() local
457 as = list_entry(ps->async_completed.next, struct async, in async_getcompleted()
459 list_del_init(&as->asynclist); in async_getcompleted()
462 return as; in async_getcompleted()
468 struct async *as; in async_getpending() local
470 list_for_each_entry(as, &ps->async_pending, asynclist) in async_getpending()
471 if (as->userurb == userurb) { in async_getpending()
472 list_del_init(&as->asynclist); in async_getpending()
473 return as; in async_getpending()
580 struct async *as; in cancel_bulk_urbs() local
587 list_for_each_entry(as, &ps->async_pending, asynclist) { in cancel_bulk_urbs()
588 if (as->bulk_addr == bulk_addr) { in cancel_bulk_urbs()
589 if (as->bulk_status != AS_CONTINUATION) in cancel_bulk_urbs()
591 as->bulk_status = AS_UNLINK; in cancel_bulk_urbs()
592 as->bulk_addr = 0; in cancel_bulk_urbs()
599 list_for_each_entry_reverse(as, &ps->async_pending, asynclist) { in cancel_bulk_urbs()
600 if (as->bulk_status == AS_UNLINK) { in cancel_bulk_urbs()
601 as->bulk_status = 0; /* Only once */ in cancel_bulk_urbs()
602 urb = as->urb; in cancel_bulk_urbs()
615 struct async *as = urb->context; in async_completed() local
616 struct usb_dev_state *ps = as->ps; in async_completed()
624 list_move_tail(&as->asynclist, &ps->async_completed); in async_completed()
625 as->status = urb->status; in async_completed()
626 signr = as->signr; in async_completed()
628 errno = as->status; in async_completed()
629 addr = as->userurb_sigval; in async_completed()
630 pid = get_pid(as->pid); in async_completed()
631 cred = get_cred(as->cred); in async_completed()
634 snoop_urb(urb->dev, as->userurb, urb->pipe, urb->actual_length, in async_completed()
635 as->status, COMPLETE, NULL, 0); in async_completed()
639 if (as->status < 0 && as->bulk_addr && as->status != -ECONNRESET && in async_completed()
640 as->status != -ENOENT) in async_completed()
641 cancel_bulk_urbs(ps, as->bulk_addr); in async_completed()
656 struct async *as; in destroy_async() local
661 as = list_last_entry(list, struct async, asynclist); in destroy_async()
662 list_del_init(&as->asynclist); in destroy_async()
663 urb = as->urb; in destroy_async()
1085 struct async *as; in usbdev_release() local
1108 as = async_getcompleted(ps); in usbdev_release()
1109 while (as) { in usbdev_release()
1110 free_async(as); in usbdev_release()
1111 as = async_getcompleted(ps); in usbdev_release()
1613 struct async *as = NULL; in proc_do_submiturb() local
1768 as = alloc_async(number_of_packets); in proc_do_submiturb()
1769 if (!as) { in proc_do_submiturb()
1774 as->usbm = find_memory_area(ps, uurb); in proc_do_submiturb()
1775 if (IS_ERR(as->usbm)) { in proc_do_submiturb()
1776 ret = PTR_ERR(as->usbm); in proc_do_submiturb()
1777 as->usbm = NULL; in proc_do_submiturb()
1784 if (as->usbm) in proc_do_submiturb()
1788 (as->usbm ? 0 : uurb->buffer_length) + in proc_do_submiturb()
1793 as->mem_usage = u; in proc_do_submiturb()
1796 as->urb->sg = kmalloc_array(num_sgs, in proc_do_submiturb()
1799 if (!as->urb->sg) { in proc_do_submiturb()
1803 as->urb->num_sgs = num_sgs; in proc_do_submiturb()
1804 sg_init_table(as->urb->sg, as->urb->num_sgs); in proc_do_submiturb()
1807 for (i = 0; i < as->urb->num_sgs; i++) { in proc_do_submiturb()
1814 sg_set_buf(&as->urb->sg[i], buf, u); in proc_do_submiturb()
1826 if (as->usbm) { in proc_do_submiturb()
1829 as->urb->transfer_buffer = as->usbm->mem + in proc_do_submiturb()
1830 (uurb_start - as->usbm->vm_start); in proc_do_submiturb()
1832 as->urb->transfer_buffer = kmalloc(uurb->buffer_length, in proc_do_submiturb()
1834 if (!as->urb->transfer_buffer) { in proc_do_submiturb()
1839 if (copy_from_user(as->urb->transfer_buffer, in proc_do_submiturb()
1852 memset(as->urb->transfer_buffer, 0, in proc_do_submiturb()
1857 as->urb->dev = ps->dev; in proc_do_submiturb()
1858 as->urb->pipe = (uurb->type << 30) | in proc_do_submiturb()
1875 as->urb->transfer_flags = u; in proc_do_submiturb()
1882 as->urb->transfer_buffer_length = uurb->buffer_length; in proc_do_submiturb()
1883 as->urb->setup_packet = (unsigned char *)dr; in proc_do_submiturb()
1885 as->urb->start_frame = uurb->start_frame; in proc_do_submiturb()
1886 as->urb->number_of_packets = number_of_packets; in proc_do_submiturb()
1887 as->urb->stream_id = stream_id; in proc_do_submiturb()
1893 as->urb->interval = 1 << in proc_do_submiturb()
1896 as->urb->interval = ep->desc.bInterval; in proc_do_submiturb()
1899 as->urb->context = as; in proc_do_submiturb()
1900 as->urb->complete = async_completed; in proc_do_submiturb()
1902 as->urb->iso_frame_desc[u].offset = totlen; in proc_do_submiturb()
1903 as->urb->iso_frame_desc[u].length = isopkt[u].length; in proc_do_submiturb()
1908 as->ps = ps; in proc_do_submiturb()
1909 as->userurb = arg; in proc_do_submiturb()
1910 as->userurb_sigval = userurb_sigval; in proc_do_submiturb()
1911 if (as->usbm) { in proc_do_submiturb()
1914 as->urb->transfer_flags |= URB_NO_TRANSFER_DMA_MAP; in proc_do_submiturb()
1915 as->urb->transfer_dma = as->usbm->dma_handle + in proc_do_submiturb()
1916 (uurb_start - as->usbm->vm_start); in proc_do_submiturb()
1918 as->userbuffer = uurb->buffer; in proc_do_submiturb()
1919 as->signr = uurb->signr; in proc_do_submiturb()
1920 as->ifnum = ifnum; in proc_do_submiturb()
1921 as->pid = get_pid(task_pid(current)); in proc_do_submiturb()
1922 as->cred = get_current_cred(); in proc_do_submiturb()
1923 snoop_urb(ps->dev, as->userurb, as->urb->pipe, in proc_do_submiturb()
1924 as->urb->transfer_buffer_length, 0, SUBMIT, in proc_do_submiturb()
1927 snoop_urb_data(as->urb, as->urb->transfer_buffer_length); in proc_do_submiturb()
1929 async_newpending(as); in proc_do_submiturb()
1938 as->bulk_addr = usb_endpoint_num(&ep->desc) | in proc_do_submiturb()
1946 as->bulk_status = AS_CONTINUATION; 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()
1956 ret = usb_submit_urb(as->urb, GFP_ATOMIC); in proc_do_submiturb()
1959 ret = usb_submit_urb(as->urb, GFP_KERNEL); in proc_do_submiturb()
1965 snoop_urb(ps->dev, as->userurb, as->urb->pipe, in proc_do_submiturb()
1967 async_removepending(as); in proc_do_submiturb()
1975 if (as) in proc_do_submiturb()
1976 free_async(as); in proc_do_submiturb()
1999 struct async *as; in proc_unlinkurb() local
2003 as = async_getpending(ps, arg); in proc_unlinkurb()
2004 if (!as) { in proc_unlinkurb()
2009 urb = as->urb; in proc_unlinkurb()
2031 static int processcompl(struct async *as, void __user * __user *arg) in processcompl() argument
2033 struct urb *urb = as->urb; in processcompl()
2034 struct usbdevfs_urb __user *userurb = as->userurb; in processcompl()
2035 void __user *addr = as->userurb; in processcompl()
2039 if (as->userbuffer && urb->actual_length) { in processcompl()
2040 if (copy_urb_data_to_user(as->userbuffer, urb)) in processcompl()
2043 if (put_user(as->status, &userurb->status)) in processcompl()
2072 struct async *as = NULL; in reap_as() local
2078 as = async_getcompleted(ps); in reap_as()
2079 if (as || !connected(ps)) in reap_as()
2089 return as; in reap_as()
2094 struct async *as = reap_as(ps); in proc_reapurb() local
2096 if (as) { in proc_reapurb()
2099 snoop(&ps->dev->dev, "reap %px\n", as->userurb); in proc_reapurb()
2100 retval = processcompl(as, (void __user * __user *)arg); in proc_reapurb()
2101 free_async(as); in proc_reapurb()
2112 struct async *as; in proc_reapurbnonblock() local
2114 as = async_getcompleted(ps); in proc_reapurbnonblock()
2115 if (as) { in proc_reapurbnonblock()
2116 snoop(&ps->dev->dev, "reap %px\n", as->userurb); in proc_reapurbnonblock()
2117 retval = processcompl(as, (void __user * __user *)arg); in proc_reapurbnonblock()
2118 free_async(as); in proc_reapurbnonblock()
2202 static int processcompl_compat(struct async *as, void __user * __user *arg) in processcompl_compat() argument
2204 struct urb *urb = as->urb; in processcompl_compat()
2205 struct usbdevfs_urb32 __user *userurb = as->userurb; in processcompl_compat()
2206 void __user *addr = as->userurb; in processcompl_compat()
2210 if (as->userbuffer && urb->actual_length) { in processcompl_compat()
2211 if (copy_urb_data_to_user(as->userbuffer, urb)) in processcompl_compat()
2214 if (put_user(as->status, &userurb->status)) in processcompl_compat()
2239 struct async *as = reap_as(ps); in proc_reapurb_compat() local
2241 if (as) { in proc_reapurb_compat()
2244 snoop(&ps->dev->dev, "reap %px\n", as->userurb); in proc_reapurb_compat()
2245 retval = processcompl_compat(as, (void __user * __user *)arg); in proc_reapurb_compat()
2246 free_async(as); in proc_reapurb_compat()
2257 struct async *as; in proc_reapurbnonblock_compat() local
2259 as = async_getcompleted(ps); in proc_reapurbnonblock_compat()
2260 if (as) { in proc_reapurbnonblock_compat()
2261 snoop(&ps->dev->dev, "reap %px\n", as->userurb); in proc_reapurbnonblock_compat()
2262 retval = processcompl_compat(as, (void __user * __user *)arg); in proc_reapurbnonblock_compat()
2263 free_async(as); in proc_reapurbnonblock_compat()