我想學習USB Linux設備驅動程序。我選擇了MS XBOX 360控制器。我注意到有一個用於Linux的通用驅動程序(xpad.ko)。不用說,我的代碼是基於xpad.c.無論如何,我建立了我的司機(360.ko)。 modprobe -r當前驅動程序(xpad,led_class,甚至usbhid)。也列入黑名單xpad驅動程序。在我的司機(360.ko)上做了insmod。 USBcore註冊我的驅動程序(usbcore:註冊的新接口驅動程序Microsoft Xbox 360控制器)。但是,它不會調用我的usb_360_probe()。任何線索?????360遊戲控制器Linux設備驅動程序問題調用我的探測功能
static struct usb_driver uDriver = {
.name = "Microsoft Xbox 360 Controller",
.probe = usb_360_probe,
.disconnect = usb_360_disconnect,
.id_table = skel_table,
};
#define USB_360_VENDOR_ID 0x045E
#define USB_360_PRODUCT_ID 0x0202//0x0289//0x028E //I tried all these product IDs!
static struct usb_device_id skel_table[] = {
{ USB_DEVICE(USB_360_VENDOR_ID, USB_360_PRODUCT_ID) },
{},
};
static int usb_360_probe(struct usb_interface *intf, const struct usb_device_id*id)
{
printk(KERN_INFO, "(360)usb_360_probe.\n");
}
static int __init usb_360_init(void)
{
int result;
printk(KERN_INFO, "(360)usb_360_init.\n");
/* register this driver with the USB subsystem */
result = usb_register(&uDriver);
if (result)
{
printk(KERN_INFO, "(360)usb_register failed.\n");
}
printk(KERN_INFO, "(360)usb_register succeeded.\n");
return result;
}
static void __exit usb_360_exit(void)
{
/* deregister this driver with the USB subsystem */
usb_deregister(&uDriver);
printk(KERN_INFO, "(360)usb_unregister succeeded.\n");
}
module_init(usb_360_init);
module_exit(usb_360_exit);
//我使用printk(KERN_INFO)作爲dmesg消息。它適用於我的其他字符驅動程序。
內核:2.6.32-21-通用
探針通常在打開,關閉和其他文件操作之前發生。另外,我不需要用戶應用程序來打開,關閉等系統調用。在探測器內部,它使用USB-中斷來捕獲按鈕按下等事件。該代碼在探針內部進入,我將所有代碼截斷。我的問題是probe()沒有調用。 – user1294023 2012-03-27 21:46:56