usb_hcd_giveback_urb(9)

πŸ“¦ version 7.3.1, in nixpkgs unstable

πŸ’– 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