Merge commit '9276b3991ba20d5a5660887ba81b0bc7bed25a0c'
[unleashed.git] / share / man / man9f / usb_pipe_close.9f
blob571ca577ca4fea3d8f6aa71a08e203a8c9a0d7a7
1 '\" te
2 .\" Copyright (c) 2004, Sun Microsystems, Inc.,
3 .\" All Rights Reserved
4 .\" 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.
5 .\" 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.
6 .\" 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]
7 .TH USB_PIPE_CLOSE 9F "Sep 16, 2016"
8 .SH NAME
9 usb_pipe_close \- Close and cleanup a USB device pipe
10 .SH SYNOPSIS
11 .LP
12 .nf
13 #include <sys/usb/usba.h>
17 \fBvoid\fR \fBusb_pipe_close\fR(\fBdev_info_t *\fR\fIdip\fR, \fBusb_pipe_handle_t\fR \fIpipe_handle\fR,
18      \fBusb_flags_t\fR \fIflags\fR,
19      \fBvoid\fR (\fI*callback\fR)(usb_pipe_handle_t \fIpipe_handle\fR,
20      \fBusb_opaque_t\fR \fIarg\fR, \fBint\fR \fIrval\fR,
21      \fBusb_cb_flags_t\fR \fIflags)\fR, \fBusb_opaque_t\fR \fIcallback_arg\fR);
22 .fi
24 .SH INTERFACE LEVEL
25 .LP
26 Solaris DDI specific (Solaris DDI)
27 .SH PARAMETERS
28 .ne 2
29 .na
30 \fB\fIdip\fR\fR
31 .ad
32 .RS 16n
33 Pointer to the device's \fBdev_info\fR structure.
34 .RE
36 .sp
37 .ne 2
38 .na
39 \fB\fIpipe_handle\fR\fR
40 .ad
41 .RS 16n
42 Handle of pipe to close. Cannot be a handle to the default control pipe.
43 .RE
45 .sp
46 .ne 2
47 .na
48 \fB\fIflags\fR\fR
49 .ad
50 .RS 16n
51 USB_FLAGS_SLEEP is the only flag recognized. Set it to wait for resources, for
52 pipe to become free, and for all pending request callbacks to complete.
53 .RE
55 .sp
56 .ne 2
57 .na
58 \fB\fIcallback\fR\fR
59 .ad
60 .RS 16n
61 This function is called on completion if the USB_FLAGS_SLEEP flag is not
62 specified. Mandatory if the USB_FLAGS_SLEEP flag has not been specified.
63 .RE
65 .sp
66 .ne 2
67 .na
68 \fB\fIcallback_arg\fR\fR
69 .ad
70 .RS 16n
71 Second argument to callback function.
72 .RE
74 .SH DESCRIPTION
75 .LP
76 The \fBusb_pipe_close()\fR function closes the pipe pointed to by
77 \fIpipe_handle\fR, releases all related resources and then frees the pipe
78 handle. This function stops polling if the pipe to be closed is an interrupt-IN
79 or isochronous-IN pipe. The default control pipe cannot be closed.
80 .sp
81 .LP
82 Pipe cleanup includes waiting for the all pending requests in the pipe to
83 finish, and then flushing residual requests remaining after waiting for several
84 seconds.  Exception handlers of flushed requests are called with a completion
85 reason of USB_CR_FLUSHED.
86 .sp
87 .LP
88 If USB_FLAGS_SLEEP is specified in \fIflags\fR, wait for all cleanup operations
89 to complete before calling the callback handler and returning.
90 .sp
91 .LP
92 If USB_FLAGS_SLEEP is not specified in \fIflags\fR, an asynchronous close (to
93 be done in a separate thread) is requested. Return immediately. The callback
94 handler is called after all pending operations are completed.
95 .sp
96 .LP
97 The \fIcallback\fR parameter is the callback handler and takes the following
98 arguments:
99 .sp
100 .ne 2
102 \fBusb_pipe_handle_t pipe_handle\fR
104 .sp .6
105 .RS 4n
106 Handle of the pipe to close.
110 .ne 2
112 \fBusb_opaque_t callback_arg\fR
114 .sp .6
115 .RS 4n
116 Callback_arg specified to \fBusb_pipe_close()\fR.
120 .ne 2
122 \fBint rval\fR
124 .sp .6
125 .RS 4n
126 Return value of close operation
130 .ne 2
132 \fBusb_cb_flags_t callback_flags\fR
134 .sp .6
135 .RS 4n
136 Status of queueing operation. Can be:
138 .ne 2
140 \fBUSB_CB_NO_INFO\fR
142 .RS 27n
143 Callback was uneventful.
147 .ne 2
149 \fBUSB_CB_ASYNC_REQ_FAILED\fR
151 .RS 27n
152 Error starting asynchronous request.
157 .SH RETURN VALUES
159 Status is returned to the caller via the callback handler's rval argument.
160 Possible callback hander rval argument values are:
162 .ne 2
164 \fBUSB_INVALID_PIPE\fR
166 .RS 23n
167 Pipe handle specifies a pipe which is closed or closing.
171 .ne 2
173 \fBUSB_INVALID_ARGS\fR
175 .RS 23n
176 \fIdip\fR or \fIpipe_handle\fR arguments are NULL.
180 .ne 2
182 \fBUSB_INVALID_CONTEXT\fR
184 .RS 23n
185 Called from interrupt context.
189 .ne 2
191 \fBUSB_INVALID_PERM\fR
193 .RS 23n
194 Pipe handle specifies  the default control pipe.
198 .ne 2
200 \fBUSB_FAILURE\fR
202 .RS 23n
203 Asynchronous resources are unavailable. In this case, USB_CB_ASYNC_REQ_FAILED
204 is passed in as the \fIcallback_flags\fR arg to the callback hander.
209 Exception handlers of any queued requests which were flushed are called with a
210 completion reason of USB_CR_FLUSHED. Exception handlers of periodic pipe
211 requests which were terminated  are called with USB_CR_PIPE_CLOSING.
214 Note that messages mirroring the above errors are logged to the console logfile
215 on error. (This provides status for calls which otherwise could provide
216 status).
217 .SH CONTEXT
219 May be called from user or kernel context regardless of arguments. May not be
220 called from a callback executing in interrupt     context. Please see
221 \fBusb_callback_flags\fR(9S) for more information on callbacks.
224 If the USB_CB_ASYNC_REQ_FAILED bit is clear in usb_cb_flags_t, the callback, if
225 supplied, can block because it is executing in kernel context. Otherwise the
226 callback cannot block. Please see \fBusb_callback_flags\fR(9S) for more
227 information on callbacks.
228 .SH EXAMPLES
229 .in +2
231 /* Synchronous close of pipe. */
232 usb_pipe_close(dip, pipe, USB_FLAGS_SLEEP, NULL, NULL);
234     --------
236 /* Template callback. */
237 void close_callback(usb_pipe_handle_t, usb_opaque_t, usb_cb_flags_t);
239 /* Asynchronous close of pipe. */
240 usb_pipe_close(dip, pipe, 0, close_callback, callback_arg);
243 .in -2
245 .SH ATTRIBUTES
247 See \fBattributes\fR(5) for descriptions of the following attributes:
252 box;
253 c | c
254 l | l .
255 ATTRIBUTE TYPE  ATTRIBUTE VALUE
257 Architecture    PCI-based systems
259 Interface stability     Committed
262 .SH SEE ALSO
264 \fBattributes\fR(5), \fBusb_get_status\fR(9F), \fBusb_pipe_drain_reqs\fR(9F),
265 \fBusb_pipe_get_state\fR(9F), \fBusb_pipe_xopen\fR(9F),
266 \fBusb_pipe_reset\fR(9F), \fBusb_callback_flags\fR(9S)