I have been learning Kernel programming and taking the Eudyptula challenge, and task 5 requires me to modify a hello world module from an earlier task to be automatically loaded when a USB keyboard is plugged, and unloaded when the keyboard is unplugged.
Now, for the sake of it, I will not be posting my code here, because that would be a huge spoiler for this task and would ruin the fun of it for others. Basically, what it does is:
- Creates a
struct usb_device_id
array with one entry that binds my module to any usb keyboard - Creates a
struct usb_driver
and initializes the proper fields; in particular, it references the usb device id table array that I created previously - Uses the macro
MODULE_DEVICE_TABLE
to register the driver.
The register / unregister routines are working. I get the expected debugging messages when I manually load and unload the module.
I copied the module to /lib/modules/$(uname -r)
and ran depmod -a
. The module is added to modules.alias
and modules.dep
, but nothing happens when I plug / unplug the keyboard.
Further research showed that I should have a modules.usbmap
file generated by depmod
where the kernel keeps a mapping between devices and drivers to load. I don't have this file anywhere in my folders tree. I also don't have a modules.pcimap
. I have checked the kernel configuration to make sure that loadable module support is enabled, as well as hotplugging support - they are.
This is Kubuntu 14.04 with self-compiled 3.16.0-rc5 kernel. What am I missing? I have gone through the kernel configuration and checked the most obvious options. I'm kind of stuck here. Any ideas?