8322 nl: misleading-indentation
[unleashed/tickless.git] / usr / src / man / man9f / usb_pipe_drain_reqs.9f
bloba987e49a5c949030a621486f8613c55d56328de6
1 '\" te
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"
7 .SH NAME
8 usb_pipe_drain_reqs \- Allow completion of pending pipe requests
9 .SH SYNOPSIS
10 .LP
11 .nf
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);
21 .fi
23 .SH INTERFACE LEVEL
24 .sp
25 .LP
26 Solaris DDI specific (Solaris DDI)
27 .SH PARAMETERS
28 .sp
29 .ne 2
30 .na
31 \fB\fIdip\fR\fR
32 .ad
33 .RS 16n
34 Pointer to the device's \fBdev_info\fR structure.
35 .RE
37 .sp
38 .ne 2
39 .na
40 \fB\fIpipe_handle\fR\fR
41 .ad
42 .RS 16n
43 Handle of the pipe containing pending requests.
44 .RE
46 .sp
47 .ne 2
48 .na
49 \fB\fItimeout\fR\fR
50 .ad
51 .RS 16n
52 Maximum wait time for requests to drain. Must be a non-negative value in
53 seconds. Zero specifies no timeout.
54 .RE
56 .sp
57 .ne 2
58 .na
59 \fB\fIflags\fR\fR
60 .ad
61 .RS 16n
62 USB_FLAGS_SLEEP is the only flag recognized. Wait for completion and do not
63 call callback.
64 .RE
66 .sp
67 .ne 2
68 .na
69 \fB\fIcallback\fR\fR
70 .ad
71 .RS 16n
72 Callback handler to notify of asynchronous completion.
73 .RE
75 .sp
76 .ne 2
77 .na
78 \fB\fIcallback_arg\fR\fR
79 .ad
80 .RS 16n
81 Second argument passed to callback function.
82 .RE
84 .SH DESCRIPTION
85 .sp
86 .LP
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
93 completed.
94 .sp
95 .LP
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:
111 .ne 2
113 \fBusb_pipe_handle_t default_pipe_handle\fR
115 .sp .6
116 .RS 4n
117 Handle of the pipe to drain.
121 .ne 2
123 \fBusb_opaque_t callback_arg\fR
125 .sp .6
126 .RS 4n
127 callback_arg specified to \fBusb_pipe_drain_reqs()\fR.
131 .ne 2
133 \fBint rval\fR
135 .sp .6
136 .RS 4n
137 Request status.
141 .ne 2
143 \fBusb_cb_flags_t callback_flags\fR
145 .sp .6
146 .RS 4n
147 Status of the queueing operation. Can be:
149 .ne 2
151 \fBUSB_CB_NO_INFO\fR
153 .RS 27n
154 Callback was uneventful.
158 .ne 2
160 \fBUSB_CB_ASYNC_REQ_FAILED\fR
162 .RS 27n
163 Error starting asynchronous request.
168 .SH RETURN VALUES
170 .ne 2
172 \fBUSB_SUCCESS\fR
174 .RS 23n
175 Request is successful.
179 .ne 2
181 \fBUSB_INVALID_ARGS\fR
183 .RS 23n
184 \fIdip\fR argument is \fBNULL\fR. USB_FLAGS_SLEEP is clear and callback is
185 \fBNULL\fR.
189 .ne 2
191 \fBUSB_INVALID_CONTEXT\fR
193 .RS 23n
194 Called from callback context with the USB_FLAGS_SLEEP flag set.
198 .ne 2
200 \fBUSB_INVALID_PIPE\fR
202 .RS 23n
203 Pipe is not open, is closing or is closed.
206 .SH CONTEXT
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.
216 .SH EXAMPLES
218 .in +2
220   mydev_detach(dev_info_t *dip, ddi_detach_cmd_t cmd)
223       ...
224       ...
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);
232       /*
233        * Dismantle streams and tear down this instance,
234        * now that all requests have been sent.
235        */
236       qprocsoff(q);
237       ...
238       ...
239       ddi_remove_minor_node(dip, NULL);
240       ...
241       ...
245 .in -2
247 .SH NOTES
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
253 before returning.
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.
259 .SH ATTRIBUTES
262 See \fBattributes\fR(5) for descriptions of the following attributes:
267 box;
268 c | c
269 l | l .
270 ATTRIBUTE TYPE  ATTRIBUTE VALUE
272 Architecture    PCI-based systems
274 Interface stability     Committed
277 .SH SEE ALSO
280 \fBattributes\fR(5), \fBusb_pipe_close\fR(9F), \fBusb_pipe_reset\fR(9F),
281 \fBusb_callback_flags\fR(9S)