'\" t .\" Title: usb_ep_queue .\" Author: .\" Generator: DocBook XSL Stylesheets v1.78.1 .\" Date: May 2018 .\" Manual: Kernel Mode Gadget API .\" Source: Kernel Hackers Manual 3.16.56 .\" Language: English .\" .TH "USB_EP_QUEUE" "9" "May 2018" "Kernel Hackers Manual 3\&.16\&" "Kernel Mode Gadget API" .\" ----------------------------------------------------------------- .\" * Define some portability stuff .\" ----------------------------------------------------------------- .\" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ .\" http://bugs.debian.org/507673 .\" http://lists.gnu.org/archive/html/groff/2009-02/msg00013.html .\" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ .ie \n(.g .ds Aq \(aq .el .ds Aq ' .\" ----------------------------------------------------------------- .\" * set default formatting .\" ----------------------------------------------------------------- .\" disable hyphenation .nh .\" disable justification (adjust text to left margin only) .ad l .\" ----------------------------------------------------------------- .\" * MAIN CONTENT STARTS HERE * .\" ----------------------------------------------------------------- .SH "NAME" usb_ep_queue \- queues (submits) an I/O request to an endpoint\&. .SH "SYNOPSIS" .HP \w'int\ usb_ep_queue('u .BI "int usb_ep_queue(struct\ usb_ep\ *\ " "ep" ", struct\ usb_request\ *\ " "req" ", gfp_t\ " "gfp_flags" ");" .SH "ARGUMENTS" .PP \fIep\fR .RS 4 the endpoint associated with the request .RE .PP \fIreq\fR .RS 4 the request being submitted .RE .PP \fIgfp_flags\fR .RS 4 GFP_* flags to use in case the lower level driver couldn\*(Aqt pre\-allocate all necessary memory with the request\&. .RE .SH "DESCRIPTION" .PP This tells the device controller to perform the specified request through that endpoint (reading or writing a buffer)\&. When the request completes, including being canceled by \fBusb_ep_dequeue\fR, the request\*(Aqs completion routine is called to return the request to the driver\&. Any endpoint (except control endpoints like ep0) may have more than one transfer request queued; they complete in FIFO order\&. Once a gadget driver submits a request, that request may not be examined or modified until it is given back to that driver through the completion callback\&. .PP Each request is turned into one or more packets\&. The controller driver never merges adjacent requests into the same packet\&. OUT transfers will sometimes use data that\*(Aqs already buffered in the hardware\&. Drivers can rely on the fact that the first byte of the request\*(Aqs buffer always corresponds to the first byte of some USB packet, for both IN and OUT transfers\&. .PP Bulk endpoints can queue any amount of data; the transfer is packetized automatically\&. The last packet will be short if the request doesn\*(Aqt fill it out completely\&. Zero length packets (ZLPs) should be avoided in portable protocols since not all usb hardware can successfully handle zero length packets\&. (ZLPs may be explicitly written, and may be implicitly written if the request \*(Aqzero\*(Aq flag is set\&.) Bulk endpoints may also be used for interrupt transfers; but the reverse is not true, and some endpoints won\*(Aqt support every interrupt transfer\&. (Such as 768 byte packets\&.) .PP Interrupt\-only endpoints are less functional than bulk endpoints, for example by not supporting queueing or not handling buffers that are larger than the endpoint\*(Aqs maxpacket size\&. They may also treat data toggle differently\&. .PP Control endpoints \&.\&.\&. after getting a \fBsetup\fR callback, the driver queues one response (even if it would be zero length)\&. That enables the status ack, after transferring data as specified in the response\&. Setup functions may return negative error codes to generate protocol stalls\&. (Note that some USB device controllers disallow protocol stall responses in some cases\&.) When control responses are deferred (the response is written after the setup callback returns), then \fBusb_ep_set_halt\fR may be used on ep0 to trigger protocol stalls\&. Depending on the controller, it may not be possible to trigger a status\-stage protocol stall when the data stage is over, that is, from within the response\*(Aqs completion routine\&. .PP For periodic endpoints, like interrupt or isochronous ones, the usb host arranges to poll once per interval, and the gadget driver usually will have queued some data to transfer at that time\&. .PP Returns zero, or a negative error code\&. Endpoints that are not enabled report errors; errors will also be reported when the usb peripheral is disconnected\&. .SH "AUTHOR" .PP \fBDavid Brownell\fR <\&dbrownell@users.sourceforge.net\&> .RS 4 Author. .RE .SH "COPYRIGHT" .br