aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/usb/serial/sierra.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/usb/serial/sierra.c')
-rw-r--r--drivers/usb/serial/sierra.c700
1 files changed, 669 insertions, 31 deletions
diff --git a/drivers/usb/serial/sierra.c b/drivers/usb/serial/sierra.c
index d29638daa987..4b5097fa48d7 100644
--- a/drivers/usb/serial/sierra.c
+++ b/drivers/usb/serial/sierra.c
@@ -1,75 +1,713 @@
1/* 1/*
2 * Sierra Wireless CDMA Wireless Serial USB driver 2 USB Driver for Sierra Wireless
3 * 3
4 * Current Copy modified by: Kevin Lloyd <linux@sierrawireless.com> 4 Copyright (C) 2006 Kevin Lloyd <linux@sierrawireless.com>
5 * Original Copyright (C) 2005-2006 Greg Kroah-Hartman <gregkh@suse.de> 5
6 * 6 IMPORTANT DISCLAIMER: This driver is not commercially supported by
7 * This program is free software; you can redistribute it and/or 7 Sierra Wireless. Use at your own risk.
8 * modify it under the terms of the GNU General Public License version 8
9 * 2 as published by the Free Software Foundation. 9 This driver is free software; you can redistribute it and/or modify
10 */ 10 it under the terms of Version 2 of the GNU General Public License as
11 published by the Free Software Foundation.
12
13 Portions based on the option driver by Matthias Urlichs <smurf@smurf.noris.de>
14 Whom based his on the Keyspan driver by Hugh Blemings <hugh@blemings.org>
15
16 History:
17*/
18
19#define DRIVER_VERSION "v.1.0.5"
20#define DRIVER_AUTHOR "Kevin Lloyd <linux@sierrawireless.com>"
21#define DRIVER_DESC "USB Driver for Sierra Wireless USB modems"
11 22
12#include <linux/kernel.h> 23#include <linux/kernel.h>
13#include <linux/init.h> 24#include <linux/jiffies.h>
25#include <linux/errno.h>
14#include <linux/tty.h> 26#include <linux/tty.h>
27#include <linux/tty_flip.h>
15#include <linux/module.h> 28#include <linux/module.h>
16#include <linux/usb.h> 29#include <linux/usb.h>
17#include <linux/usb/serial.h> 30#include <linux/usb/serial.h>
18 31
32
19static struct usb_device_id id_table [] = { 33static struct usb_device_id id_table [] = {
20 { USB_DEVICE(0x1199, 0x0018) }, /* Sierra Wireless MC5720 */ 34 { USB_DEVICE(0x1199, 0x0018) }, /* Sierra Wireless MC5720 */
21 { USB_DEVICE(0x1199, 0x0020) }, /* Sierra Wireless MC5725 */ 35 { USB_DEVICE(0x1199, 0x0020) }, /* Sierra Wireless MC5725 */
22 { USB_DEVICE(0x1199, 0x0017) }, /* Sierra Wireless EM5625 */ 36 { USB_DEVICE(0x1199, 0x0017) }, /* Sierra Wireless EM5625 */
23 { USB_DEVICE(0x1199, 0x0019) }, /* Sierra Wireless AirCard 595 */ 37 { USB_DEVICE(0x1199, 0x0019) }, /* Sierra Wireless AirCard 595 */
38 { USB_DEVICE(0x1199, 0x0218) }, /* Sierra Wireless MC5720 */
24 { USB_DEVICE(0x1199, 0x6802) }, /* Sierra Wireless MC8755 */ 39 { USB_DEVICE(0x1199, 0x6802) }, /* Sierra Wireless MC8755 */
25 { USB_DEVICE(0x1199, 0x6803) }, /* Sierra Wireless MC8765 */ 40 { USB_DEVICE(0x1199, 0x6803) }, /* Sierra Wireless MC8765 */
41 { USB_DEVICE(0x1199, 0x6804) }, /* Sierra Wireless MC8755 for Europe */
26 { USB_DEVICE(0x1199, 0x6812) }, /* Sierra Wireless MC8775 */ 42 { USB_DEVICE(0x1199, 0x6812) }, /* Sierra Wireless MC8775 */
27 { USB_DEVICE(0x1199, 0x6820) }, /* Sierra Wireless AirCard 875 */ 43 { USB_DEVICE(0x1199, 0x6820) }, /* Sierra Wireless AirCard 875 */
28 /* Following devices are supported in the airprime.c driver */ 44
29 /* { USB_DEVICE(0x1199, 0x0112) }, */ /* Sierra Wireless AirCard 580 */ 45 { USB_DEVICE(0x1199, 0x0112) }, /* Sierra Wireless AirCard 580 */
30 /* { USB_DEVICE(0x0F3D, 0x0112) }, */ /* AirPrime/Sierra PC 5220 */ 46 { USB_DEVICE(0x0F3D, 0x0112) }, /* AirPrime/Sierra PC 5220 */
31 { } 47 { }
32}; 48};
33MODULE_DEVICE_TABLE(usb, id_table); 49MODULE_DEVICE_TABLE(usb, id_table);
34 50
51static struct usb_device_id id_table_1port [] = {
52 { USB_DEVICE(0x1199, 0x0112) }, /* Sierra Wireless AirCard 580 */
53 { USB_DEVICE(0x0F3D, 0x0112) }, /* AirPrime/Sierra PC 5220 */
54 { }
55};
56
57static struct usb_device_id id_table_3port [] = {
58 { USB_DEVICE(0x1199, 0x0018) }, /* Sierra Wireless MC5720 */
59 { USB_DEVICE(0x1199, 0x0020) }, /* Sierra Wireless MC5725 */
60 { USB_DEVICE(0x1199, 0x0017) }, /* Sierra Wireless EM5625 */
61 { USB_DEVICE(0x1199, 0x0019) }, /* Sierra Wireless AirCard 595 */
62 { USB_DEVICE(0x1199, 0x0218) }, /* Sierra Wireless MC5720 */
63 { USB_DEVICE(0x1199, 0x6802) }, /* Sierra Wireless MC8755 */
64 { USB_DEVICE(0x1199, 0x6803) }, /* Sierra Wireless MC8765 */
65 { USB_DEVICE(0x1199, 0x6804) }, /* Sierra Wireless MC8755 for Europe */
66 { USB_DEVICE(0x1199, 0x6812) }, /* Sierra Wireless MC8775 */
67 { USB_DEVICE(0x1199, 0x6820) }, /* Sierra Wireless AirCard 875 */
68 { }
69};
70
35static struct usb_driver sierra_driver = { 71static struct usb_driver sierra_driver = {
36 .name = "sierra_wireless", 72 .name = "sierra",
37 .probe = usb_serial_probe, 73 .probe = usb_serial_probe,
38 .disconnect = usb_serial_disconnect, 74 .disconnect = usb_serial_disconnect,
39 .id_table = id_table, 75 .id_table = id_table,
76 .no_dynamic_id = 1,
77};
78
79
80static int debug;
81
82/* per port private data */
83#define N_IN_URB 4
84#define N_OUT_URB 1
85#define IN_BUFLEN 4096
86#define OUT_BUFLEN 128
87
88struct sierra_port_private {
89 /* Input endpoints and buffer for this port */
90 struct urb *in_urbs[N_IN_URB];
91 char in_buffer[N_IN_URB][IN_BUFLEN];
92 /* Output endpoints and buffer for this port */
93 struct urb *out_urbs[N_OUT_URB];
94 char out_buffer[N_OUT_URB][OUT_BUFLEN];
95
96 /* Settings for the port */
97 int rts_state; /* Handshaking pins (outputs) */
98 int dtr_state;
99 int cts_state; /* Handshaking pins (inputs) */
100 int dsr_state;
101 int dcd_state;
102 int ri_state;
103
104 unsigned long tx_start_time[N_OUT_URB];
105};
106
107static int sierra_send_setup(struct usb_serial_port *port)
108{
109 struct usb_serial *serial = port->serial;
110 struct sierra_port_private *portdata;
111
112 dbg("%s", __FUNCTION__);
113
114 portdata = usb_get_serial_port_data(port);
115
116 if (port->tty) {
117 int val = 0;
118 if (portdata->dtr_state)
119 val |= 0x01;
120 if (portdata->rts_state)
121 val |= 0x02;
122
123 return usb_control_msg(serial->dev,
124 usb_rcvctrlpipe(serial->dev, 0),
125 0x22,0x21,val,0,NULL,0,USB_CTRL_SET_TIMEOUT);
126 }
127
128 return 0;
129}
130
131static void sierra_rx_throttle(struct usb_serial_port *port)
132{
133 dbg("%s", __FUNCTION__);
134}
135
136static void sierra_rx_unthrottle(struct usb_serial_port *port)
137{
138 dbg("%s", __FUNCTION__);
139}
140
141static void sierra_break_ctl(struct usb_serial_port *port, int break_state)
142{
143 /* Unfortunately, I don't know how to send a break */
144 dbg("%s", __FUNCTION__);
145}
146
147static void sierra_set_termios(struct usb_serial_port *port,
148 struct termios *old_termios)
149{
150 dbg("%s", __FUNCTION__);
151
152 sierra_send_setup(port);
153}
154
155static int sierra_tiocmget(struct usb_serial_port *port, struct file *file)
156{
157 unsigned int value;
158 struct sierra_port_private *portdata;
159
160 portdata = usb_get_serial_port_data(port);
161
162 value = ((portdata->rts_state) ? TIOCM_RTS : 0) |
163 ((portdata->dtr_state) ? TIOCM_DTR : 0) |
164 ((portdata->cts_state) ? TIOCM_CTS : 0) |
165 ((portdata->dsr_state) ? TIOCM_DSR : 0) |
166 ((portdata->dcd_state) ? TIOCM_CAR : 0) |
167 ((portdata->ri_state) ? TIOCM_RNG : 0);
168
169 return value;
170}
171
172static int sierra_tiocmset(struct usb_serial_port *port, struct file *file,
173 unsigned int set, unsigned int clear)
174{
175 struct sierra_port_private *portdata;
176
177 portdata = usb_get_serial_port_data(port);
178
179 if (set & TIOCM_RTS)
180 portdata->rts_state = 1;
181 if (set & TIOCM_DTR)
182 portdata->dtr_state = 1;
183
184 if (clear & TIOCM_RTS)
185 portdata->rts_state = 0;
186 if (clear & TIOCM_DTR)
187 portdata->dtr_state = 0;
188 return sierra_send_setup(port);
189}
190
191static int sierra_ioctl(struct usb_serial_port *port, struct file *file,
192 unsigned int cmd, unsigned long arg)
193{
194 return -ENOIOCTLCMD;
195}
196
197/* Write */
198static int sierra_write(struct usb_serial_port *port,
199 const unsigned char *buf, int count)
200{
201 struct sierra_port_private *portdata;
202 int i;
203 int left, todo;
204 struct urb *this_urb = NULL; /* spurious */
205 int err;
206
207 portdata = usb_get_serial_port_data(port);
208
209 dbg("%s: write (%d chars)", __FUNCTION__, count);
210
211 i = 0;
212 left = count;
213 for (i=0; left > 0 && i < N_OUT_URB; i++) {
214 todo = left;
215 if (todo > OUT_BUFLEN)
216 todo = OUT_BUFLEN;
217
218 this_urb = portdata->out_urbs[i];
219 if (this_urb->status == -EINPROGRESS) {
220 if (time_before(jiffies,
221 portdata->tx_start_time[i] + 10 * HZ))
222 continue;
223 usb_unlink_urb(this_urb);
224 continue;
225 }
226 if (this_urb->status != 0)
227 dbg("usb_write %p failed (err=%d)",
228 this_urb, this_urb->status);
229
230 dbg("%s: endpoint %d buf %d", __FUNCTION__,
231 usb_pipeendpoint(this_urb->pipe), i);
232
233 /* send the data */
234 memcpy (this_urb->transfer_buffer, buf, todo);
235 this_urb->transfer_buffer_length = todo;
236
237 this_urb->dev = port->serial->dev;
238 err = usb_submit_urb(this_urb, GFP_ATOMIC);
239 if (err) {
240 dbg("usb_submit_urb %p (write bulk) failed "
241 "(%d, has %d)", this_urb,
242 err, this_urb->status);
243 continue;
244 }
245 portdata->tx_start_time[i] = jiffies;
246 buf += todo;
247 left -= todo;
248 }
249
250 count -= left;
251 dbg("%s: wrote (did %d)", __FUNCTION__, count);
252 return count;
253}
254
255static void sierra_indat_callback(struct urb *urb)
256{
257 int err;
258 int endpoint;
259 struct usb_serial_port *port;
260 struct tty_struct *tty;
261 unsigned char *data = urb->transfer_buffer;
262
263 dbg("%s: %p", __FUNCTION__, urb);
264
265 endpoint = usb_pipeendpoint(urb->pipe);
266 port = (struct usb_serial_port *) urb->context;
267
268 if (urb->status) {
269 dbg("%s: nonzero status: %d on endpoint %02x.",
270 __FUNCTION__, urb->status, endpoint);
271 } else {
272 tty = port->tty;
273 if (urb->actual_length) {
274 tty_buffer_request_room(tty, urb->actual_length);
275 tty_insert_flip_string(tty, data, urb->actual_length);
276 tty_flip_buffer_push(tty);
277 } else {
278 dbg("%s: empty read urb received", __FUNCTION__);
279 }
280
281 /* Resubmit urb so we continue receiving */
282 if (port->open_count && urb->status != -ESHUTDOWN) {
283 err = usb_submit_urb(urb, GFP_ATOMIC);
284 if (err)
285 printk(KERN_ERR "%s: resubmit read urb failed. "
286 "(%d)", __FUNCTION__, err);
287 }
288 }
289 return;
290}
291
292static void sierra_outdat_callback(struct urb *urb)
293{
294 struct usb_serial_port *port;
295
296 dbg("%s", __FUNCTION__);
297
298 port = (struct usb_serial_port *) urb->context;
299
300 usb_serial_port_softint(port);
301}
302
303static void sierra_instat_callback(struct urb *urb)
304{
305 int err;
306 struct usb_serial_port *port = (struct usb_serial_port *) urb->context;
307 struct sierra_port_private *portdata = usb_get_serial_port_data(port);
308 struct usb_serial *serial = port->serial;
309
310 dbg("%s", __FUNCTION__);
311 dbg("%s: urb %p port %p has data %p", __FUNCTION__,urb,port,portdata);
312
313 if (urb->status == 0) {
314 struct usb_ctrlrequest *req_pkt =
315 (struct usb_ctrlrequest *)urb->transfer_buffer;
316
317 if (!req_pkt) {
318 dbg("%s: NULL req_pkt\n", __FUNCTION__);
319 return;
320 }
321 if ((req_pkt->bRequestType == 0xA1) &&
322 (req_pkt->bRequest == 0x20)) {
323 int old_dcd_state;
324 unsigned char signals = *((unsigned char *)
325 urb->transfer_buffer +
326 sizeof(struct usb_ctrlrequest));
327
328 dbg("%s: signal x%x", __FUNCTION__, signals);
329
330 old_dcd_state = portdata->dcd_state;
331 portdata->cts_state = 1;
332 portdata->dcd_state = ((signals & 0x01) ? 1 : 0);
333 portdata->dsr_state = ((signals & 0x02) ? 1 : 0);
334 portdata->ri_state = ((signals & 0x08) ? 1 : 0);
335
336 if (port->tty && !C_CLOCAL(port->tty) &&
337 old_dcd_state && !portdata->dcd_state)
338 tty_hangup(port->tty);
339 } else {
340 dbg("%s: type %x req %x", __FUNCTION__,
341 req_pkt->bRequestType,req_pkt->bRequest);
342 }
343 } else
344 dbg("%s: error %d", __FUNCTION__, urb->status);
345
346 /* Resubmit urb so we continue receiving IRQ data */
347 if (urb->status != -ESHUTDOWN) {
348 urb->dev = serial->dev;
349 err = usb_submit_urb(urb, GFP_ATOMIC);
350 if (err)
351 dbg("%s: resubmit intr urb failed. (%d)",
352 __FUNCTION__, err);
353 }
354}
355
356static int sierra_write_room(struct usb_serial_port *port)
357{
358 struct sierra_port_private *portdata;
359 int i;
360 int data_len = 0;
361 struct urb *this_urb;
362
363 portdata = usb_get_serial_port_data(port);
364
365 for (i=0; i < N_OUT_URB; i++) {
366 this_urb = portdata->out_urbs[i];
367 if (this_urb && this_urb->status != -EINPROGRESS)
368 data_len += OUT_BUFLEN;
369 }
370
371 dbg("%s: %d", __FUNCTION__, data_len);
372 return data_len;
373}
374
375static int sierra_chars_in_buffer(struct usb_serial_port *port)
376{
377 struct sierra_port_private *portdata;
378 int i;
379 int data_len = 0;
380 struct urb *this_urb;
381
382 portdata = usb_get_serial_port_data(port);
383
384 for (i=0; i < N_OUT_URB; i++) {
385 this_urb = portdata->out_urbs[i];
386 if (this_urb && this_urb->status == -EINPROGRESS)
387 data_len += this_urb->transfer_buffer_length;
388 }
389 dbg("%s: %d", __FUNCTION__, data_len);
390 return data_len;
391}
392
393static int sierra_open(struct usb_serial_port *port, struct file *filp)
394{
395 struct sierra_port_private *portdata;
396 struct usb_serial *serial = port->serial;
397 int i, err;
398 struct urb *urb;
399
400 portdata = usb_get_serial_port_data(port);
401
402 dbg("%s", __FUNCTION__);
403
404 /* Set some sane defaults */
405 portdata->rts_state = 1;
406 portdata->dtr_state = 1;
407
408 /* Reset low level data toggle and start reading from endpoints */
409 for (i = 0; i < N_IN_URB; i++) {
410 urb = portdata->in_urbs[i];
411 if (! urb)
412 continue;
413 if (urb->dev != serial->dev) {
414 dbg("%s: dev %p != %p", __FUNCTION__,
415 urb->dev, serial->dev);
416 continue;
417 }
418
419 /*
420 * make sure endpoint data toggle is synchronized with the
421 * device
422 */
423 usb_clear_halt(urb->dev, urb->pipe);
424
425 err = usb_submit_urb(urb, GFP_KERNEL);
426 if (err) {
427 dbg("%s: submit urb %d failed (%d) %d",
428 __FUNCTION__, i, err,
429 urb->transfer_buffer_length);
430 }
431 }
432
433 /* Reset low level data toggle on out endpoints */
434 for (i = 0; i < N_OUT_URB; i++) {
435 urb = portdata->out_urbs[i];
436 if (! urb)
437 continue;
438 urb->dev = serial->dev;
439 /* usb_settoggle(urb->dev, usb_pipeendpoint(urb->pipe),
440 usb_pipeout(urb->pipe), 0); */
441 }
442
443 port->tty->low_latency = 1;
444
445 sierra_send_setup(port);
446
447 return (0);
448}
449
450static inline void stop_urb(struct urb *urb)
451{
452 if (urb && urb->status == -EINPROGRESS)
453 usb_kill_urb(urb);
454}
455
456static void sierra_close(struct usb_serial_port *port, struct file *filp)
457{
458 int i;
459 struct usb_serial *serial = port->serial;
460 struct sierra_port_private *portdata;
461
462 dbg("%s", __FUNCTION__);
463 portdata = usb_get_serial_port_data(port);
464
465 portdata->rts_state = 0;
466 portdata->dtr_state = 0;
467
468 if (serial->dev) {
469 sierra_send_setup(port);
470
471 /* Stop reading/writing urbs */
472 for (i = 0; i < N_IN_URB; i++)
473 stop_urb(portdata->in_urbs[i]);
474 for (i = 0; i < N_OUT_URB; i++)
475 stop_urb(portdata->out_urbs[i]);
476 }
477 port->tty = NULL;
478}
479
480/* Helper functions used by sierra_setup_urbs */
481static struct urb *sierra_setup_urb(struct usb_serial *serial, int endpoint,
482 int dir, void *ctx, char *buf, int len,
483 usb_complete_t callback)
484{
485 struct urb *urb;
486
487 if (endpoint == -1)
488 return NULL; /* endpoint not needed */
489
490 urb = usb_alloc_urb(0, GFP_KERNEL); /* No ISO */
491 if (urb == NULL) {
492 dbg("%s: alloc for endpoint %d failed.", __FUNCTION__, endpoint);
493 return NULL;
494 }
495
496 /* Fill URB using supplied data. */
497 usb_fill_bulk_urb(urb, serial->dev,
498 usb_sndbulkpipe(serial->dev, endpoint) | dir,
499 buf, len, callback, ctx);
500
501 return urb;
502}
503
504/* Setup urbs */
505static void sierra_setup_urbs(struct usb_serial *serial)
506{
507 int i,j;
508 struct usb_serial_port *port;
509 struct sierra_port_private *portdata;
510
511 dbg("%s", __FUNCTION__);
512
513 for (i = 0; i < serial->num_ports; i++) {
514 port = serial->port[i];
515 portdata = usb_get_serial_port_data(port);
516
517 /* Do indat endpoints first */
518 for (j = 0; j < N_IN_URB; ++j) {
519 portdata->in_urbs[j] = sierra_setup_urb (serial,
520 port->bulk_in_endpointAddress, USB_DIR_IN, port,
521 portdata->in_buffer[j], IN_BUFLEN, sierra_indat_callback);
522 }
523
524 /* outdat endpoints */
525 for (j = 0; j < N_OUT_URB; ++j) {
526 portdata->out_urbs[j] = sierra_setup_urb (serial,
527 port->bulk_out_endpointAddress, USB_DIR_OUT, port,
528 portdata->out_buffer[j], OUT_BUFLEN, sierra_outdat_callback);
529 }
530 }
531}
532
533static int sierra_startup(struct usb_serial *serial)
534{
535 int i, err;
536 struct usb_serial_port *port;
537 struct sierra_port_private *portdata;
538
539 dbg("%s", __FUNCTION__);
540
541 /* Now setup per port private data */
542 for (i = 0; i < serial->num_ports; i++) {
543 port = serial->port[i];
544 portdata = kzalloc(sizeof(*portdata), GFP_KERNEL);
545 if (!portdata) {
546 dbg("%s: kmalloc for sierra_port_private (%d) failed!.",
547 __FUNCTION__, i);
548 return (1);
549 }
550
551 usb_set_serial_port_data(port, portdata);
552
553 if (! port->interrupt_in_urb)
554 continue;
555 err = usb_submit_urb(port->interrupt_in_urb, GFP_KERNEL);
556 if (err)
557 dbg("%s: submit irq_in urb failed %d",
558 __FUNCTION__, err);
559 }
560
561 sierra_setup_urbs(serial);
562
563 return (0);
564}
565
566static void sierra_shutdown(struct usb_serial *serial)
567{
568 int i, j;
569 struct usb_serial_port *port;
570 struct sierra_port_private *portdata;
571
572 dbg("%s", __FUNCTION__);
573
574 /* Stop reading/writing urbs */
575 for (i = 0; i < serial->num_ports; ++i) {
576 port = serial->port[i];
577 portdata = usb_get_serial_port_data(port);
578 for (j = 0; j < N_IN_URB; j++)
579 stop_urb(portdata->in_urbs[j]);
580 for (j = 0; j < N_OUT_URB; j++)
581 stop_urb(portdata->out_urbs[j]);
582 }
583
584 /* Now free them */
585 for (i = 0; i < serial->num_ports; ++i) {
586 port = serial->port[i];
587 portdata = usb_get_serial_port_data(port);
588
589 for (j = 0; j < N_IN_URB; j++) {
590 if (portdata->in_urbs[j]) {
591 usb_free_urb(portdata->in_urbs[j]);
592 portdata->in_urbs[j] = NULL;
593 }
594 }
595 for (j = 0; j < N_OUT_URB; j++) {
596 if (portdata->out_urbs[j]) {
597 usb_free_urb(portdata->out_urbs[j]);
598 portdata->out_urbs[j] = NULL;
599 }
600 }
601 }
602
603 /* Now free per port private data */
604 for (i = 0; i < serial->num_ports; i++) {
605 port = serial->port[i];
606 kfree(usb_get_serial_port_data(port));
607 }
608}
609
610static struct usb_serial_driver sierra_1port_device = {
611 .driver = {
612 .owner = THIS_MODULE,
613 .name = "sierra1",
614 },
615 .description = "Sierra USB modem (1 port)",
616 .id_table = id_table_1port,
617 .num_interrupt_in = NUM_DONT_CARE,
618 .num_bulk_in = 1,
619 .num_bulk_out = 1,
620 .num_ports = 1,
621 .open = sierra_open,
622 .close = sierra_close,
623 .write = sierra_write,
624 .write_room = sierra_write_room,
625 .chars_in_buffer = sierra_chars_in_buffer,
626 .throttle = sierra_rx_throttle,
627 .unthrottle = sierra_rx_unthrottle,
628 .ioctl = sierra_ioctl,
629 .set_termios = sierra_set_termios,
630 .break_ctl = sierra_break_ctl,
631 .tiocmget = sierra_tiocmget,
632 .tiocmset = sierra_tiocmset,
633 .attach = sierra_startup,
634 .shutdown = sierra_shutdown,
635 .read_int_callback = sierra_instat_callback,
40}; 636};
41 637
42static struct usb_serial_driver sierra_device = { 638static struct usb_serial_driver sierra_3port_device = {
43 .driver = { 639 .driver = {
44 .owner = THIS_MODULE, 640 .owner = THIS_MODULE,
45 .name = "Sierra_Wireless", 641 .name = "sierra3",
46 }, 642 },
47 .id_table = id_table, 643 .description = "Sierra USB modem (3 port)",
48 .num_interrupt_in = NUM_DONT_CARE, 644 .id_table = id_table_3port,
49 .num_bulk_in = NUM_DONT_CARE, 645 .num_interrupt_in = NUM_DONT_CARE,
50 .num_bulk_out = NUM_DONT_CARE, 646 .num_bulk_in = 3,
51 .num_ports = 3, 647 .num_bulk_out = 3,
648 .num_ports = 3,
649 .open = sierra_open,
650 .close = sierra_close,
651 .write = sierra_write,
652 .write_room = sierra_write_room,
653 .chars_in_buffer = sierra_chars_in_buffer,
654 .throttle = sierra_rx_throttle,
655 .unthrottle = sierra_rx_unthrottle,
656 .ioctl = sierra_ioctl,
657 .set_termios = sierra_set_termios,
658 .break_ctl = sierra_break_ctl,
659 .tiocmget = sierra_tiocmget,
660 .tiocmset = sierra_tiocmset,
661 .attach = sierra_startup,
662 .shutdown = sierra_shutdown,
663 .read_int_callback = sierra_instat_callback,
52}; 664};
53 665
666/* Functions used by new usb-serial code. */
54static int __init sierra_init(void) 667static int __init sierra_init(void)
55{ 668{
56 int retval; 669 int retval;
57 670 retval = usb_serial_register(&sierra_1port_device);
58 retval = usb_serial_register(&sierra_device); 671 if (retval)
672 goto failed_1port_device_register;
673 retval = usb_serial_register(&sierra_3port_device);
59 if (retval) 674 if (retval)
60 return retval; 675 goto failed_3port_device_register;
676
677
61 retval = usb_register(&sierra_driver); 678 retval = usb_register(&sierra_driver);
62 if (retval) 679 if (retval)
63 usb_serial_deregister(&sierra_device); 680 goto failed_driver_register;
681
682 info(DRIVER_DESC ": " DRIVER_VERSION);
683
684 return 0;
685
686failed_driver_register:
687 usb_serial_deregister(&sierra_3port_device);
688failed_3port_device_register:
689 usb_serial_deregister(&sierra_1port_device);
690failed_1port_device_register:
64 return retval; 691 return retval;
65} 692}
66 693
67static void __exit sierra_exit(void) 694static void __exit sierra_exit(void)
68{ 695{
69 usb_deregister(&sierra_driver); 696 usb_deregister (&sierra_driver);
70 usb_serial_deregister(&sierra_device); 697 usb_serial_deregister(&sierra_1port_device);
698 usb_serial_deregister(&sierra_3port_device);
71} 699}
72 700
73module_init(sierra_init); 701module_init(sierra_init);
74module_exit(sierra_exit); 702module_exit(sierra_exit);
703
704MODULE_AUTHOR(DRIVER_AUTHOR);
705MODULE_DESCRIPTION(DRIVER_DESC);
706MODULE_VERSION(DRIVER_VERSION);
75MODULE_LICENSE("GPL"); 707MODULE_LICENSE("GPL");
708
709#ifdef CONFIG_USB_DEBUG
710module_param(debug, bool, S_IRUGO | S_IWUSR);
711MODULE_PARM_DESC(debug, "Debug messages");
712#endif
713