USBD_REF_WAIT(9) Kernel Developer's Manual USBD_REF_WAIT(9)

usbd_ref_incr, usbd_ref_decr, usbd_ref_waitwait for all USB device references to complete

#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);

The () function is used on a device level to tsleep(9) until the reference counter has reached zero.

To increase the reference counter use (). To decrease the reference counter use (). Once the reference counter has been decreased to zero, usbd_ref_decr() will call () to interrupt the () at the point where usbd_ref_wait() was previously set.

Typical use cases to wait for tasks to complete is at device closing or detachment.

usbd_ref_incr(), usbd_ref_decr(), and usbd_ref_wait() can be called during autoconf or from process context.

usb(4), tsleep(9), wakeup(9)

June 30, 2016 OpenBSD 7.6