xref: /linux-6.15/drivers/usb/serial/usb_debug.c (revision 715b1dc0)
1958e8741SGreg Kroah-Hartman /*
2958e8741SGreg Kroah-Hartman  * USB Debug cable driver
3958e8741SGreg Kroah-Hartman  *
4958e8741SGreg Kroah-Hartman  * Copyright (C) 2006 Greg Kroah-Hartman <[email protected]>
5958e8741SGreg Kroah-Hartman  *
6958e8741SGreg Kroah-Hartman  *	This program is free software; you can redistribute it and/or
7958e8741SGreg Kroah-Hartman  *	modify it under the terms of the GNU General Public License version
8958e8741SGreg Kroah-Hartman  *	2 as published by the Free Software Foundation.
9958e8741SGreg Kroah-Hartman  */
10958e8741SGreg Kroah-Hartman 
11958e8741SGreg Kroah-Hartman #include <linux/kernel.h>
12958e8741SGreg Kroah-Hartman #include <linux/init.h>
13958e8741SGreg Kroah-Hartman #include <linux/tty.h>
14958e8741SGreg Kroah-Hartman #include <linux/module.h>
15958e8741SGreg Kroah-Hartman #include <linux/usb.h>
16958e8741SGreg Kroah-Hartman #include <linux/usb/serial.h>
17958e8741SGreg Kroah-Hartman 
18*715b1dc0SJason Wessel #define URB_DEBUG_MAX_IN_FLIGHT_URBS	4000
1971be4f81SAleksey Gorelov #define USB_DEBUG_MAX_PACKET_SIZE	8
2071be4f81SAleksey Gorelov 
21958e8741SGreg Kroah-Hartman static struct usb_device_id id_table [] = {
22958e8741SGreg Kroah-Hartman 	{ USB_DEVICE(0x0525, 0x127a) },
23958e8741SGreg Kroah-Hartman 	{ },
24958e8741SGreg Kroah-Hartman };
25958e8741SGreg Kroah-Hartman MODULE_DEVICE_TABLE(usb, id_table);
26958e8741SGreg Kroah-Hartman 
27958e8741SGreg Kroah-Hartman static struct usb_driver debug_driver = {
28958e8741SGreg Kroah-Hartman 	.name =		"debug",
29958e8741SGreg Kroah-Hartman 	.probe =	usb_serial_probe,
30958e8741SGreg Kroah-Hartman 	.disconnect =	usb_serial_disconnect,
31958e8741SGreg Kroah-Hartman 	.id_table =	id_table,
32958e8741SGreg Kroah-Hartman 	.no_dynamic_id = 	1,
33958e8741SGreg Kroah-Hartman };
34958e8741SGreg Kroah-Hartman 
35619b572aSRoel Kluin static int usb_debug_open(struct tty_struct *tty, struct usb_serial_port *port,
3695da310eSAlan Cox 							struct file *filp)
3771be4f81SAleksey Gorelov {
3871be4f81SAleksey Gorelov 	port->bulk_out_size = USB_DEBUG_MAX_PACKET_SIZE;
3995da310eSAlan Cox 	return usb_serial_generic_open(tty, port, filp);
4071be4f81SAleksey Gorelov }
4171be4f81SAleksey Gorelov 
42958e8741SGreg Kroah-Hartman static struct usb_serial_driver debug_device = {
43958e8741SGreg Kroah-Hartman 	.driver = {
44958e8741SGreg Kroah-Hartman 		.owner =	THIS_MODULE,
45958e8741SGreg Kroah-Hartman 		.name =		"debug",
46958e8741SGreg Kroah-Hartman 	},
47958e8741SGreg Kroah-Hartman 	.id_table =		id_table,
48958e8741SGreg Kroah-Hartman 	.num_ports =		1,
4971be4f81SAleksey Gorelov 	.open =			usb_debug_open,
50*715b1dc0SJason Wessel 	.max_in_flight_urbs =	URB_DEBUG_MAX_IN_FLIGHT_URBS,
51958e8741SGreg Kroah-Hartman };
52958e8741SGreg Kroah-Hartman 
53958e8741SGreg Kroah-Hartman static int __init debug_init(void)
54958e8741SGreg Kroah-Hartman {
55958e8741SGreg Kroah-Hartman 	int retval;
56958e8741SGreg Kroah-Hartman 
57958e8741SGreg Kroah-Hartman 	retval = usb_serial_register(&debug_device);
58958e8741SGreg Kroah-Hartman 	if (retval)
59958e8741SGreg Kroah-Hartman 		return retval;
60958e8741SGreg Kroah-Hartman 	retval = usb_register(&debug_driver);
61958e8741SGreg Kroah-Hartman 	if (retval)
62958e8741SGreg Kroah-Hartman 		usb_serial_deregister(&debug_device);
63958e8741SGreg Kroah-Hartman 	return retval;
64958e8741SGreg Kroah-Hartman }
65958e8741SGreg Kroah-Hartman 
66958e8741SGreg Kroah-Hartman static void __exit debug_exit(void)
67958e8741SGreg Kroah-Hartman {
68958e8741SGreg Kroah-Hartman 	usb_deregister(&debug_driver);
69958e8741SGreg Kroah-Hartman 	usb_serial_deregister(&debug_device);
70958e8741SGreg Kroah-Hartman }
71958e8741SGreg Kroah-Hartman 
72958e8741SGreg Kroah-Hartman module_init(debug_init);
73958e8741SGreg Kroah-Hartman module_exit(debug_exit);
74958e8741SGreg Kroah-Hartman MODULE_LICENSE("GPL");
75