diff options
author | Nathan Hjelm <hjelmn@me.com> | 2021-10-28 10:25:03 -0600 |
---|---|---|
committer | Nathan Hjelm <hjelmn@me.com> | 2021-10-28 10:25:03 -0600 |
commit | 4f6754f3c6529a78a22cb6bdc9274671a911c64c (patch) | |
tree | 96a799641e481ca98b8633ccfd36aa1d524b7f42 | |
parent | e88b77ff6e848df299e4d9ed4926581991b7ffdf (diff) | |
download | libusb-4f6754f3c6529a78a22cb6bdc9274671a911c64c.tar.gz |
darwin: add support for handling new error code (kUSBHostReturnPipeStalled)
With macOS Monterey Apple started using a new error code to indicate a pipe
stall. This new error code needs to be handled both in translation to libusb
error codes and when handling errors setting the alt setting.
References #1011
Signed-off-by: Nathan Hjelm <hjelmn@google.com>
-rw-r--r-- | libusb/os/darwin_usb.c | 10 | ||||
-rw-r--r-- | libusb/version_nano.h | 2 |
2 files changed, 10 insertions, 2 deletions
diff --git a/libusb/os/darwin_usb.c b/libusb/os/darwin_usb.c index 1243e87..007ffd1 100644 --- a/libusb/os/darwin_usb.c +++ b/libusb/os/darwin_usb.c @@ -107,6 +107,9 @@ static const char *darwin_error_str (IOReturn result) { case kIOReturnExclusiveAccess: return "another process has device opened for exclusive access"; case kIOUSBPipeStalled: +#if defined(kUSBHostReturnPipeStalled) + case kUSBHostReturnPipeStalled: +#endif return "pipe is stalled"; case kIOReturnError: return "could not establish a connection to the Darwin kernel"; @@ -146,6 +149,9 @@ static enum libusb_error darwin_to_libusb (IOReturn result) { case kIOReturnExclusiveAccess: return LIBUSB_ERROR_ACCESS; case kIOUSBPipeStalled: +#if defined(kUSBHostReturnPipeStalled) + case kUSBHostReturnPipeStalled: +#endif return LIBUSB_ERROR_PIPE; case kIOReturnBadArgument: return LIBUSB_ERROR_INVALID_PARAM; @@ -1603,8 +1609,10 @@ static int darwin_set_interface_altsetting(struct libusb_device_handle *dev_hand else usbi_warn (HANDLE_CTX (dev_handle), "SetAlternateInterface: %s", darwin_error_str(kresult)); - if (kresult != kIOUSBPipeStalled) + ret = darwin_to_libusb(kresult); + if (ret != LIBUSB_ERROR_PIPE) { return darwin_to_libusb (kresult); + } /* If a device only supports a default setting for the specified interface, then a STALL (kIOUSBPipeStalled) may be returned. Ref: USB 2.0 specs 9.4.10. diff --git a/libusb/version_nano.h b/libusb/version_nano.h index 0243e23..08f69c6 100644 --- a/libusb/version_nano.h +++ b/libusb/version_nano.h @@ -1 +1 @@ -#define LIBUSB_NANO 11656 +#define LIBUSB_NANO 11657 |