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"
9 usb_pipe_close \- Close and cleanup a USB device pipe
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);
26 Solaris DDI specific (Solaris DDI)
33 Pointer to the device's \fBdev_info\fR structure.
39 \fB\fIpipe_handle\fR\fR
42 Handle of pipe to close. Cannot be a handle to the default control pipe.
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.
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.
68 \fB\fIcallback_arg\fR\fR
71 Second argument to callback function.
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.
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.
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.
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.
97 The \fIcallback\fR parameter is the callback handler and takes the following
102 \fBusb_pipe_handle_t pipe_handle\fR
106 Handle of the pipe to close.
112 \fBusb_opaque_t callback_arg\fR
116 Callback_arg specified to \fBusb_pipe_close()\fR.
126 Return value of close operation
132 \fBusb_cb_flags_t callback_flags\fR
136 Status of queueing operation. Can be:
143 Callback was uneventful.
149 \fBUSB_CB_ASYNC_REQ_FAILED\fR
152 Error starting asynchronous request.
159 Status is returned to the caller via the callback handler's rval argument.
160 Possible callback hander rval argument values are:
164 \fBUSB_INVALID_PIPE\fR
167 Pipe handle specifies a pipe which is closed or closing.
173 \fBUSB_INVALID_ARGS\fR
176 \fIdip\fR or \fIpipe_handle\fR arguments are NULL.
182 \fBUSB_INVALID_CONTEXT\fR
185 Called from interrupt context.
191 \fBUSB_INVALID_PERM\fR
194 Pipe handle specifies the default control pipe.
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
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.
231 /* Synchronous close of pipe. */
232 usb_pipe_close(dip, pipe, USB_FLAGS_SLEEP, NULL, NULL);
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);
247 See \fBattributes\fR(5) for descriptions of the following attributes:
255 ATTRIBUTE TYPE ATTRIBUTE VALUE
257 Architecture PCI-based systems
259 Interface stability Committed
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)