Advertisement
Guest User

Untitled

a guest
Sep 2nd, 2014
135
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.27 KB | None | 0 0
  1. #include <linux/module.h>
  2. #include <linux/kernel.h>
  3. #include <linux/usb.h>
  4. #include <linux/usb/input.h>
  5. #include <linux/hid.h>
  6.  
  7. MODULE_LICENSE("GPL");
  8. MODULE_AUTHOR("Parisa Bakhtou");
  9. MODULE_DESCRIPTION("USB_KBD Module");
  10.  
  11. static struct usb_device_id usb_kbd_id_table[] = {
  12. { USB_INTERFACE_INFO(
  13. USB_INTERFACE_CLASS_HID,
  14. USB_INTERFACE_SUBCLASS_BOOT,
  15. USB_INTERFACE_PROTOCOL_KEYBOARD) },
  16. { }
  17. };
  18.  
  19. MODULE_DEVICE_TABLE(usb, usb_kbd_id_table);
  20.  
  21. static int kbd_probe(struct usb_interface *interface,
  22. const struct usb_device_id *id)
  23. {
  24. pr_info("USB keyboard probe function calledn");
  25. /* pr_info("Hello World!n"); */
  26. return 0;
  27. }
  28.  
  29. static void kbd_disconnect(struct usb_interface *interface)
  30. {
  31. pr_info("USB keyboard disconnect function calledn");
  32. }
  33.  
  34. static struct usb_driver kbd_driver = {
  35. .name = "usbkbd",
  36. .probe = kbd_probe,
  37. .disconnect = kbd_disconnect,
  38. .id_table = usb_kbd_id_table,
  39. };
  40.  
  41. static int __init kbd_init(void)
  42. {
  43. int res = 0;
  44. res = usb_register(&kbd_driver);
  45. if (res)
  46. pr_err("usb_register failed with error %d", res);
  47. return res;
  48. }
  49.  
  50. static void __exit kbd_exit(void)
  51. {
  52. pr_debug("USB Keyboard Removed..n");
  53. usb_deregister(&kbd_driver);
  54. return;
  55. }
  56.  
  57. module_init(kbd_init);
  58. module_exit(kbd_exit);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement