Você está com as funções usb_register
e probe
Aqui está um driver de dispositivo atualizado com usb_register
e probe
functions
#include <linux/module.h>
#include <linux/kernel.h>
#include <linux/usb.h>
#include <linux/usb/input.h>
#include <linux/hid.h>
MODULE_LICENSE("GPL");
MODULE_AUTHOR("Aruna Hewapathirane");
MODULE_DESCRIPTION("A USB Keyboard Driver Kernel Module");
static struct usb_device_id usb_kbd_id_table[] = {
{ USB_INTERFACE_INFO(
USB_INTERFACE_CLASS_HID,
USB_INTERFACE_SUBCLASS_BOOT,
USB_INTERFACE_PROTOCOL_KEYBOARD) },
{ } /* Terminating entry */
};
MODULE_DEVICE_TABLE(usb, usb_kbd_id_table);
static int kbd_probe(struct usb_interface *interface,
const struct usb_device_id *id)
{
pr_info("USB keyboard probe function called\n");
return 0;
}
static void kbd_disconnect(struct usb_interface *interface)
{
pr_info("USB keyboard disconnect function called\n");
}
static struct usb_driver kbd_driver = {
.name = "usbkbd",
.probe = kbd_probe,
.disconnect = kbd_disconnect,
.id_table = usb_kbd_id_table,
};
static int __init kbd_init(void)
{
int res = 0;
res = usb_register(&kbd_driver);
if (res)
pr_err("usb_register failed with error %d", res);
return res;
}
static void __exit kbd_exit(void)
{
pr_debug("USB Keyboard Removed..\n");
usb_deregister(&kbd_driver);
return;
}
module_init(kbd_init);
module_exit(kbd_exit);
Por favor, consulte as então pergunta sobre o uso da função probe
.