1

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?

4ntoine
  • 19,816
  • 21
  • 96
  • 220

1 Answers1

0

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);
    }
}
4ntoine
  • 19,816
  • 21
  • 96
  • 220
  • And, I suppose, you should always check [this][1]http://libusb.sourceforge.net/doc/functions.html before scratching head on something that is about libusb-0.1. Its always good to try whatever you can, and then go for places like SO. This will help you in actually solving your issues on your own. Despite of trying what you know, If you can't get through, Welcome to SO! –  Aug 02 '13 at 05:21