USBD_REF_WAIT(9)

πŸ“¦ in nixpkgs unstable

πŸ‘‘ USBD_REF_WAIT(9) β€” wait for all USB device references to complete πŸ’…

okay bestie, this is the kernel dev manual page for USBD_REF_WAIT(9), and it's literally all about waiting for USB device references to finish so nothing gets yanked out from under you. iconic behavior, no cap 🫢


✨ NAME ✨

usbd_ref_incr, usbd_ref_decr, usbd_ref_wait β€” wait for all USB device references to complete 🌸


πŸŽ€ SYNOPSIS πŸŽ€

#include <dev/usb/usb.h>
#include <dev/usb/usbdi.h>

void
usbd_ref_incr(struct usbd_device *dev);

void
usbd_ref_decr(struct usbd_device *dev);

void
usbd_ref_wait(struct usbd_device *dev);

πŸ¦‹ DESCRIPTION πŸ¦‹

So the main character here is usbd_ref_wait() πŸ’– It's used at the device level to call tsleep(9) and wait until the reference counter has reached zero. like it literally will not let the vibe move on until that counter says 0, periodt ✨

To bump the reference counter up, use usbd_ref_incr() πŸ‘‘ To bring the reference counter down, use usbd_ref_decr() πŸ’…

And here's the slay part: once the reference counter has been decreased all the way to zero, usbd_ref_decr() will call wakeup() to interrupt the tsleep() at the point where usbd_ref_wait() was previously set 😭πŸ”₯

Typical use cases for waiting for tasks to complete are at device closing or detachment. very "bestie don't leave yet, we're still finishing up" energy ngl 🫢


🌈 CONTEXT 🌈

usbd_ref_incr(), usbd_ref_decr(), and usbd_ref_wait() can be called during autoconf or from process context. lowkey flexible, highkey useful ✨


🌟 SEE ALSO 🌟


bestie reminder: this page is giving "wait for all USB device references to complete" energy, and the important bit is that the counter going to zero is what wakes up the tsleep() from usbd_ref_wait(). don't forget it πŸ’€πŸ’–

cute little sign-off: this one comes from the Debian manual pages, dated June 30, 2016, and it's serving kernel-developer-manual realness πŸŽ€πŸ¦‹πŸ’œ

πŸ“¦ where this page comes from
  • nixpkgs unstable: cvs-export
  • πŸ’– girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms