usb_get_intf(9)
π 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:
usb_find_common_endpoints(9)usb_find_common_endpoints_reverse(9)usb_find_endpoint(9)usb_check_bulk_endpoints(9)usb_check_int_endpoints(9)usb_find_alt_setting(9)usb_ifnum_to_if(9)usb_altnum_to_altsetting(9)usb_find_interface(9)usb_for_each_dev(9)usb_release_dev(9)usb_alloc_dev(9)usb_get_dev(9)usb_put_dev(9)usb_put_intf(9)usb_intf_get_dma_device(9)usb_lock_device_for_reset(9)usb_get_current_frame_number(9)usb_alloc_coherent(9)usb_free_coherent(9)usb_alloc_noncoherent(9)usb_free_noncoherent(9)usb_endpoint_max_periodic_payload(9)usb_endpoint_is_hs_isoc_double(9)
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
- 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