Lines Matching refs:urb
486 static int rh_call_control (struct usb_hcd *hcd, struct urb *urb) in rh_call_control() argument
490 u8 *ubuf = urb->transfer_buffer; in rh_call_control()
502 status = usb_hcd_link_urb_to_ep(hcd, urb); in rh_call_control()
506 urb->hcpriv = hcd; /* Indicate it's queued */ in rh_call_control()
508 cmd = (struct usb_ctrlrequest *) urb->setup_packet; in rh_call_control()
514 if (wLength > urb->transfer_buffer_length) in rh_call_control()
531 urb->actual_length = 0; in rh_call_control()
628 urb->actual_length = rh_string(wValue & 0xff, in rh_call_control()
717 if (urb->transfer_buffer_length < len) in rh_call_control()
718 len = urb->transfer_buffer_length; in rh_call_control()
719 urb->actual_length = len; in rh_call_control()
743 usb_hcd_unlink_urb_from_ep(hcd, urb); in rh_call_control()
744 usb_hcd_giveback_urb(hcd, urb, status); in rh_call_control()
761 struct urb *urb; in usb_hcd_poll_rh_status() local
776 urb = hcd->status_urb; in usb_hcd_poll_rh_status()
777 if (urb) { in usb_hcd_poll_rh_status()
780 urb->actual_length = length; in usb_hcd_poll_rh_status()
781 memcpy(urb->transfer_buffer, buffer, length); in usb_hcd_poll_rh_status()
783 usb_hcd_unlink_urb_from_ep(hcd, urb); in usb_hcd_poll_rh_status()
784 usb_hcd_giveback_urb(hcd, urb, 0); in usb_hcd_poll_rh_status()
810 static int rh_queue_status (struct usb_hcd *hcd, struct urb *urb) in rh_queue_status() argument
814 unsigned len = 1 + (urb->dev->maxchild / 8); in rh_queue_status()
817 if (hcd->status_urb || urb->transfer_buffer_length < len) { in rh_queue_status()
823 retval = usb_hcd_link_urb_to_ep(hcd, urb); in rh_queue_status()
827 hcd->status_urb = urb; in rh_queue_status()
828 urb->hcpriv = hcd; /* indicate it's queued */ in rh_queue_status()
841 static int rh_urb_enqueue (struct usb_hcd *hcd, struct urb *urb) in rh_urb_enqueue() argument
843 if (usb_endpoint_xfer_int(&urb->ep->desc)) in rh_urb_enqueue()
844 return rh_queue_status (hcd, urb); in rh_urb_enqueue()
845 if (usb_endpoint_xfer_control(&urb->ep->desc)) in rh_urb_enqueue()
846 return rh_call_control (hcd, urb); in rh_urb_enqueue()
855 static int usb_rh_urb_dequeue(struct usb_hcd *hcd, struct urb *urb, int status) in usb_rh_urb_dequeue() argument
861 rc = usb_hcd_check_unlink_urb(hcd, urb, status); in usb_rh_urb_dequeue()
865 if (usb_endpoint_num(&urb->ep->desc) == 0) { /* Control URB */ in usb_rh_urb_dequeue()
871 if (urb == hcd->status_urb) { in usb_rh_urb_dequeue()
873 usb_hcd_unlink_urb_from_ep(hcd, urb); in usb_rh_urb_dequeue()
874 usb_hcd_giveback_urb(hcd, urb, status); in usb_rh_urb_dequeue()
1250 int usb_hcd_link_urb_to_ep(struct usb_hcd *hcd, struct urb *urb) in usb_hcd_link_urb_to_ep() argument
1257 if (unlikely(atomic_read(&urb->reject))) { in usb_hcd_link_urb_to_ep()
1262 if (unlikely(!urb->ep->enabled)) { in usb_hcd_link_urb_to_ep()
1267 if (unlikely(!urb->dev->can_submit)) { in usb_hcd_link_urb_to_ep()
1277 urb->unlinked = 0; in usb_hcd_link_urb_to_ep()
1278 list_add_tail(&urb->urb_list, &urb->ep->urb_list); in usb_hcd_link_urb_to_ep()
1308 int usb_hcd_check_unlink_urb(struct usb_hcd *hcd, struct urb *urb, in usb_hcd_check_unlink_urb() argument
1314 list_for_each(tmp, &urb->ep->urb_list) { in usb_hcd_check_unlink_urb()
1315 if (tmp == &urb->urb_list) in usb_hcd_check_unlink_urb()
1318 if (tmp != &urb->urb_list) in usb_hcd_check_unlink_urb()
1324 if (urb->unlinked) in usb_hcd_check_unlink_urb()
1326 urb->unlinked = status; in usb_hcd_check_unlink_urb()
1341 void usb_hcd_unlink_urb_from_ep(struct usb_hcd *hcd, struct urb *urb) in usb_hcd_unlink_urb_from_ep() argument
1345 list_del_init(&urb->urb_list); in usb_hcd_unlink_urb_from_ep()
1434 void usb_hcd_unmap_urb_setup_for_dma(struct usb_hcd *hcd, struct urb *urb) in usb_hcd_unmap_urb_setup_for_dma() argument
1437 (urb->transfer_flags & URB_SETUP_MAP_SINGLE)) in usb_hcd_unmap_urb_setup_for_dma()
1439 urb->setup_dma, in usb_hcd_unmap_urb_setup_for_dma()
1442 else if (urb->transfer_flags & URB_SETUP_MAP_LOCAL) in usb_hcd_unmap_urb_setup_for_dma()
1443 hcd_free_coherent(urb->dev->bus, in usb_hcd_unmap_urb_setup_for_dma()
1444 &urb->setup_dma, in usb_hcd_unmap_urb_setup_for_dma()
1445 (void **) &urb->setup_packet, in usb_hcd_unmap_urb_setup_for_dma()
1450 urb->transfer_flags &= ~(URB_SETUP_MAP_SINGLE | URB_SETUP_MAP_LOCAL); in usb_hcd_unmap_urb_setup_for_dma()
1454 static void unmap_urb_for_dma(struct usb_hcd *hcd, struct urb *urb) in unmap_urb_for_dma() argument
1457 hcd->driver->unmap_urb_for_dma(hcd, urb); in unmap_urb_for_dma()
1459 usb_hcd_unmap_urb_for_dma(hcd, urb); in unmap_urb_for_dma()
1462 void usb_hcd_unmap_urb_for_dma(struct usb_hcd *hcd, struct urb *urb) in usb_hcd_unmap_urb_for_dma() argument
1466 usb_hcd_unmap_urb_setup_for_dma(hcd, urb); in usb_hcd_unmap_urb_for_dma()
1468 dir = usb_urb_dir_in(urb) ? DMA_FROM_DEVICE : DMA_TO_DEVICE; in usb_hcd_unmap_urb_for_dma()
1470 (urb->transfer_flags & URB_DMA_MAP_SG)) in usb_hcd_unmap_urb_for_dma()
1472 urb->sg, in usb_hcd_unmap_urb_for_dma()
1473 urb->num_sgs, in usb_hcd_unmap_urb_for_dma()
1476 (urb->transfer_flags & URB_DMA_MAP_PAGE)) in usb_hcd_unmap_urb_for_dma()
1478 urb->transfer_dma, in usb_hcd_unmap_urb_for_dma()
1479 urb->transfer_buffer_length, in usb_hcd_unmap_urb_for_dma()
1482 (urb->transfer_flags & URB_DMA_MAP_SINGLE)) in usb_hcd_unmap_urb_for_dma()
1484 urb->transfer_dma, in usb_hcd_unmap_urb_for_dma()
1485 urb->transfer_buffer_length, in usb_hcd_unmap_urb_for_dma()
1487 else if (urb->transfer_flags & URB_MAP_LOCAL) in usb_hcd_unmap_urb_for_dma()
1488 hcd_free_coherent(urb->dev->bus, in usb_hcd_unmap_urb_for_dma()
1489 &urb->transfer_dma, in usb_hcd_unmap_urb_for_dma()
1490 &urb->transfer_buffer, in usb_hcd_unmap_urb_for_dma()
1491 urb->transfer_buffer_length, in usb_hcd_unmap_urb_for_dma()
1495 urb->transfer_flags &= ~(URB_DMA_MAP_SG | URB_DMA_MAP_PAGE | in usb_hcd_unmap_urb_for_dma()
1500 static int map_urb_for_dma(struct usb_hcd *hcd, struct urb *urb, in map_urb_for_dma() argument
1504 return hcd->driver->map_urb_for_dma(hcd, urb, mem_flags); in map_urb_for_dma()
1506 return usb_hcd_map_urb_for_dma(hcd, urb, mem_flags); in map_urb_for_dma()
1509 int usb_hcd_map_urb_for_dma(struct usb_hcd *hcd, struct urb *urb, in usb_hcd_map_urb_for_dma() argument
1521 if (usb_endpoint_xfer_control(&urb->ep->desc)) { in usb_hcd_map_urb_for_dma()
1525 urb->setup_dma = dma_map_single( in usb_hcd_map_urb_for_dma()
1527 urb->setup_packet, in usb_hcd_map_urb_for_dma()
1531 urb->setup_dma)) in usb_hcd_map_urb_for_dma()
1533 urb->transfer_flags |= URB_SETUP_MAP_SINGLE; in usb_hcd_map_urb_for_dma()
1536 urb->dev->bus, mem_flags, in usb_hcd_map_urb_for_dma()
1537 &urb->setup_dma, in usb_hcd_map_urb_for_dma()
1538 (void **)&urb->setup_packet, in usb_hcd_map_urb_for_dma()
1543 urb->transfer_flags |= URB_SETUP_MAP_LOCAL; in usb_hcd_map_urb_for_dma()
1547 dir = usb_urb_dir_in(urb) ? DMA_FROM_DEVICE : DMA_TO_DEVICE; in usb_hcd_map_urb_for_dma()
1548 if (urb->transfer_buffer_length != 0 in usb_hcd_map_urb_for_dma()
1549 && !(urb->transfer_flags & URB_NO_TRANSFER_DMA_MAP)) { in usb_hcd_map_urb_for_dma()
1551 if (urb->num_sgs) { in usb_hcd_map_urb_for_dma()
1555 if (usb_endpoint_xfer_isoc(&urb->ep->desc)) { in usb_hcd_map_urb_for_dma()
1562 urb->sg, in usb_hcd_map_urb_for_dma()
1563 urb->num_sgs, in usb_hcd_map_urb_for_dma()
1568 urb->transfer_flags |= URB_DMA_MAP_SG; in usb_hcd_map_urb_for_dma()
1569 urb->num_mapped_sgs = n; in usb_hcd_map_urb_for_dma()
1570 if (n != urb->num_sgs) in usb_hcd_map_urb_for_dma()
1571 urb->transfer_flags |= in usb_hcd_map_urb_for_dma()
1573 } else if (urb->sg) { in usb_hcd_map_urb_for_dma()
1574 struct scatterlist *sg = urb->sg; in usb_hcd_map_urb_for_dma()
1575 urb->transfer_dma = dma_map_page( in usb_hcd_map_urb_for_dma()
1579 urb->transfer_buffer_length, in usb_hcd_map_urb_for_dma()
1582 urb->transfer_dma)) in usb_hcd_map_urb_for_dma()
1585 urb->transfer_flags |= URB_DMA_MAP_PAGE; in usb_hcd_map_urb_for_dma()
1586 } else if (is_vmalloc_addr(urb->transfer_buffer)) { in usb_hcd_map_urb_for_dma()
1590 urb->transfer_dma = dma_map_single( in usb_hcd_map_urb_for_dma()
1592 urb->transfer_buffer, in usb_hcd_map_urb_for_dma()
1593 urb->transfer_buffer_length, in usb_hcd_map_urb_for_dma()
1596 urb->transfer_dma)) in usb_hcd_map_urb_for_dma()
1599 urb->transfer_flags |= URB_DMA_MAP_SINGLE; in usb_hcd_map_urb_for_dma()
1603 urb->dev->bus, mem_flags, in usb_hcd_map_urb_for_dma()
1604 &urb->transfer_dma, in usb_hcd_map_urb_for_dma()
1605 &urb->transfer_buffer, in usb_hcd_map_urb_for_dma()
1606 urb->transfer_buffer_length, in usb_hcd_map_urb_for_dma()
1609 urb->transfer_flags |= URB_MAP_LOCAL; in usb_hcd_map_urb_for_dma()
1611 if (ret && (urb->transfer_flags & (URB_SETUP_MAP_SINGLE | in usb_hcd_map_urb_for_dma()
1613 usb_hcd_unmap_urb_for_dma(hcd, urb); in usb_hcd_map_urb_for_dma()
1626 int usb_hcd_submit_urb (struct urb *urb, gfp_t mem_flags) in usb_hcd_submit_urb() argument
1629 struct usb_hcd *hcd = bus_to_hcd(urb->dev->bus); in usb_hcd_submit_urb()
1635 usb_get_urb(urb); in usb_hcd_submit_urb()
1636 atomic_inc(&urb->use_count); in usb_hcd_submit_urb()
1637 atomic_inc(&urb->dev->urbnum); in usb_hcd_submit_urb()
1638 usbmon_urb_submit(&hcd->self, urb); in usb_hcd_submit_urb()
1648 if (is_root_hub(urb->dev)) { in usb_hcd_submit_urb()
1649 status = rh_urb_enqueue(hcd, urb); in usb_hcd_submit_urb()
1651 status = map_urb_for_dma(hcd, urb, mem_flags); in usb_hcd_submit_urb()
1653 status = hcd->driver->urb_enqueue(hcd, urb, mem_flags); in usb_hcd_submit_urb()
1655 unmap_urb_for_dma(hcd, urb); in usb_hcd_submit_urb()
1660 usbmon_urb_submit_error(&hcd->self, urb, status); in usb_hcd_submit_urb()
1661 urb->hcpriv = NULL; in usb_hcd_submit_urb()
1662 INIT_LIST_HEAD(&urb->urb_list); in usb_hcd_submit_urb()
1663 atomic_dec(&urb->use_count); in usb_hcd_submit_urb()
1664 atomic_dec(&urb->dev->urbnum); in usb_hcd_submit_urb()
1665 if (atomic_read(&urb->reject)) in usb_hcd_submit_urb()
1667 usb_put_urb(urb); in usb_hcd_submit_urb()
1679 static int unlink1(struct usb_hcd *hcd, struct urb *urb, int status) in unlink1() argument
1683 if (is_root_hub(urb->dev)) in unlink1()
1684 value = usb_rh_urb_dequeue(hcd, urb, status); in unlink1()
1690 value = hcd->driver->urb_dequeue(hcd, urb, status); in unlink1()
1701 int usb_hcd_unlink_urb (struct urb *urb, int status) in usb_hcd_unlink_urb() argument
1704 struct usb_device *udev = urb->dev; in usb_hcd_unlink_urb()
1714 if (atomic_read(&urb->use_count) > 0) { in usb_hcd_unlink_urb()
1720 hcd = bus_to_hcd(urb->dev->bus); in usb_hcd_unlink_urb()
1721 retval = unlink1(hcd, urb, status); in usb_hcd_unlink_urb()
1726 urb, retval); in usb_hcd_unlink_urb()
1734 static void __usb_hcd_giveback_urb(struct urb *urb) in __usb_hcd_giveback_urb() argument
1736 struct usb_hcd *hcd = bus_to_hcd(urb->dev->bus); in __usb_hcd_giveback_urb()
1737 struct usb_anchor *anchor = urb->anchor; in __usb_hcd_giveback_urb()
1738 int status = urb->unlinked; in __usb_hcd_giveback_urb()
1741 urb->hcpriv = NULL; in __usb_hcd_giveback_urb()
1742 if (unlikely((urb->transfer_flags & URB_SHORT_NOT_OK) && in __usb_hcd_giveback_urb()
1743 urb->actual_length < urb->transfer_buffer_length && in __usb_hcd_giveback_urb()
1747 unmap_urb_for_dma(hcd, urb); in __usb_hcd_giveback_urb()
1748 usbmon_urb_complete(&hcd->self, urb, status); in __usb_hcd_giveback_urb()
1750 usb_unanchor_urb(urb); in __usb_hcd_giveback_urb()
1755 urb->status = status; in __usb_hcd_giveback_urb()
1768 urb->complete(urb); in __usb_hcd_giveback_urb()
1772 atomic_dec(&urb->use_count); in __usb_hcd_giveback_urb()
1773 if (unlikely(atomic_read(&urb->reject))) in __usb_hcd_giveback_urb()
1775 usb_put_urb(urb); in __usb_hcd_giveback_urb()
1790 struct urb *urb; in usb_giveback_urb_bh() local
1792 urb = list_entry(local_list.next, struct urb, urb_list); in usb_giveback_urb_bh()
1793 list_del_init(&urb->urb_list); in usb_giveback_urb_bh()
1794 bh->completing_ep = urb->ep; in usb_giveback_urb_bh()
1795 __usb_hcd_giveback_urb(urb); in usb_giveback_urb_bh()
1824 void usb_hcd_giveback_urb(struct usb_hcd *hcd, struct urb *urb, int status) in usb_hcd_giveback_urb() argument
1830 if (likely(!urb->unlinked)) in usb_hcd_giveback_urb()
1831 urb->unlinked = status; in usb_hcd_giveback_urb()
1833 if (!hcd_giveback_urb_in_bh(hcd) && !is_root_hub(urb->dev)) { in usb_hcd_giveback_urb()
1834 __usb_hcd_giveback_urb(urb); in usb_hcd_giveback_urb()
1838 if (usb_pipeisoc(urb->pipe) || usb_pipeint(urb->pipe)) { in usb_hcd_giveback_urb()
1847 list_add_tail(&urb->urb_list, &bh->head); in usb_hcd_giveback_urb()
1870 struct urb *urb; in usb_hcd_flush_endpoint() local
1880 list_for_each_entry_reverse(urb, &ep->urb_list, urb_list) { in usb_hcd_flush_endpoint()
1883 if (urb->unlinked) in usb_hcd_flush_endpoint()
1885 usb_get_urb (urb); in usb_hcd_flush_endpoint()
1886 is_in = usb_urb_dir_in(urb); in usb_hcd_flush_endpoint()
1890 unlink1(hcd, urb, -ESHUTDOWN); in usb_hcd_flush_endpoint()
1893 urb, usb_endpoint_num(&ep->desc), in usb_hcd_flush_endpoint()
1909 usb_put_urb (urb); in usb_hcd_flush_endpoint()
1922 urb = NULL; in usb_hcd_flush_endpoint()
1924 urb = list_entry (ep->urb_list.prev, struct urb, in usb_hcd_flush_endpoint()
1926 usb_get_urb (urb); in usb_hcd_flush_endpoint()
1930 if (urb) { in usb_hcd_flush_endpoint()
1931 usb_kill_urb (urb); in usb_hcd_flush_endpoint()
1932 usb_put_urb (urb); in usb_hcd_flush_endpoint()