|USB_PIPE_DRAIN_REQS(9F)||Kernel Functions for Drivers||USB_PIPE_DRAIN_REQS(9F)|
usb_pipe_drain_reqs - Allow completion of pending pipe requests
#include <sys/usb/usba.h> int usb_pipe_drain_reqs(dev_info_t *dip, usb_pipe_handle_t pipe_handle,
uint_t timeout, usb_flags_t usb_flags,
void (*callback)(usb_pipe_handle_t pipe_handle,
usb_opaque_t callback_arg, int rval, usb_cb_flags_t flags),
illumos DDI specific (illumos DDI)
The usb_pipe_drain_reqs() function provides waits for pending requests to complete and then provides synchronous or asynchronous notification that all pending requests on a non-shared pipe indicated by pipe_handle have completed. For a shared pipe (such as the default control pipe used by multiple drivers each managing one interface of a device), this function provides notification that all pending requests on that pipe that are associated with a given dip are completed.
The usb_pipe_drain_reqs() function can be used to notify a close procedure when the default control pipe is clear during device closure, thereby allowing the close procedure to continue safely. Normally, a synchronous call to usb_pipe_close(9F) allows all requests in a pipe to finish before returning. However, a client driver cannot close the default control pipe.
If USB_FLAGS_SLEEP is set in flags, block until all pending requests are completed. Otherwise, return immediately and call the callback handler when all pending requests are completed.
The callback parameter accepts the asynchronous callback handler, which takes the following arguments:
May be called from user or kernel context.
If the USB_CB_ASYNC_REQ_FAILED bit is clear in usb_cb_flags_t, the callback, if supplied, can block because it is executing in kernel context. Otherwise the callback cannot block. Please see usb_callback_flags(9S) for more information on callbacks.
mydev_detach(dev_info_t *dip, ddi_detach_cmd_t cmd)
mydev_state->pipe_state = CLOSED;
/* Wait for pending requests of a pipe to finish. Don't timeout. */
dip, pipe_handle, 0, USB_FLAGS_SLEEP, NULL, 0);
* Dismantle streams and tear down this instance,
* now that all requests have been sent.
For pipes other than the default control pipe, it is recommended to close the pipe using a synchronous usb_pipe_close(). usb_pipe_close() with the USB_FLAGS_SLEEP flag allows any pending requests in that pipe to complete before returning.
Do not call usb_pipe_drain_reqs() while additional requests are being submitted by a different thread. This action can stall the calling thread of usb_pipe_drain_reqs() unnecessarily.
See attributes(7) for descriptions of the following attributes:
|ATTRIBUTE TYPE||ATTRIBUTE VALUE|
|January 5, 2004||OmniOS|