From 4d9fc6264366f971a7382e7b5bb91c46c440c0f1 Mon Sep 17 00:00:00 2001 From: Roman Kalashnikov Date: Sat, 28 Oct 2017 20:31:39 +0300 Subject: [PATCH] linux_usbfs: Fixed excessive check Closes #358 Signed-off-by: Chris Dickens --- libusb/os/linux_usbfs.c | 8 +++----- libusb/version_nano.h | 2 +- 2 files changed, 4 insertions(+), 6 deletions(-) diff --git a/libusb/os/linux_usbfs.c b/libusb/os/linux_usbfs.c index 98cce75..9486d66 100644 --- a/libusb/os/linux_usbfs.c +++ b/libusb/os/linux_usbfs.c @@ -1716,10 +1716,7 @@ static int detach_kernel_driver_and_claim(struct libusb_device_handle *handle, strcpy(dc.driver, "usbfs"); dc.flags = USBFS_DISCONNECT_CLAIM_EXCEPT_DRIVER; r = ioctl(fd, IOCTL_USBFS_DISCONNECT_CLAIM, &dc); - if (r == 0 || (r != 0 && errno != ENOTTY)) { - if (r == 0) - return 0; - + if (r != 0 && errno != ENOTTY) { switch (errno) { case EBUSY: return LIBUSB_ERROR_BUSY; @@ -1731,7 +1728,8 @@ static int detach_kernel_driver_and_claim(struct libusb_device_handle *handle, usbi_err(HANDLE_CTX(handle), "disconnect-and-claim failed errno %d", errno); return LIBUSB_ERROR_OTHER; - } + } else if (r == 0) + return 0; /* Fallback code for kernels which don't support the disconnect-and-claim ioctl */ diff --git a/libusb/version_nano.h b/libusb/version_nano.h index d7e79b6..129f818 100644 --- a/libusb/version_nano.h +++ b/libusb/version_nano.h @@ -1 +1 @@ -#define LIBUSB_NANO 11217 +#define LIBUSB_NANO 11218 -- 2.7.4