usb-test2.c 975 B

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. #include <linux/kernel.h>
  2. #include <linux/platform_device.h>
  3. #include <linux/leds.h>
  4. #include <linux/module.h>
  5. #include <linux/init.h>
  6. #include <linux/hid.h>
  7. #include <linux/hidraw.h>
  8. #define USB_VENDOR_ID_MICROCHIP 0x04d8
  9. MODULE_LICENSE("GPL");
  10. MODULE_AUTHOR("encrypt");
  11. MODULE_DESCRIPTION("Dummy led");
  12. static int usbio_probe(struct hid_device *hdev, const struct hid_device_id *id)
  13. {
  14. u8 buf[5] = {0x80, 0x80 };
  15. hid_hw_start(hdev, HID_CONNECT_HIDRAW);
  16. hid_hw_raw_request(hdev, buf[0], buf, 2, HID_FEATURE_REPORT, HID_REQ_SET_REPORT);
  17. return 0;
  18. }
  19. static void usbio_remove(struct hid_device *hdev)
  20. {
  21. hid_hw_stop(hdev);
  22. }
  23. static const struct hid_device_id usbio_table[] = {
  24. { HID_USB_DEVICE(USB_VENDOR_ID_MICROCHIP, 0x0003) },
  25. {}
  26. };
  27. MODULE_DEVICE_TABLE(hid, usbio_table);
  28. static struct hid_driver usbio_driver = {
  29. .name = "usbio",
  30. .probe = usbio_probe,
  31. .remove = usbio_remove,
  32. .id_table = usbio_table
  33. };
  34. module_hid_driver(usbio_driver);