drivers/usb/core/hcd.c
Source file repositories/reference/linux-study-clean/drivers/usb/core/hcd.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/usb/core/hcd.c- Extension
.c- Size
- 92100 bytes
- Lines
- 3193
- Domain
- Driver Families
- Bucket
- drivers/usb
- Inferred role
- Driver Families: exported/initcall integration point
- Status
- integration implementation candidate
Why This File Exists
Repeatable hardware-adapter layer. Deep compatibility for every driver is out of scope; this atlas records patterns, probe lifecycles, bus glue, IRQ/DMA usage, and links back to core abstractions.
- Repeatable hardware-adapter layer. Deep compatibility for every driver is out of scope; this atlas records patterns, probe lifecycles, bus glue, IRQ/DMA usage, and links back to core abstractions.
- Exports symbols or registers init work; inspect boot/module ordering and who consumes the exported contract.
- Uses kernel synchronization; read lock ordering, sleepability, and interrupt context assumptions before translating.
- Touches IRQ or DMA behavior; this matters for the representative real-device path.
- Allocates kernel memory; connect allocation flags and lifetime to context constraints.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
linux/bcd.hlinux/module.hlinux/version.hlinux/kernel.hlinux/sched/task_stack.hlinux/slab.hlinux/completion.hlinux/utsname.hlinux/mm.hasm/io.hlinux/device.hlinux/dma-mapping.hlinux/mutex.hasm/irq.hasm/byteorder.hlinux/unaligned.hlinux/platform_device.hlinux/workqueue.hlinux/pm_runtime.hlinux/types.hlinux/genalloc.hlinux/io.hlinux/kcov.hlinux/phy/phy.hlinux/usb.hlinux/usb/hcd.hlinux/usb/otg.husb.hphy.h
Detected Declarations
function ascii2descfunction rh_stringfunction rh_call_controlfunction usb_hcd_poll_rh_statusfunction rh_timer_funcfunction rh_queue_statusfunction rh_urb_enqueuefunction usb_rh_urb_dequeuefunction usb_bus_initfunction usb_register_busfunction usb_deregister_busfunction usb_new_devicefunction usb_hcd_end_port_resumefunction usb_hcd_end_port_resumefunction usb_calc_bus_timefunction enqueuefunction dequeuefunction usb_hcd_giveback_urbfunction hcd_alloc_coherentfunction hcd_free_coherentfunction usb_hcd_unmap_urb_setup_for_dmafunction unmap_urb_for_dmafunction usb_hcd_unmap_urb_for_dmafunction map_urb_for_dmafunction usb_hcd_map_urb_for_dmafunction usb_submit_urbfunction queuesfunction usb_hcd_unlink_urbfunction __usb_hcd_giveback_urbfunction usb_giveback_urb_bhfunction usb_hcd_giveback_urbfunction usb_hcd_flush_endpointfunction usb_hcd_alloc_bandwidthfunction usb_hcd_disable_endpointfunction usb_hcd_reset_endpointfunction usb_alloc_streamsfunction usb_free_streamsfunction usb_hcd_unlink_urbfunction usb_hcd_get_frame_numberfunction usb_ehset_completionfunction ehset_single_step_set_featurefunction msecs_to_jiffiesfunction hcd_bus_suspendfunction hcd_bus_resumefunction usb_hub_for_each_childfunction hcd_resume_workfunction suspendedfunction usb_bus_start_enum
Annotated Snippet
switch (wValue & 0xff00) {
case USB_DT_DEVICE << 8:
switch (hcd->speed) {
case HCD_USB32:
case HCD_USB31:
bufp = usb31_rh_dev_descriptor;
break;
case HCD_USB3:
bufp = usb3_rh_dev_descriptor;
break;
case HCD_USB2:
bufp = usb2_rh_dev_descriptor;
break;
case HCD_USB11:
bufp = usb11_rh_dev_descriptor;
break;
default:
goto error;
}
len = 18;
if (hcd->has_tt)
patch_protocol = 1;
break;
case USB_DT_CONFIG << 8:
switch (hcd->speed) {
case HCD_USB32:
case HCD_USB31:
case HCD_USB3:
bufp = ss_rh_config_descriptor;
len = sizeof ss_rh_config_descriptor;
break;
case HCD_USB2:
bufp = hs_rh_config_descriptor;
len = sizeof hs_rh_config_descriptor;
break;
case HCD_USB11:
bufp = fs_rh_config_descriptor;
len = sizeof fs_rh_config_descriptor;
break;
default:
goto error;
}
if (device_can_wakeup(&hcd->self.root_hub->dev))
patch_wakeup = 1;
break;
case USB_DT_STRING << 8:
if ((wValue & 0xff) < 4)
urb->actual_length = rh_string(wValue & 0xff,
hcd, ubuf, wLength);
else /* unsupported IDs --> "protocol stall" */
goto error;
break;
case USB_DT_BOS << 8:
goto nongeneric;
default:
goto error;
}
break;
case DeviceRequest | USB_REQ_GET_INTERFACE:
tbuf[0] = 0;
len = 1;
fallthrough;
case DeviceOutRequest | USB_REQ_SET_INTERFACE:
break;
case DeviceOutRequest | USB_REQ_SET_ADDRESS:
/* wValue == urb->dev->devaddr */
dev_dbg (hcd->self.controller, "root hub device address %d\n",
wValue);
break;
/* INTERFACE REQUESTS (no defined feature/status flags) */
/* ENDPOINT REQUESTS */
case EndpointRequest | USB_REQ_GET_STATUS:
/* ENDPOINT_HALT flag */
tbuf[0] = 0;
tbuf[1] = 0;
len = 2;
fallthrough;
case EndpointOutRequest | USB_REQ_CLEAR_FEATURE:
case EndpointOutRequest | USB_REQ_SET_FEATURE:
dev_dbg (hcd->self.controller, "no endpoint features yet\n");
break;
/* CLASS REQUESTS (and errors) */
default:
nongeneric:
/* non-generic request */
Annotation
- Immediate include surface: `linux/bcd.h`, `linux/module.h`, `linux/version.h`, `linux/kernel.h`, `linux/sched/task_stack.h`, `linux/slab.h`, `linux/completion.h`, `linux/utsname.h`.
- Detected declarations: `function ascii2desc`, `function rh_string`, `function rh_call_control`, `function usb_hcd_poll_rh_status`, `function rh_timer_func`, `function rh_queue_status`, `function rh_urb_enqueue`, `function usb_rh_urb_dequeue`, `function usb_bus_init`, `function usb_register_bus`.
- Atlas domain: Driver Families / drivers/usb.
- Implementation status: integration implementation candidate.
- Synchronization appears in or near this file; preserve lock ordering, sleepability, and interrupt-context constraints.
- IRQ or DMA behavior appears here, which is relevant to the selected PCIe/NVMe device path.
Implementation Notes
- This generated page is the file-by-file coverage layer; curated subsystem chapters should link here when they synthesize a multi-file control flow.
- Core OS pages should be promoted from atlas-only to deep-reviewed when they explain data structures, invariants, locking, lifecycle, and C implementation snippets.
- Driver-family pages are intentionally pattern-oriented unless they are part of the selected PCIe/NVMe representative device path.