I am trying to familiarize myself with the Linux kernel module. So I wrote this simplest module that works on usb. I'm not sure what I am missing. The module is loading. Also on dmesg I see this:
[27245.911387] usbcore: registered new interface driver testusb [27245.911392] testusb: driver registered successfully
but when I insert the joystick, my testusb_probe function is not called. Any idea where I'm wrong. here is the module code:
#include <linux/kernel.h> #include <linux/module.h> #include <linux/usb.h> static int testusb_probe(struct usb_interface *interface, const struct usb_device_id *id) { printk("testusb: probe module\n"); return 0; } static void testusb_disconnect(struct usb_interface *interface) { printk("testusb: disconnect module\n"); } static struct usb_driver testusb_driver = { name: "testusb", probe: testusb_probe, disconnect: testusb_disconnect, }; static int __init testusb_init(void) { int result; result = usb_register(&testusb_driver); if (result) { printk("testusb: registering driver failed"); } else { printk("testusb: driver registered successfully"); } return result; } static void __exit testusb_exit(void) { usb_deregister(&testusb_driver); printk("testusb: module deregistered"); } module_init(testusb_init); module_exit(testusb_exit); MODULE_AUTHOR("Dal Chand"); MODULE_LICENSE("GPL");
source share