2 .\" Copyright (c) 2004, Sun Microsystems, Inc., All Rights Reserved
3 .\" The contents of this file are subject to the terms of the Common Development and Distribution License (the "License"). You may not use this file except in compliance with the License.
4 .\" You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE or http://www.opensolaris.org/os/licensing. See the License for the specific language governing permissions and limitations under the License.
5 .\" When distributing Covered Code, include this CDDL HEADER in each file and include the License file at usr/src/OPENSOLARIS.LICENSE. If applicable, add the following below this CDDL HEADER, with the fields enclosed by brackets "[]" replaced with your own identifying information: Portions Copyright [yyyy] [name of copyright owner]
6 .TH USB_PIPE_DRAIN_REQS 9F "Jan 5, 2004"
8 usb_pipe_drain_reqs \- Allow completion of pending pipe requests
12 #include <sys/usb/usba.h>
16 \fBint\fR \fBusb_pipe_drain_reqs\fR(\fBdev_info_t *\fR\fIdip\fR, \fBusb_pipe_handle_t\fR \fIpipe_handle\fR,
17 \fBuint_t\fR \fItimeout\fR, \fBusb_flags_t\fR \fIusb_flags\fR,
18 \fBvoid (*\fR\fIcallback\fR)(usb_pipe_handle_t \fIpipe_handle\fR,
19 \fBusb_opaque_t\fR \fIcallback_arg\fR, \fBint\fR \fIrval\fR, \fBusb_cb_flags_t\fR \fIflags)\fR,
20 \fBusb_opaque_t\fR \fIcallback_arg\fR);
26 Solaris DDI specific (Solaris DDI)
34 Pointer to the device's \fBdev_info\fR structure.
40 \fB\fIpipe_handle\fR\fR
43 Handle of the pipe containing pending requests.
52 Maximum wait time for requests to drain. Must be a non-negative value in
53 seconds. Zero specifies no timeout.
62 USB_FLAGS_SLEEP is the only flag recognized. Wait for completion and do not
72 Callback handler to notify of asynchronous completion.
78 \fB\fIcallback_arg\fR\fR
81 Second argument passed to callback function.
87 The \fBusb_pipe_drain_reqs()\fR function provides waits for pending requests to
88 complete and then provides synchronous or asynchronous notification that all
89 pending requests on a non-shared pipe indicated by pipe_handle have completed.
90 For a shared pipe (such as the default control pipe used by multiple drivers
91 each managing one interface of a device), this function provides notification
92 that all pending requests on that pipe that are associated with a given dip are
96 The \fBusb_pipe_drain_reqs()\fR function can be used to notify a close
97 procedure when the default control pipe is clear during device closure, thereby
98 allowing the close procedure to continue safely. Normally, a synchronous call
99 to \fBusb_pipe_close\fR(9F) allows all requests in a pipe to finish before
100 returning. However, a client driver cannot close the default control pipe.
103 If USB_FLAGS_SLEEP is set in flags, block until all pending requests are
104 completed. Otherwise, return immediately and call the callback handler when all
105 pending requests are completed.
108 The \fIcallback\fR parameter accepts the asynchronous callback handler, which
109 takes the following arguments:
113 \fBusb_pipe_handle_t default_pipe_handle\fR
117 Handle of the pipe to drain.
123 \fBusb_opaque_t callback_arg\fR
127 callback_arg specified to \fBusb_pipe_drain_reqs()\fR.
143 \fBusb_cb_flags_t callback_flags\fR
147 Status of the queueing operation. Can be:
154 Callback was uneventful.
160 \fBUSB_CB_ASYNC_REQ_FAILED\fR
163 Error starting asynchronous request.
175 Request is successful.
181 \fBUSB_INVALID_ARGS\fR
184 \fIdip\fR argument is \fBNULL\fR. USB_FLAGS_SLEEP is clear and callback is
191 \fBUSB_INVALID_CONTEXT\fR
194 Called from callback context with the USB_FLAGS_SLEEP flag set.
200 \fBUSB_INVALID_PIPE\fR
203 Pipe is not open, is closing or is closed.
209 May be called from user or kernel context.
212 If the USB_CB_ASYNC_REQ_FAILED bit is clear in usb_cb_flags_t, the callback, if
213 supplied, can block because it is executing in kernel context. Otherwise the
214 callback cannot block. Please see \fBusb_callback_flags\fR(9S) for more
215 information on callbacks.
220 mydev_detach(dev_info_t *dip, ddi_detach_cmd_t cmd)
226 mydev_state->pipe_state = CLOSED;
228 /* Wait for pending requests of a pipe to finish. Don't timeout. */
229 (void) usb_pipe_drain_reqs(
230 dip, pipe_handle, 0, USB_FLAGS_SLEEP, NULL, 0);
233 * Dismantle streams and tear down this instance,
234 * now that all requests have been sent.
239 ddi_remove_minor_node(dip, NULL);
250 For pipes other than the default control pipe, it is recommended to close the
251 pipe using a synchronous \fBusb_pipe_close()\fR. \fBusb_pipe_close()\fR with
252 the USB_FLAGS_SLEEP flag allows any pending requests in that pipe to complete
256 Do not call \fBusb_pipe_drain_reqs()\fR while additional requests are being
257 submitted by a different thread. This action can stall the calling thread of
258 \fBusb_pipe_drain_reqs()\fR unnecessarily.
262 See \fBattributes\fR(5) for descriptions of the following attributes:
270 ATTRIBUTE TYPE ATTRIBUTE VALUE
272 Architecture PCI-based systems
274 Interface stability Committed
280 \fBattributes\fR(5), \fBusb_pipe_close\fR(9F), \fBusb_pipe_reset\fR(9F),
281 \fBusb_callback_flags\fR(9S)