usb_debug.c 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  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 URB_DEBUG_MAX_IN_FLIGHT_URBS 4000
  17. #define USB_DEBUG_MAX_PACKET_SIZE 8
  18. static struct usb_device_id id_table [] = {
  19. { USB_DEVICE(0x0525, 0x127a) },
  20. { },
  21. };
  22. MODULE_DEVICE_TABLE(usb, id_table);
  23. static struct usb_driver debug_driver = {
  24. .name = "debug",
  25. .probe = usb_serial_probe,
  26. .disconnect = usb_serial_disconnect,
  27. .id_table = id_table,
  28. .no_dynamic_id = 1,
  29. };
  30. static int usb_debug_open(struct tty_struct *tty, struct usb_serial_port *port,
  31. struct file *filp)
  32. {
  33. port->bulk_out_size = USB_DEBUG_MAX_PACKET_SIZE;
  34. return usb_serial_generic_open(tty, port, filp);
  35. }
  36. static struct usb_serial_driver debug_device = {
  37. .driver = {
  38. .owner = THIS_MODULE,
  39. .name = "debug",
  40. },
  41. .id_table = id_table,
  42. .num_ports = 1,
  43. .open = usb_debug_open,
  44. .max_in_flight_urbs = URB_DEBUG_MAX_IN_FLIGHT_URBS,
  45. };
  46. static int __init debug_init(void)
  47. {
  48. int retval;
  49. retval = usb_serial_register(&debug_device);
  50. if (retval)
  51. return retval;
  52. retval = usb_register(&debug_driver);
  53. if (retval)
  54. usb_serial_deregister(&debug_device);
  55. return retval;
  56. }
  57. static void __exit debug_exit(void)
  58. {
  59. usb_deregister(&debug_driver);
  60. usb_serial_deregister(&debug_device);
  61. }
  62. module_init(debug_init);
  63. module_exit(debug_exit);
  64. MODULE_LICENSE("GPL");