Lines Matching refs:hcd
435 rh_string(int id, struct usb_hcd const *hcd, u8 *data, unsigned len) in rh_string() argument
452 s = hcd->self.bus_name; in rh_string()
456 s = hcd->product_desc; in rh_string()
461 init_utsname()->release, hcd->driver->description); in rh_string()
474 static int rh_call_control (struct usb_hcd *hcd, struct urb *urb) in rh_call_control() argument
490 status = usb_hcd_link_urb_to_ep(hcd, urb); in rh_call_control()
494 urb->hcpriv = hcd; /* Indicate it's queued */ in rh_call_control()
541 tbuf[0] = (device_may_wakeup(&hcd->self.root_hub->dev) in rh_call_control()
549 device_set_wakeup_enable(&hcd->self.root_hub->dev, 0); in rh_call_control()
554 if (device_can_wakeup(&hcd->self.root_hub->dev) in rh_call_control()
556 device_set_wakeup_enable(&hcd->self.root_hub->dev, 1); in rh_call_control()
569 switch (hcd->speed) { in rh_call_control()
590 if (hcd->has_tt) in rh_call_control()
594 switch (hcd->speed) { in rh_call_control()
613 if (device_can_wakeup(&hcd->self.root_hub->dev)) in rh_call_control()
619 hcd, ubuf, wLength); in rh_call_control()
637 dev_dbg (hcd->self.controller, "root hub device address %d\n", in rh_call_control()
653 dev_dbg (hcd->self.controller, "no endpoint features yet\n"); in rh_call_control()
679 status = hcd->driver->hub_control (hcd, in rh_call_control()
684 usb_hub_adjust_deviceremovable(hcd->self.root_hub, in rh_call_control()
695 dev_dbg (hcd->self.controller, in rh_call_control()
733 usb_hcd_unlink_urb_from_ep(hcd, urb); in rh_call_control()
734 usb_hcd_giveback_urb(hcd, urb, status); in rh_call_control()
749 void usb_hcd_poll_rh_status(struct usb_hcd *hcd) in usb_hcd_poll_rh_status() argument
756 if (unlikely(!hcd->rh_pollable)) in usb_hcd_poll_rh_status()
758 if (!hcd->uses_new_polling && !hcd->status_urb) in usb_hcd_poll_rh_status()
761 length = hcd->driver->hub_status_data(hcd, buffer); in usb_hcd_poll_rh_status()
766 urb = hcd->status_urb; in usb_hcd_poll_rh_status()
768 clear_bit(HCD_FLAG_POLL_PENDING, &hcd->flags); in usb_hcd_poll_rh_status()
769 hcd->status_urb = NULL; in usb_hcd_poll_rh_status()
773 usb_hcd_unlink_urb_from_ep(hcd, urb); in usb_hcd_poll_rh_status()
774 usb_hcd_giveback_urb(hcd, urb, 0); in usb_hcd_poll_rh_status()
777 set_bit(HCD_FLAG_POLL_PENDING, &hcd->flags); in usb_hcd_poll_rh_status()
786 if (hcd->uses_new_polling ? HCD_POLL_RH(hcd) : in usb_hcd_poll_rh_status()
787 (length == 0 && hcd->status_urb != NULL)) in usb_hcd_poll_rh_status()
788 mod_timer (&hcd->rh_timer, (jiffies/(HZ/4) + 1) * (HZ/4)); in usb_hcd_poll_rh_status()
802 static int rh_queue_status (struct usb_hcd *hcd, struct urb *urb) in rh_queue_status() argument
809 if (hcd->status_urb || urb->transfer_buffer_length < len) { in rh_queue_status()
810 dev_dbg (hcd->self.controller, "not queuing rh status urb\n"); in rh_queue_status()
815 retval = usb_hcd_link_urb_to_ep(hcd, urb); in rh_queue_status()
819 hcd->status_urb = urb; in rh_queue_status()
820 urb->hcpriv = hcd; /* indicate it's queued */ in rh_queue_status()
821 if (!hcd->uses_new_polling) in rh_queue_status()
822 mod_timer(&hcd->rh_timer, (jiffies/(HZ/4) + 1) * (HZ/4)); in rh_queue_status()
825 else if (HCD_POLL_PENDING(hcd)) in rh_queue_status()
826 mod_timer(&hcd->rh_timer, jiffies); in rh_queue_status()
833 static int rh_urb_enqueue (struct usb_hcd *hcd, struct urb *urb) in rh_urb_enqueue() argument
836 return rh_queue_status (hcd, urb); in rh_urb_enqueue()
838 return rh_call_control (hcd, urb); in rh_urb_enqueue()
847 static int usb_rh_urb_dequeue(struct usb_hcd *hcd, struct urb *urb, int status) in usb_rh_urb_dequeue() argument
853 rc = usb_hcd_check_unlink_urb(hcd, urb, status); in usb_rh_urb_dequeue()
861 if (!hcd->uses_new_polling) in usb_rh_urb_dequeue()
862 del_timer (&hcd->rh_timer); in usb_rh_urb_dequeue()
863 if (urb == hcd->status_urb) { in usb_rh_urb_dequeue()
864 hcd->status_urb = NULL; in usb_rh_urb_dequeue()
865 usb_hcd_unlink_urb_from_ep(hcd, urb); in usb_rh_urb_dequeue()
866 usb_hcd_giveback_urb(hcd, urb, status); in usb_rh_urb_dequeue()
884 struct usb_hcd *hcd; in authorized_default_show() local
886 hcd = bus_to_hcd(usb_bus); in authorized_default_show()
887 return snprintf(buf, PAGE_SIZE, "%u\n", !!HCD_DEV_AUTHORIZED(hcd)); in authorized_default_show()
898 struct usb_hcd *hcd; in authorized_default_store() local
900 hcd = bus_to_hcd(usb_bus); in authorized_default_store()
904 set_bit(HCD_FLAG_DEV_AUTHORIZED, &hcd->flags); in authorized_default_store()
906 clear_bit(HCD_FLAG_DEV_AUTHORIZED, &hcd->flags); in authorized_default_store()
927 struct usb_hcd *hcd = bus_to_hcd(usb_dev->bus); in interface_authorized_default_show() local
929 return sprintf(buf, "%u\n", !!HCD_INTF_AUTHORIZED(hcd)); in interface_authorized_default_show()
943 struct usb_hcd *hcd = bus_to_hcd(usb_dev->bus); in interface_authorized_default_store() local
951 set_bit(HCD_FLAG_INTF_AUTHORIZED, &hcd->flags); in interface_authorized_default_store()
953 clear_bit(HCD_FLAG_INTF_AUTHORIZED, &hcd->flags); in interface_authorized_default_store()
1068 static int register_root_hub(struct usb_hcd *hcd) in register_root_hub() argument
1070 struct device *parent_dev = hcd->self.controller; in register_root_hub()
1071 struct usb_device *usb_dev = hcd->self.root_hub; in register_root_hub()
1111 hcd->rh_registered = 1; in register_root_hub()
1115 if (HCD_DEAD(hcd)) in register_root_hub()
1116 usb_hc_died (hcd); /* This time clean up */ in register_root_hub()
1241 int usb_hcd_link_urb_to_ep(struct usb_hcd *hcd, struct urb *urb) in usb_hcd_link_urb_to_ep() argument
1267 if (HCD_RH_RUNNING(hcd)) { in usb_hcd_link_urb_to_ep()
1299 int usb_hcd_check_unlink_urb(struct usb_hcd *hcd, struct urb *urb, in usb_hcd_check_unlink_urb() argument
1332 void usb_hcd_unlink_urb_from_ep(struct usb_hcd *hcd, struct urb *urb) in usb_hcd_unlink_urb_from_ep() argument
1425 void usb_hcd_unmap_urb_setup_for_dma(struct usb_hcd *hcd, struct urb *urb) in usb_hcd_unmap_urb_setup_for_dma() argument
1429 dma_unmap_single(hcd->self.sysdev, in usb_hcd_unmap_urb_setup_for_dma()
1445 static void unmap_urb_for_dma(struct usb_hcd *hcd, struct urb *urb) in unmap_urb_for_dma() argument
1447 if (hcd->driver->unmap_urb_for_dma) in unmap_urb_for_dma()
1448 hcd->driver->unmap_urb_for_dma(hcd, urb); in unmap_urb_for_dma()
1450 usb_hcd_unmap_urb_for_dma(hcd, urb); in unmap_urb_for_dma()
1453 void usb_hcd_unmap_urb_for_dma(struct usb_hcd *hcd, struct urb *urb) in usb_hcd_unmap_urb_for_dma() argument
1457 usb_hcd_unmap_urb_setup_for_dma(hcd, urb); in usb_hcd_unmap_urb_for_dma()
1462 dma_unmap_sg(hcd->self.sysdev, in usb_hcd_unmap_urb_for_dma()
1468 dma_unmap_page(hcd->self.sysdev, in usb_hcd_unmap_urb_for_dma()
1474 dma_unmap_single(hcd->self.sysdev, in usb_hcd_unmap_urb_for_dma()
1491 static int map_urb_for_dma(struct usb_hcd *hcd, struct urb *urb, in map_urb_for_dma() argument
1494 if (hcd->driver->map_urb_for_dma) in map_urb_for_dma()
1495 return hcd->driver->map_urb_for_dma(hcd, urb, mem_flags); in map_urb_for_dma()
1497 return usb_hcd_map_urb_for_dma(hcd, urb, mem_flags); in map_urb_for_dma()
1500 int usb_hcd_map_urb_for_dma(struct usb_hcd *hcd, struct urb *urb, in usb_hcd_map_urb_for_dma() argument
1513 if (hcd->self.uses_pio_for_control) in usb_hcd_map_urb_for_dma()
1515 if (IS_ENABLED(CONFIG_HAS_DMA) && hcd->self.uses_dma) { in usb_hcd_map_urb_for_dma()
1525 hcd->self.sysdev, in usb_hcd_map_urb_for_dma()
1529 if (dma_mapping_error(hcd->self.sysdev, in usb_hcd_map_urb_for_dma()
1533 } else if (hcd->driver->flags & HCD_LOCAL_MEM) { in usb_hcd_map_urb_for_dma()
1549 if (IS_ENABLED(CONFIG_HAS_DMA) && hcd->self.uses_dma) { in usb_hcd_map_urb_for_dma()
1560 hcd->self.sysdev, in usb_hcd_map_urb_for_dma()
1575 hcd->self.sysdev, in usb_hcd_map_urb_for_dma()
1580 if (dma_mapping_error(hcd->self.sysdev, in usb_hcd_map_urb_for_dma()
1593 hcd->self.sysdev, in usb_hcd_map_urb_for_dma()
1597 if (dma_mapping_error(hcd->self.sysdev, in usb_hcd_map_urb_for_dma()
1603 } else if (hcd->driver->flags & HCD_LOCAL_MEM) { in usb_hcd_map_urb_for_dma()
1615 usb_hcd_unmap_urb_for_dma(hcd, urb); in usb_hcd_map_urb_for_dma()
1631 struct usb_hcd *hcd = bus_to_hcd(urb->dev->bus); in usb_hcd_submit_urb() local
1640 usbmon_urb_submit(&hcd->self, urb); in usb_hcd_submit_urb()
1651 status = rh_urb_enqueue(hcd, urb); in usb_hcd_submit_urb()
1653 status = map_urb_for_dma(hcd, urb, mem_flags); in usb_hcd_submit_urb()
1655 status = hcd->driver->urb_enqueue(hcd, urb, mem_flags); in usb_hcd_submit_urb()
1657 unmap_urb_for_dma(hcd, urb); in usb_hcd_submit_urb()
1662 usbmon_urb_submit_error(&hcd->self, urb, status); in usb_hcd_submit_urb()
1681 static int unlink1(struct usb_hcd *hcd, struct urb *urb, int status) in unlink1() argument
1686 value = usb_rh_urb_dequeue(hcd, urb, status); in unlink1()
1692 value = hcd->driver->urb_dequeue(hcd, urb, status); in unlink1()
1705 struct usb_hcd *hcd; in usb_hcd_unlink_urb() local
1722 hcd = bus_to_hcd(urb->dev->bus); in usb_hcd_unlink_urb()
1723 retval = unlink1(hcd, urb, status); in usb_hcd_unlink_urb()
1738 struct usb_hcd *hcd = bus_to_hcd(urb->dev->bus); in __usb_hcd_giveback_urb() local
1749 unmap_urb_for_dma(hcd, urb); in __usb_hcd_giveback_urb()
1750 usbmon_urb_complete(&hcd->self, urb, status); in __usb_hcd_giveback_urb()
1826 void usb_hcd_giveback_urb(struct usb_hcd *hcd, struct urb *urb, int status) in usb_hcd_giveback_urb() argument
1835 if (!hcd_giveback_urb_in_bh(hcd) && !is_root_hub(urb->dev)) { in usb_hcd_giveback_urb()
1841 bh = &hcd->high_prio_bh; in usb_hcd_giveback_urb()
1844 bh = &hcd->low_prio_bh; in usb_hcd_giveback_urb()
1871 struct usb_hcd *hcd; in usb_hcd_flush_endpoint() local
1877 hcd = bus_to_hcd(udev->bus); in usb_hcd_flush_endpoint()
1892 unlink1(hcd, urb, -ESHUTDOWN); in usb_hcd_flush_endpoint()
1893 dev_dbg (hcd->self.controller, in usb_hcd_flush_endpoint()
1968 struct usb_hcd *hcd; in usb_hcd_alloc_bandwidth() local
1971 hcd = bus_to_hcd(udev->bus); in usb_hcd_alloc_bandwidth()
1972 if (!hcd->driver->check_bandwidth) in usb_hcd_alloc_bandwidth()
1980 hcd->driver->drop_endpoint(hcd, udev, ep); in usb_hcd_alloc_bandwidth()
1983 hcd->driver->drop_endpoint(hcd, udev, ep); in usb_hcd_alloc_bandwidth()
1985 hcd->driver->check_bandwidth(hcd, udev); in usb_hcd_alloc_bandwidth()
2001 ret = hcd->driver->drop_endpoint(hcd, udev, ep); in usb_hcd_alloc_bandwidth()
2007 ret = hcd->driver->drop_endpoint(hcd, udev, ep); in usb_hcd_alloc_bandwidth()
2025 ret = hcd->driver->add_endpoint(hcd, udev, &alt->endpoint[j]); in usb_hcd_alloc_bandwidth()
2054 ret = hcd->driver->drop_endpoint(hcd, udev, in usb_hcd_alloc_bandwidth()
2061 ret = hcd->driver->add_endpoint(hcd, udev, in usb_hcd_alloc_bandwidth()
2067 ret = hcd->driver->check_bandwidth(hcd, udev); in usb_hcd_alloc_bandwidth()
2070 hcd->driver->reset_bandwidth(hcd, udev); in usb_hcd_alloc_bandwidth()
2085 struct usb_hcd *hcd; in usb_hcd_disable_endpoint() local
2088 hcd = bus_to_hcd(udev->bus); in usb_hcd_disable_endpoint()
2089 if (hcd->driver->endpoint_disable) in usb_hcd_disable_endpoint()
2090 hcd->driver->endpoint_disable(hcd, ep); in usb_hcd_disable_endpoint()
2104 struct usb_hcd *hcd = bus_to_hcd(udev->bus); in usb_hcd_reset_endpoint() local
2106 if (hcd->driver->endpoint_reset) in usb_hcd_reset_endpoint()
2107 hcd->driver->endpoint_reset(hcd, ep); in usb_hcd_reset_endpoint()
2138 struct usb_hcd *hcd; in usb_alloc_streams() local
2143 hcd = bus_to_hcd(dev->bus); in usb_alloc_streams()
2144 if (!hcd->driver->alloc_streams || !hcd->driver->free_streams) in usb_alloc_streams()
2160 ret = hcd->driver->alloc_streams(hcd, dev, eps, num_eps, in usb_alloc_streams()
2188 struct usb_hcd *hcd; in usb_free_streams() local
2193 hcd = bus_to_hcd(dev->bus); in usb_free_streams()
2202 ret = hcd->driver->free_streams(hcd, dev, eps, num_eps, mem_flags); in usb_free_streams()
2229 struct usb_hcd *hcd = bus_to_hcd(udev->bus); in usb_hcd_get_frame_number() local
2231 if (!HCD_RH_RUNNING(hcd)) in usb_hcd_get_frame_number()
2233 return hcd->driver->get_frame_number (hcd); in usb_hcd_get_frame_number()
2242 struct usb_hcd *hcd = bus_to_hcd(rhdev->bus); in hcd_bus_suspend() local
2244 int old_state = hcd->state; in hcd_bus_suspend()
2249 if (HCD_DEAD(hcd)) { in hcd_bus_suspend()
2254 if (!hcd->driver->bus_suspend) { in hcd_bus_suspend()
2257 clear_bit(HCD_FLAG_RH_RUNNING, &hcd->flags); in hcd_bus_suspend()
2258 hcd->state = HC_STATE_QUIESCING; in hcd_bus_suspend()
2259 status = hcd->driver->bus_suspend(hcd); in hcd_bus_suspend()
2263 hcd->state = HC_STATE_SUSPENDED; in hcd_bus_suspend()
2266 usb_phy_roothub_suspend(hcd->self.sysdev, in hcd_bus_suspend()
2267 hcd->phy_roothub); in hcd_bus_suspend()
2273 status = hcd->driver->hub_status_data(hcd, buffer); in hcd_bus_suspend()
2282 if (!HCD_DEAD(hcd)) { in hcd_bus_suspend()
2283 set_bit(HCD_FLAG_RH_RUNNING, &hcd->flags); in hcd_bus_suspend()
2284 hcd->state = old_state; in hcd_bus_suspend()
2295 struct usb_hcd *hcd = bus_to_hcd(rhdev->bus); in hcd_bus_resume() local
2297 int old_state = hcd->state; in hcd_bus_resume()
2301 if (HCD_DEAD(hcd)) { in hcd_bus_resume()
2307 status = usb_phy_roothub_resume(hcd->self.sysdev, in hcd_bus_resume()
2308 hcd->phy_roothub); in hcd_bus_resume()
2313 if (!hcd->driver->bus_resume) in hcd_bus_resume()
2315 if (HCD_RH_RUNNING(hcd)) in hcd_bus_resume()
2318 hcd->state = HC_STATE_RESUMING; in hcd_bus_resume()
2319 status = hcd->driver->bus_resume(hcd); in hcd_bus_resume()
2320 clear_bit(HCD_FLAG_WAKEUP_PENDING, &hcd->flags); in hcd_bus_resume()
2326 if (!HCD_DEAD(hcd)) { in hcd_bus_resume()
2330 set_bit(HCD_FLAG_RH_RUNNING, &hcd->flags); in hcd_bus_resume()
2331 hcd->state = HC_STATE_RUNNING; in hcd_bus_resume()
2349 hcd->state = old_state; in hcd_bus_resume()
2350 usb_phy_roothub_suspend(hcd->self.sysdev, hcd->phy_roothub); in hcd_bus_resume()
2354 usb_hc_died(hcd); in hcd_bus_resume()
2362 struct usb_hcd *hcd = container_of(work, struct usb_hcd, wakeup_work); in hcd_resume_work() local
2363 struct usb_device *udev = hcd->self.root_hub; in hcd_resume_work()
2377 void usb_hcd_resume_root_hub (struct usb_hcd *hcd) in usb_hcd_resume_root_hub() argument
2382 if (hcd->rh_registered) { in usb_hcd_resume_root_hub()
2383 pm_wakeup_event(&hcd->self.root_hub->dev, 0); in usb_hcd_resume_root_hub()
2384 set_bit(HCD_FLAG_WAKEUP_PENDING, &hcd->flags); in usb_hcd_resume_root_hub()
2385 queue_work(pm_wq, &hcd->wakeup_work); in usb_hcd_resume_root_hub()
2412 struct usb_hcd *hcd; in usb_bus_start_enum() local
2419 hcd = bus_to_hcd(bus); in usb_bus_start_enum()
2420 if (port_num && hcd->driver->start_port_reset) in usb_bus_start_enum()
2421 status = hcd->driver->start_port_reset(hcd, port_num); in usb_bus_start_enum()
2427 mod_timer(&hcd->rh_timer, jiffies + msecs_to_jiffies(10)); in usb_bus_start_enum()
2448 struct usb_hcd *hcd = __hcd; in usb_hcd_irq() local
2451 if (unlikely(HCD_DEAD(hcd) || !HCD_HW_ACCESSIBLE(hcd))) in usb_hcd_irq()
2453 else if (hcd->driver->irq(hcd) == IRQ_NONE) in usb_hcd_irq()
2474 void usb_hc_died (struct usb_hcd *hcd) in usb_hc_died() argument
2478 dev_err (hcd->self.controller, "HC died; cleaning up\n"); in usb_hc_died()
2481 clear_bit(HCD_FLAG_RH_RUNNING, &hcd->flags); in usb_hc_died()
2482 set_bit(HCD_FLAG_DEAD, &hcd->flags); in usb_hc_died()
2483 if (hcd->rh_registered) { in usb_hc_died()
2484 clear_bit(HCD_FLAG_POLL_RH, &hcd->flags); in usb_hc_died()
2487 usb_set_device_state (hcd->self.root_hub, in usb_hc_died()
2489 usb_kick_hub_wq(hcd->self.root_hub); in usb_hc_died()
2491 if (usb_hcd_is_primary_hcd(hcd) && hcd->shared_hcd) { in usb_hc_died()
2492 hcd = hcd->shared_hcd; in usb_hc_died()
2493 clear_bit(HCD_FLAG_RH_RUNNING, &hcd->flags); in usb_hc_died()
2494 set_bit(HCD_FLAG_DEAD, &hcd->flags); in usb_hc_died()
2495 if (hcd->rh_registered) { in usb_hc_died()
2496 clear_bit(HCD_FLAG_POLL_RH, &hcd->flags); in usb_hc_died()
2499 usb_set_device_state(hcd->self.root_hub, in usb_hc_died()
2501 usb_kick_hub_wq(hcd->self.root_hub); in usb_hc_died()
2523 struct usb_hcd *hcd; in __usb_create_hcd() local
2525 hcd = kzalloc(sizeof(*hcd) + driver->hcd_priv_size, GFP_KERNEL); in __usb_create_hcd()
2526 if (!hcd) in __usb_create_hcd()
2529 hcd->address0_mutex = kmalloc(sizeof(*hcd->address0_mutex), in __usb_create_hcd()
2531 if (!hcd->address0_mutex) { in __usb_create_hcd()
2532 kfree(hcd); in __usb_create_hcd()
2536 mutex_init(hcd->address0_mutex); in __usb_create_hcd()
2537 hcd->bandwidth_mutex = kmalloc(sizeof(*hcd->bandwidth_mutex), in __usb_create_hcd()
2539 if (!hcd->bandwidth_mutex) { in __usb_create_hcd()
2540 kfree(hcd->address0_mutex); in __usb_create_hcd()
2541 kfree(hcd); in __usb_create_hcd()
2545 mutex_init(hcd->bandwidth_mutex); in __usb_create_hcd()
2546 dev_set_drvdata(dev, hcd); in __usb_create_hcd()
2549 hcd->address0_mutex = primary_hcd->address0_mutex; in __usb_create_hcd()
2550 hcd->bandwidth_mutex = primary_hcd->bandwidth_mutex; in __usb_create_hcd()
2551 hcd->primary_hcd = primary_hcd; in __usb_create_hcd()
2553 hcd->shared_hcd = primary_hcd; in __usb_create_hcd()
2554 primary_hcd->shared_hcd = hcd; in __usb_create_hcd()
2558 kref_init(&hcd->kref); in __usb_create_hcd()
2560 usb_bus_init(&hcd->self); in __usb_create_hcd()
2561 hcd->self.controller = dev; in __usb_create_hcd()
2562 hcd->self.sysdev = sysdev; in __usb_create_hcd()
2563 hcd->self.bus_name = bus_name; in __usb_create_hcd()
2564 hcd->self.uses_dma = (sysdev->dma_mask != NULL); in __usb_create_hcd()
2566 timer_setup(&hcd->rh_timer, rh_timer_func, 0); in __usb_create_hcd()
2568 INIT_WORK(&hcd->wakeup_work, hcd_resume_work); in __usb_create_hcd()
2571 hcd->driver = driver; in __usb_create_hcd()
2572 hcd->speed = driver->flags & HCD_MASK; in __usb_create_hcd()
2573 hcd->product_desc = (driver->product_desc) ? driver->product_desc : in __usb_create_hcd()
2575 return hcd; in __usb_create_hcd()
2635 struct usb_hcd *hcd = container_of (kref, struct usb_hcd, kref); in hcd_release() local
2638 if (hcd->shared_hcd) { in hcd_release()
2639 struct usb_hcd *peer = hcd->shared_hcd; in hcd_release()
2644 kfree(hcd->address0_mutex); in hcd_release()
2645 kfree(hcd->bandwidth_mutex); in hcd_release()
2648 kfree(hcd); in hcd_release()
2651 struct usb_hcd *usb_get_hcd (struct usb_hcd *hcd) in usb_get_hcd() argument
2653 if (hcd) in usb_get_hcd()
2654 kref_get (&hcd->kref); in usb_get_hcd()
2655 return hcd; in usb_get_hcd()
2659 void usb_put_hcd (struct usb_hcd *hcd) in usb_put_hcd() argument
2661 if (hcd) in usb_put_hcd()
2662 kref_put (&hcd->kref, hcd_release); in usb_put_hcd()
2666 int usb_hcd_is_primary_hcd(struct usb_hcd *hcd) in usb_hcd_is_primary_hcd() argument
2668 if (!hcd->primary_hcd) in usb_hcd_is_primary_hcd()
2670 return hcd == hcd->primary_hcd; in usb_hcd_is_primary_hcd()
2674 int usb_hcd_find_raw_port_number(struct usb_hcd *hcd, int port1) in usb_hcd_find_raw_port_number() argument
2676 if (!hcd->driver->find_raw_port_number) in usb_hcd_find_raw_port_number()
2679 return hcd->driver->find_raw_port_number(hcd, port1); in usb_hcd_find_raw_port_number()
2682 static int usb_hcd_request_irqs(struct usb_hcd *hcd, in usb_hcd_request_irqs() argument
2687 if (hcd->driver->irq) { in usb_hcd_request_irqs()
2689 snprintf(hcd->irq_descr, sizeof(hcd->irq_descr), "%s:usb%d", in usb_hcd_request_irqs()
2690 hcd->driver->description, hcd->self.busnum); in usb_hcd_request_irqs()
2692 hcd->irq_descr, hcd); in usb_hcd_request_irqs()
2694 dev_err(hcd->self.controller, in usb_hcd_request_irqs()
2699 hcd->irq = irqnum; in usb_hcd_request_irqs()
2700 dev_info(hcd->self.controller, "irq %d, %s 0x%08llx\n", irqnum, in usb_hcd_request_irqs()
2701 (hcd->driver->flags & HCD_MEMORY) ? in usb_hcd_request_irqs()
2703 (unsigned long long)hcd->rsrc_start); in usb_hcd_request_irqs()
2705 hcd->irq = 0; in usb_hcd_request_irqs()
2706 if (hcd->rsrc_start) in usb_hcd_request_irqs()
2707 dev_info(hcd->self.controller, "%s 0x%08llx\n", in usb_hcd_request_irqs()
2708 (hcd->driver->flags & HCD_MEMORY) ? in usb_hcd_request_irqs()
2710 (unsigned long long)hcd->rsrc_start); in usb_hcd_request_irqs()
2719 static void usb_put_invalidate_rhdev(struct usb_hcd *hcd) in usb_put_invalidate_rhdev() argument
2724 rhdev = hcd->self.root_hub; in usb_put_invalidate_rhdev()
2725 hcd->self.root_hub = NULL; in usb_put_invalidate_rhdev()
2740 int usb_add_hcd(struct usb_hcd *hcd, in usb_add_hcd() argument
2746 if (!hcd->skip_phy_initialization && usb_hcd_is_primary_hcd(hcd)) { in usb_add_hcd()
2747 hcd->phy_roothub = usb_phy_roothub_alloc(hcd->self.sysdev); in usb_add_hcd()
2748 if (IS_ERR(hcd->phy_roothub)) in usb_add_hcd()
2749 return PTR_ERR(hcd->phy_roothub); in usb_add_hcd()
2751 retval = usb_phy_roothub_init(hcd->phy_roothub); in usb_add_hcd()
2755 retval = usb_phy_roothub_power_on(hcd->phy_roothub); in usb_add_hcd()
2760 dev_info(hcd->self.controller, "%s\n", hcd->product_desc); in usb_add_hcd()
2764 if (hcd->wireless) in usb_add_hcd()
2765 clear_bit(HCD_FLAG_DEV_AUTHORIZED, &hcd->flags); in usb_add_hcd()
2767 set_bit(HCD_FLAG_DEV_AUTHORIZED, &hcd->flags); in usb_add_hcd()
2770 set_bit(HCD_FLAG_DEV_AUTHORIZED, &hcd->flags); in usb_add_hcd()
2772 clear_bit(HCD_FLAG_DEV_AUTHORIZED, &hcd->flags); in usb_add_hcd()
2774 set_bit(HCD_FLAG_HW_ACCESSIBLE, &hcd->flags); in usb_add_hcd()
2777 set_bit(HCD_FLAG_INTF_AUTHORIZED, &hcd->flags); in usb_add_hcd()
2783 retval = hcd_buffer_create(hcd); in usb_add_hcd()
2785 dev_dbg(hcd->self.sysdev, "pool alloc failed\n"); in usb_add_hcd()
2789 retval = usb_register_bus(&hcd->self); in usb_add_hcd()
2793 rhdev = usb_alloc_dev(NULL, &hcd->self, 0); in usb_add_hcd()
2795 dev_err(hcd->self.sysdev, "unable to allocate root hub\n"); in usb_add_hcd()
2800 hcd->self.root_hub = rhdev; in usb_add_hcd()
2806 switch (hcd->speed) { in usb_add_hcd()
2841 set_bit(HCD_FLAG_RH_RUNNING, &hcd->flags); in usb_add_hcd()
2846 if (hcd->driver->reset) { in usb_add_hcd()
2847 retval = hcd->driver->reset(hcd); in usb_add_hcd()
2849 dev_err(hcd->self.controller, "can't setup: %d\n", in usb_add_hcd()
2854 hcd->rh_pollable = 1; in usb_add_hcd()
2857 if (device_can_wakeup(hcd->self.controller) in usb_add_hcd()
2858 && device_can_wakeup(&hcd->self.root_hub->dev)) in usb_add_hcd()
2859 dev_dbg(hcd->self.controller, "supports USB remote wakeup\n"); in usb_add_hcd()
2862 init_giveback_urb_bh(&hcd->high_prio_bh); in usb_add_hcd()
2863 init_giveback_urb_bh(&hcd->low_prio_bh); in usb_add_hcd()
2868 if (usb_hcd_is_primary_hcd(hcd) && irqnum) { in usb_add_hcd()
2869 retval = usb_hcd_request_irqs(hcd, irqnum, irqflags); in usb_add_hcd()
2874 hcd->state = HC_STATE_RUNNING; in usb_add_hcd()
2875 retval = hcd->driver->start(hcd); in usb_add_hcd()
2877 dev_err(hcd->self.controller, "startup error %d\n", retval); in usb_add_hcd()
2882 retval = register_root_hub(hcd); in usb_add_hcd()
2892 if (hcd->uses_new_polling && HCD_POLL_RH(hcd)) in usb_add_hcd()
2893 usb_hcd_poll_rh_status(hcd); in usb_add_hcd()
2898 clear_bit(HCD_FLAG_RH_RUNNING, &hcd->flags); in usb_add_hcd()
2899 if (HC_IS_RUNNING(hcd->state)) in usb_add_hcd()
2900 hcd->state = HC_STATE_QUIESCING; in usb_add_hcd()
2902 hcd->rh_registered = 0; in usb_add_hcd()
2906 cancel_work_sync(&hcd->wakeup_work); in usb_add_hcd()
2912 hcd->rh_pollable = 0; in usb_add_hcd()
2913 clear_bit(HCD_FLAG_POLL_RH, &hcd->flags); in usb_add_hcd()
2914 del_timer_sync(&hcd->rh_timer); in usb_add_hcd()
2915 hcd->driver->stop(hcd); in usb_add_hcd()
2916 hcd->state = HC_STATE_HALT; in usb_add_hcd()
2917 clear_bit(HCD_FLAG_POLL_RH, &hcd->flags); in usb_add_hcd()
2918 del_timer_sync(&hcd->rh_timer); in usb_add_hcd()
2920 if (usb_hcd_is_primary_hcd(hcd) && hcd->irq > 0) in usb_add_hcd()
2921 free_irq(irqnum, hcd); in usb_add_hcd()
2925 usb_put_invalidate_rhdev(hcd); in usb_add_hcd()
2927 usb_deregister_bus(&hcd->self); in usb_add_hcd()
2929 hcd_buffer_destroy(hcd); in usb_add_hcd()
2931 usb_phy_roothub_power_off(hcd->phy_roothub); in usb_add_hcd()
2933 usb_phy_roothub_exit(hcd->phy_roothub); in usb_add_hcd()
2947 void usb_remove_hcd(struct usb_hcd *hcd) in usb_remove_hcd() argument
2949 struct usb_device *rhdev = hcd->self.root_hub; in usb_remove_hcd()
2951 dev_info(hcd->self.controller, "remove, state %x\n", hcd->state); in usb_remove_hcd()
2956 clear_bit(HCD_FLAG_RH_RUNNING, &hcd->flags); in usb_remove_hcd()
2957 if (HC_IS_RUNNING (hcd->state)) in usb_remove_hcd()
2958 hcd->state = HC_STATE_QUIESCING; in usb_remove_hcd()
2960 dev_dbg(hcd->self.controller, "roothub graceful disconnect\n"); in usb_remove_hcd()
2962 hcd->rh_registered = 0; in usb_remove_hcd()
2966 cancel_work_sync(&hcd->wakeup_work); in usb_remove_hcd()
2988 hcd->rh_pollable = 0; in usb_remove_hcd()
2989 clear_bit(HCD_FLAG_POLL_RH, &hcd->flags); in usb_remove_hcd()
2990 del_timer_sync(&hcd->rh_timer); in usb_remove_hcd()
2992 hcd->driver->stop(hcd); in usb_remove_hcd()
2993 hcd->state = HC_STATE_HALT; in usb_remove_hcd()
2996 clear_bit(HCD_FLAG_POLL_RH, &hcd->flags); in usb_remove_hcd()
2997 del_timer_sync(&hcd->rh_timer); in usb_remove_hcd()
2999 if (usb_hcd_is_primary_hcd(hcd)) { in usb_remove_hcd()
3000 if (hcd->irq > 0) in usb_remove_hcd()
3001 free_irq(hcd->irq, hcd); in usb_remove_hcd()
3004 usb_deregister_bus(&hcd->self); in usb_remove_hcd()
3005 hcd_buffer_destroy(hcd); in usb_remove_hcd()
3007 usb_phy_roothub_power_off(hcd->phy_roothub); in usb_remove_hcd()
3008 usb_phy_roothub_exit(hcd->phy_roothub); in usb_remove_hcd()
3010 usb_put_invalidate_rhdev(hcd); in usb_remove_hcd()
3011 hcd->flags = 0; in usb_remove_hcd()
3018 struct usb_hcd *hcd = platform_get_drvdata(dev); in usb_hcd_platform_shutdown() local
3020 if (hcd->driver->shutdown) in usb_hcd_platform_shutdown()
3021 hcd->driver->shutdown(hcd); in usb_hcd_platform_shutdown()