usb_disconnect(9)
π usb_disconnect(9) β kernel API manual energy
okay so bestie, buckle up, we're looking at usb_disconnect(9) from the Kernel API Manual and honestly? it's giving "cleanup era" β¨
π NAME π
usb_disconnect β disconnect a device (usbcore-internal)
like, it's an internal thing, iykyk, don't go calling it from your random driver fr fr π
π¦ SYNOPSIS π¦
void usb_disconnect (struct usb_device **pdev );
that's it. that's the whole signature. no return value, it just does the thing π
πΈ ARGUMENTS πΈ
pdevβ pointer to the device being disconnected. yes it's a double pointer, yes it's a whole vibe, it's a pointer to the pointer of the device getting yeeted π«Ά
β CONTEXT β
task context, might sleep π΄
translation: you're allowed to block here. do not bring this into an interrupt context, she will NOT survive it.
π DESCRIPTION π
Something got disconnected. Get rid of it and all of its children. that's the whole plot. no cap, entire family tree, gone π§Ήβ¨
okay but the important bits, listen up:
- If
*pdevis a normal device then the parent hub must already be locked. π like, you show up with the lock already held or you don't show up at all. - If
*pdevis a root hub then the caller must hold theusb_bus_idr_lock, which protects the set of root hubs as well as the list of buses. two-for-one protection, iconic π
Only hub drivers (including virtual root hub drivers for host controllers) should ever call this. nobody else. hands off. not your function, not your moment π ββοΈ
β οΈ This call is synchronous, and may not be used in an interrupt context. it sleeps. it blocks. it takes its sweet time and you WILL respect that π
π₯ SEE ALSO π₯
Kernel file ./drivers/usb/core/hub.c β and the whole friend group:
usb_hub_set_port_power(9)usb_hub_clear_tt_buffer(9)usb_remove_device(9)usb_set_device_state(9)usb_enumerate_device_otg(9)usb_enumerate_device(9)usb_new_device(9)usb_deauthorize_device(9)get_port_ssp_rate(9)usb_root_hub_lost_power(9)hub_hc_release_resources(9)usb_reset_and_verify_device(9)usb_reset_device(9)usb_queue_reset_device(9)usb_hub_find_child(9)usb_get_hub_port_acpi_handle(9)
and that's the page, bestie π this one lives in ./drivers/usb/core, dated October 2026 β take care of her, mwah ππβ¨
π¦ 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