usb_debug.c 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  1. /*
  2. * USB Debug cable driver
  3. *
  4. * Copyright (C) 2006 Greg Kroah-Hartman <greg@kroah.com>
  5. *
  6. * This program is free software; you can redistribute it and/or
  7. * modify it under the terms of the GNU General Public License version
  8. * 2 as published by the Free Software Foundation.
  9. */
  10. #include <linux/kernel.h>
  11. #include <linux/init.h>
  12. #include <linux/tty.h>
  13. #include <linux/module.h>
  14. #include <linux/usb.h>
  15. #include <linux/usb/serial.h>
  16. #define USB_DEBUG_MAX_PACKET_SIZE 8
  17. static struct usb_device_id id_table [] = {
  18. { USB_DEVICE(0x0525, 0x127a) },
  19. { },
  20. };
  21. MODULE_DEVICE_TABLE(usb, id_table);
  22. static struct usb_driver debug_driver = {
  23. .name = "debug",
  24. .probe = usb_serial_probe,
  25. .disconnect = usb_serial_disconnect,
  26. .id_table = id_table,
  27. .no_dynamic_id = 1,
  28. };
  29. static int usb_debug_open(struct tty_struct *tty, struct usb_serial_port *port,
  30. struct file *filp)
  31. {
  32. port->bulk_out_size = USB_DEBUG_MAX_PACKET_SIZE;
  33. return usb_serial_generic_open(tty, port, filp);
  34. }
  35. static struct usb_serial_driver debug_device = {
  36. .driver = {
  37. .owner = THIS_MODULE,
  38. .name = "debug",
  39. },
  40. .id_table = id_table,
  41. .num_ports = 1,
  42. .open = usb_debug_open,
  43. };
  44. static int __init debug_init(void)
  45. {
  46. int retval;
  47. retval = usb_serial_register(&debug_device);
  48. if (retval)
  49. return retval;
  50. retval = usb_register(&debug_driver);
  51. if (retval)
  52. usb_serial_deregister(&debug_device);
  53. return retval;
  54. }
  55. static void __exit debug_exit(void)
  56. {
  57. usb_deregister(&debug_driver);
  58. usb_serial_deregister(&debug_device);
  59. }
  60. module_init(debug_init);
  61. module_exit(debug_exit);
  62. MODULE_LICENSE("GPL");