12

I'm writing a device driver for a usb device using libusb. When I attempt to claim the device I get the error code LIBUSB_ERROR_BUSY (-6). According to the documentation that means that the device has already been claimed (link).

How do I find out which driver/program has claimed the device and more importantly, how can I, myself, claim the device once it's claimed.

Code snippet:

r = libusb_claim_interface(handle[0], 0);
if (r < 0) {
    fprintf(stderr, "libusb_claim_interface error %d\n", r);
    goto out_release;
}
printf("claimed interface\n");

Output:

libusb_claim_interface error -6
jairo
  • 175
  • 1
  • 2
  • 9
  • I found this post looking for "_How do I find out which driver/program has claimed the device_", and so I wanted to link this question: [Is there a way to figure out what is using a Linux kernel module?](http://stackoverflow.com/questions/448999/is-there-a-way-to-figure-out-what-is-using-a-linux-kernel-module), which I think is relevant, because it says that it is not possible to see which programs claim a driver/module. – sdaau Mar 18 '13 at 19:59

3 Answers3

18

Do you call libusb_detach_kernel_driver() before libusb_claim_interface()? This may be necessary.

David Grayson
  • 84,103
  • 24
  • 152
  • 189
4

The issue is most likely that interface is claimed by another Linux driver. call libusb_detach_kernel_driver() and specify the interface number and then you should be able to connect it.

linsek
  • 3,334
  • 9
  • 42
  • 55
0

Did you call libusb_set_configuration() before libusb_claim_interface()?

This must be called even if there is only one configuration in the descriptor.

Turbo J
  • 7,563
  • 1
  • 23
  • 43
  • I did try it but got the exact same error back (-6). Taking a peak at `usb-devices` from the terminal lists `usb-storage` as the driver for the device. For some reason the device is getting a driver assigned and I haven't been able to prevent this. I've tried by using udev rules. – jairo Jun 20 '11 at 14:15