如何将驱动程序与USB设备绑定?
我正在为Linux 编写USB 设备驱动。它是用于操纵杆的。 每次插入时,linux 都会加载一个 hid 驱动程序。有没有办法告诉 Linux 在我插入时加载我的?或者至少不加载默认的?
我可以在默认驱动程序的取消绑定中回显 ID,并在我的驱动程序的绑定中回显它;但我想要更自动化的东西.. 谢谢
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
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
自己的 USB 驱动程序优先于 usbhid
如果您想阻止绑定到
usbhid
驱动程序,可以使用其HID_QUIRK_IGNORE
(= 4) 设置。要坚持使用 Karl Bielefeldt 使用的示例,请添加一些
/etc/modprobe.d/*.conf
文件(并且可能重新创建 initramfs)。这将告诉 hid-core 忽略该设备。因此,usbhid
将查看它,但将其留给其他驱动程序。自己的 HID 驱动程序优先于 hid-generic
但是,如果您的其他驱动程序是 HID 驱动程序而不是 USB 驱动程序,则您需要
usbhid
绑定到 USB 上的驱动程序级别,并且您需要自己的 HID 驱动程序才能优先于hid-generic
。这是我自己面临的问题,目前我还没有找到解决方案,除非稍后解除绑定并重新绑定设备。Own USB driver taking precedence over usbhid
If you want to prevent binding to the
usbhid
driver, you can use itsHID_QUIRK_IGNORE
(= 4) setting. To stick with the example Karl Bielefeldt used, addto some
/etc/modprobe.d/*.conf
file (and perhaps recreate your initramfs). That will tellhid-core
to ignore that device. Sousbhid
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 overhid-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.这里有一个解决类似问题的线程。总而言之,您可以将如下内容添加到您的
/etc/udev/rules.d
文件之一:Here's a thread with a fix for a similar problem. To summarize, you add something like the following to one of your
/etc/udev/rules.d
files:http://lwn.net/Articles/143397/ 与上面的答案非常相似,也许有些更多细节。
http://lwn.net/Articles/143397/ is very similar to the above answer, maybe some more details.