usb_hcd_giveback_urb(9)
π usb_hcd_giveback_urb(9) β the Kernel API Manual, bestie edition π
okay so this one is from the Kernel API Manual, page usb_hcd_giveback_urb(9), and it's genuinely the "handing your friend back their hoodie" of kernel functions π«Ά
β¨ NAME β¨
usb_hcd_giveback_urb β return URB from HCD to device driver
β¨ SYNOPSIS β¨
void usb_hcd_giveback_urb (struct usb_hcd *hcd , struct urb *urb , int
status );
π ARGUMENTS π
hcdβ the host controller that's returning the URB πurbβ the urb being returned to the USB device driver.statusβ the completion status code for the URB, iykyk.
π CONTEXT π
atomic. No cap, that's the whole vibe.
Here's the tea β: the completion callback gets invoked either in a work queue (BH) context or in the caller's context β which one depends on whether the HCD_BH flag is set in the hcd structure. One exception tho π: URBs submitted to the root hub always complete in BH context. periodt.
πΈ DESCRIPTION πΈ
So what this does is hand the URB from the HCD over to its USB device driver, using its completion function. At this point the HCD has freed all per-urb resources (and is fully done using urb->hcpriv β like, it's moved on, it's not looking back π
). It's also released all HCD locks, so the device driver literally won't cause problems if it frees, modifies, or resubmits this URB. go off, king π
If urb was unlinked, the value of status will be overridden by urb->unlinked. That's just how it is, bestie.
Also, erroneous short transfers are detected in case the HCD hasn't checked for them. considerate of it fr fr π§
π SEE ALSO π
Kernel file ./drivers/usb/core/hcd.c β plus the whole friend group:
ascii2desc(9), rh_string(9), usb_bus_init(9), usb_register_bus(9), usb_deregister_bus(9), register_root_hub(9), usb_calc_bus_time(9), usb_hcd_link_urb_to_ep(9), usb_hcd_check_unlink_urb(9), usb_hcd_unlink_urb_from_ep(9), usb_hcd_alloc_bandwidth(9), usb_hcd_reset_endpoint(9), usb_alloc_streams(9), usb_free_streams(9), usb_hcd_resume_root_hub(9), usb_bus_start_enum(9), usb_hcd_irq(9), usb_hc_died(9), usb_create_shared_hcd(9), usb_create_hcd(9), usb_stop_hcd(9), usb_add_hcd(9), usb_remove_hcd(9)
that's the whole page, bestie!! π¦ this one lives in ./drivers/usb/core and it's dated October 2026 β so like, future vibes only β mwah, go read some kernel source π
π¦ where this page comes from
- nixpkgs unstable: linux-manual 7.3.1
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms