usb_get_intf(9)

πŸ“¦ version 7.3.1, in nixpkgs unstable

πŸ’– usb_get_intf β€” a Kernel API Manual moment πŸ’–

okay so bestie, we're in the Kernel API Manual today and the vibe is reference counting. stay with me, it's actually slay.

✨ NAME ✨

usb_get_intf β€” literally just bumps up the reference count of the usb interface structure. that's the whole job. iconic behaviour honestly.

🌸 SYNOPSIS 🌸

struct usb_interface * usb_get_intf (struct usb_interface *intf );

πŸŽ€ ARGUMENTS πŸŽ€

  • intf β€” the interface being referenced. that's the one you're out here counting refs for πŸ’…

πŸ¦‹ DESCRIPTION πŸ¦‹

so every live reference to an interface must be refcounted. no cap, that's the rule.

drivers for USB interfaces should normally record these references in their probe methods, like, right when they bind to an interface. and then they release them by calling usb_put_intf in their disconnect methods. cute little matched set, we love a symmetry moment 🫢

BUT β€” and this is the plot twist β€” if a driver does not access the usb_interface structure after its disconnect method returns, then refcounting is not necessary. why? because the USB core guarantees that a usb_interface will not be deallocated until after its driver has been unbound. so like, the core's got you. periodt.

⭐ RETURN ⭐

a pointer to the interface with the incremented reference counter. same interface, one more ref. she ate πŸ’…

πŸ”₯ SEE ALSO πŸ”₯

kernel file ./drivers/usb/core/usb.c, and honestly the whole friend group:


and that's the page, bestie πŸ’œ this one lives in ./drivers/usb/core, and the version girlies stamped it October 2026 β€” go get that ref 🌈✨

πŸ“¦ where this page comes from