Darwin: handle kIOReturnUnderrun
authorHoi-Ho Chan <hoiho.chan@gmail.com>
Wed, 28 Jul 2010 03:04:17 +0000 (21:04 -0600)
committerDaniel Drake <dan@reactivated.net>
Wed, 28 Jul 2010 03:05:50 +0000 (21:05 -0600)
This return code indicates that the device returned a data packet
less than the max packet size. In libusb backend terms, this is
a successful transfer.

AUTHORS
libusb/os/darwin_usb.c

diff --git a/AUTHORS b/AUTHORS
index 6ee0d45..849ac06 100644 (file)
--- a/AUTHORS
+++ b/AUTHORS
@@ -14,6 +14,7 @@ David Moore
 Felipe Balbi
 Francesco Montorsi
 Hans Ulrich Niedermann
+Hoi-Ho Chan
 Ludovic Rousseau
 Martin Koegler
 Mikhail Gusarov
index 6adcb27..fae75b4 100644 (file)
@@ -90,6 +90,7 @@ static const char *darwin_error_str (int result) {
 
 static int darwin_to_libusb (int result) {
   switch (result) {
+  case kIOReturnUnderrun:
   case kIOReturnSuccess:
     return LIBUSB_SUCCESS;
   case kIOReturnNotOpen:
@@ -1335,6 +1336,7 @@ static void darwin_async_io_callback (void *refcon, IOReturn result, void *arg0)
 
 static int darwin_transfer_status (struct usbi_transfer *itransfer, kern_return_t result) {
   switch (result) {
+  case kIOReturnUnderrun:
   case kIOReturnSuccess:
     return LIBUSB_TRANSFER_COMPLETED;
   case kIOReturnAborted:
@@ -1371,7 +1373,7 @@ static void darwin_handle_callback (struct usbi_transfer *itransfer, kern_return
   usbi_info (ITRANSFER_CTX (itransfer), "handling %s completion with kernel status %d",
             isControl ? "control" : isBulk ? "bulk" : isIsoc ? "isoc" : "interrupt", result);
 
-  if (kIOReturnSuccess == result) {
+  if (kIOReturnSuccess == result || kIOReturnUnderrun == result) {
     if (isIsoc && tpriv->isoc_framelist) {
       /* copy isochronous results back */