Commit | Line | Data |
---|---|---|
d75662e1 BP |
1 | /* |
2 | * This code was developed for the Quatech USB line for linux, it used | |
3 | * much of the code developed by Greg Kroah-Hartman for USB serial devices | |
4 | * | |
5 | */ | |
6 | ||
7 | #include <linux/errno.h> | |
d75662e1 BP |
8 | #include <linux/slab.h> |
9 | #include <linux/tty.h> | |
10 | #include <linux/tty_driver.h> | |
11 | #include <linux/tty_flip.h> | |
12 | #include <linux/module.h> | |
13 | #include <linux/serial.h> | |
14 | #include <linux/usb.h> | |
15 | #include <linux/usb/serial.h> | |
16 | #include <linux/uaccess.h> | |
17 | ||
d75662e1 BP |
18 | /* Version Information */ |
19 | #define DRIVER_VERSION "v2.14" | |
20 | #define DRIVER_AUTHOR "Tim Gobeli, Quatech, Inc" | |
21 | #define DRIVER_DESC "Quatech USB to Serial Driver" | |
22 | ||
23 | #define USB_VENDOR_ID_QUATECH 0x061d /* Quatech VID */ | |
d75662e1 BP |
24 | #define QUATECH_SSU200 0xC030 /* SSU200 */ |
25 | #define QUATECH_DSU100 0xC040 /* DSU100 */ | |
26 | #define QUATECH_DSU200 0xC050 /* DSU200 */ | |
27 | #define QUATECH_QSU100 0xC060 /* QSU100 */ | |
28 | #define QUATECH_QSU200 0xC070 /* QSU200 */ | |
29 | #define QUATECH_ESU100A 0xC080 /* ESU100A */ | |
30 | #define QUATECH_ESU100B 0xC081 /* ESU100B */ | |
31 | #define QUATECH_ESU200A 0xC0A0 /* ESU200A */ | |
32 | #define QUATECH_ESU200B 0xC0A1 /* ESU200B */ | |
33 | #define QUATECH_HSU100A 0xC090 /* HSU100A */ | |
34 | #define QUATECH_HSU100B 0xC091 /* HSU100B */ | |
35 | #define QUATECH_HSU100C 0xC092 /* HSU100C */ | |
36 | #define QUATECH_HSU100D 0xC093 /* HSU100D */ | |
37 | #define QUATECH_HSU200A 0xC0B0 /* HSU200A */ | |
38 | #define QUATECH_HSU200B 0xC0B1 /* HSU200B */ | |
39 | #define QUATECH_HSU200C 0xC0B2 /* HSU200C */ | |
40 | #define QUATECH_HSU200D 0xC0B3 /* HSU200D */ | |
d75662e1 BP |
41 | |
42 | #define QT_SET_GET_DEVICE 0xc2 | |
43 | #define QT_OPEN_CLOSE_CHANNEL 0xca | |
44 | #define QT_GET_SET_PREBUF_TRIG_LVL 0xcc | |
45 | #define QT_SET_ATF 0xcd | |
46 | #define QT_GET_SET_REGISTER 0xc0 | |
47 | #define QT_GET_SET_UART 0xc1 | |
48 | #define QT_HW_FLOW_CONTROL_MASK 0xc5 | |
49 | #define QT_SW_FLOW_CONTROL_MASK 0xc6 | |
50 | #define QT_SW_FLOW_CONTROL_DISABLE 0xc7 | |
51 | #define QT_BREAK_CONTROL 0xc8 | |
52 | ||
53 | #define USBD_TRANSFER_DIRECTION_IN 0xc0 | |
54 | #define USBD_TRANSFER_DIRECTION_OUT 0x40 | |
55 | ||
56 | #define MAX_BAUD_RATE 460800 | |
57 | #define MAX_BAUD_REMAINDER 4608 | |
58 | ||
59 | #define DIV_LATCH_LS 0x00 | |
60 | #define XMT_HOLD_REGISTER 0x00 | |
61 | #define XVR_BUFFER_REGISTER 0x00 | |
62 | #define DIV_LATCH_MS 0x01 | |
63 | #define FIFO_CONTROL_REGISTER 0x02 | |
64 | #define LINE_CONTROL_REGISTER 0x03 | |
65 | #define MODEM_CONTROL_REGISTER 0x04 | |
66 | #define LINE_STATUS_REGISTER 0x05 | |
67 | #define MODEM_STATUS_REGISTER 0x06 | |
68 | ||
69 | #define SERIAL_MCR_DTR 0x01 | |
70 | #define SERIAL_MCR_RTS 0x02 | |
71 | #define SERIAL_MCR_LOOP 0x10 | |
72 | ||
73 | #define SERIAL_MSR_CTS 0x10 | |
74 | #define SERIAL_MSR_CD 0x80 | |
75 | #define SERIAL_MSR_RI 0x40 | |
76 | #define SERIAL_MSR_DSR 0x20 | |
77 | #define SERIAL_MSR_MASK 0xf0 | |
78 | ||
79 | #define SERIAL_8_DATA 0x03 | |
80 | #define SERIAL_7_DATA 0x02 | |
81 | #define SERIAL_6_DATA 0x01 | |
82 | #define SERIAL_5_DATA 0x00 | |
83 | ||
84 | #define SERIAL_ODD_PARITY 0X08 | |
85 | #define SERIAL_EVEN_PARITY 0X18 | |
86 | #define SERIAL_TWO_STOPB 0x04 | |
87 | #define SERIAL_ONE_STOPB 0x00 | |
88 | ||
89 | #define DEFAULT_DIVISOR 0x30 /* gives 9600 baud rate */ | |
90 | #define DEFAULT_LCR SERIAL_8_DATA /* 8, none , 1 */ | |
91 | ||
92 | #define FULLPWRBIT 0x00000080 | |
93 | #define NEXT_BOARD_POWER_BIT 0x00000004 | |
94 | ||
95 | #define SERIAL_LSR_OE 0x02 | |
96 | #define SERIAL_LSR_PE 0x04 | |
97 | #define SERIAL_LSR_FE 0x08 | |
98 | #define SERIAL_LSR_BI 0x10 | |
99 | ||
100 | #define SERIAL_MSR_CTS 0x10 | |
101 | #define SERIAL_MSR_CD 0x80 | |
102 | #define SERIAL_MSR_RI 0x40 | |
103 | #define SERIAL_MSR_DSR 0x20 | |
104 | #define SERIAL_MSR_MASK 0xf0 | |
105 | ||
106 | #define PREFUFF_LEVEL_CONSERVATIVE 128 | |
107 | #define ATC_DISABLED 0x0 | |
108 | ||
109 | #define RR_BITS 0x03 /* for clearing clock bits */ | |
110 | #define DUPMODE_BITS 0xc0 | |
111 | #define CLKS_X4 0x02 | |
112 | ||
113 | #define LOOPMODE_BITS 0x41 /* LOOP1 = b6, LOOP0 = b0 (PORT B) */ | |
114 | #define ALL_LOOPBACK 0x01 | |
115 | #define MODEM_CTRL 0x40 | |
116 | #define RS232_MODE 0x00 | |
117 | ||
68e24113 | 118 | static const struct usb_device_id id_table[] = { |
d75662e1 BP |
119 | {USB_DEVICE(USB_VENDOR_ID_QUATECH, QUATECH_SSU200)}, |
120 | {USB_DEVICE(USB_VENDOR_ID_QUATECH, QUATECH_DSU100)}, | |
121 | {USB_DEVICE(USB_VENDOR_ID_QUATECH, QUATECH_DSU200)}, | |
122 | {USB_DEVICE(USB_VENDOR_ID_QUATECH, QUATECH_QSU100)}, | |
123 | {USB_DEVICE(USB_VENDOR_ID_QUATECH, QUATECH_QSU200)}, | |
124 | {USB_DEVICE(USB_VENDOR_ID_QUATECH, QUATECH_ESU100A)}, | |
125 | {USB_DEVICE(USB_VENDOR_ID_QUATECH, QUATECH_ESU100B)}, | |
126 | {USB_DEVICE(USB_VENDOR_ID_QUATECH, QUATECH_ESU200A)}, | |
127 | {USB_DEVICE(USB_VENDOR_ID_QUATECH, QUATECH_ESU200B)}, | |
128 | {USB_DEVICE(USB_VENDOR_ID_QUATECH, QUATECH_HSU100A)}, | |
129 | {USB_DEVICE(USB_VENDOR_ID_QUATECH, QUATECH_HSU100B)}, | |
130 | {USB_DEVICE(USB_VENDOR_ID_QUATECH, QUATECH_HSU100C)}, | |
131 | {USB_DEVICE(USB_VENDOR_ID_QUATECH, QUATECH_HSU100D)}, | |
132 | {USB_DEVICE(USB_VENDOR_ID_QUATECH, QUATECH_HSU200A)}, | |
133 | {USB_DEVICE(USB_VENDOR_ID_QUATECH, QUATECH_HSU200B)}, | |
134 | {USB_DEVICE(USB_VENDOR_ID_QUATECH, QUATECH_HSU200C)}, | |
135 | {USB_DEVICE(USB_VENDOR_ID_QUATECH, QUATECH_HSU200D)}, | |
d75662e1 BP |
136 | {} /* Terminating entry */ |
137 | }; | |
68e24113 | 138 | MODULE_DEVICE_TABLE(usb, id_table); |
d75662e1 BP |
139 | |
140 | struct qt_get_device_data { | |
141 | __u8 porta; | |
142 | __u8 portb; | |
143 | __u8 portc; | |
144 | }; | |
145 | ||
146 | struct qt_open_channel_data { | |
147 | __u8 line_status; | |
148 | __u8 modem_status; | |
149 | }; | |
150 | ||
151 | struct quatech_port { | |
152 | int port_num; /* number of the port */ | |
153 | struct urb *write_urb; /* write URB for this port */ | |
154 | struct urb *read_urb; /* read URB for this port */ | |
155 | struct urb *int_urb; | |
156 | ||
d68edc28 BB |
157 | __u8 shadow_lcr; /* last LCR value received */ |
158 | __u8 shadow_mcr; /* last MCR value received */ | |
159 | __u8 shadow_msr; /* last MSR value received */ | |
160 | __u8 shadow_lsr; /* last LSR value received */ | |
d75662e1 BP |
161 | char open_ports; |
162 | ||
163 | /* Used for TIOCMIWAIT */ | |
164 | wait_queue_head_t msr_wait; | |
165 | char prev_status, diff_status; | |
166 | ||
167 | wait_queue_head_t wait; | |
168 | ||
169 | struct async_icount icount; | |
170 | ||
171 | struct usb_serial_port *port; /* owner of this object */ | |
d68edc28 | 172 | struct qt_get_device_data device_data; |
fa2d8bbb | 173 | struct mutex lock; |
d75662e1 | 174 | bool read_urb_busy; |
d68edc28 BB |
175 | int rx_holding; |
176 | int read_bulk_stopped; | |
177 | char close_pending; | |
d75662e1 BP |
178 | }; |
179 | ||
d75662e1 BP |
180 | static int port_paranoia_check(struct usb_serial_port *port, |
181 | const char *function) | |
182 | { | |
183 | if (!port) { | |
e8656b02 | 184 | pr_debug("%s - port == NULL", function); |
d75662e1 BP |
185 | return -1; |
186 | } | |
187 | if (!port->serial) { | |
e8656b02 | 188 | pr_debug("%s - port->serial == NULL\n", function); |
d75662e1 BP |
189 | return -1; |
190 | } | |
191 | ||
192 | return 0; | |
193 | } | |
194 | ||
195 | static int serial_paranoia_check(struct usb_serial *serial, | |
196 | const char *function) | |
197 | { | |
198 | if (!serial) { | |
e8656b02 | 199 | pr_debug("%s - serial == NULL\n", function); |
d75662e1 BP |
200 | return -1; |
201 | } | |
202 | ||
203 | if (!serial->type) { | |
e8656b02 | 204 | pr_debug("%s - serial->type == NULL!", function); |
d75662e1 BP |
205 | return -1; |
206 | } | |
207 | ||
208 | return 0; | |
209 | } | |
210 | ||
211 | static inline struct quatech_port *qt_get_port_private(struct usb_serial_port | |
212 | *port) | |
213 | { | |
214 | return (struct quatech_port *)usb_get_serial_port_data(port); | |
215 | } | |
216 | ||
217 | static inline void qt_set_port_private(struct usb_serial_port *port, | |
218 | struct quatech_port *data) | |
219 | { | |
220 | usb_set_serial_port_data(port, (void *)data); | |
221 | } | |
222 | ||
223 | static struct usb_serial *get_usb_serial(struct usb_serial_port *port, | |
224 | const char *function) | |
225 | { | |
226 | /* if no port was specified, or it fails a paranoia check */ | |
227 | if (!port || | |
228 | port_paranoia_check(port, function) || | |
229 | serial_paranoia_check(port->serial, function)) { | |
230 | /* | |
231 | * then say that we dont have a valid usb_serial thing, | |
232 | * which will end up genrating -ENODEV return values | |
233 | */ | |
234 | return NULL; | |
235 | } | |
236 | ||
237 | return port->serial; | |
238 | } | |
239 | ||
d68edc28 | 240 | static void process_line_status(struct quatech_port *qt_port, |
d75662e1 BP |
241 | unsigned char line_status) |
242 | { | |
243 | ||
d68edc28 | 244 | qt_port->shadow_lsr = |
d75662e1 BP |
245 | line_status & (SERIAL_LSR_OE | SERIAL_LSR_PE | SERIAL_LSR_FE | |
246 | SERIAL_LSR_BI); | |
d75662e1 BP |
247 | } |
248 | ||
d68edc28 | 249 | static void process_modem_status(struct quatech_port *qt_port, |
d75662e1 BP |
250 | unsigned char modem_status) |
251 | { | |
252 | ||
d68edc28 | 253 | qt_port->shadow_msr = modem_status; |
d75662e1 | 254 | wake_up_interruptible(&qt_port->wait); |
d75662e1 BP |
255 | } |
256 | ||
d68edc28 | 257 | static void process_rx_char(struct usb_serial_port *port, unsigned char data) |
d75662e1 | 258 | { |
d75662e1 | 259 | struct urb *urb = port->read_urb; |
94362fd7 | 260 | if (urb->actual_length) |
92a19f9c | 261 | tty_insert_flip_char(&port->port, data, TTY_NORMAL); |
d75662e1 BP |
262 | } |
263 | ||
264 | static void qt_write_bulk_callback(struct urb *urb) | |
265 | { | |
d75662e1 BP |
266 | int status; |
267 | struct quatech_port *quatech_port; | |
268 | ||
269 | status = urb->status; | |
270 | ||
271 | if (status) { | |
01295448 YT |
272 | dev_dbg(&urb->dev->dev, |
273 | "nonzero write bulk status received:%d\n", status); | |
d75662e1 BP |
274 | return; |
275 | } | |
276 | ||
277 | quatech_port = urb->context; | |
278 | ||
6aad04f2 | 279 | tty_port_tty_wakeup(&quatech_port->port->port); |
d75662e1 BP |
280 | } |
281 | ||
282 | static void qt_interrupt_callback(struct urb *urb) | |
283 | { | |
284 | /* FIXME */ | |
285 | } | |
286 | ||
2e124b4a | 287 | static void qt_status_change_check(struct urb *urb, |
bbbd527b YT |
288 | struct quatech_port *qt_port, |
289 | struct usb_serial_port *port) | |
290 | { | |
291 | int flag, i; | |
292 | unsigned char *data = urb->transfer_buffer; | |
d68edc28 | 293 | unsigned int rx_count = urb->actual_length; |
bbbd527b | 294 | |
d68edc28 | 295 | for (i = 0; i < rx_count; ++i) { |
bbbd527b | 296 | /* Look ahead code here */ |
d68edc28 | 297 | if ((i <= (rx_count - 3)) && (data[i] == 0x1b) |
bbbd527b YT |
298 | && (data[i + 1] == 0x1b)) { |
299 | flag = 0; | |
300 | switch (data[i + 2]) { | |
301 | case 0x00: | |
d68edc28 | 302 | if (i > (rx_count - 4)) { |
9d36976f YT |
303 | dev_dbg(&port->dev, |
304 | "Illegal escape seuences in received data\n"); | |
305 | break; | |
306 | } | |
307 | ||
d68edc28 | 308 | process_line_status(qt_port, data[i + 3]); |
9d36976f YT |
309 | |
310 | i += 3; | |
311 | flag = 1; | |
312 | break; | |
313 | ||
bbbd527b | 314 | case 0x01: |
d68edc28 | 315 | if (i > (rx_count - 4)) { |
9d36976f YT |
316 | dev_dbg(&port->dev, |
317 | "Illegal escape seuences in received data\n"); | |
318 | break; | |
319 | } | |
320 | ||
d68edc28 | 321 | process_modem_status(qt_port, data[i + 3]); |
9d36976f YT |
322 | |
323 | i += 3; | |
324 | flag = 1; | |
bbbd527b YT |
325 | break; |
326 | ||
327 | case 0xff: | |
328 | dev_dbg(&port->dev, "No status sequence.\n"); | |
329 | ||
d68edc28 BB |
330 | process_rx_char(port, data[i]); |
331 | process_rx_char(port, data[i + 1]); | |
bbbd527b YT |
332 | |
333 | i += 2; | |
334 | break; | |
335 | } | |
336 | if (flag == 1) | |
337 | continue; | |
338 | } | |
339 | ||
92a19f9c JS |
340 | if (urb->actual_length) |
341 | tty_insert_flip_char(&port->port, data[i], TTY_NORMAL); | |
bbbd527b YT |
342 | |
343 | } | |
2e124b4a | 344 | tty_flip_buffer_push(&port->port); |
bbbd527b YT |
345 | } |
346 | ||
d75662e1 BP |
347 | static void qt_read_bulk_callback(struct urb *urb) |
348 | { | |
349 | ||
350 | struct usb_serial_port *port = urb->context; | |
351 | struct usb_serial *serial = get_usb_serial(port, __func__); | |
352 | struct quatech_port *qt_port = qt_get_port_private(port); | |
bbbd527b | 353 | int result; |
d75662e1 BP |
354 | |
355 | if (urb->status) { | |
d68edc28 | 356 | qt_port->read_bulk_stopped = 1; |
bbbd527b YT |
357 | dev_dbg(&urb->dev->dev, |
358 | "%s - nonzero write bulk status received: %d\n", | |
e8656b02 | 359 | __func__, urb->status); |
d75662e1 BP |
360 | return; |
361 | } | |
362 | ||
01295448 | 363 | dev_dbg(&port->dev, |
d68edc28 | 364 | "%s - port->rx_holding = %d\n", __func__, qt_port->rx_holding); |
d75662e1 BP |
365 | |
366 | if (port_paranoia_check(port, __func__) != 0) { | |
d68edc28 | 367 | qt_port->read_bulk_stopped = 1; |
6732c8bb | 368 | return; |
d75662e1 BP |
369 | } |
370 | ||
e8656b02 | 371 | if (!serial) |
6732c8bb | 372 | return; |
e8656b02 | 373 | |
d68edc28 | 374 | if (qt_port->close_pending == 1) { |
d75662e1 | 375 | /* Were closing , stop reading */ |
01295448 | 376 | dev_dbg(&port->dev, |
d68edc28 BB |
377 | "%s - (qt_port->close_pending == 1\n", __func__); |
378 | qt_port->read_bulk_stopped = 1; | |
6732c8bb | 379 | return; |
d75662e1 BP |
380 | } |
381 | ||
382 | /* | |
d68edc28 | 383 | * rx_holding is asserted by throttle, if we assert it, we're not |
d75662e1 BP |
384 | * receiving any more characters and let the box handle the flow |
385 | * control | |
386 | */ | |
d68edc28 BB |
387 | if (qt_port->rx_holding == 1) { |
388 | qt_port->read_bulk_stopped = 1; | |
6732c8bb | 389 | return; |
d75662e1 BP |
390 | } |
391 | ||
392 | if (urb->status) { | |
d68edc28 | 393 | qt_port->read_bulk_stopped = 1; |
d75662e1 | 394 | |
bbbd527b YT |
395 | dev_dbg(&port->dev, |
396 | "%s - nonzero read bulk status received: %d\n", | |
e8656b02 | 397 | __func__, urb->status); |
6732c8bb | 398 | return; |
d75662e1 BP |
399 | } |
400 | ||
bbbd527b | 401 | if (urb->actual_length) |
2e124b4a | 402 | qt_status_change_check(urb, qt_port, port); |
d75662e1 BP |
403 | |
404 | /* Continue trying to always read */ | |
405 | usb_fill_bulk_urb(port->read_urb, serial->dev, | |
406 | usb_rcvbulkpipe(serial->dev, | |
407 | port->bulk_in_endpointAddress), | |
408 | port->read_urb->transfer_buffer, | |
409 | port->read_urb->transfer_buffer_length, | |
410 | qt_read_bulk_callback, port); | |
411 | result = usb_submit_urb(port->read_urb, GFP_ATOMIC); | |
412 | if (result) | |
bbbd527b YT |
413 | dev_dbg(&port->dev, |
414 | "%s - failed resubmitting read urb, error %d", | |
e8656b02 | 415 | __func__, result); |
d75662e1 | 416 | else { |
bbbd527b | 417 | if (urb->actual_length) { |
2e124b4a | 418 | tty_flip_buffer_push(&port->port); |
6732c8bb | 419 | tty_schedule_flip(&port->port); |
d75662e1 BP |
420 | } |
421 | } | |
422 | ||
423 | schedule_work(&port->work); | |
424 | } | |
425 | ||
426 | /* | |
427 | * qt_get_device | |
428 | * Issue a GET_DEVICE vendor-specific request on the default control pipe If | |
429 | * successful, fills in the qt_get_device_data structure pointed to by | |
430 | * device_data, otherwise return a negative error number of the problem. | |
431 | */ | |
432 | ||
433 | static int qt_get_device(struct usb_serial *serial, | |
434 | struct qt_get_device_data *device_data) | |
435 | { | |
436 | int result; | |
437 | unsigned char *transfer_buffer; | |
438 | ||
439 | transfer_buffer = | |
440 | kmalloc(sizeof(struct qt_get_device_data), GFP_KERNEL); | |
441 | if (!transfer_buffer) | |
442 | return -ENOMEM; | |
443 | ||
444 | result = usb_control_msg(serial->dev, usb_rcvctrlpipe(serial->dev, 0), | |
445 | QT_SET_GET_DEVICE, 0xc0, 0, 0, | |
446 | transfer_buffer, | |
447 | sizeof(struct qt_get_device_data), 300); | |
448 | if (result > 0) | |
449 | memcpy(device_data, transfer_buffer, | |
450 | sizeof(struct qt_get_device_data)); | |
451 | kfree(transfer_buffer); | |
452 | ||
453 | return result; | |
454 | } | |
455 | ||
456 | /**************************************************************************** | |
d68edc28 | 457 | * box_set_prebuffer_level |
d75662e1 BP |
458 | TELLS BOX WHEN TO ASSERT FLOW CONTROL |
459 | ****************************************************************************/ | |
d68edc28 | 460 | static int box_set_prebuffer_level(struct usb_serial *serial) |
d75662e1 BP |
461 | { |
462 | int result; | |
463 | __u16 buffer_length; | |
464 | ||
465 | buffer_length = PREFUFF_LEVEL_CONSERVATIVE; | |
466 | result = usb_control_msg(serial->dev, usb_sndctrlpipe(serial->dev, 0), | |
467 | QT_GET_SET_PREBUF_TRIG_LVL, 0x40, | |
468 | buffer_length, 0, NULL, 0, 300); | |
469 | return result; | |
470 | } | |
471 | ||
472 | /**************************************************************************** | |
d68edc28 | 473 | * box_set_atc |
d75662e1 BP |
474 | TELLS BOX WHEN TO ASSERT automatic transmitter control |
475 | ****************************************************************************/ | |
d68edc28 | 476 | static int box_set_atc(struct usb_serial *serial, __u16 n_mode) |
d75662e1 BP |
477 | { |
478 | int result; | |
479 | __u16 buffer_length; | |
480 | ||
481 | buffer_length = PREFUFF_LEVEL_CONSERVATIVE; | |
482 | ||
483 | result = | |
484 | usb_control_msg(serial->dev, usb_sndctrlpipe(serial->dev, 0), | |
d68edc28 | 485 | QT_SET_ATF, 0x40, n_mode, 0, NULL, 0, 300); |
d75662e1 BP |
486 | |
487 | return result; | |
488 | } | |
489 | ||
490 | /** | |
491 | * qt_set_device | |
492 | * Issue a SET_DEVICE vendor-specific request on the default control pipe If | |
493 | * successful returns the number of bytes written, otherwise it returns a | |
494 | * negative error number of the problem. | |
495 | */ | |
496 | static int qt_set_device(struct usb_serial *serial, | |
497 | struct qt_get_device_data *device_data) | |
498 | { | |
499 | int result; | |
500 | __u16 length; | |
d68edc28 | 501 | __u16 port_settings; |
d75662e1 | 502 | |
d68edc28 BB |
503 | port_settings = ((__u16) (device_data->portb)); |
504 | port_settings = (port_settings << 8); | |
505 | port_settings += ((__u16) (device_data->porta)); | |
d75662e1 BP |
506 | |
507 | length = sizeof(struct qt_get_device_data); | |
d75662e1 BP |
508 | |
509 | result = usb_control_msg(serial->dev, usb_sndctrlpipe(serial->dev, 0), | |
d68edc28 | 510 | QT_SET_GET_DEVICE, 0x40, port_settings, |
d75662e1 BP |
511 | 0, NULL, 0, 300); |
512 | return result; | |
513 | } | |
514 | ||
ef2af122 | 515 | static int qt_open_channel(struct usb_serial *serial, __u16 uart_num, |
d68edc28 | 516 | struct qt_open_channel_data *pdevice_data) |
d75662e1 BP |
517 | { |
518 | int result; | |
519 | ||
520 | result = usb_control_msg(serial->dev, usb_rcvctrlpipe(serial->dev, 0), | |
521 | QT_OPEN_CLOSE_CHANNEL, | |
ef2af122 | 522 | USBD_TRANSFER_DIRECTION_IN, 1, uart_num, |
d68edc28 | 523 | pdevice_data, |
d75662e1 BP |
524 | sizeof(struct qt_open_channel_data), 300); |
525 | ||
526 | return result; | |
527 | ||
528 | } | |
529 | ||
ef2af122 | 530 | static int qt_close_channel(struct usb_serial *serial, __u16 uart_num) |
d75662e1 BP |
531 | { |
532 | int result; | |
533 | ||
534 | result = usb_control_msg(serial->dev, usb_rcvctrlpipe(serial->dev, 0), | |
535 | QT_OPEN_CLOSE_CHANNEL, | |
ef2af122 | 536 | USBD_TRANSFER_DIRECTION_OUT, 0, uart_num, |
d75662e1 BP |
537 | NULL, 0, 300); |
538 | ||
539 | return result; | |
540 | ||
541 | } | |
542 | ||
543 | /**************************************************************************** | |
d68edc28 | 544 | * box_get_register |
d75662e1 | 545 | * issuse a GET_REGISTER vendor-spcific request on the default control pipe |
d68edc28 | 546 | * If successful, fills in the p_value with the register value asked for |
d75662e1 | 547 | ****************************************************************************/ |
ef2af122 | 548 | static int box_get_register(struct usb_serial *serial, unsigned short uart_num, |
d68edc28 | 549 | unsigned short register_num, __u8 *p_value) |
d75662e1 BP |
550 | { |
551 | int result; | |
552 | __u16 current_length; | |
553 | ||
554 | current_length = sizeof(struct qt_get_device_data); | |
555 | ||
556 | result = | |
557 | usb_control_msg(serial->dev, usb_rcvctrlpipe(serial->dev, 0), | |
d68edc28 | 558 | QT_GET_SET_REGISTER, 0xC0, register_num, |
ef2af122 | 559 | uart_num, (void *)p_value, sizeof(*p_value), 300); |
d75662e1 BP |
560 | |
561 | return result; | |
562 | } | |
563 | ||
564 | /**************************************************************************** | |
d68edc28 | 565 | * box_set_register |
d75662e1 | 566 | * issuse a GET_REGISTER vendor-spcific request on the default control pipe |
d68edc28 | 567 | * If successful, fills in the p_value with the register value asked for |
d75662e1 | 568 | ****************************************************************************/ |
ef2af122 | 569 | static int box_set_register(struct usb_serial *serial, unsigned short uart_num, |
d68edc28 | 570 | unsigned short register_num, unsigned short value) |
d75662e1 BP |
571 | { |
572 | int result; | |
d68edc28 | 573 | unsigned short reg_and_byte; |
d75662e1 | 574 | |
d68edc28 BB |
575 | reg_and_byte = value; |
576 | reg_and_byte = reg_and_byte << 8; | |
577 | reg_and_byte = reg_and_byte + register_num; | |
d75662e1 BP |
578 | |
579 | /* | |
580 | result = usb_control_msg(serial->dev, usb_sndctrlpipe(serial->dev, 0), | |
d68edc28 | 581 | QT_GET_SET_REGISTER, 0xC0, register_num, |
ef2af122 | 582 | uart_num, NULL, 0, 300); |
d75662e1 BP |
583 | */ |
584 | ||
585 | result = | |
586 | usb_control_msg(serial->dev, usb_sndctrlpipe(serial->dev, 0), | |
ef2af122 | 587 | QT_GET_SET_REGISTER, 0x40, reg_and_byte, uart_num, |
d75662e1 BP |
588 | NULL, 0, 300); |
589 | ||
590 | return result; | |
591 | } | |
592 | ||
593 | /* | |
594 | * qt_setuart | |
1351acce | 595 | * issues a SET_UART vendor-specific request on the default control pipe |
d75662e1 BP |
596 | * If successful sets baud rate divisor and LCR value |
597 | */ | |
ef2af122 | 598 | static int qt_setuart(struct usb_serial *serial, unsigned short uart_num, |
d68edc28 | 599 | unsigned short default_divisor, unsigned char default_lcr) |
d75662e1 BP |
600 | { |
601 | int result; | |
d68edc28 | 602 | unsigned short uart_num_and_lcr; |
d75662e1 | 603 | |
ef2af122 | 604 | uart_num_and_lcr = (default_lcr << 8) + uart_num; |
d75662e1 BP |
605 | |
606 | result = | |
607 | usb_control_msg(serial->dev, usb_sndctrlpipe(serial->dev, 0), | |
608 | QT_GET_SET_UART, 0x40, default_divisor, | |
d68edc28 | 609 | uart_num_and_lcr, NULL, 0, 300); |
d75662e1 BP |
610 | |
611 | return result; | |
612 | } | |
613 | ||
d68edc28 BB |
614 | static int box_set_hw_flow_ctrl(struct usb_serial *serial, unsigned int index, |
615 | int b_set) | |
d75662e1 BP |
616 | { |
617 | __u8 mcr = 0; | |
d68edc28 | 618 | __u8 msr = 0, mout_value = 0; |
d75662e1 BP |
619 | unsigned int status; |
620 | ||
d68edc28 | 621 | if (b_set == 1) { |
d75662e1 BP |
622 | /* flow control, box will clear RTS line to prevent remote */ |
623 | mcr = SERIAL_MCR_RTS; | |
624 | } /* device from xmitting more chars */ | |
625 | else { | |
626 | /* no flow control to remote device */ | |
627 | mcr = 0; | |
628 | ||
629 | } | |
d68edc28 | 630 | mout_value = mcr << 8; |
d75662e1 | 631 | |
d68edc28 | 632 | if (b_set == 1) { |
d75662e1 BP |
633 | /* flow control, box will inhibit xmit data if CTS line is |
634 | * asserted */ | |
635 | msr = SERIAL_MSR_CTS; | |
636 | } else { | |
637 | /* Box will not inhimbe xmit data due to CTS line */ | |
638 | msr = 0; | |
639 | } | |
d68edc28 | 640 | mout_value |= msr; |
d75662e1 BP |
641 | |
642 | status = | |
643 | usb_control_msg(serial->dev, usb_sndctrlpipe(serial->dev, 0), | |
d68edc28 | 644 | QT_HW_FLOW_CONTROL_MASK, 0x40, mout_value, |
d75662e1 BP |
645 | index, NULL, 0, 300); |
646 | return status; | |
647 | ||
648 | } | |
649 | ||
d68edc28 | 650 | static int box_set_sw_flow_ctrl(struct usb_serial *serial, __u16 index, |
d75662e1 BP |
651 | unsigned char stop_char, unsigned char start_char) |
652 | { | |
d68edc28 | 653 | __u16 n_sw_flow_out; |
d75662e1 BP |
654 | int result; |
655 | ||
d68edc28 BB |
656 | n_sw_flow_out = start_char << 8; |
657 | n_sw_flow_out = (unsigned short)stop_char; | |
d75662e1 BP |
658 | |
659 | result = | |
660 | usb_control_msg(serial->dev, usb_sndctrlpipe(serial->dev, 0), | |
d68edc28 | 661 | QT_SW_FLOW_CONTROL_MASK, 0x40, n_sw_flow_out, |
d75662e1 BP |
662 | index, NULL, 0, 300); |
663 | return result; | |
664 | ||
665 | } | |
666 | ||
d68edc28 | 667 | static int box_disable_sw_flow_ctrl(struct usb_serial *serial, __u16 index) |
d75662e1 BP |
668 | { |
669 | int result; | |
670 | ||
671 | result = | |
672 | usb_control_msg(serial->dev, usb_sndctrlpipe(serial->dev, 0), | |
673 | QT_SW_FLOW_CONTROL_DISABLE, 0x40, 0, index, | |
674 | NULL, 0, 300); | |
675 | return result; | |
676 | ||
677 | } | |
678 | ||
679 | static int qt_startup(struct usb_serial *serial) | |
680 | { | |
e8656b02 | 681 | struct device *dev = &serial->dev->dev; |
d75662e1 BP |
682 | struct usb_serial_port *port; |
683 | struct quatech_port *qt_port; | |
d68edc28 | 684 | struct qt_get_device_data device_data; |
d75662e1 BP |
685 | int i; |
686 | int status; | |
687 | ||
d75662e1 BP |
688 | /* Now setup per port private data */ |
689 | for (i = 0; i < serial->num_ports; i++) { | |
690 | port = serial->port[i]; | |
691 | qt_port = kzalloc(sizeof(*qt_port), GFP_KERNEL); | |
692 | if (!qt_port) { | |
1695eb36 | 693 | for (--i; i >= 0; i--) { |
de8f8bd6 ON |
694 | port = serial->port[i]; |
695 | kfree(usb_get_serial_port_data(port)); | |
696 | usb_set_serial_port_data(port, NULL); | |
697 | } | |
d75662e1 BP |
698 | return -ENOMEM; |
699 | } | |
fa2d8bbb | 700 | mutex_init(&qt_port->lock); |
d75662e1 BP |
701 | |
702 | usb_set_serial_port_data(port, qt_port); | |
703 | ||
704 | } | |
705 | ||
d68edc28 | 706 | status = qt_get_device(serial, &device_data); |
e8656b02 | 707 | if (status < 0) |
d75662e1 | 708 | goto startup_error; |
d75662e1 | 709 | |
d68edc28 | 710 | dev_dbg(dev, "device_data.portb = 0x%x\n", device_data.portb); |
d75662e1 | 711 | |
d68edc28 BB |
712 | device_data.portb &= ~FULLPWRBIT; |
713 | dev_dbg(dev, "Changing device_data.portb to 0x%x\n", device_data.portb); | |
d75662e1 | 714 | |
d68edc28 | 715 | status = qt_set_device(serial, &device_data); |
d75662e1 | 716 | if (status < 0) { |
e8656b02 | 717 | dev_dbg(dev, "qt_set_device failed\n"); |
d75662e1 BP |
718 | goto startup_error; |
719 | } | |
720 | ||
d68edc28 | 721 | status = qt_get_device(serial, &device_data); |
d75662e1 | 722 | if (status < 0) { |
e8656b02 | 723 | dev_dbg(dev, "qt_get_device failed\n"); |
d75662e1 BP |
724 | goto startup_error; |
725 | } | |
726 | ||
727 | switch (serial->dev->descriptor.idProduct) { | |
d75662e1 BP |
728 | case QUATECH_DSU100: |
729 | case QUATECH_QSU100: | |
730 | case QUATECH_ESU100A: | |
731 | case QUATECH_ESU100B: | |
732 | case QUATECH_HSU100A: | |
733 | case QUATECH_HSU100B: | |
734 | case QUATECH_HSU100C: | |
735 | case QUATECH_HSU100D: | |
d68edc28 BB |
736 | device_data.porta &= ~(RR_BITS | DUPMODE_BITS); |
737 | device_data.porta |= CLKS_X4; | |
738 | device_data.portb &= ~(LOOPMODE_BITS); | |
739 | device_data.portb |= RS232_MODE; | |
d75662e1 BP |
740 | break; |
741 | ||
742 | case QUATECH_SSU200: | |
743 | case QUATECH_DSU200: | |
744 | case QUATECH_QSU200: | |
745 | case QUATECH_ESU200A: | |
746 | case QUATECH_ESU200B: | |
747 | case QUATECH_HSU200A: | |
748 | case QUATECH_HSU200B: | |
749 | case QUATECH_HSU200C: | |
750 | case QUATECH_HSU200D: | |
d68edc28 BB |
751 | device_data.porta &= ~(RR_BITS | DUPMODE_BITS); |
752 | device_data.porta |= CLKS_X4; | |
753 | device_data.portb &= ~(LOOPMODE_BITS); | |
754 | device_data.portb |= ALL_LOOPBACK; | |
d75662e1 BP |
755 | break; |
756 | default: | |
d68edc28 BB |
757 | device_data.porta &= ~(RR_BITS | DUPMODE_BITS); |
758 | device_data.porta |= CLKS_X4; | |
759 | device_data.portb &= ~(LOOPMODE_BITS); | |
760 | device_data.portb |= RS232_MODE; | |
d75662e1 BP |
761 | break; |
762 | ||
763 | } | |
764 | ||
d68edc28 | 765 | status = box_set_prebuffer_level(serial); /* sets to default value */ |
d75662e1 | 766 | if (status < 0) { |
d68edc28 | 767 | dev_dbg(dev, "box_set_prebuffer_level failed\n"); |
d75662e1 BP |
768 | goto startup_error; |
769 | } | |
770 | ||
d68edc28 | 771 | status = box_set_atc(serial, ATC_DISABLED); |
d75662e1 | 772 | if (status < 0) { |
d68edc28 | 773 | dev_dbg(dev, "box_set_atc failed\n"); |
d75662e1 BP |
774 | goto startup_error; |
775 | } | |
776 | ||
d68edc28 | 777 | dev_dbg(dev, "device_data.portb = 0x%x\n", device_data.portb); |
d75662e1 | 778 | |
d68edc28 BB |
779 | device_data.portb |= NEXT_BOARD_POWER_BIT; |
780 | dev_dbg(dev, "Changing device_data.portb to 0x%x\n", device_data.portb); | |
d75662e1 | 781 | |
d68edc28 | 782 | status = qt_set_device(serial, &device_data); |
d75662e1 | 783 | if (status < 0) { |
e8656b02 | 784 | dev_dbg(dev, "qt_set_device failed\n"); |
d75662e1 BP |
785 | goto startup_error; |
786 | } | |
787 | ||
d75662e1 BP |
788 | return 0; |
789 | ||
790 | startup_error: | |
791 | for (i = 0; i < serial->num_ports; i++) { | |
792 | port = serial->port[i]; | |
793 | qt_port = qt_get_port_private(port); | |
794 | kfree(qt_port); | |
795 | usb_set_serial_port_data(port, NULL); | |
796 | } | |
797 | ||
d75662e1 BP |
798 | return -EIO; |
799 | } | |
800 | ||
801 | static void qt_release(struct usb_serial *serial) | |
802 | { | |
803 | struct usb_serial_port *port; | |
804 | struct quatech_port *qt_port; | |
805 | int i; | |
806 | ||
d75662e1 BP |
807 | for (i = 0; i < serial->num_ports; i++) { |
808 | port = serial->port[i]; | |
809 | if (!port) | |
810 | continue; | |
811 | ||
812 | qt_port = usb_get_serial_port_data(port); | |
813 | kfree(qt_port); | |
814 | usb_set_serial_port_data(port, NULL); | |
815 | } | |
816 | ||
817 | } | |
818 | ||
04e9d11b YT |
819 | static void qt_submit_urb_from_open(struct usb_serial *serial, |
820 | struct usb_serial_port *port) | |
821 | { | |
822 | int result; | |
823 | struct usb_serial_port *port0 = serial->port[0]; | |
824 | ||
825 | /* set up interrupt urb */ | |
826 | usb_fill_int_urb(port0->interrupt_in_urb, | |
827 | serial->dev, | |
828 | usb_rcvintpipe(serial->dev, | |
829 | port0->interrupt_in_endpointAddress), | |
830 | port0->interrupt_in_buffer, | |
831 | port0->interrupt_in_urb->transfer_buffer_length, | |
832 | qt_interrupt_callback, serial, | |
833 | port0->interrupt_in_urb->interval); | |
834 | ||
835 | result = usb_submit_urb(port0->interrupt_in_urb, | |
836 | GFP_KERNEL); | |
837 | if (result) { | |
838 | dev_err(&port->dev, | |
839 | "%s - Error %d submitting interrupt urb\n", | |
840 | __func__, result); | |
841 | } | |
842 | } | |
843 | ||
35e2bed5 | 844 | static int qt_open(struct tty_struct *tty, |
2386b331 | 845 | struct usb_serial_port *port) |
d75662e1 BP |
846 | { |
847 | struct usb_serial *serial; | |
848 | struct quatech_port *quatech_port; | |
849 | struct quatech_port *port0; | |
d68edc28 | 850 | struct qt_open_channel_data channel_data; |
d75662e1 BP |
851 | |
852 | int result; | |
853 | ||
854 | if (port_paranoia_check(port, __func__)) | |
855 | return -ENODEV; | |
856 | ||
d75662e1 BP |
857 | serial = port->serial; |
858 | ||
859 | if (serial_paranoia_check(serial, __func__)) | |
860 | return -ENODEV; | |
861 | ||
862 | quatech_port = qt_get_port_private(port); | |
863 | port0 = qt_get_port_private(serial->port[0]); | |
864 | ||
865 | if (quatech_port == NULL || port0 == NULL) | |
866 | return -ENODEV; | |
867 | ||
868 | usb_clear_halt(serial->dev, port->write_urb->pipe); | |
869 | usb_clear_halt(serial->dev, port->read_urb->pipe); | |
870 | port0->open_ports++; | |
871 | ||
d68edc28 | 872 | result = qt_get_device(serial, &port0->device_data); |
d75662e1 BP |
873 | |
874 | /* Port specific setups */ | |
ce49b628 | 875 | result = qt_open_channel(serial, port->port_number, &channel_data); |
d75662e1 | 876 | if (result < 0) { |
e8656b02 | 877 | dev_dbg(&port->dev, "qt_open_channel failed\n"); |
d75662e1 BP |
878 | return result; |
879 | } | |
e8656b02 | 880 | dev_dbg(&port->dev, "qt_open_channel completed.\n"); |
d75662e1 BP |
881 | |
882 | /* FIXME: are these needed? Does it even do anything useful? */ | |
d68edc28 | 883 | quatech_port->shadow_lsr = channel_data.line_status & |
d75662e1 BP |
884 | (SERIAL_LSR_OE | SERIAL_LSR_PE | SERIAL_LSR_FE | SERIAL_LSR_BI); |
885 | ||
d68edc28 | 886 | quatech_port->shadow_msr = channel_data.modem_status & |
d75662e1 BP |
887 | (SERIAL_MSR_CTS | SERIAL_MSR_DSR | SERIAL_MSR_RI | SERIAL_MSR_CD); |
888 | ||
889 | /* Set Baud rate to default and turn off (default)flow control here */ | |
1143832e | 890 | result = qt_setuart(serial, port->port_number, DEFAULT_DIVISOR, DEFAULT_LCR); |
d75662e1 | 891 | if (result < 0) { |
e8656b02 | 892 | dev_dbg(&port->dev, "qt_setuart failed\n"); |
d75662e1 BP |
893 | return result; |
894 | } | |
e8656b02 | 895 | dev_dbg(&port->dev, "qt_setuart completed.\n"); |
d75662e1 BP |
896 | |
897 | /* | |
bbc9a991 | 898 | * Put this here to make it responsive to stty and defaults set by |
d75662e1 BP |
899 | * the tty layer |
900 | */ | |
d75662e1 BP |
901 | |
902 | /* Check to see if we've set up our endpoint info yet */ | |
903 | if (port0->open_ports == 1) { | |
04e9d11b YT |
904 | if (serial->port[0]->interrupt_in_buffer == NULL) |
905 | qt_submit_urb_from_open(serial, port); | |
d75662e1 BP |
906 | } |
907 | ||
e5b1e206 | 908 | dev_dbg(&port->dev, "minor number is %d\n", port->minor); |
01295448 YT |
909 | dev_dbg(&port->dev, |
910 | "Bulkin endpoint is %d\n", port->bulk_in_endpointAddress); | |
911 | dev_dbg(&port->dev, | |
912 | "BulkOut endpoint is %d\n", port->bulk_out_endpointAddress); | |
913 | dev_dbg(&port->dev, "Interrupt endpoint is %d\n", | |
914 | port->interrupt_in_endpointAddress); | |
915 | dev_dbg(&port->dev, "port's number in the device is %d\n", | |
916 | quatech_port->port_num); | |
d75662e1 BP |
917 | quatech_port->read_urb = port->read_urb; |
918 | ||
919 | /* set up our bulk in urb */ | |
920 | ||
921 | usb_fill_bulk_urb(quatech_port->read_urb, | |
922 | serial->dev, | |
923 | usb_rcvbulkpipe(serial->dev, | |
924 | port->bulk_in_endpointAddress), | |
925 | port->bulk_in_buffer, | |
926 | quatech_port->read_urb->transfer_buffer_length, | |
927 | qt_read_bulk_callback, quatech_port); | |
928 | ||
01295448 YT |
929 | dev_dbg(&port->dev, "qt_open: bulkin endpoint is %d\n", |
930 | port->bulk_in_endpointAddress); | |
d75662e1 BP |
931 | quatech_port->read_urb_busy = true; |
932 | result = usb_submit_urb(quatech_port->read_urb, GFP_KERNEL); | |
933 | if (result) { | |
934 | dev_err(&port->dev, | |
935 | "%s - Error %d submitting control urb\n", | |
936 | __func__, result); | |
937 | quatech_port->read_urb_busy = false; | |
938 | } | |
939 | ||
940 | /* initialize our wait queues */ | |
941 | init_waitqueue_head(&quatech_port->wait); | |
942 | init_waitqueue_head(&quatech_port->msr_wait); | |
943 | ||
944 | /* initialize our icount structure */ | |
945 | memset(&(quatech_port->icount), 0x00, sizeof(quatech_port->icount)); | |
946 | ||
947 | return 0; | |
948 | ||
949 | } | |
950 | ||
951 | static int qt_chars_in_buffer(struct tty_struct *tty) | |
952 | { | |
953 | struct usb_serial_port *port = tty->driver_data; | |
954 | struct usb_serial *serial; | |
955 | int chars = 0; | |
956 | ||
957 | serial = get_usb_serial(port, __func__); | |
958 | ||
d75662e1 BP |
959 | if (serial->num_bulk_out) { |
960 | if (port->write_urb->status == -EINPROGRESS) | |
961 | chars = port->write_urb->transfer_buffer_length; | |
962 | } | |
963 | ||
d75662e1 BP |
964 | return chars; |
965 | } | |
966 | ||
967 | static void qt_block_until_empty(struct tty_struct *tty, | |
968 | struct quatech_port *qt_port) | |
969 | { | |
970 | int timeout = HZ / 10; | |
971 | int wait = 30; | |
972 | int count; | |
973 | ||
974 | while (1) { | |
975 | ||
976 | count = qt_chars_in_buffer(tty); | |
977 | ||
978 | if (count <= 0) | |
979 | return; | |
980 | ||
981 | interruptible_sleep_on_timeout(&qt_port->wait, timeout); | |
982 | ||
983 | wait--; | |
984 | if (wait == 0) { | |
e8656b02 | 985 | dev_dbg(&qt_port->port->dev, "%s - TIMEOUT", __func__); |
d75662e1 BP |
986 | return; |
987 | } else { | |
988 | wait = 30; | |
989 | } | |
990 | } | |
991 | } | |
992 | ||
f3a75688 | 993 | static void qt_close(struct usb_serial_port *port) |
d75662e1 BP |
994 | { |
995 | struct usb_serial *serial = port->serial; | |
996 | struct quatech_port *qt_port; | |
997 | struct quatech_port *port0; | |
d9dea3c1 | 998 | struct tty_struct *tty; |
d75662e1 BP |
999 | int status; |
1000 | unsigned int index; | |
1001 | status = 0; | |
1002 | ||
d9dea3c1 | 1003 | tty = tty_port_tty_get(&port->port); |
e5b1e206 | 1004 | index = port->port_number; |
d75662e1 BP |
1005 | |
1006 | qt_port = qt_get_port_private(port); | |
1007 | port0 = qt_get_port_private(serial->port[0]); | |
1008 | ||
1009 | /* shutdown any bulk reads that might be going on */ | |
1010 | if (serial->num_bulk_out) | |
1011 | usb_unlink_urb(port->write_urb); | |
1012 | if (serial->num_bulk_in) | |
1013 | usb_unlink_urb(port->read_urb); | |
1014 | ||
1015 | /* wait up to for transmitter to empty */ | |
1016 | if (serial->dev) | |
1017 | qt_block_until_empty(tty, qt_port); | |
f3a75688 | 1018 | tty_kref_put(tty); |
d75662e1 BP |
1019 | |
1020 | /* Close uart channel */ | |
1021 | status = qt_close_channel(serial, index); | |
1022 | if (status < 0) | |
1143832e | 1023 | dev_dbg(&port->dev, "%s - qt_close_channel failed.\n", __func__); |
d75662e1 BP |
1024 | |
1025 | port0->open_ports--; | |
1026 | ||
1143832e | 1027 | dev_dbg(&port->dev, "qt_num_open_ports in close%d\n", port0->open_ports); |
d75662e1 BP |
1028 | |
1029 | if (port0->open_ports == 0) { | |
1030 | if (serial->port[0]->interrupt_in_urb) { | |
01295448 | 1031 | dev_dbg(&port->dev, "Shutdown interrupt_in_urb\n"); |
d75662e1 BP |
1032 | usb_kill_urb(serial->port[0]->interrupt_in_urb); |
1033 | } | |
1034 | ||
1035 | } | |
1036 | ||
1037 | if (qt_port->write_urb) { | |
1038 | /* if this urb had a transfer buffer already (old tx) free it */ | |
ef055f10 | 1039 | kfree(qt_port->write_urb->transfer_buffer); |
d75662e1 BP |
1040 | usb_free_urb(qt_port->write_urb); |
1041 | } | |
1042 | ||
1043 | } | |
1044 | ||
1045 | static int qt_write(struct tty_struct *tty, struct usb_serial_port *port, | |
1046 | const unsigned char *buf, int count) | |
1047 | { | |
1048 | int result; | |
1049 | struct usb_serial *serial = get_usb_serial(port, __func__); | |
1050 | ||
1051 | if (serial == NULL) | |
1052 | return -ENODEV; | |
1053 | ||
d75662e1 | 1054 | if (count == 0) { |
01295448 YT |
1055 | dev_dbg(&port->dev, |
1056 | "%s - write request of 0 bytes\n", __func__); | |
d75662e1 BP |
1057 | return 0; |
1058 | } | |
1059 | ||
1060 | /* only do something if we have a bulk out endpoint */ | |
1061 | if (serial->num_bulk_out) { | |
1062 | if (port->write_urb->status == -EINPROGRESS) { | |
e8656b02 | 1063 | dev_dbg(&port->dev, "%s - already writing\n", __func__); |
d75662e1 BP |
1064 | return 0; |
1065 | } | |
1066 | ||
1067 | count = | |
1068 | (count > port->bulk_out_size) ? port->bulk_out_size : count; | |
1069 | memcpy(port->write_urb->transfer_buffer, buf, count); | |
1070 | ||
1071 | /* set up our urb */ | |
1072 | ||
1073 | usb_fill_bulk_urb(port->write_urb, serial->dev, | |
1074 | usb_sndbulkpipe(serial->dev, | |
1075 | port-> | |
1076 | bulk_out_endpointAddress), | |
1077 | port->write_urb->transfer_buffer, count, | |
1078 | qt_write_bulk_callback, port); | |
1079 | ||
1080 | /* send the data out the bulk port */ | |
1081 | result = usb_submit_urb(port->write_urb, GFP_ATOMIC); | |
1082 | if (result) | |
01295448 YT |
1083 | dev_dbg(&port->dev, |
1084 | "%s - failed submitting write urb, error %d\n", | |
e8656b02 | 1085 | __func__, result); |
d75662e1 BP |
1086 | else |
1087 | result = count; | |
1088 | ||
1089 | return result; | |
1090 | } | |
1091 | ||
1092 | /* no bulk out, so return 0 bytes written */ | |
1093 | return 0; | |
1094 | } | |
1095 | ||
1096 | static int qt_write_room(struct tty_struct *tty) | |
1097 | { | |
1098 | struct usb_serial_port *port = tty->driver_data; | |
1099 | struct usb_serial *serial; | |
1100 | struct quatech_port *qt_port; | |
d75662e1 BP |
1101 | |
1102 | int retval = -EINVAL; | |
1103 | ||
e8656b02 | 1104 | if (port_paranoia_check(port, __func__)) |
d75662e1 | 1105 | return -1; |
d75662e1 BP |
1106 | |
1107 | serial = get_usb_serial(port, __func__); | |
1108 | ||
1109 | if (!serial) | |
1110 | return -ENODEV; | |
1111 | ||
1112 | qt_port = qt_get_port_private(port); | |
1113 | ||
fa2d8bbb | 1114 | mutex_lock(&qt_port->lock); |
d75662e1 | 1115 | |
d75662e1 BP |
1116 | if (serial->num_bulk_out) { |
1117 | if (port->write_urb->status != -EINPROGRESS) | |
1118 | retval = port->bulk_out_size; | |
1119 | } | |
1120 | ||
fa2d8bbb | 1121 | mutex_unlock(&qt_port->lock); |
d75662e1 BP |
1122 | return retval; |
1123 | ||
1124 | } | |
1125 | ||
00a0d0d6 | 1126 | static int qt_ioctl(struct tty_struct *tty, |
d75662e1 BP |
1127 | unsigned int cmd, unsigned long arg) |
1128 | { | |
1129 | struct usb_serial_port *port = tty->driver_data; | |
1130 | struct quatech_port *qt_port = qt_get_port_private(port); | |
d75662e1 BP |
1131 | unsigned int index; |
1132 | ||
e8656b02 | 1133 | dev_dbg(&port->dev, "%s cmd 0x%04x\n", __func__, cmd); |
d75662e1 | 1134 | |
e5b1e206 | 1135 | index = port->port_number; |
d75662e1 BP |
1136 | |
1137 | if (cmd == TIOCMIWAIT) { | |
1138 | while (qt_port != NULL) { | |
1139 | interruptible_sleep_on(&qt_port->msr_wait); | |
1140 | if (signal_pending(current)) | |
1141 | return -ERESTARTSYS; | |
1142 | else { | |
1143 | char diff = qt_port->diff_status; | |
1144 | ||
1145 | if (diff == 0) | |
1146 | return -EIO; /* no change => error */ | |
1147 | ||
1148 | /* Consume all events */ | |
1149 | qt_port->diff_status = 0; | |
1150 | ||
1151 | if (((arg & TIOCM_RNG) | |
1152 | && (diff & SERIAL_MSR_RI)) | |
1153 | || ((arg & TIOCM_DSR) | |
1154 | && (diff & SERIAL_MSR_DSR)) | |
1155 | || ((arg & TIOCM_CD) | |
1156 | && (diff & SERIAL_MSR_CD)) | |
1157 | || ((arg & TIOCM_CTS) | |
1158 | && (diff & SERIAL_MSR_CTS))) { | |
1159 | return 0; | |
1160 | } | |
1161 | } | |
1162 | } | |
1163 | return 0; | |
1164 | } | |
1165 | ||
1143832e | 1166 | dev_dbg(&port->dev, "%s -No ioctl for that one.\n", __func__); |
d75662e1 BP |
1167 | return -ENOIOCTLCMD; |
1168 | } | |
1169 | ||
1170 | static void qt_set_termios(struct tty_struct *tty, | |
1171 | struct usb_serial_port *port, | |
1172 | struct ktermios *old_termios) | |
1173 | { | |
9b12daf7 | 1174 | struct ktermios *termios = &tty->termios; |
d68edc28 | 1175 | unsigned char new_lcr = 0; |
d75662e1 BP |
1176 | unsigned int cflag = termios->c_cflag; |
1177 | unsigned int index; | |
1178 | int baud, divisor, remainder; | |
1179 | int status; | |
1180 | ||
e5b1e206 | 1181 | index = port->port_number; |
d75662e1 | 1182 | |
9b12daf7 | 1183 | switch (cflag & CSIZE) { |
d75662e1 | 1184 | case CS5: |
d68edc28 | 1185 | new_lcr |= SERIAL_5_DATA; |
d75662e1 BP |
1186 | break; |
1187 | case CS6: | |
d68edc28 | 1188 | new_lcr |= SERIAL_6_DATA; |
d75662e1 BP |
1189 | break; |
1190 | case CS7: | |
d68edc28 | 1191 | new_lcr |= SERIAL_7_DATA; |
d75662e1 BP |
1192 | break; |
1193 | default: | |
9b12daf7 AC |
1194 | termios->c_cflag &= ~CSIZE; |
1195 | termios->c_cflag |= CS8; | |
d75662e1 | 1196 | case CS8: |
d68edc28 | 1197 | new_lcr |= SERIAL_8_DATA; |
d75662e1 BP |
1198 | break; |
1199 | } | |
1200 | ||
1201 | /* Parity stuff */ | |
1202 | if (cflag & PARENB) { | |
1203 | if (cflag & PARODD) | |
d68edc28 | 1204 | new_lcr |= SERIAL_ODD_PARITY; |
d75662e1 | 1205 | else |
d68edc28 | 1206 | new_lcr |= SERIAL_EVEN_PARITY; |
d75662e1 BP |
1207 | } |
1208 | if (cflag & CSTOPB) | |
d68edc28 | 1209 | new_lcr |= SERIAL_TWO_STOPB; |
d75662e1 | 1210 | else |
d68edc28 | 1211 | new_lcr |= SERIAL_ONE_STOPB; |
d75662e1 | 1212 | |
e8656b02 | 1213 | dev_dbg(&port->dev, "%s - 4\n", __func__); |
d75662e1 BP |
1214 | |
1215 | /* Thats the LCR stuff, go ahead and set it */ | |
1216 | baud = tty_get_baud_rate(tty); | |
1217 | if (!baud) | |
1218 | /* pick a default, any default... */ | |
1219 | baud = 9600; | |
1220 | ||
e8656b02 | 1221 | dev_dbg(&port->dev, "%s - got baud = %d\n", __func__, baud); |
d75662e1 BP |
1222 | |
1223 | divisor = MAX_BAUD_RATE / baud; | |
1224 | remainder = MAX_BAUD_RATE % baud; | |
1225 | /* Round to nearest divisor */ | |
1226 | if (((remainder * 2) >= baud) && (baud != 110)) | |
1227 | divisor++; | |
1228 | ||
1229 | /* | |
1230 | * Set Baud rate to default and turn off (default)flow control here | |
1231 | */ | |
1232 | status = | |
d68edc28 | 1233 | qt_setuart(port->serial, index, (unsigned short)divisor, new_lcr); |
d75662e1 | 1234 | if (status < 0) { |
e8656b02 | 1235 | dev_dbg(&port->dev, "qt_setuart failed\n"); |
d75662e1 BP |
1236 | return; |
1237 | } | |
1238 | ||
1239 | /* Now determine flow control */ | |
1240 | if (cflag & CRTSCTS) { | |
1143832e | 1241 | dev_dbg(&port->dev, "%s - Enabling HW flow control\n", __func__); |
d75662e1 BP |
1242 | |
1243 | /* Enable RTS/CTS flow control */ | |
d68edc28 | 1244 | status = box_set_hw_flow_ctrl(port->serial, index, 1); |
d75662e1 BP |
1245 | |
1246 | if (status < 0) { | |
d68edc28 | 1247 | dev_dbg(&port->dev, "box_set_hw_flow_ctrl failed\n"); |
d75662e1 BP |
1248 | return; |
1249 | } | |
1250 | } else { | |
1251 | /* Disable RTS/CTS flow control */ | |
01295448 | 1252 | dev_dbg(&port->dev, |
1143832e | 1253 | "%s - disabling HW flow control\n", __func__); |
d75662e1 | 1254 | |
d68edc28 | 1255 | status = box_set_hw_flow_ctrl(port->serial, index, 0); |
d75662e1 | 1256 | if (status < 0) { |
d68edc28 | 1257 | dev_dbg(&port->dev, "box_set_hw_flow_ctrl failed\n"); |
d75662e1 BP |
1258 | return; |
1259 | } | |
1260 | ||
1261 | } | |
1262 | ||
1263 | /* if we are implementing XON/XOFF, set the start and stop character in | |
1264 | * the device */ | |
1265 | if (I_IXOFF(tty) || I_IXON(tty)) { | |
1266 | unsigned char stop_char = STOP_CHAR(tty); | |
1267 | unsigned char start_char = START_CHAR(tty); | |
1268 | status = | |
d68edc28 | 1269 | box_set_sw_flow_ctrl(port->serial, index, stop_char, |
d75662e1 BP |
1270 | start_char); |
1271 | if (status < 0) | |
01295448 | 1272 | dev_dbg(&port->dev, |
d68edc28 | 1273 | "box_set_sw_flow_ctrl (enabled) failed\n"); |
d75662e1 BP |
1274 | |
1275 | } else { | |
1276 | /* disable SW flow control */ | |
d68edc28 | 1277 | status = box_disable_sw_flow_ctrl(port->serial, index); |
d75662e1 | 1278 | if (status < 0) |
01295448 | 1279 | dev_dbg(&port->dev, |
d68edc28 | 1280 | "box_set_sw_flow_ctrl (diabling) failed\n"); |
d75662e1 BP |
1281 | |
1282 | } | |
9b12daf7 | 1283 | termios->c_cflag &= ~CMSPAR; |
01295448 YT |
1284 | /* FIXME: |
1285 | Error cases should be returning the actual bits changed only | |
1286 | */ | |
d75662e1 BP |
1287 | } |
1288 | ||
1289 | static void qt_break(struct tty_struct *tty, int break_state) | |
1290 | { | |
1291 | struct usb_serial_port *port = tty->driver_data; | |
1292 | struct usb_serial *serial = get_usb_serial(port, __func__); | |
1293 | struct quatech_port *qt_port; | |
1294 | u16 index, onoff; | |
1295 | unsigned int result; | |
d75662e1 | 1296 | |
e5b1e206 | 1297 | index = port->port_number; |
d75662e1 BP |
1298 | |
1299 | qt_port = qt_get_port_private(port); | |
1300 | ||
1301 | if (break_state == -1) | |
1302 | onoff = 1; | |
1303 | else | |
1304 | onoff = 0; | |
1305 | ||
fa2d8bbb | 1306 | mutex_lock(&qt_port->lock); |
d75662e1 | 1307 | |
d75662e1 BP |
1308 | result = |
1309 | usb_control_msg(serial->dev, usb_sndctrlpipe(serial->dev, 0), | |
1310 | QT_BREAK_CONTROL, 0x40, onoff, index, NULL, 0, 300); | |
1311 | ||
fa2d8bbb | 1312 | mutex_unlock(&qt_port->lock); |
d75662e1 BP |
1313 | } |
1314 | ||
1315 | static inline int qt_real_tiocmget(struct tty_struct *tty, | |
1316 | struct usb_serial_port *port, | |
60b33c13 | 1317 | struct usb_serial *serial) |
d75662e1 BP |
1318 | { |
1319 | ||
1320 | u8 mcr; | |
1321 | u8 msr; | |
1322 | unsigned int result = 0; | |
1323 | int status; | |
1324 | unsigned int index; | |
1325 | ||
e5b1e206 | 1326 | index = port->port_number; |
d75662e1 | 1327 | status = |
d68edc28 | 1328 | box_get_register(port->serial, index, MODEM_CONTROL_REGISTER, &mcr); |
d75662e1 BP |
1329 | if (status >= 0) { |
1330 | status = | |
d68edc28 | 1331 | box_get_register(port->serial, index, |
d75662e1 BP |
1332 | MODEM_STATUS_REGISTER, &msr); |
1333 | ||
1334 | } | |
1335 | ||
1336 | if (status >= 0) { | |
1337 | result = ((mcr & SERIAL_MCR_DTR) ? TIOCM_DTR : 0) | |
1338 | /* DTR IS SET */ | |
1339 | | ((mcr & SERIAL_MCR_RTS) ? TIOCM_RTS : 0) | |
1340 | /* RTS IS SET */ | |
1341 | | ((msr & SERIAL_MSR_CTS) ? TIOCM_CTS : 0) | |
1342 | /* CTS is set */ | |
1343 | | ((msr & SERIAL_MSR_CD) ? TIOCM_CAR : 0) | |
1344 | /* Carrier detect is set */ | |
1345 | | ((msr & SERIAL_MSR_RI) ? TIOCM_RI : 0) | |
1346 | /* Ring indicator set */ | |
1347 | | ((msr & SERIAL_MSR_DSR) ? TIOCM_DSR : 0); | |
1348 | /* DSR is set */ | |
1349 | return result; | |
1350 | ||
1351 | } else | |
1352 | return -ESPIPE; | |
1353 | } | |
1354 | ||
1355 | static inline int qt_real_tiocmset(struct tty_struct *tty, | |
1356 | struct usb_serial_port *port, | |
d75662e1 BP |
1357 | struct usb_serial *serial, |
1358 | unsigned int value) | |
1359 | { | |
1360 | ||
1361 | u8 mcr; | |
1362 | int status; | |
1363 | unsigned int index; | |
1364 | ||
e5b1e206 | 1365 | index = port->port_number; |
d75662e1 | 1366 | status = |
d68edc28 | 1367 | box_get_register(port->serial, index, MODEM_CONTROL_REGISTER, &mcr); |
d75662e1 BP |
1368 | if (status < 0) |
1369 | return -ESPIPE; | |
1370 | ||
1371 | /* | |
1351acce | 1372 | * Turn off the RTS and DTR and loopback and then only turn on what was |
d75662e1 BP |
1373 | * asked for |
1374 | */ | |
1375 | mcr &= ~(SERIAL_MCR_RTS | SERIAL_MCR_DTR | SERIAL_MCR_LOOP); | |
1376 | if (value & TIOCM_RTS) | |
1377 | mcr |= SERIAL_MCR_RTS; | |
1378 | if (value & TIOCM_DTR) | |
1379 | mcr |= SERIAL_MCR_DTR; | |
1380 | if (value & TIOCM_LOOP) | |
1381 | mcr |= SERIAL_MCR_LOOP; | |
1382 | ||
1383 | status = | |
d68edc28 | 1384 | box_set_register(port->serial, index, MODEM_CONTROL_REGISTER, mcr); |
d75662e1 BP |
1385 | if (status < 0) |
1386 | return -ESPIPE; | |
1387 | else | |
1388 | return 0; | |
1389 | } | |
1390 | ||
60b33c13 | 1391 | static int qt_tiocmget(struct tty_struct *tty) |
d75662e1 BP |
1392 | { |
1393 | struct usb_serial_port *port = tty->driver_data; | |
1394 | struct usb_serial *serial = get_usb_serial(port, __func__); | |
1395 | struct quatech_port *qt_port = qt_get_port_private(port); | |
7b11eb3e | 1396 | int retval; |
d75662e1 | 1397 | |
d75662e1 BP |
1398 | if (!serial) |
1399 | return -ENODEV; | |
1400 | ||
fa2d8bbb | 1401 | mutex_lock(&qt_port->lock); |
60b33c13 | 1402 | retval = qt_real_tiocmget(tty, port, serial); |
fa2d8bbb | 1403 | mutex_unlock(&qt_port->lock); |
d75662e1 BP |
1404 | return retval; |
1405 | } | |
1406 | ||
20b9d177 | 1407 | static int qt_tiocmset(struct tty_struct *tty, |
d75662e1 BP |
1408 | unsigned int set, unsigned int clear) |
1409 | { | |
1410 | ||
1411 | struct usb_serial_port *port = tty->driver_data; | |
1412 | struct usb_serial *serial = get_usb_serial(port, __func__); | |
1413 | struct quatech_port *qt_port = qt_get_port_private(port); | |
7b11eb3e | 1414 | int retval; |
d75662e1 | 1415 | |
d75662e1 BP |
1416 | if (!serial) |
1417 | return -ENODEV; | |
1418 | ||
fa2d8bbb | 1419 | mutex_lock(&qt_port->lock); |
20b9d177 | 1420 | retval = qt_real_tiocmset(tty, port, serial, set); |
fa2d8bbb | 1421 | mutex_unlock(&qt_port->lock); |
d75662e1 BP |
1422 | return retval; |
1423 | } | |
1424 | ||
1425 | static void qt_throttle(struct tty_struct *tty) | |
1426 | { | |
1427 | struct usb_serial_port *port = tty->driver_data; | |
1428 | struct usb_serial *serial = get_usb_serial(port, __func__); | |
1429 | struct quatech_port *qt_port; | |
d75662e1 | 1430 | |
d75662e1 BP |
1431 | if (!serial) |
1432 | return; | |
1433 | ||
1434 | qt_port = qt_get_port_private(port); | |
1435 | ||
fa2d8bbb | 1436 | mutex_lock(&qt_port->lock); |
d75662e1 BP |
1437 | |
1438 | /* pass on to the driver specific version of this function */ | |
d68edc28 | 1439 | qt_port->rx_holding = 1; |
d75662e1 | 1440 | |
fa2d8bbb | 1441 | mutex_unlock(&qt_port->lock); |
d75662e1 BP |
1442 | } |
1443 | ||
7028035d YT |
1444 | static void qt_submit_urb_from_unthrottle(struct usb_serial_port *port, |
1445 | struct usb_serial *serial) | |
1446 | { | |
1447 | int result; | |
1448 | ||
1449 | /* Start reading from the device */ | |
1450 | usb_fill_bulk_urb(port->read_urb, serial->dev, | |
1451 | usb_rcvbulkpipe(serial->dev, | |
1452 | port->bulk_in_endpointAddress), | |
1453 | port->read_urb->transfer_buffer, | |
1454 | port->read_urb->transfer_buffer_length, | |
1455 | qt_read_bulk_callback, port); | |
1456 | ||
1457 | result = usb_submit_urb(port->read_urb, GFP_ATOMIC); | |
1458 | ||
1459 | if (result) | |
1460 | dev_err(&port->dev, | |
1461 | "%s - failed restarting read urb, error %d\n", | |
1462 | __func__, result); | |
1463 | } | |
1464 | ||
d75662e1 BP |
1465 | static void qt_unthrottle(struct tty_struct *tty) |
1466 | { | |
1467 | struct usb_serial_port *port = tty->driver_data; | |
1468 | struct usb_serial *serial = get_usb_serial(port, __func__); | |
1469 | struct quatech_port *qt_port; | |
d75662e1 BP |
1470 | |
1471 | if (!serial) | |
1472 | return; | |
1473 | ||
1474 | qt_port = qt_get_port_private(port); | |
1475 | ||
fa2d8bbb | 1476 | mutex_lock(&qt_port->lock); |
d75662e1 | 1477 | |
d68edc28 BB |
1478 | if (qt_port->rx_holding == 1) { |
1479 | dev_dbg(&port->dev, "%s -qt_port->rx_holding == 1\n", __func__); | |
d75662e1 | 1480 | |
d68edc28 BB |
1481 | qt_port->rx_holding = 0; |
1482 | dev_dbg(&port->dev, "%s - qt_port->rx_holding = 0\n", __func__); | |
d75662e1 BP |
1483 | |
1484 | /* if we have a bulk endpoint, start it up */ | |
d68edc28 | 1485 | if ((serial->num_bulk_in) && (qt_port->read_bulk_stopped == 1)) |
7028035d | 1486 | qt_submit_urb_from_unthrottle(port, serial); |
d75662e1 | 1487 | } |
fa2d8bbb | 1488 | mutex_unlock(&qt_port->lock); |
d75662e1 BP |
1489 | } |
1490 | ||
1491 | static int qt_calc_num_ports(struct usb_serial *serial) | |
1492 | { | |
1493 | int num_ports; | |
1494 | ||
d75662e1 BP |
1495 | num_ports = |
1496 | (serial->interface->cur_altsetting->desc.bNumEndpoints - 1) / 2; | |
1497 | ||
1498 | return num_ports; | |
1499 | } | |
1500 | ||
1501 | static struct usb_serial_driver quatech_device = { | |
1502 | .driver = { | |
1503 | .owner = THIS_MODULE, | |
1504 | .name = "serqt", | |
1505 | }, | |
1506 | .description = DRIVER_DESC, | |
68e24113 | 1507 | .id_table = id_table, |
d75662e1 BP |
1508 | .num_ports = 8, |
1509 | .open = qt_open, | |
1510 | .close = qt_close, | |
1511 | .write = qt_write, | |
1512 | .write_room = qt_write_room, | |
1513 | .chars_in_buffer = qt_chars_in_buffer, | |
1514 | .throttle = qt_throttle, | |
1515 | .unthrottle = qt_unthrottle, | |
1516 | .calc_num_ports = qt_calc_num_ports, | |
1517 | .ioctl = qt_ioctl, | |
1518 | .set_termios = qt_set_termios, | |
1519 | .break_ctl = qt_break, | |
1520 | .tiocmget = qt_tiocmget, | |
1521 | .tiocmset = qt_tiocmset, | |
1522 | .attach = qt_startup, | |
1523 | .release = qt_release, | |
1524 | }; | |
1525 | ||
69276a33 AS |
1526 | static struct usb_serial_driver * const serial_drivers[] = { |
1527 | &quatech_device, NULL | |
1528 | }; | |
1529 | ||
68e24113 | 1530 | module_usb_serial_driver(serial_drivers, id_table); |
d75662e1 BP |
1531 | |
1532 | MODULE_AUTHOR(DRIVER_AUTHOR); | |
1533 | MODULE_DESCRIPTION(DRIVER_DESC); | |
1534 | MODULE_LICENSE("GPL"); |