Question

In libusb-1.0 one can use libusb_kernel_driver_active for this:

if (libusb_kernel_driver_active(dev_handle, 0) == 1) { //find out if kernel driver is attached
        cout<<"Kernel Driver Active"<<endl;
        if(libusb_detach_kernel_driver(dev_handle, 0) == 0) //detach it
            cout<<"Kernel Driver Detached!"<<endl;
    }

How to check it using libusb-0.1?

Was it helpful?

Solution

for libusb-compat you can use usb_get_driver_np:

API_EXPORTED int usb_get_driver_np(usb_dev_handle *dev, int interface,
    char *name, unsigned int namelen)
{
    int r = libusb_kernel_driver_active(dev->handle, interface);
    if (r == 1) {
        /* libusb-1.0 doesn't expose driver name, so fill in a dummy value */
        snprintf(name, namelen, "dummy");
        return 0;
    } else if (r == 0) {
        return -(errno=ENODATA);
    } else {
        return compat_err(r);
    }
}
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top