mirror of
https://github.com/ipxe/ipxe
synced 2025-12-25 17:12:40 +03:00
[usb] Generalise zero-length packet generation logic
The decision on whether or not a zero-length packet needs to be transmitted is independent of the host controller and belongs in the USB core. Signed-off-by: Michael Brown <mcb30@ipxe.org>
This commit is contained in:
@@ -530,6 +530,7 @@ int usb_stream ( struct usb_endpoint *ep, struct io_buffer *iobuf,
|
||||
int terminate ) {
|
||||
struct usb_device *usb = ep->usb;
|
||||
struct usb_port *port = usb->port;
|
||||
int zlp;
|
||||
int rc;
|
||||
|
||||
/* Fail immediately if device has been unplugged */
|
||||
@@ -541,8 +542,13 @@ int usb_stream ( struct usb_endpoint *ep, struct io_buffer *iobuf,
|
||||
( ( rc = usb_endpoint_reset ( ep ) ) != 0 ) )
|
||||
return rc;
|
||||
|
||||
/* Append a zero-length packet if necessary */
|
||||
zlp = terminate;
|
||||
if ( iob_len ( iobuf ) & ( ep->mtu - 1 ) )
|
||||
zlp = 0;
|
||||
|
||||
/* Enqueue stream transfer */
|
||||
if ( ( rc = ep->host->stream ( ep, iobuf, terminate ) ) != 0 ) {
|
||||
if ( ( rc = ep->host->stream ( ep, iobuf, zlp ) ) != 0 ) {
|
||||
DBGC ( usb, "USB %s %s could not enqueue stream transfer: %s\n",
|
||||
usb->name, usb_endpoint_name ( ep ), strerror ( rc ) );
|
||||
return rc;
|
||||
|
||||
Reference in New Issue
Block a user