usb_driver hotplug probe callback
Jaret Flores
jarflores at gmail.com
Thu Aug 14 16:21:48 EDT 2014
I know I am not supposed to get too much help on the eudyptula
challenges, but I can't seem to figure this last thing out.
The goal is to write (the skeleton of) a usb driver module that loads
and registers the driver when a usb keyboard is plugged in. What I
have so far does exactly that except that the struct usb_driver:
1) probe function is not called (neither via keyboard plugin nor when
module is loaded manually with modprobe).
2) disconnect function is called only after the module is unloaded
(with rmmod) AND THEN the keyboard is unplugged.
>From ldd3:
for probe: "This function is called by the USB core when it thinks it
has a struct usb_interface that this driver can handle."
for disconnect: "This function is called by the USB core when the
struct usb_interface has been removed from the system or when the
driver is being unloaded from the USB core."
>From the quotes, it seems the kernel does not think my driver is valid
to handle the keyboard (though 2 may not actually be abnormal
behavior). I am thinking, perhaps the struct usb_device_id table is
wrong or incomplete:
static struct usb_device_id hw_id_table[] = {
{USB_INTERFACE_INFO(USB_INTERFACE_CLASS_HID,
USB_INTERFACE_SUBCLASS_BOOT, USB_INTERFACE_PROTOCOL_KEYBOARD)},
{}
};
MODULE_DEVICE_TABLE(usb, hw_id_table);
There is also a USB_DEVICE_INFO() macro, but I cannot seem to find a
file analogous to include/uapi/linux/hid.h which (would) define the
arguments to USB_DEVICE_INFO(). Is this the problem? Or am I missing
something else?
Thanks for the info,
Jaret
More information about the Kernelnewbies
mailing list