Results 1 to 1 of 1
Hi,
I'm a beginner of driver developmenting.
I write a simple usb driver for probing usb mouse, when the usb mouse plugin in, "----found pip's usb mouse" will be printed, ...
Enjoy an ad free experience by logging in. Not a member yet? Register.
- 02-29-2012 #1Just Joined!
- Join Date
- Sep 2011
- Posts
- 2
why the driver can't probe usb mouse plugin in or plugin out
Hi,
I'm a beginner of driver developmenting.
I write a simple usb driver for probing usb mouse, when the usb mouse plugin in, "----found pip's usb mouse" will be printed, and when the usb mouse plugin out, "----disconnect pip's usb driver" will be printed. however when I plugin in usb mouse, probe function isn't called, I don't know why? the code is below:
Code:#include <linux/module.h> #include <linux/types.h> #include <linux/kernel.h> #include <linux/sched.h> #include <linux/init.h> #include <linux/slab.h> #include <linux/input.h> #include <linux/usb.h> #include <linux/usb_input.h> #include <asm/uaccess.h> #include <linux/kref.h> MODULE_LICENSE("GPL"); static struct usb_device_id um_id_table[] = { {USB_INTERFACE_INFO(3, 1, 2)}, { } }; MODULE_DEVICE_TABLE(usb, um_id_table); static int um_probe(struct usb_interface *intf, const struct usb_device_id *id) { printk("----found pip's usb mouse\n"); return 0; } static void um_disconnect(struct usb_interface *intf) { printk("----disconnect pip's usb driver\n"); } static struct usb_driver usbmouse_drv = { .owner = THIS_MODULE, .name = "usbmouse_pip", .id_table = um_id_table, .probe = um_probe, .disconnect = um_disconnect, }; static void usbmouse_exit(void) { printk(KERN_NOTICE "usbmouse driver unloading...\n"); usb_deregister(&usbmouse_drv); } static int usbmouse_init(void) { int retval; printk(KERN_NOTICE "usbmouse driver init....\n"); retval = usb_register(&usbmouse_drv); printk("my usbmouse driver register, the return value is %d\n", retval); return 0; } module_init(usbmouse_init); module_exit(usbmouse_exit);


Reply With Quote
