Bug 1106 - Factor out generic libusb_detach_kernel_driver() handling
Summary: Factor out generic libusb_detach_kernel_driver() handling
Status: CONFIRMED
Alias: None
Product: libsigrok
Classification: Unclassified
Component: Other (show other bugs)
Version: unreleased development snapshot
Hardware: All All
: Normal normal
Target Milestone: ---
Assignee: Nobody
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2018-01-01 14:41 CET by Uwe Hermann
Modified: 2018-01-01 14:41 CET (History)
0 users



Attachments

Note You need to log in before you can comment on or make changes to this bug.
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.