usb_disconnect(9)

πŸ“¦ version 7.3.1, in nixpkgs unstable

πŸ’… 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 *pdev is 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 *pdev is a root hub then the caller must hold the usb_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:


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