Bug 1106

Summary: Factor out generic libusb_detach_kernel_driver() handling
Product: libsigrok Reporter: Uwe Hermann <uwe>
Component: OtherAssignee: Nobody <nobody>
Status: CONFIRMED ---    
Severity: normal    
Priority: Normal    
Version: unreleased development snapshot   
Target Milestone: ---   
Hardware: All   
OS: All   

Description Uwe Hermann 2018-01-01 14:41:36 CET
Many libsigrok drivers do slight different things around libusb_detach_kernel_driver, partially different log messages etc.

It would be nice (and yield shorter code, less boilerplate) to factor out this stuff into src/usb.c. E.g. an implementation like this from fx2lafw:


if (libusb_has_capability(LIBUSB_CAP_SUPPORTS_DETACH_KERNEL_DRIVER)) {
        if (libusb_kernel_driver_active(usb->devhdl, USB_INTERFACE) == 1) {
                if ((ret = libusb_detach_kernel_driver(usb->devhdl, USB_INTERFACE)) < 0) {
                        sr_err("Failed to detach kernel driver: %s.",
                                libusb_error_name(ret));
                        ret = SR_ERR;   
                        break;
                } 
        }
}

The same also applies to re-attaching again after libsigok is done with the device, which is currently not done consistently in all drivers.