xref: /linux/drivers/usb/serial/usb_debug.c (revision 71be4f81e97fe1f42c48a6dfc411dc6d3c18687f)
1958e8741SGreg Kroah-Hartman /*
2958e8741SGreg Kroah-Hartman  * USB Debug cable driver
3958e8741SGreg Kroah-Hartman  *
4958e8741SGreg Kroah-Hartman  * Copyright (C) 2006 Greg Kroah-Hartman <greg@kroah.com>
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*71be4f81SAleksey Gorelov #define USB_DEBUG_MAX_PACKET_SIZE	8
19*71be4f81SAleksey Gorelov 
20958e8741SGreg Kroah-Hartman static struct usb_device_id id_table [] = {
21958e8741SGreg Kroah-Hartman 	{ USB_DEVICE(0x0525, 0x127a) },
22958e8741SGreg Kroah-Hartman 	{ },
23958e8741SGreg Kroah-Hartman };
24958e8741SGreg Kroah-Hartman MODULE_DEVICE_TABLE(usb, id_table);
25958e8741SGreg Kroah-Hartman 
26958e8741SGreg Kroah-Hartman static struct usb_driver debug_driver = {
27958e8741SGreg Kroah-Hartman 	.name =		"debug",
28958e8741SGreg Kroah-Hartman 	.probe =	usb_serial_probe,
29958e8741SGreg Kroah-Hartman 	.disconnect =	usb_serial_disconnect,
30958e8741SGreg Kroah-Hartman 	.id_table =	id_table,
31958e8741SGreg Kroah-Hartman 	.no_dynamic_id = 	1,
32958e8741SGreg Kroah-Hartman };
33958e8741SGreg Kroah-Hartman 
34*71be4f81SAleksey Gorelov int usb_debug_open(struct usb_serial_port *port, struct file *filp)
35*71be4f81SAleksey Gorelov {
36*71be4f81SAleksey Gorelov 	port->bulk_out_size = USB_DEBUG_MAX_PACKET_SIZE;
37*71be4f81SAleksey Gorelov 	return usb_serial_generic_open(port, filp);
38*71be4f81SAleksey Gorelov }
39*71be4f81SAleksey Gorelov 
40958e8741SGreg Kroah-Hartman static struct usb_serial_driver debug_device = {
41958e8741SGreg Kroah-Hartman 	.driver = {
42958e8741SGreg Kroah-Hartman 		.owner =	THIS_MODULE,
43958e8741SGreg Kroah-Hartman 		.name =		"debug",
44958e8741SGreg Kroah-Hartman 	},
45958e8741SGreg Kroah-Hartman 	.id_table =		id_table,
46958e8741SGreg Kroah-Hartman 	.num_ports =		1,
47*71be4f81SAleksey Gorelov 	.open =			usb_debug_open,
48958e8741SGreg Kroah-Hartman };
49958e8741SGreg Kroah-Hartman 
50958e8741SGreg Kroah-Hartman static int __init debug_init(void)
51958e8741SGreg Kroah-Hartman {
52958e8741SGreg Kroah-Hartman 	int retval;
53958e8741SGreg Kroah-Hartman 
54958e8741SGreg Kroah-Hartman 	retval = usb_serial_register(&debug_device);
55958e8741SGreg Kroah-Hartman 	if (retval)
56958e8741SGreg Kroah-Hartman 		return retval;
57958e8741SGreg Kroah-Hartman 	retval = usb_register(&debug_driver);
58958e8741SGreg Kroah-Hartman 	if (retval)
59958e8741SGreg Kroah-Hartman 		usb_serial_deregister(&debug_device);
60958e8741SGreg Kroah-Hartman 	return retval;
61958e8741SGreg Kroah-Hartman }
62958e8741SGreg Kroah-Hartman 
63958e8741SGreg Kroah-Hartman static void __exit debug_exit(void)
64958e8741SGreg Kroah-Hartman {
65958e8741SGreg Kroah-Hartman 	usb_deregister(&debug_driver);
66958e8741SGreg Kroah-Hartman 	usb_serial_deregister(&debug_device);
67958e8741SGreg Kroah-Hartman }
68958e8741SGreg Kroah-Hartman 
69958e8741SGreg Kroah-Hartman module_init(debug_init);
70958e8741SGreg Kroah-Hartman module_exit(debug_exit);
71958e8741SGreg Kroah-Hartman MODULE_LICENSE("GPL");
72