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
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.
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.
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.
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With