Merge git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux-2.6
[wrt350n-kernel.git] / drivers / usb / serial / sierra.c
blobaaf65df7614f38865b037b4dc3d9b38ba305080b
1 /*
2 USB Driver for Sierra Wireless
4 Copyright (C) 2006, 2007, 2008 Kevin Lloyd <linux@sierrawireless.com>
6 IMPORTANT DISCLAIMER: This driver is not commercially supported by
7 Sierra Wireless. Use at your own risk.
9 This driver is free software; you can redistribute it and/or modify
10 it under the terms of Version 2 of the GNU General Public License as
11 published by the Free Software Foundation.
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>
17 #define DRIVER_VERSION "v.1.2.7"
18 #define DRIVER_AUTHOR "Kevin Lloyd <linux@sierrawireless.com>"
19 #define DRIVER_DESC "USB Driver for Sierra Wireless USB modems"
21 #include <linux/kernel.h>
22 #include <linux/jiffies.h>
23 #include <linux/errno.h>
24 #include <linux/tty.h>
25 #include <linux/tty_flip.h>
26 #include <linux/module.h>
27 #include <linux/usb.h>
28 #include <linux/usb/serial.h>
29 #include <linux/usb/ch9.h>
31 #define SWIMS_USB_REQUEST_SetPower 0x00
32 #define SWIMS_USB_REQUEST_SetNmea 0x07
33 #define SWIMS_USB_REQUEST_SetMode 0x0B
34 #define SWIMS_USB_REQUEST_TYPE_VSC_SET 0x40
35 #define SWIMS_SET_MODE_Modem 0x0001
37 /* per port private data */
38 #define N_IN_URB 4
39 #define N_OUT_URB 4
40 #define IN_BUFLEN 4096
42 static int debug;
43 static int nmea;
44 static int truinstall = 1;
46 enum devicetype {
47 DEVICE_3_PORT = 0,
48 DEVICE_1_PORT = 1,
49 DEVICE_INSTALLER = 2,
52 static int sierra_set_power_state(struct usb_device *udev, __u16 swiState)
54 int result;
55 dev_dbg(&udev->dev, "%s", "SET POWER STATE\n");
56 result = usb_control_msg(udev, usb_sndctrlpipe(udev, 0),
57 SWIMS_USB_REQUEST_SetPower, /* __u8 request */
58 SWIMS_USB_REQUEST_TYPE_VSC_SET, /* __u8 request type */
59 swiState, /* __u16 value */
60 0, /* __u16 index */
61 NULL, /* void *data */
62 0, /* __u16 size */
63 USB_CTRL_SET_TIMEOUT); /* int timeout */
64 return result;
67 static int sierra_set_ms_mode(struct usb_device *udev, __u16 eSWocMode)
69 int result;
70 dev_dbg(&udev->dev, "%s", "DEVICE MODE SWITCH\n");
71 result = usb_control_msg(udev, usb_sndctrlpipe(udev, 0),
72 SWIMS_USB_REQUEST_SetMode, /* __u8 request */
73 SWIMS_USB_REQUEST_TYPE_VSC_SET, /* __u8 request type */
74 eSWocMode, /* __u16 value */
75 0x0000, /* __u16 index */
76 NULL, /* void *data */
77 0, /* __u16 size */
78 USB_CTRL_SET_TIMEOUT); /* int timeout */
79 return result;
82 static int sierra_vsc_set_nmea(struct usb_device *udev, __u16 enable)
84 int result;
85 dev_dbg(&udev->dev, "%s", "NMEA Enable sent\n");
86 result = usb_control_msg(udev, usb_sndctrlpipe(udev, 0),
87 SWIMS_USB_REQUEST_SetNmea, /* __u8 request */
88 SWIMS_USB_REQUEST_TYPE_VSC_SET, /* __u8 request type */
89 enable, /* __u16 value */
90 0x0000, /* __u16 index */
91 NULL, /* void *data */
92 0, /* __u16 size */
93 USB_CTRL_SET_TIMEOUT); /* int timeout */
94 return result;
97 static int sierra_calc_num_ports(struct usb_serial *serial)
99 int result;
100 int *num_ports = usb_get_serial_data(serial);
102 result = *num_ports;
104 if (result) {
105 kfree(num_ports);
106 usb_set_serial_data(serial, NULL);
109 return result;
112 static int sierra_probe(struct usb_serial *serial,
113 const struct usb_device_id *id)
115 int result = 0;
116 struct usb_device *udev;
117 int *num_ports;
118 u8 ifnum;
120 num_ports = kmalloc(sizeof(*num_ports), GFP_KERNEL);
121 if (!num_ports)
122 return -ENOMEM;
124 ifnum = serial->interface->cur_altsetting->desc.bInterfaceNumber;
125 udev = serial->dev;
127 /* Check if in installer mode */
128 if (truinstall && id->driver_info == DEVICE_INSTALLER) {
129 dev_dbg(&udev->dev, "%s", "FOUND TRU-INSTALL DEVICE(SW)\n");
130 result = sierra_set_ms_mode(udev, SWIMS_SET_MODE_Modem);
131 /* Don't bind to the device when in installer mode */
132 kfree(num_ports);
133 return -EIO;
134 } else if (id->driver_info == DEVICE_1_PORT)
135 *num_ports = 1;
136 else if (ifnum == 0x99)
137 *num_ports = 0;
138 else
139 *num_ports = 3;
141 * save off our num_ports info so that we can use it in the
142 * calc_num_ports callback
144 usb_set_serial_data(serial, (void *)num_ports);
146 return result;
149 static struct usb_device_id id_table [] = {
150 { USB_DEVICE(0x1199, 0x0017) }, /* Sierra Wireless EM5625 */
151 { USB_DEVICE(0x1199, 0x0018) }, /* Sierra Wireless MC5720 */
152 { USB_DEVICE(0x1199, 0x0218) }, /* Sierra Wireless MC5720 */
153 { USB_DEVICE(0x0f30, 0x1b1d) }, /* Sierra Wireless MC5720 */
154 { USB_DEVICE(0x1199, 0x0020) }, /* Sierra Wireless MC5725 */
155 { USB_DEVICE(0x1199, 0x0220) }, /* Sierra Wireless MC5725 */
156 { USB_DEVICE(0x1199, 0x0019) }, /* Sierra Wireless AirCard 595 */
157 { USB_DEVICE(0x1199, 0x0021) }, /* Sierra Wireless AirCard 597E */
158 { USB_DEVICE(0x1199, 0x0120) }, /* Sierra Wireless USB Dongle 595U */
159 { USB_DEVICE(0x1199, 0x0023) }, /* Sierra Wireless AirCard */
161 { USB_DEVICE(0x1199, 0x6802) }, /* Sierra Wireless MC8755 */
162 { USB_DEVICE(0x1199, 0x6804) }, /* Sierra Wireless MC8755 */
163 { USB_DEVICE(0x1199, 0x6803) }, /* Sierra Wireless MC8765 */
164 { USB_DEVICE(0x1199, 0x6812) }, /* Sierra Wireless MC8775 & AC 875U */
165 { USB_DEVICE(0x1199, 0x6813) }, /* Sierra Wireless MC8775 (Thinkpad internal) */
166 { USB_DEVICE(0x1199, 0x6820) }, /* Sierra Wireless AirCard 875 */
167 { USB_DEVICE(0x1199, 0x6832) }, /* Sierra Wireless MC8780*/
168 { USB_DEVICE(0x1199, 0x6833) }, /* Sierra Wireless MC8781*/
169 { USB_DEVICE(0x1199, 0x6850) }, /* Sierra Wireless AirCard 880 */
170 { USB_DEVICE(0x1199, 0x6851) }, /* Sierra Wireless AirCard 881 */
171 { USB_DEVICE(0x1199, 0x6852) }, /* Sierra Wireless AirCard 880 E */
172 { USB_DEVICE(0x1199, 0x6853) }, /* Sierra Wireless AirCard 881 E */
173 { USB_DEVICE(0x1199, 0x6855) }, /* Sierra Wireless AirCard 880 U */
174 { USB_DEVICE(0x1199, 0x6856) }, /* Sierra Wireless AirCard 881 U */
176 { USB_DEVICE(0x1199, 0x6468) }, /* Sierra Wireless MP3G - EVDO */
177 { USB_DEVICE(0x1199, 0x6469) }, /* Sierra Wireless MP3G - UMTS/HSPA */
179 { USB_DEVICE(0x1199, 0x0112), .driver_info = DEVICE_1_PORT }, /* Sierra Wireless AirCard 580 */
180 { USB_DEVICE(0x0F3D, 0x0112), .driver_info = DEVICE_1_PORT }, /* Airprime/Sierra PC 5220 */
181 <<<<<<< HEAD:drivers/usb/serial/sierra.c
182 { USB_DEVICE(0x05C6, 0x6613), .driver_info = DEVICE_1_PORT }, /* Onda H600/ZTE MF330 */
183 =======
184 >>>>>>> 264e3e889d86e552b4191d69bb60f4f3b383135a:drivers/usb/serial/sierra.c
186 { USB_DEVICE(0x1199, 0x0FFF), .driver_info = DEVICE_INSTALLER},
189 MODULE_DEVICE_TABLE(usb, id_table);
191 static struct usb_driver sierra_driver = {
192 .name = "sierra",
193 .probe = usb_serial_probe,
194 .disconnect = usb_serial_disconnect,
195 .id_table = id_table,
196 .no_dynamic_id = 1,
199 struct sierra_port_private {
200 spinlock_t lock; /* lock the structure */
201 int outstanding_urbs; /* number of out urbs in flight */
203 /* Input endpoints and buffer for this port */
204 struct urb *in_urbs[N_IN_URB];
205 char in_buffer[N_IN_URB][IN_BUFLEN];
207 /* Settings for the port */
208 int rts_state; /* Handshaking pins (outputs) */
209 int dtr_state;
210 int cts_state; /* Handshaking pins (inputs) */
211 int dsr_state;
212 int dcd_state;
213 int ri_state;
216 static int sierra_send_setup(struct usb_serial_port *port)
218 struct usb_serial *serial = port->serial;
219 struct sierra_port_private *portdata;
220 __u16 interface = 0;
222 dbg("%s", __FUNCTION__);
224 portdata = usb_get_serial_port_data(port);
226 if (port->tty) {
227 int val = 0;
228 if (portdata->dtr_state)
229 val |= 0x01;
230 if (portdata->rts_state)
231 val |= 0x02;
233 /* Determine which port is targeted */
234 if (port->bulk_out_endpointAddress == 2)
235 interface = 0;
236 else if (port->bulk_out_endpointAddress == 4)
237 interface = 1;
238 else if (port->bulk_out_endpointAddress == 5)
239 interface = 2;
241 return usb_control_msg(serial->dev,
242 usb_rcvctrlpipe(serial->dev, 0),
243 0x22, 0x21, val, interface,
244 NULL, 0, USB_CTRL_SET_TIMEOUT);
247 return 0;
250 static void sierra_rx_throttle(struct usb_serial_port *port)
252 dbg("%s", __FUNCTION__);
255 static void sierra_rx_unthrottle(struct usb_serial_port *port)
257 dbg("%s", __FUNCTION__);
260 static void sierra_break_ctl(struct usb_serial_port *port, int break_state)
262 /* Unfortunately, I don't know how to send a break */
263 dbg("%s", __FUNCTION__);
266 static void sierra_set_termios(struct usb_serial_port *port,
267 struct ktermios *old_termios)
269 dbg("%s", __FUNCTION__);
270 tty_termios_copy_hw(port->tty->termios, old_termios);
271 sierra_send_setup(port);
274 static int sierra_tiocmget(struct usb_serial_port *port, struct file *file)
276 unsigned int value;
277 struct sierra_port_private *portdata;
279 portdata = usb_get_serial_port_data(port);
281 value = ((portdata->rts_state) ? TIOCM_RTS : 0) |
282 ((portdata->dtr_state) ? TIOCM_DTR : 0) |
283 ((portdata->cts_state) ? TIOCM_CTS : 0) |
284 ((portdata->dsr_state) ? TIOCM_DSR : 0) |
285 ((portdata->dcd_state) ? TIOCM_CAR : 0) |
286 ((portdata->ri_state) ? TIOCM_RNG : 0);
288 return value;
291 static int sierra_tiocmset(struct usb_serial_port *port, struct file *file,
292 unsigned int set, unsigned int clear)
294 struct sierra_port_private *portdata;
296 portdata = usb_get_serial_port_data(port);
298 if (set & TIOCM_RTS)
299 portdata->rts_state = 1;
300 if (set & TIOCM_DTR)
301 portdata->dtr_state = 1;
303 if (clear & TIOCM_RTS)
304 portdata->rts_state = 0;
305 if (clear & TIOCM_DTR)
306 portdata->dtr_state = 0;
307 return sierra_send_setup(port);
310 static int sierra_ioctl(struct usb_serial_port *port, struct file *file,
311 unsigned int cmd, unsigned long arg)
313 return -ENOIOCTLCMD;
316 static void sierra_outdat_callback(struct urb *urb)
318 struct usb_serial_port *port = urb->context;
319 struct sierra_port_private *portdata = usb_get_serial_port_data(port);
320 int status = urb->status;
321 unsigned long flags;
323 dbg("%s - port %d", __FUNCTION__, port->number);
325 /* free up the transfer buffer, as usb_free_urb() does not do this */
326 kfree(urb->transfer_buffer);
328 if (status)
329 dbg("%s - nonzero write bulk status received: %d",
330 __FUNCTION__, status);
332 spin_lock_irqsave(&portdata->lock, flags);
333 --portdata->outstanding_urbs;
334 spin_unlock_irqrestore(&portdata->lock, flags);
336 usb_serial_port_softint(port);
339 /* Write */
340 static int sierra_write(struct usb_serial_port *port,
341 const unsigned char *buf, int count)
343 struct sierra_port_private *portdata = usb_get_serial_port_data(port);
344 struct usb_serial *serial = port->serial;
345 unsigned long flags;
346 unsigned char *buffer;
347 struct urb *urb;
348 int status;
350 portdata = usb_get_serial_port_data(port);
352 dbg("%s: write (%d chars)", __FUNCTION__, count);
354 spin_lock_irqsave(&portdata->lock, flags);
355 if (portdata->outstanding_urbs > N_OUT_URB) {
356 spin_unlock_irqrestore(&portdata->lock, flags);
357 dbg("%s - write limit hit\n", __FUNCTION__);
358 return 0;
360 portdata->outstanding_urbs++;
361 spin_unlock_irqrestore(&portdata->lock, flags);
363 buffer = kmalloc(count, GFP_ATOMIC);
364 if (!buffer) {
365 dev_err(&port->dev, "out of memory\n");
366 count = -ENOMEM;
367 goto error_no_buffer;
370 urb = usb_alloc_urb(0, GFP_ATOMIC);
371 if (!urb) {
372 dev_err(&port->dev, "no more free urbs\n");
373 count = -ENOMEM;
374 goto error_no_urb;
377 memcpy(buffer, buf, count);
379 usb_serial_debug_data(debug, &port->dev, __FUNCTION__, count, buffer);
381 usb_fill_bulk_urb(urb, serial->dev,
382 usb_sndbulkpipe(serial->dev,
383 port->bulk_out_endpointAddress),
384 buffer, count, sierra_outdat_callback, port);
386 /* send it down the pipe */
387 status = usb_submit_urb(urb, GFP_ATOMIC);
388 if (status) {
389 dev_err(&port->dev, "%s - usb_submit_urb(write bulk) failed "
390 "with status = %d\n", __FUNCTION__, status);
391 count = status;
392 goto error;
395 /* we are done with this urb, so let the host driver
396 * really free it when it is finished with it */
397 usb_free_urb(urb);
399 return count;
400 error:
401 usb_free_urb(urb);
402 error_no_urb:
403 kfree(buffer);
404 error_no_buffer:
405 spin_lock_irqsave(&portdata->lock, flags);
406 --portdata->outstanding_urbs;
407 spin_unlock_irqrestore(&portdata->lock, flags);
408 return count;
411 static void sierra_indat_callback(struct urb *urb)
413 int err;
414 int endpoint;
415 struct usb_serial_port *port;
416 struct tty_struct *tty;
417 unsigned char *data = urb->transfer_buffer;
418 int status = urb->status;
420 dbg("%s: %p", __FUNCTION__, urb);
422 endpoint = usb_pipeendpoint(urb->pipe);
423 port = (struct usb_serial_port *) urb->context;
425 if (status) {
426 dbg("%s: nonzero status: %d on endpoint %02x.",
427 __FUNCTION__, status, endpoint);
428 } else {
429 tty = port->tty;
430 if (urb->actual_length) {
431 tty_buffer_request_room(tty, urb->actual_length);
432 tty_insert_flip_string(tty, data, urb->actual_length);
433 tty_flip_buffer_push(tty);
434 } else {
435 dbg("%s: empty read urb received", __FUNCTION__);
438 /* Resubmit urb so we continue receiving */
439 if (port->open_count && status != -ESHUTDOWN) {
440 err = usb_submit_urb(urb, GFP_ATOMIC);
441 if (err)
442 dev_err(&port->dev, "resubmit read urb failed."
443 "(%d)\n", err);
446 return;
449 static void sierra_instat_callback(struct urb *urb)
451 int err;
452 int status = urb->status;
453 struct usb_serial_port *port = (struct usb_serial_port *) urb->context;
454 struct sierra_port_private *portdata = usb_get_serial_port_data(port);
455 struct usb_serial *serial = port->serial;
457 dbg("%s", __FUNCTION__);
458 dbg("%s: urb %p port %p has data %p", __FUNCTION__,urb,port,portdata);
460 if (status == 0) {
461 struct usb_ctrlrequest *req_pkt =
462 (struct usb_ctrlrequest *)urb->transfer_buffer;
464 if (!req_pkt) {
465 dbg("%s: NULL req_pkt\n", __FUNCTION__);
466 return;
468 if ((req_pkt->bRequestType == 0xA1) &&
469 (req_pkt->bRequest == 0x20)) {
470 int old_dcd_state;
471 unsigned char signals = *((unsigned char *)
472 urb->transfer_buffer +
473 sizeof(struct usb_ctrlrequest));
475 dbg("%s: signal x%x", __FUNCTION__, signals);
477 old_dcd_state = portdata->dcd_state;
478 portdata->cts_state = 1;
479 portdata->dcd_state = ((signals & 0x01) ? 1 : 0);
480 portdata->dsr_state = ((signals & 0x02) ? 1 : 0);
481 portdata->ri_state = ((signals & 0x08) ? 1 : 0);
483 if (port->tty && !C_CLOCAL(port->tty) &&
484 old_dcd_state && !portdata->dcd_state)
485 tty_hangup(port->tty);
486 } else {
487 dbg("%s: type %x req %x", __FUNCTION__,
488 req_pkt->bRequestType,req_pkt->bRequest);
490 } else
491 dbg("%s: error %d", __FUNCTION__, status);
493 /* Resubmit urb so we continue receiving IRQ data */
494 if (status != -ESHUTDOWN) {
495 urb->dev = serial->dev;
496 err = usb_submit_urb(urb, GFP_ATOMIC);
497 if (err)
498 dbg("%s: resubmit intr urb failed. (%d)",
499 __FUNCTION__, err);
503 static int sierra_write_room(struct usb_serial_port *port)
505 struct sierra_port_private *portdata = usb_get_serial_port_data(port);
506 unsigned long flags;
508 dbg("%s - port %d", __FUNCTION__, port->number);
510 /* try to give a good number back based on if we have any free urbs at
511 * this point in time */
512 spin_lock_irqsave(&portdata->lock, flags);
513 if (portdata->outstanding_urbs > N_OUT_URB * 2 / 3) {
514 spin_unlock_irqrestore(&portdata->lock, flags);
515 dbg("%s - write limit hit\n", __FUNCTION__);
516 return 0;
518 spin_unlock_irqrestore(&portdata->lock, flags);
520 return 2048;
523 static int sierra_chars_in_buffer(struct usb_serial_port *port)
525 dbg("%s - port %d", __FUNCTION__, port->number);
528 * We can't really account for how much data we
529 * have sent out, but hasn't made it through to the
530 * device as we can't see the backend here, so just
531 * tell the tty layer that everything is flushed.
533 return 0;
536 static int sierra_open(struct usb_serial_port *port, struct file *filp)
538 struct sierra_port_private *portdata;
539 struct usb_serial *serial = port->serial;
540 int i;
541 struct urb *urb;
542 int result;
544 portdata = usb_get_serial_port_data(port);
546 dbg("%s", __FUNCTION__);
548 /* Set some sane defaults */
549 portdata->rts_state = 1;
550 portdata->dtr_state = 1;
552 /* Reset low level data toggle and start reading from endpoints */
553 for (i = 0; i < N_IN_URB; i++) {
554 urb = portdata->in_urbs[i];
555 if (!urb)
556 continue;
557 if (urb->dev != serial->dev) {
558 dbg("%s: dev %p != %p", __FUNCTION__,
559 urb->dev, serial->dev);
560 continue;
564 * make sure endpoint data toggle is synchronized with the
565 * device
567 usb_clear_halt(urb->dev, urb->pipe);
569 result = usb_submit_urb(urb, GFP_KERNEL);
570 if (result) {
571 dev_err(&port->dev, "submit urb %d failed (%d) %d\n",
572 i, result, urb->transfer_buffer_length);
576 port->tty->low_latency = 1;
578 sierra_send_setup(port);
580 /* start up the interrupt endpoint if we have one */
581 if (port->interrupt_in_urb) {
582 result = usb_submit_urb(port->interrupt_in_urb, GFP_KERNEL);
583 if (result)
584 dev_err(&port->dev, "submit irq_in urb failed %d\n",
585 result);
587 return 0;
590 static void sierra_close(struct usb_serial_port *port, struct file *filp)
592 int i;
593 struct usb_serial *serial = port->serial;
594 struct sierra_port_private *portdata;
596 dbg("%s", __FUNCTION__);
597 portdata = usb_get_serial_port_data(port);
599 portdata->rts_state = 0;
600 portdata->dtr_state = 0;
602 if (serial->dev) {
603 mutex_lock(&serial->disc_mutex);
604 if (!serial->disconnected)
605 sierra_send_setup(port);
606 mutex_unlock(&serial->disc_mutex);
608 /* Stop reading/writing urbs */
609 for (i = 0; i < N_IN_URB; i++)
610 usb_kill_urb(portdata->in_urbs[i]);
613 usb_kill_urb(port->interrupt_in_urb);
615 port->tty = NULL;
618 static int sierra_startup(struct usb_serial *serial)
620 struct usb_serial_port *port;
621 struct sierra_port_private *portdata;
622 struct urb *urb;
623 int i;
624 int j;
626 dbg("%s", __FUNCTION__);
628 /* Set Device mode to D0 */
629 sierra_set_power_state(serial->dev, 0x0000);
631 /* Check NMEA and set */
632 if (nmea)
633 sierra_vsc_set_nmea(serial->dev, 1);
635 /* Now setup per port private data */
636 for (i = 0; i < serial->num_ports; i++) {
637 port = serial->port[i];
638 portdata = kzalloc(sizeof(*portdata), GFP_KERNEL);
639 if (!portdata) {
640 dbg("%s: kmalloc for sierra_port_private (%d) failed!.",
641 __FUNCTION__, i);
642 return -ENOMEM;
644 spin_lock_init(&portdata->lock);
646 usb_set_serial_port_data(port, portdata);
648 /* initialize the in urbs */
649 for (j = 0; j < N_IN_URB; ++j) {
650 urb = usb_alloc_urb(0, GFP_KERNEL);
651 if (urb == NULL) {
652 dbg("%s: alloc for in port failed.",
653 __FUNCTION__);
654 continue;
656 /* Fill URB using supplied data. */
657 usb_fill_bulk_urb(urb, serial->dev,
658 usb_rcvbulkpipe(serial->dev,
659 port->bulk_in_endpointAddress),
660 portdata->in_buffer[j], IN_BUFLEN,
661 sierra_indat_callback, port);
662 portdata->in_urbs[j] = urb;
666 return 0;
669 static void sierra_shutdown(struct usb_serial *serial)
671 int i, j;
672 struct usb_serial_port *port;
673 struct sierra_port_private *portdata;
675 dbg("%s", __FUNCTION__);
677 for (i = 0; i < serial->num_ports; ++i) {
678 port = serial->port[i];
679 if (!port)
680 continue;
681 portdata = usb_get_serial_port_data(port);
682 if (!portdata)
683 continue;
685 for (j = 0; j < N_IN_URB; j++) {
686 usb_kill_urb(portdata->in_urbs[j]);
687 usb_free_urb(portdata->in_urbs[j]);
688 portdata->in_urbs[j] = NULL;
690 kfree(portdata);
691 usb_set_serial_port_data(port, NULL);
695 static struct usb_serial_driver sierra_device = {
696 .driver = {
697 .owner = THIS_MODULE,
698 .name = "sierra1",
700 .description = "Sierra USB modem",
701 .id_table = id_table,
702 .usb_driver = &sierra_driver,
703 .num_interrupt_in = NUM_DONT_CARE,
704 .num_bulk_in = NUM_DONT_CARE,
705 .num_bulk_out = NUM_DONT_CARE,
706 .calc_num_ports = sierra_calc_num_ports,
707 .probe = sierra_probe,
708 .open = sierra_open,
709 .close = sierra_close,
710 .write = sierra_write,
711 .write_room = sierra_write_room,
712 .chars_in_buffer = sierra_chars_in_buffer,
713 .throttle = sierra_rx_throttle,
714 .unthrottle = sierra_rx_unthrottle,
715 .ioctl = sierra_ioctl,
716 .set_termios = sierra_set_termios,
717 .break_ctl = sierra_break_ctl,
718 .tiocmget = sierra_tiocmget,
719 .tiocmset = sierra_tiocmset,
720 .attach = sierra_startup,
721 .shutdown = sierra_shutdown,
722 .read_int_callback = sierra_instat_callback,
725 /* Functions used by new usb-serial code. */
726 static int __init sierra_init(void)
728 int retval;
729 retval = usb_serial_register(&sierra_device);
730 if (retval)
731 goto failed_device_register;
734 retval = usb_register(&sierra_driver);
735 if (retval)
736 goto failed_driver_register;
738 info(DRIVER_DESC ": " DRIVER_VERSION);
740 return 0;
742 failed_driver_register:
743 usb_serial_deregister(&sierra_device);
744 failed_device_register:
745 return retval;
748 static void __exit sierra_exit(void)
750 usb_deregister (&sierra_driver);
751 usb_serial_deregister(&sierra_device);
754 module_init(sierra_init);
755 module_exit(sierra_exit);
757 MODULE_AUTHOR(DRIVER_AUTHOR);
758 MODULE_DESCRIPTION(DRIVER_DESC);
759 MODULE_VERSION(DRIVER_VERSION);
760 MODULE_LICENSE("GPL");
762 module_param(truinstall, bool, 0);
763 MODULE_PARM_DESC(truinstall, "TRU-Install support");
765 module_param(nmea, bool, 0);
766 MODULE_PARM_DESC(nmea, "NMEA streaming");
768 #ifdef CONFIG_USB_DEBUG
769 module_param(debug, bool, S_IRUGO | S_IWUSR);
770 MODULE_PARM_DESC(debug, "Debug messages");
771 #endif