usb_debug.c 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  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. int usb_debug_open(struct usb_serial_port *port, struct file *filp)
  30. {
  31. port->bulk_out_size = USB_DEBUG_MAX_PACKET_SIZE;
  32. return usb_serial_generic_open(port, filp);
  33. }
  34. static struct usb_serial_driver debug_device = {
  35. .driver = {
  36. .owner = THIS_MODULE,
  37. .name = "debug",
  38. },
  39. .id_table = id_table,
  40. .num_ports = 1,
  41. .open = usb_debug_open,
  42. };
  43. static int __init debug_init(void)
  44. {
  45. int retval;
  46. retval = usb_serial_register(&debug_device);
  47. if (retval)
  48. return retval;
  49. retval = usb_register(&debug_driver);
  50. if (retval)
  51. usb_serial_deregister(&debug_device);
  52. return retval;
  53. }
  54. static void __exit debug_exit(void)
  55. {
  56. usb_deregister(&debug_driver);
  57. usb_serial_deregister(&debug_device);
  58. }
  59. module_init(debug_init);
  60. module_exit(debug_exit);
  61. MODULE_LICENSE("GPL");