summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaniel Drake <dsd@gentoo.org>2009-06-20 22:33:21 +0100
committerDaniel Drake <dsd@gentoo.org>2009-06-20 22:33:21 +0100
commit615f18e64e96ae4ecc8e43d0de00933059a5209a (patch)
tree1c8e5bcc86b5eaf8f99bfdf3c7e2aaf59f2ef2e0
parent86f79fbf61c2018bdf009c7ebf92b38f3a16fd0c (diff)
downloadlibusb-615f18e64e96ae4ecc8e43d0de00933059a5209a.tar.gz
Linux: fix sending of zero length bulk packets
Note that there are is a kernel bug preventing this from working properly at the moment, even after this fix.
-rw-r--r--libusb/os/linux_usbfs.c6
1 files changed, 5 insertions, 1 deletions
diff --git a/libusb/os/linux_usbfs.c b/libusb/os/linux_usbfs.c
index 08de28c..f9899cf 100644
--- a/libusb/os/linux_usbfs.c
+++ b/libusb/os/linux_usbfs.c
@@ -1276,7 +1276,9 @@ static int submit_bulk_transfer(struct usbi_transfer *itransfer,
int num_urbs = transfer->length / MAX_BULK_BUFFER_LENGTH;
int last_urb_partial = 0;
- if ((transfer->length % MAX_BULK_BUFFER_LENGTH) > 0) {
+ if (transfer->length == 0) {
+ num_urbs = 1;
+ } else if ((transfer->length % MAX_BULK_BUFFER_LENGTH) > 0) {
last_urb_partial = 1;
num_urbs++;
}
@@ -1300,6 +1302,8 @@ static int submit_bulk_transfer(struct usbi_transfer *itransfer,
urb->buffer = transfer->buffer + (i * MAX_BULK_BUFFER_LENGTH);
if (i == num_urbs - 1 && last_urb_partial)
urb->buffer_length = transfer->length % MAX_BULK_BUFFER_LENGTH;
+ else if (transfer->length == 0)
+ urb->buffer_length = 0;
else
urb->buffer_length = MAX_BULK_BUFFER_LENGTH;