darwin: only attempt to auto-detach driver is one is active
authorNathan Hjelm <hjelmn@google.com>
Thu, 22 Jul 2021 05:12:19 +0000 (23:12 -0600)
committerNathan Hjelm <hjelmn@cs.unm.edu>
Thu, 22 Jul 2021 12:22:35 +0000 (06:22 -0600)
This commit improves the auto-detach code so that it doesn't attempt to detach a kernel
driver if none exists. This will avoid extra info/warning output on the failed detach.

Closes #960

Signed-off-by: Nathan Hjelm <hjelmn@google.com>
libusb/os/darwin_usb.c
libusb/version_nano.h

index 85ca1e8..319289b 100644 (file)
@@ -2490,7 +2490,7 @@ static int darwin_attach_kernel_driver (struct libusb_device_handle *dev_handle,
 
 static int darwin_capture_claim_interface(struct libusb_device_handle *dev_handle, uint8_t iface) {
   enum libusb_error ret;
-  if (dev_handle->auto_detach_kernel_driver) {
+  if (dev_handle->auto_detach_kernel_driver && darwin_kernel_driver_active(dev_handle, iface)) {
     ret = darwin_detach_kernel_driver (dev_handle, iface);
     if (ret != LIBUSB_SUCCESS) {
       usbi_info (HANDLE_CTX (dev_handle), "failed to auto-detach the kernel driver for this device, ret=%d", ret);
index 8dd74ce..0e73473 100644 (file)
@@ -1 +1 @@
-#define LIBUSB_NANO 11643
+#define LIBUSB_NANO 11644