aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/usb/serial/usb_debug.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/usb/serial/usb_debug.c')
-rw-r--r--drivers/usb/serial/usb_debug.c41
1 files changed, 41 insertions, 0 deletions
diff --git a/drivers/usb/serial/usb_debug.c b/drivers/usb/serial/usb_debug.c
index 6c9cbb59552a..614800972dc3 100644
--- a/drivers/usb/serial/usb_debug.c
+++ b/drivers/usb/serial/usb_debug.c
@@ -15,7 +15,19 @@
15#include <linux/usb.h> 15#include <linux/usb.h>
16#include <linux/usb/serial.h> 16#include <linux/usb/serial.h>
17 17
18#define URB_DEBUG_MAX_IN_FLIGHT_URBS 4000
18#define USB_DEBUG_MAX_PACKET_SIZE 8 19#define USB_DEBUG_MAX_PACKET_SIZE 8
20#define USB_DEBUG_BRK_SIZE 8
21static char USB_DEBUG_BRK[USB_DEBUG_BRK_SIZE] = {
22 0x00,
23 0xff,
24 0x01,
25 0xfe,
26 0x00,
27 0xfe,
28 0x01,
29 0xff,
30};
19 31
20static struct usb_device_id id_table [] = { 32static struct usb_device_id id_table [] = {
21 { USB_DEVICE(0x0525, 0x127a) }, 33 { USB_DEVICE(0x0525, 0x127a) },
@@ -38,6 +50,32 @@ static int usb_debug_open(struct tty_struct *tty, struct usb_serial_port *port,
38 return usb_serial_generic_open(tty, port, filp); 50 return usb_serial_generic_open(tty, port, filp);
39} 51}
40 52
53/* This HW really does not support a serial break, so one will be
54 * emulated when ever the break state is set to true.
55 */
56static void usb_debug_break_ctl(struct tty_struct *tty, int break_state)
57{
58 struct usb_serial_port *port = tty->driver_data;
59 if (!break_state)
60 return;
61 usb_serial_generic_write(tty, port, USB_DEBUG_BRK, USB_DEBUG_BRK_SIZE);
62}
63
64static void usb_debug_read_bulk_callback(struct urb *urb)
65{
66 struct usb_serial_port *port = urb->context;
67
68 if (urb->actual_length == USB_DEBUG_BRK_SIZE &&
69 memcmp(urb->transfer_buffer, USB_DEBUG_BRK,
70 USB_DEBUG_BRK_SIZE) == 0) {
71 usb_serial_handle_break(port);
72 usb_serial_generic_resubmit_read_urb(port, GFP_ATOMIC);
73 return;
74 }
75
76 usb_serial_generic_read_bulk_callback(urb);
77}
78
41static struct usb_serial_driver debug_device = { 79static struct usb_serial_driver debug_device = {
42 .driver = { 80 .driver = {
43 .owner = THIS_MODULE, 81 .owner = THIS_MODULE,
@@ -46,6 +84,9 @@ static struct usb_serial_driver debug_device = {
46 .id_table = id_table, 84 .id_table = id_table,
47 .num_ports = 1, 85 .num_ports = 1,
48 .open = usb_debug_open, 86 .open = usb_debug_open,
87 .max_in_flight_urbs = URB_DEBUG_MAX_IN_FLIGHT_URBS,
88 .break_ctl = usb_debug_break_ctl,
89 .read_bulk_callback = usb_debug_read_bulk_callback,
49}; 90};
50 91
51static int __init debug_init(void) 92static int __init debug_init(void)