Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I bind a driver with a USB device?

Tags:

I am writing a USB device drive for linux. it's for a joystick. every time plug it in, linux loads a hid driver. is there a way to tell Linux to load mine when I plug it in? or at least not load the default one?

I can echo the id in unbind of the default driver and echo it in bind of my driver; but I would like something more automatic.. thanks

like image 943
pvinis Avatar asked Oct 15 '10 23:10

pvinis


People also ask

How does the kernel bind a driver to a device?

When device_register is called for a device, it is inserted into the end of this list. The bus object also contains a list of all drivers of that bus type. When driver_register is called for a driver, it is inserted at the end of this list. These are the two events which trigger driver binding.

What is bind and unbind in Linux?

You can bind a process to a processor or unbind a previously bound process. You must have root user authority to bind or unbind a process you do not own.


1 Answers

Own USB driver taking precedence over usbhid

If you want to prevent binding to the usbhid driver, you can use its HID_QUIRK_IGNORE (= 4) setting. To stick with the example Karl Bielefeldt used, add

options usbhid quirks=0x15c2:0x0043:0x04 

to some /etc/modprobe.d/*.conf file (and perhaps recreate your initramfs). That will tell hid-core to ignore that device. So usbhid will have a look at it but leave it for some other driver instead.

Own HID driver taking precedence over hid-generic

However, if your other driver is a HID driver not an USB driver, then you need usbhid to bind to the driver on the USB level, and you need your own HID driver to take precedence over hid-generic. This is the problem I'm facing my self, and for which I haven't found a solution yet, short of unbinding and rebinding the device later on.

like image 179
MvG Avatar answered Sep 19 '22 15:09

MvG