'\" te .\" Copyright (c) 2004, Sun Microsystems, Inc., .\" All Rights Reserved .\" 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. .\" 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. .\" 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] .TH USB_PIPE_CLOSE 9F "Jan 5, 2004" .SH NAME usb_pipe_close \- Close and cleanup a USB device pipe .SH SYNOPSIS .LP .nf #include \fBvoid\fR \fBusb_pipe_close\fR(\fBdev_info_t *\fR\fIdip\fR, \fBusb_pipe_handle_t\fR \fIpipe_handle\fR, \fBusb_flags_t\fR \fIflags\fR, \fBvoid\fR (\fI*callback\fR)(usb_pipe_handle_t \fIpipe_handle\fR, \fBusb_opaque_t\fR \fIarg\fR, \fBint\fR \fIrval\fR, \fBusb_cb_flags_t\fR \fIflags)\fR, \fBusb_opaque_t\fR \fIcallback_arg\fR); .fi .SH INTERFACE LEVEL .sp .LP Solaris DDI specific (Solaris DDI) .SH PARAMETERS .sp .ne 2 .na \fB\fIdip\fR\fR .ad .RS 16n Pointer to the device's \fBdev_info\fR structure. .RE .sp .ne 2 .na \fB\fIpipe_handle\fR\fR .ad .RS 16n Handle of pipe to close. Cannot be a handle to the default control pipe. .RE .sp .ne 2 .na \fB\fIflags\fR\fR .ad .RS 16n USB_FLAGS_SLEEP is the only flag recognized. Set it to wait for resources, for pipe to become free, and for all pending request callbacks to complete. .RE .sp .ne 2 .na \fB\fIcallback\fR\fR .ad .RS 16n This function is called on completion if the USB_FLAGS_SLEEP flag is not specified. Mandatory if the USB_FLAGS_SLEEP flag has not been specified. .RE .sp .ne 2 .na \fB\fIcallback_arg\fR\fR .ad .RS 16n Second argument to callback function. .RE .SH DESCRIPTION .sp .LP The \fBusb_pipe_close()\fR function closes the pipe pointed to by \fIpipe_handle\fR, releases all related resources and then frees the pipe handle. This function stops polling if the pipe to be closed is an interrupt-IN or isochronous-IN pipe. The default control pipe cannot be closed. .sp .LP Pipe cleanup includes waiting for the all pending requests in the pipe to finish, and then flushing residual requests remaining after waiting for several seconds. Exception handlers of flushed requests are called with a completion reason of USB_CR_FLUSHED. .sp .LP If USB_FLAGS_SLEEP is specified in \fIflags\fR, wait for all cleanup operations to complete before calling the callback handler and returning. .sp .LP If USB_FLAGS_SLEEP is not specified in \fIflags\fR, an asynchronous close (to be done in a separate thread) is requested. Return immediately. The callback handler is called after all pending operations are completed. .sp .LP The \fIcallback\fR parameter is the callback handler and takes the following arguments: .sp .ne 2 .na \fBusb_pipe_handle_t pipe_handle\fR .ad .sp .6 .RS 4n Handle of the pipe to close. .RE .sp .ne 2 .na \fBusb_opaque_t callback_arg\fR .ad .sp .6 .RS 4n Callback_arg specified to \fBusb_pipe_close()\fR. .RE .sp .ne 2 .na \fBint rval\fR .ad .sp .6 .RS 4n Return value of close operation .RE .sp .ne 2 .na \fBusb_cb_flags_t callback_flags\fR .ad .sp .6 .RS 4n Status of queueing operation. Can be: .sp .ne 2 .na \fBUSB_CB_NO_INFO\fR .ad .RS 27n Callback was uneventful. .RE .sp .ne 2 .na \fBUSB_CB_ASYNC_REQ_FAILED\fR .ad .RS 27n Error starting asynchronous request. .RE .RE .SH RETURN VALUES .sp .LP Status is returned to the caller via the callback handler's rval argument. Possible callback hander rval argument values are: .sp .ne 2 .na \fBUSB_INVALID_PIPE\fR .ad .RS 23n Pipe handle specifies a pipe which is closed or closing. .RE .sp .ne 2 .na \fBUSB_INVALID_ARGS\fR .ad .RS 23n \fIdip\fR or \fIpipe_handle\fR arguments are NULL. .RE .sp .ne 2 .na \fBUSB_INVALID_CONTEXT\fR .ad .RS 23n Called from interrupt context. .RE .sp .ne 2 .na \fBUSB_INVALID_PERM\fR .ad .RS 23n Pipe handle specifies the default control pipe. .RE .sp .ne 2 .na \fBUSB_FAILURE\fR .ad .RS 23n Asynchronous resources are unavailable. In this case, USB_CB_ASYNC_REQ_FAILED is passed in as the \fIcallback_flags\fR arg to the callback hander. .RE .sp .LP Exception handlers of any queued requests which were flushed are called with a completion reason of USB_CR_FLUSHED. Exception handlers of periodic pipe requests which were terminated are called with USB_CR_PIPE_CLOSING. .sp .LP Note that messages mirroring the above errors are logged to the console logfile on error. (This provides status for calls which otherwise could provide status). .SH CONTEXT .sp .LP May be called from user or kernel context regardless of arguments. May not be called from a callback executing in interrupt context. Please see \fBusb_callback_flags\fR(9S) for more information on callbacks. .sp .LP 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 \fBusb_callback_flags\fR(9S) for more information on callbacks. .SH EXAMPLES .sp .in +2 .nf /* Synchronous close of pipe. */ usb_pipe_close(dip, pipe, USB_FLAGS_SLEEP, NULL, NULL); -------- /* Template callback. */ void close_callback(usb_pipe_handle_t, usb_opaque_t, usb_cb_flags_t); /* Asynchronous close of pipe. */ usb_pipe_close(dip, pipe, 0, close_callback, callback_arg); .fi .in -2 .SH ATTRIBUTES .sp .LP See \fBattributes\fR(5) for descriptions of the following attributes: .sp .sp .TS box; c | c l | l . ATTRIBUTE TYPE ATTRIBUTE VALUE _ Architecture PCI-based systems _ Interface stability Committed .TE .SH SEE ALSO .sp .LP \fBattributes\fR(5), \fBusb_get_status\fR(9F), \fBusb_pipe_drain_reqs\fR(9F), \fBusb_pipe_get_state\fR(9F), \fBusb_pipe_open\fR(9F), \fBusb_pipe_reset\fR(9F), \fBusb_callback_flags\fR(9S)