Skip to content

Commit

Permalink
m4/nut_check_libusb.m4, drivers/usb-common.h + nutdrv_atcl_usb.c + ri…
Browse files Browse the repository at this point in the history
…chcomm_usb.c: only apply usb_detach_kernel_driver_np to libusb-0.1 builds (no alias tricks)
  • Loading branch information
jimklimov committed Dec 25, 2021
1 parent 777406a commit abb01ed
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 3 deletions.
3 changes: 2 additions & 1 deletion drivers/nutdrv_atcl_usb.c
Original file line number Diff line number Diff line change
Expand Up @@ -457,7 +457,8 @@ static int usb_device_open(usb_dev_handle **handlep, USBDevice_t *device, USBDev
#endif /* WITH_LIBUSB_1_0 */
return ret;
}
#ifdef HAVE_USB_DETACH_KERNEL_DRIVER_NP

#if WITH_LIBUSB_0_1 && (defined HAVE_USB_DETACH_KERNEL_DRIVER_NP)
/* this method requires at least libusb 0.1.8:
* it forces device claiming by unbinding
* attached driver... From libhid */
Expand Down
2 changes: 1 addition & 1 deletion drivers/richcomm_usb.c
Original file line number Diff line number Diff line change
Expand Up @@ -506,7 +506,7 @@ static int usb_device_open(usb_dev_handle **handlep, USBDevice_t *device, USBDev
#endif /* WITH_LIBUSB_1_0 */
return ret;
}
#ifdef HAVE_USB_DETACH_KERNEL_DRIVER_NP
#if WITH_LIBUSB_0_1 && (defined HAVE_USB_DETACH_KERNEL_DRIVER_NP)
/* this method requires at least libusb 0.1.8:
* it force device claiming by unbinding
* attached driver... From libhid */
Expand Down
1 change: 0 additions & 1 deletion drivers/usb-common.h
Original file line number Diff line number Diff line change
Expand Up @@ -309,7 +309,6 @@
#define usb_set_configuration libusb_set_configuration
#define usb_release_interface libusb_release_interface
#define usb_reset libusb_reset_device
#define usb_detach_kernel_driver_np libusb_detach_kernel_driver_np

/* FIXME: some original libusb1.c code cast the (int) argument
* as (enum libusb_error) - should we force that in the macro? */
Expand Down
3 changes: 3 additions & 0 deletions m4/nut_check_libusb.m4
Original file line number Diff line number Diff line change
Expand Up @@ -215,6 +215,9 @@ if test -z "${nut_have_libusb_seen}"; then
AC_CHECK_FUNCS(libusb_detach_kernel_driver_np)
dnl From libusb-0.1 - check these to have valid config.h definitions
dnl Note: confusingly, FreeBSD does find both as defined
dnl (despite being spread across usb.h and libusb.h),
dnl so our source code has to care :\
AC_CHECK_FUNCS(usb_detach_kernel_driver_np)
fi
else
Expand Down

0 comments on commit abb01ed

Please sign in to comment.