Linux USB 设备驱动程序未被探测到
我正在开发 Linux 的设备驱动程序。这是一款 USB 数位板。问题是驱动程序的探测回调永远不会被调用。 dmesg 只是显示:
generic-usb: probe of 0003:099A:2620.000F failed with error -22
并且我永远无法连接到设备。系统驱动程序似乎以某种方式覆盖了我的驱动程序?
我的代码正在注册&使用 insmod / rmmod 正确取消注册:
#include <linux/module.h>
#include <linux/kernel.h>
#include <linux/init.h>
#include <linux/usb.h>
#include <linux/slab.h>
MODULE_DEVICE_TABLE (usb, id_table);
struct usb_device_id id_table[] =
{
{USB_DEVICE(0x099a, 0x2620)}, //Zippy Technology Corp. Digi Tablet
{0}
};
void dt_disconnect(struct usb_interface *interface)
{
printk("dt_disconnect called\n");
}
int dt_probe(struct usb_interface *interface, const struct usb_device_id *id)
{
printk("dt_probe called\n");
return 0;
}
static struct usb_driver dt_driver =
{
.name = "Zippy Technology Corp. Digi Tablet",
.probe = dt_probe,
.disconnect = dt_disconnect,
.id_table = id_table
};
static int __init dt_init(void)
{
//0 means success
int error = usb_register(&dt_driver);
if(error)
printk("dt_init failed\n");
return 0;
}
static void __exit dt_exit(void)
{
//void
usb_deregister(&dt_driver);
}
module_init(dt_init);
module_exit(dt_exit);
MODULE_LICENSE("GPL");
从未调用 dt_probe。我使用的是 Linux 2.6.40(Fedora 15 的 3.0 版本),并且大多数有关此内容的文档都非常旧,所以我想我应该在这里询问。有什么想法吗?
I'm working on a device driver for Linux. It's a USB pen tablet. The problem is that the driver's probe callback never gets called. dmesg just shows:
generic-usb: probe of 0003:099A:2620.000F failed with error -22
and i never get to connect to the device. It seems like the systems drivers are overriding my driver in some way?
My code is registering & unregistering correctly using insmod / rmmod:
#include <linux/module.h>
#include <linux/kernel.h>
#include <linux/init.h>
#include <linux/usb.h>
#include <linux/slab.h>
MODULE_DEVICE_TABLE (usb, id_table);
struct usb_device_id id_table[] =
{
{USB_DEVICE(0x099a, 0x2620)}, //Zippy Technology Corp. Digi Tablet
{0}
};
void dt_disconnect(struct usb_interface *interface)
{
printk("dt_disconnect called\n");
}
int dt_probe(struct usb_interface *interface, const struct usb_device_id *id)
{
printk("dt_probe called\n");
return 0;
}
static struct usb_driver dt_driver =
{
.name = "Zippy Technology Corp. Digi Tablet",
.probe = dt_probe,
.disconnect = dt_disconnect,
.id_table = id_table
};
static int __init dt_init(void)
{
//0 means success
int error = usb_register(&dt_driver);
if(error)
printk("dt_init failed\n");
return 0;
}
static void __exit dt_exit(void)
{
//void
usb_deregister(&dt_driver);
}
module_init(dt_init);
module_exit(dt_exit);
MODULE_LICENSE("GPL");
dt_probe is never called. I'm using Linux 2.6.40 (Fedora 15's version of 3.0) and most documentation about this stuff is very old so I thought I'd ask here. Any thoughts?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
是的,usbhid 驱动程序会覆盖您的驱动程序。您需要从正在运行的内核中删除 usbhid 驱动程序。首先将设备与系统断开连接,然后使用“modprobe -r usbhid”删除 usbhid 模块。现在插入您的模块并连接设备,然后您的驱动程序将被获取。
Yes, usbhid driver overrides your driver. You need to remove the usbhid driver from the running kernel. First deattach your device from the system and use "modprobe -r usbhid" to remove the usbhid module. Now insert your module and attach the device, then your driver will be taken.