向驱动程序注册(/绑定/匹配)设备 [英] Register(/bind/match) a device with a driver

查看:81
本文介绍了向驱动程序注册(/绑定/匹配)设备的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在linux上编写一个USB驱动程序(用于游戏手柄),当我将其插入时,ti会加载usbhid.我如何才能使它加载我的驱动程序(gp_driver)? 我做了取消绑定的usbhid并绑定到了我的驱动程序技巧,但我不想每次都这样做.

I am writing a usb driver (for a gamepad) on linux, and when I plug it in, ti loads usbhid. How can I make it so it loads my driver (gp_driver)? I did the unbind usbhid and bind to my driver trick, but I don't want to do it every single time.

我应该已经加载驱动程序了吗? 我应该在驱动程序中编写代码吗? 我的驱动程序中有供应商和产品ID.

Should I have my driver already loaded? Should I code something in my driver? I have the vendor and product id in my driver..

谢谢

推荐答案

您将要为设备创建udev规则,该规则可用于创建设备文件,设置设备文件的权限以及加载相关的驱动程序

You will want to create a udev rule for your device, which can take care of creating your device file, setting permissions on the device file, and loading relevant drivers.

http://www.redhat.com/magazine/002dec04 /features/udev/

来自: http://plugcomputer.org/plugwiki/index.php/Load_Serial_Drivers_Automatically_Using_udev

# if no driver has claimed the interface yet, load ftdi_sio
ACTION=="add", SUBSYSTEM=="usb", ENV{DEVTYPE}=="usb_interface", \
        ATTRS{idVendor}=="9e88", ATTRS{idProduct}=="9e8f", \
        DRIVER=="", \
        RUN+="/sbin/modprobe -b ftdi_sio"

这篇关于向驱动程序注册(/绑定/匹配)设备的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆