2 USB Driver for Sierra Wireless
4 Copyright (C) 2006, 2007, 2008 Kevin Lloyd <klloyd@sierrawireless.com>,
6 Copyright (C) 2008 - 2011 Elina Pasheva, Matthew Safar, Rory Filer
7 <linux@sierrawireless.com>
9 IMPORTANT DISCLAIMER: This driver is not commercially supported by
10 Sierra Wireless. Use at your own risk.
12 This driver is free software; you can redistribute it and/or modify
13 it under the terms of Version 2 of the GNU General Public License as
14 published by the Free Software Foundation.
16 Portions based on the option driver by Matthias Urlichs <smurf@smurf.noris.de>
17 Whom based his on the Keyspan driver by Hugh Blemings <hugh@blemings.org>
19 /* Uncomment to log function calls */
21 /* Uncomment to force power level set to auto when attaching a device */
22 /*#define POWER_LEVEL_AUTO*/
24 /* Sierra driver - kernel 3.0 */
25 #define DRIVER_VERSION "v.1.7.40"
26 #define DRIVER_AUTHOR "Kevin Lloyd, Elina Pasheva, Matthew Safar, Rory Filer"
27 #define DRIVER_DESC "USB Driver for Sierra Wireless USB modems"
29 #include <linux/kernel.h>
30 #include <linux/jiffies.h>
31 #include <linux/errno.h>
32 #include <linux/tty.h>
33 #include <linux/slab.h>
34 #include <linux/tty_flip.h>
35 #include <linux/module.h>
36 #include <linux/usb.h>
37 #include <linux/usb/serial.h>
38 #include <asm/unaligned.h>
40 #define SWIMS_USB_REQUEST_SetPower 0x00
41 #define SWIMS_USB_REQUEST_GetFwAttr 0x06
42 #define SWIMS_USB_REQUEST_SetNmea 0x07
43 #define USB_REQUEST_TYPE_CLASS 0xA1
44 #define USB_REQUEST_IFACE 0x20
47 #define N_OUT_URB_HM 64
50 #define IN_BUFLEN 4096
52 #define MAX_TRANSFER (PAGE_SIZE - 512)
53 /* MAX_TRANSFER is chosen so that the VM is not stressed by
54 allocations > PAGE_SIZE and the number of packets in a page
55 is an integer 512 is the largest possible packet on EHCI */
57 #define SWI_FW_ATTR_PM_MASK 0x02
58 /* PORTION_LEN defines the length of device attribute buffer */
59 #define PORTION_LEN 4096
64 /* sysfs attributes */
65 static int sierra_create_sysfs_attrs(struct usb_serial_port
*port
);
66 static int sierra_remove_sysfs_attrs(struct usb_serial_port
*port
);
68 /* Used in interface blacklisting */
69 struct sierra_iface_info
{
70 const u32 infolen
; /* number of interface numbers on blacklist */
71 const u8
*ifaceinfo
; /* pointer to the array holding the numbers */
74 /* per interface statistics */
75 struct sierra_intf_stats
{
76 atomic_t rx_bytes
; /* received bytes */
77 atomic_t indat_cb_cnt
; /* indat callback count */
78 atomic_t indat_cb_fail
; /* indat cb with error */
80 atomic_t tx_bytes
; /* transmitted bytes */
81 atomic_t write_cnt
; /* no. of writes */
82 atomic_t write_err
; /* no. of failed writes */
84 atomic_t delayed_writes
; /* no. of delayed writes */
85 atomic_t delayed_write_err
; /* no. of delayed write errs */
87 atomic_t outdat_cb_cnt
; /* outdat callback count */
88 atomic_t outdat_cb_fail
; /* outdat cb with error */
92 struct sierra_intf_private
{
94 unsigned int suspended
:1;
97 struct sierra_intf_stats stats
;
100 static int sierra_set_power_state(struct usb_device
*udev
, __u16 swiState
)
103 dev_dbg(&udev
->dev
, "%s\n", __func__
);
104 result
= usb_control_msg(udev
, usb_sndctrlpipe(udev
, 0),
105 SWIMS_USB_REQUEST_SetPower
, /* __u8 request */
106 USB_TYPE_VENDOR
, /* __u8 request type */
107 swiState
, /* __u16 value */
109 NULL
, /* void *data */
111 USB_CTRL_SET_TIMEOUT
); /* int timeout */
115 static int sierra_vsc_set_nmea(struct usb_device
*udev
, __u16 enable
)
118 dev_dbg(&udev
->dev
, "%s\n", __func__
);
119 result
= usb_control_msg(udev
, usb_sndctrlpipe(udev
, 0),
120 SWIMS_USB_REQUEST_SetNmea
, /* __u8 request */
121 USB_TYPE_VENDOR
, /* __u8 request type */
122 enable
, /* __u16 value */
123 0x0000, /* __u16 index */
124 NULL
, /* void *data */
126 USB_CTRL_SET_TIMEOUT
); /* int timeout */
130 static int sierra_get_fw_attr(struct usb_device
*udev
, u16
*data
)
135 dev_dbg(&udev
->dev
, "%s\n", __func__
);
137 attrdata
= kmalloc(sizeof(*attrdata
), GFP_KERNEL
);
141 result
= usb_control_msg(udev
,
142 usb_rcvctrlpipe(udev
, 0),
143 SWIMS_USB_REQUEST_GetFwAttr
, /* __u8 request*/
144 USB_TYPE_VENDOR
| USB_DIR_IN
, /* request type*/
145 0x0000, /* __u16 value */
146 0x0000, /* __u16 index */
147 attrdata
, /* void *data */
148 sizeof(*attrdata
), /* _u16 size */
149 USB_CTRL_SET_TIMEOUT
); /* in timeout */
162 static int sierra_calc_num_ports(struct usb_serial
*serial
)
165 u8 ifnum
, numendpoints
;
167 dev_dbg(&serial
->dev
->dev
, "%s\n", __func__
);
169 ifnum
= serial
->interface
->cur_altsetting
->desc
.bInterfaceNumber
;
170 numendpoints
= serial
->interface
->cur_altsetting
->desc
.bNumEndpoints
;
172 /* Dummy interface present on some SKUs should be ignored */
175 else if (numendpoints
<= 3)
178 num_ports
= (numendpoints
-1)/2;
182 static int is_blacklisted(const u8 ifnum
,
183 const struct sierra_iface_info
*blacklist
)
189 info
= blacklist
->ifaceinfo
;
191 for (i
= 0; i
< blacklist
->infolen
; i
++) {
192 if (info
[i
] == ifnum
)
199 static int is_himemory(const u8 ifnum
,
200 const struct sierra_iface_info
*himemorylist
)
206 info
= himemorylist
->ifaceinfo
;
208 for (i
=0; i
< himemorylist
->infolen
; i
++) {
209 if (info
[i
] == ifnum
)
216 static int sierra_calc_interface(struct usb_serial
*serial
)
219 struct usb_interface
*p_interface
;
220 struct usb_host_interface
*p_host_interface
;
222 /* Get the interface structure pointer from the serial struct */
223 p_interface
= serial
->interface
;
225 /* Get a pointer to the host interface structure */
226 p_host_interface
= p_interface
->cur_altsetting
;
228 /* read the interface descriptor for this active altsetting
229 * to find out the interface number we are on */
230 interface
= p_host_interface
->desc
.bInterfaceNumber
;
235 static int sierra_probe(struct usb_serial
*serial
,
236 const struct usb_device_id
*id
)
239 struct usb_device
*udev
;
240 struct sierra_intf_private
*intfdata
;
244 dev_dbg(&udev
->dev
, "%s\n", __func__
);
246 ifnum
= sierra_calc_interface(serial
);
248 * If this interface supports more than 1 alternate
251 if (serial
->interface
->num_altsetting
== 2) {
252 dev_dbg(&udev
->dev
, "Selecting alt setting for interface %d\n",
254 /* We know the alternate setting is for composite USB interface
257 usb_set_interface(udev
, ifnum
, 1);
260 /* ifnum could have changed - by calling usb_set_interface */
261 ifnum
= sierra_calc_interface(serial
);
263 if (is_blacklisted(ifnum
,
264 (struct sierra_iface_info
*)id
->driver_info
)) {
265 dev_dbg(&serial
->dev
->dev
,
266 "Ignoring blacklisted interface #%d\n", ifnum
);
270 intfdata
= serial
->private = kzalloc(sizeof(struct sierra_intf_private
),
274 spin_lock_init(&intfdata
->susp_lock
);
279 /* interfaces with higher memory requirements */
280 static const u8 hi_memory_typeA_ifaces
[] = { 0, 2 };
281 static const struct sierra_iface_info typeA_interface_list
= {
282 .infolen
= ARRAY_SIZE(hi_memory_typeA_ifaces
),
283 .ifaceinfo
= hi_memory_typeA_ifaces
,
286 static const u8 hi_memory_typeB_ifaces
[] = { 3, 4, 5, 6 };
287 static const struct sierra_iface_info typeB_interface_list
= {
288 .infolen
= ARRAY_SIZE(hi_memory_typeB_ifaces
),
289 .ifaceinfo
= hi_memory_typeB_ifaces
,
292 /* 'blacklist' of interfaces not served by this driver */
293 static const u8 direct_ip_non_serial_ifaces
[] = { 7, 8, 9, 10, 11 };
294 static const struct sierra_iface_info direct_ip_interface_blacklist
= {
295 .infolen
= ARRAY_SIZE( direct_ip_non_serial_ifaces
),
296 .ifaceinfo
= direct_ip_non_serial_ifaces
,
299 static const struct usb_device_id id_table
[] = {
300 { USB_DEVICE(0x0F3D, 0x0112) }, /* Airprime/Sierra PC 5220 */
301 { USB_DEVICE(0x03F0, 0x1B1D) }, /* HP ev2200 a.k.a MC5720 */
302 { USB_DEVICE(0x03F0, 0x1E1D) }, /* HP hs2300 a.k.a MC8775 */
303 { USB_DEVICE(0x03F0, 0x211D) }, /* HP ev2210 a.k.a MC5725 */
305 { USB_DEVICE(0x1199, 0x0017) }, /* Sierra Wireless EM5625 */
306 { USB_DEVICE(0x1199, 0x0018) }, /* Sierra Wireless MC5720 */
307 { USB_DEVICE(0x1199, 0x0218) }, /* Sierra Wireless MC5720 */
308 { USB_DEVICE(0x1199, 0x0020) }, /* Sierra Wireless MC5725 */
309 { USB_DEVICE(0x1199, 0x0220) }, /* Sierra Wireless MC5725 */
310 { USB_DEVICE(0x1199, 0x0022) }, /* Sierra Wireless EM5725 */
311 { USB_DEVICE(0x1199, 0x0024) }, /* Sierra Wireless MC5727 */
312 { USB_DEVICE(0x1199, 0x0224) }, /* Sierra Wireless MC5727 */
313 { USB_DEVICE(0x1199, 0x0019) }, /* Sierra Wireless AirCard 595 */
314 { USB_DEVICE(0x1199, 0x0021) }, /* Sierra Wireless AirCard 597E */
315 { USB_DEVICE(0x1199, 0x0112) }, /* Sierra Wireless AirCard 580 */
316 { USB_DEVICE(0x1199, 0x0120) }, /* Sierra Wireless USB Dongle 595U */
317 { USB_DEVICE(0x1199, 0x0301) }, /* Sierra Wireless USB Dongle 250U/3G */
318 /* Sierra Wireless MC5728 */
319 { USB_DEVICE_AND_INTERFACE_INFO(0x1199, 0x0400, 0xFF, 0xFF, 0xFF) },
321 /* Sierra Wireless C597 */
322 { USB_DEVICE_AND_INTERFACE_INFO(0x1199, 0x0023, 0xFF, 0xFF, 0xFF) },
323 /* Sierra Wireless T598 */
324 { USB_DEVICE_AND_INTERFACE_INFO(0x1199, 0x0025, 0xFF, 0xFF, 0xFF) },
325 { USB_DEVICE(0x1199, 0x0026) }, /* Sierra Wireless T11 */
326 { USB_DEVICE(0x1199, 0x0027) }, /* Sierra Wireless AC402 */
327 { USB_DEVICE(0x1199, 0x0028) }, /* Sierra Wireless MC5728 */
328 { USB_DEVICE(0x114F, 0x6000) }, /* Sierra Wireless Q26 Elite */
330 { USB_DEVICE(0x1199, 0x6802) }, /* Sierra Wireless MC8755 */
331 { USB_DEVICE(0x1199, 0x6803) }, /* Sierra Wireless MC8765 */
332 { USB_DEVICE(0x1199, 0x6804) }, /* Sierra Wireless MC8755 */
333 { USB_DEVICE(0x1199, 0x6805) }, /* Sierra Wireless MC8765 */
334 { USB_DEVICE(0x1199, 0x6808) }, /* Sierra Wireless MC8755 */
335 { USB_DEVICE(0x1199, 0x6809) }, /* Sierra Wireless MC8765 */
336 { USB_DEVICE(0x1199, 0x6812) }, /* Sierra Wireless MC8775 & AC 875U */
337 { USB_DEVICE(0x1199, 0x6813) }, /* Sierra Wireless MC8775 */
338 { USB_DEVICE(0x1199, 0x6815) }, /* Sierra Wireless MC8775 */
339 { USB_DEVICE(0x1199, 0x6816) }, /* Sierra Wireless MC8775 */
340 { USB_DEVICE(0x1199, 0x6820) }, /* Sierra Wireless AirCard 875 */
341 { USB_DEVICE(0x1199, 0x6821) }, /* Sierra Wireless AirCard 875U */
342 { USB_DEVICE(0x1199, 0x6822) }, /* Sierra Wireless AirCard 875E */
343 { USB_DEVICE(0x1199, 0x6832) }, /* Sierra Wireless MC8780 */
344 { USB_DEVICE(0x1199, 0x6833) }, /* Sierra Wireless MC8781 */
345 { USB_DEVICE(0x1199, 0x6834) }, /* Sierra Wireless MC8780 */
346 { USB_DEVICE(0x1199, 0x6835) }, /* Sierra Wireless MC8781 */
347 { USB_DEVICE(0x1199, 0x6838) }, /* Sierra Wireless MC8780 */
348 { USB_DEVICE(0x1199, 0x6839) }, /* Sierra Wireless MC8781 */
349 { USB_DEVICE(0x1199, 0x683A) }, /* Sierra Wireless MC8785 */
350 { USB_DEVICE(0x1199, 0x683B) }, /* Sierra Wireless MC8785 Composite */
351 /* Sierra Wireless MC8790, MC8791, MC8792 Composite */
352 { USB_DEVICE(0x1199, 0x683C) },
353 { USB_DEVICE(0x1199, 0x683D) }, /* Sierra Wireless MC8791 Composite */
354 /* Sierra Wireless MC8790, MC8791, MC8792 */
355 { USB_DEVICE(0x1199, 0x683E) },
356 { USB_DEVICE(0x1199, 0x6850) }, /* Sierra Wireless AirCard 880 */
357 { USB_DEVICE(0x1199, 0x6851) }, /* Sierra Wireless AirCard 881 */
358 { USB_DEVICE(0x1199, 0x6852) }, /* Sierra Wireless AirCard 880 E */
359 { USB_DEVICE(0x1199, 0x6853) }, /* Sierra Wireless AirCard 881 E */
360 { USB_DEVICE(0x1199, 0x6855) }, /* Sierra Wireless AirCard 880 U */
361 { USB_DEVICE(0x1199, 0x6856) }, /* Sierra Wireless AirCard 881 U */
362 { USB_DEVICE(0x1199, 0x6859) }, /* Sierra Wireless AirCard 885 E */
363 { USB_DEVICE(0x1199, 0x685A) }, /* Sierra Wireless AirCard 885 E */
364 /* Sierra Wireless C885 */
365 { USB_DEVICE_AND_INTERFACE_INFO(0x1199, 0x6880, 0xFF, 0xFF, 0xFF)},
366 /* Sierra Wireless C888, Air Card 501, USB 303, USB 304 */
367 { USB_DEVICE_AND_INTERFACE_INFO(0x1199, 0x6890, 0xFF, 0xFF, 0xFF)},
368 /* Sierra Wireless C22/C33 */
369 { USB_DEVICE_AND_INTERFACE_INFO(0x1199, 0x6891, 0xFF, 0xFF, 0xFF)},
370 /* Sierra Wireless HSPA Non-Composite Device */
371 { USB_DEVICE_AND_INTERFACE_INFO(0x1199, 0x6892, 0xFF, 0xFF, 0xFF)},
372 { USB_DEVICE(0x1199, 0x6893) }, /* Sierra Wireless Device */
373 /* Sierra Wireless Direct IP modems */
374 { USB_DEVICE_AND_INTERFACE_INFO(0x1199, 0x68A3, 0xFF, 0xFF, 0xFF),
375 .driver_info
= (kernel_ulong_t
)&direct_ip_interface_blacklist
377 /* AT&T Direct IP modems */
378 { USB_DEVICE_AND_INTERFACE_INFO(0x0F3D, 0x68A3, 0xFF, 0xFF, 0xFF),
379 .driver_info
= (kernel_ulong_t
)&direct_ip_interface_blacklist
381 /* Sierra Wireless Direct IP LTE modems */
382 { USB_DEVICE_AND_INTERFACE_INFO(0x1199, 0x68AA, 0xFF, 0xFF, 0xFF),
383 .driver_info
= (kernel_ulong_t
)&direct_ip_interface_blacklist
385 /* AT&T Direct IP LTE modems */
386 { USB_DEVICE_AND_INTERFACE_INFO(0x0F3D, 0x68AA, 0xFF, 0xFF, 0xFF),
387 .driver_info
= (kernel_ulong_t
)&direct_ip_interface_blacklist
389 /* Wireless 5720 VZW Mobile Broadband (EVDO Rev-A) Minicard GPS Port */
390 { USB_DEVICE(0x413C, 0x8133) },
394 MODULE_DEVICE_TABLE(usb
, id_table
);
396 /* per port private data */
397 struct sierra_port_private
{
398 spinlock_t lock
; /* lock the structure */
399 int outstanding_urbs
; /* number of out urbs in flight */
401 struct usb_anchor active
;
402 struct usb_anchor delayed
;
406 /* Input endpoints and buffers for this port */
407 struct urb
*in_urbs
[N_IN_URB_HM
];
409 /* Settings for the port */
410 int rts_state
; /* Handshaking pins (outputs) */
412 int cts_state
; /* Handshaking pins (inputs) */
416 unsigned int opened
:1;
419 static int sierra_send_setup(struct usb_serial_port
*port
)
421 struct usb_serial
*serial
= port
->serial
;
422 struct sierra_port_private
*portdata
= usb_get_serial_port_data(port
);
428 dev_dbg(&port
->dev
, "%s\n", __func__
);
430 if (portdata
->dtr_state
)
432 if (portdata
->rts_state
)
435 /* If composite device then properly report interface */
436 if (serial
->num_ports
== 1) {
437 interface
= sierra_calc_interface(serial
);
438 /* Control message is sent only to interfaces with
439 * interrupt_in endpoints
441 if (port
->interrupt_in_urb
) {
442 /* send control message */
447 /* Otherwise the need to do non-composite mapping */
449 if (port
->bulk_out_endpointAddress
== 2)
451 else if (port
->bulk_out_endpointAddress
== 4)
453 else if (port
->bulk_out_endpointAddress
== 5)
461 usb_autopm_get_interface(serial
->interface
);
462 retval
= usb_control_msg(serial
->dev
, usb_rcvctrlpipe(serial
->dev
, 0),
463 0x22, 0x21, val
, interface
, NULL
, 0, USB_CTRL_SET_TIMEOUT
);
464 usb_autopm_put_interface(serial
->interface
);
469 static void sierra_set_termios(struct tty_struct
*tty
,
470 struct usb_serial_port
*port
, struct ktermios
*old_termios
)
472 dev_dbg(&port
->dev
, "%s\n", __func__
);
473 tty_termios_copy_hw(tty
->termios
, old_termios
);
474 sierra_send_setup(port
);
477 static int sierra_tiocmget(struct tty_struct
*tty
)
479 struct usb_serial_port
*port
= tty
->driver_data
;
481 struct sierra_port_private
*portdata
;
483 dev_dbg(&port
->dev
, "%s\n", __func__
);
484 portdata
= usb_get_serial_port_data(port
);
486 value
= ((portdata
->rts_state
) ? TIOCM_RTS
: 0) |
487 ((portdata
->dtr_state
) ? TIOCM_DTR
: 0) |
488 ((portdata
->cts_state
) ? TIOCM_CTS
: 0) |
489 ((portdata
->dsr_state
) ? TIOCM_DSR
: 0) |
490 ((portdata
->dcd_state
) ? TIOCM_CAR
: 0) |
491 ((portdata
->ri_state
) ? TIOCM_RNG
: 0);
496 static int sierra_tiocmset(struct tty_struct
*tty
,
497 unsigned int set
, unsigned int clear
)
499 struct usb_serial_port
*port
= tty
->driver_data
;
500 struct sierra_port_private
*portdata
;
502 portdata
= usb_get_serial_port_data(port
);
505 portdata
->rts_state
= 1;
507 portdata
->dtr_state
= 1;
509 if (clear
& TIOCM_RTS
)
510 portdata
->rts_state
= 0;
511 if (clear
& TIOCM_DTR
)
512 portdata
->dtr_state
= 0;
513 return sierra_send_setup(port
);
516 static void sierra_release_urb(struct urb
*urb
)
518 struct usb_serial_port
*port
;
521 dev_dbg(&port
->dev
, "%s: %p\n", __func__
, urb
);
526 /* Sysfs Attributes */
528 static ssize_t
show_suspend_status(struct device
*dev
,
529 struct device_attribute
*attr
, char *buf
)
531 struct usb_serial_port
*port
;
532 struct sierra_port_private
*portdata
;
533 struct sierra_intf_private
*intfdata
;
535 unsigned int flag_suspended
= 0;
537 port
= to_usb_serial_port(dev
);
538 portdata
= usb_get_serial_port_data(port
);
539 intfdata
= port
->serial
->private;
541 spin_lock_irqsave(&intfdata
->susp_lock
, flags
);
542 flag_suspended
= intfdata
->suspended
;
543 spin_unlock_irqrestore(&intfdata
->susp_lock
, flags
);
545 return snprintf(buf
, PORTION_LEN
, "%i\n", flag_suspended
);
548 static ssize_t
show_stats(struct device
*dev
,
549 struct device_attribute
*attr
, char *buf
)
551 struct usb_serial_port
*port
;
552 struct sierra_intf_private
*intfdata
;
554 port
= to_usb_serial_port(dev
);
555 intfdata
= port
->serial
->private;
557 return snprintf(buf
, PORTION_LEN
,
558 "rx: %i B\tindat: %i\tindat err: %i\n"
559 "tx: %i B\toutdat: %i\toutdat err: %i\n"
560 "writes: %i\t\twrite err: %i\n"
561 "delayed writes: %i\tdelayed write err: %i\n",
562 atomic_read(&intfdata
->stats
.rx_bytes
), atomic_read(&intfdata
->stats
.indat_cb_cnt
), atomic_read(&intfdata
->stats
.indat_cb_fail
),
563 atomic_read(&intfdata
->stats
.tx_bytes
), atomic_read(&intfdata
->stats
.outdat_cb_cnt
), atomic_read(&intfdata
->stats
.outdat_cb_fail
),
564 atomic_read(&intfdata
->stats
.write_cnt
), atomic_read(&intfdata
->stats
.write_err
),
565 atomic_read(&intfdata
->stats
.delayed_writes
), atomic_read(&intfdata
->stats
.delayed_write_err
)
569 /* Read only suspend status */
570 static DEVICE_ATTR(suspend_status
, S_IWUSR
| S_IRUGO
, show_suspend_status
,
573 /* Read only statistics */
574 static DEVICE_ATTR(stats
, S_IWUSR
| S_IRUGO
, show_stats
, NULL
);
576 static int sierra_create_sysfs_attrs(struct usb_serial_port
*port
)
580 result
= device_create_file(&port
->dev
, &dev_attr_stats
);
581 if (unlikely (result
< 0))
583 return device_create_file(&port
->dev
, &dev_attr_suspend_status
);
586 static int sierra_remove_sysfs_attrs(struct usb_serial_port
*port
)
588 device_remove_file(&port
->dev
, &dev_attr_stats
);
589 device_remove_file(&port
->dev
, &dev_attr_suspend_status
);
593 static void sierra_outdat_callback(struct urb
*urb
)
595 struct usb_serial_port
*port
= urb
->context
;
596 struct sierra_port_private
*portdata
= usb_get_serial_port_data(port
);
597 struct sierra_intf_private
*intfdata
;
598 int status
= urb
->status
;
600 dev_dbg(&port
->dev
, "%s - port %d\n", __func__
, port
->number
);
601 intfdata
= port
->serial
->private;
603 usb_autopm_put_interface_async(port
->serial
->interface
);
605 atomic_inc(&intfdata
->stats
.outdat_cb_cnt
);
608 dev_dbg(&port
->dev
, "%s - nonzero write bulk status "
609 "received: %d\n", __func__
, status
);
610 atomic_inc(&intfdata
->stats
.outdat_cb_fail
);
613 spin_lock(&portdata
->lock
);
614 --portdata
->outstanding_urbs
;
615 spin_unlock(&portdata
->lock
);
617 spin_lock(&intfdata
->susp_lock
);
618 --intfdata
->in_flight
;
619 spin_unlock(&intfdata
->susp_lock
);
621 usb_serial_port_softint(port
);
625 static int sierra_write(struct tty_struct
*tty
,
626 struct usb_serial_port
*port
,
627 const unsigned char *buf
, int count
)
629 struct sierra_port_private
*portdata
= usb_get_serial_port_data(port
);
630 struct sierra_intf_private
*intfdata
;
631 struct usb_serial
*serial
= port
->serial
;
633 unsigned char *buffer
;
635 size_t writesize
= min((size_t)count
, (size_t)MAX_TRANSFER
);
638 /* verify that we actually have some data to write */
642 dev_dbg(&port
->dev
, "%s: write (%zu bytes)\n", __func__
, writesize
);
644 intfdata
= serial
->private;
646 spin_lock_irqsave(&portdata
->lock
, flags
);
647 if (portdata
->outstanding_urbs
> portdata
->num_out_urbs
) {
648 spin_unlock_irqrestore(&portdata
->lock
, flags
);
649 dev_dbg(&port
->dev
, "%s - write limit hit\n", __func__
);
652 portdata
->outstanding_urbs
++;
653 spin_unlock_irqrestore(&portdata
->lock
, flags
);
655 retval
= usb_autopm_get_interface_async(serial
->interface
);
656 if (unlikely(retval
< 0)) {
657 spin_lock_irqsave(&portdata
->lock
, flags
);
658 portdata
->outstanding_urbs
--;
659 spin_unlock_irqrestore(&portdata
->lock
, flags
);
663 buffer
= kmalloc(writesize
, GFP_ATOMIC
);
665 dev_err(&port
->dev
, "out of memory\n");
666 spin_lock_irqsave(&portdata
->lock
, flags
);
667 --portdata
->outstanding_urbs
;
668 spin_unlock_irqrestore(&portdata
->lock
, flags
);
669 usb_autopm_put_interface_async(serial
->interface
);
673 urb
= usb_alloc_urb(0, GFP_ATOMIC
);
675 dev_err(&port
->dev
, "no more free urbs\n");
677 spin_lock_irqsave(&portdata
->lock
, flags
);
678 --portdata
->outstanding_urbs
;
679 spin_unlock_irqrestore(&portdata
->lock
, flags
);
680 usb_autopm_put_interface_async(serial
->interface
);
684 memcpy(buffer
, buf
, writesize
);
686 usb_serial_debug_data(debug
, &port
->dev
, __func__
, writesize
, buffer
);
688 usb_fill_bulk_urb(urb
, serial
->dev
,
689 usb_sndbulkpipe(serial
->dev
,
690 port
->bulk_out_endpointAddress
),
691 buffer
, writesize
, sierra_outdat_callback
, port
);
693 /* Handle the need to send a zero length packet and release the
696 urb
->transfer_flags
|= (URB_ZERO_PACKET
| URB_FREE_BUFFER
);
698 spin_lock_irqsave(&intfdata
->susp_lock
, flags
);
700 if (intfdata
->suspended
) {
701 usb_anchor_urb(urb
, &portdata
->delayed
);
702 spin_unlock_irqrestore(&intfdata
->susp_lock
, flags
);
703 /* release our reference to this urb, the USB core will
704 * eventually free it entirely */
708 usb_anchor_urb(urb
, &portdata
->active
);
710 /* send it down the pipe */
711 retval
= usb_submit_urb(urb
, GFP_ATOMIC
);
713 usb_unanchor_urb(urb
);
714 spin_unlock_irqrestore(&intfdata
->susp_lock
, flags
);
716 dev_err(&port
->dev
, "%s - usb_submit_urb(write bulk) failed "
717 "with status = %d\n", __func__
, retval
);
719 spin_lock_irqsave(&portdata
->lock
, flags
);
720 --portdata
->outstanding_urbs
;
721 spin_unlock_irqrestore(&portdata
->lock
, flags
);
722 usb_autopm_put_interface_async(serial
->interface
);
723 atomic_inc(&intfdata
->stats
.write_err
);
726 intfdata
->in_flight
++;
727 spin_unlock_irqrestore(&intfdata
->susp_lock
, flags
);
728 atomic_inc(&intfdata
->stats
.write_cnt
);
729 atomic_add(writesize
, &intfdata
->stats
.tx_bytes
);
731 /* release our reference to this urb, the USB core will eventually
732 * free it entirely */
738 static void sierra_indat_callback(struct urb
*urb
)
742 struct usb_serial_port
*port
= urb
->context
;
743 struct tty_struct
*tty
;
744 struct sierra_intf_private
*intfdata
;
745 unsigned char *data
= urb
->transfer_buffer
;
746 int status
= urb
->status
;
748 endpoint
= usb_pipeendpoint(urb
->pipe
);
750 dev_dbg(&port
->dev
, "%s: %p\n", __func__
, urb
);
752 intfdata
= port
->serial
->private;
754 atomic_inc(&intfdata
->stats
.indat_cb_cnt
); /* indat calls */
757 dev_dbg(&port
->dev
, "%s: nonzero status: %d on"
758 " endpoint %02x\n", __func__
, status
, endpoint
);
759 atomic_inc(&intfdata
->stats
.indat_cb_fail
); /* indat fails */
761 if (urb
->actual_length
) {
762 tty
= tty_port_tty_get(&port
->port
);
764 tty_insert_flip_string(tty
, data
,
766 tty_flip_buffer_push(tty
);
769 /* tty invalid after this point */
771 atomic_add(urb
->actual_length
,
772 &intfdata
->stats
.rx_bytes
);
773 usb_serial_debug_data(debug
, &port
->dev
,
774 __func__
, urb
->actual_length
, data
);
777 dev_dbg(&port
->dev
, "%s: empty read urb"
778 " received\n", __func__
);
782 /* Resubmit urb so we continue receiving */
783 if (status
!= -ESHUTDOWN
&& status
!= -ENOENT
&& status
!= -ENODEV
) {
784 usb_mark_last_busy(port
->serial
->dev
);
785 err
= usb_submit_urb(urb
, GFP_ATOMIC
);
786 if (err
&& err
!= -ENODEV
)
787 dev_err(&port
->dev
, "resubmit read urb failed."
794 static void sierra_instat_callback(struct urb
*urb
)
797 int status
= urb
->status
;
798 struct usb_serial_port
*port
= urb
->context
;
799 struct sierra_port_private
*portdata
= usb_get_serial_port_data(port
);
800 struct usb_serial
*serial
= port
->serial
;
802 dev_dbg(&port
->dev
, "%s: %p\n", __func__
, urb
);
805 struct usb_ctrlrequest
*req_pkt
=
806 (struct usb_ctrlrequest
*)urb
->transfer_buffer
;
808 const u16
*sigp
= (u16
*)(req_pkt
+ 1);
809 /* usb_ctrlrequest we parsed is followed by two bytes of data
810 * make sure we received that many bytes
812 if (urb
->actual_length
>= sizeof(*req_pkt
) + sizeof(*sigp
) &&
813 req_pkt
->bRequestType
== USB_REQUEST_TYPE_CLASS
&&
814 req_pkt
->bRequest
== USB_REQUEST_IFACE
) {
816 const u16 signals
= get_unaligned_le16(sigp
);
817 struct tty_struct
*tty
;
819 dev_dbg(&port
->dev
, "%s: signal 0x%x\n", __func__
,
822 old_dcd_state
= portdata
->dcd_state
;
823 /* Note: CTS from modem is in reverse logic! */
824 portdata
->cts_state
= ((signals
& 0x100) ? 0 : 1);
825 portdata
->dcd_state
= ((signals
& 0x01) ? 1 : 0);
826 portdata
->dsr_state
= ((signals
& 0x02) ? 1 : 0);
827 portdata
->ri_state
= ((signals
& 0x08) ? 1 : 0);
829 tty
= tty_port_tty_get(&port
->port
);
830 if (tty
&& !C_CLOCAL(tty
) &&
831 old_dcd_state
&& !portdata
->dcd_state
)
835 /* dump the data we don't understand to log */
836 usb_serial_debug_data(1, &port
->dev
, __func__
,
837 urb
->actual_length
, urb
->transfer_buffer
);
840 dev_dbg(&port
->dev
, "%s: error %d\n", __func__
, status
);
842 /* Resubmit urb so we continue receiving IRQ data */
843 if (status
!= -ESHUTDOWN
&& status
!= -ENOENT
&& status
!= -ENODEV
) {
844 usb_mark_last_busy(serial
->dev
);
845 urb
->dev
= serial
->dev
;
846 err
= usb_submit_urb(urb
, GFP_ATOMIC
);
847 if (err
&& err
!= -ENODEV
)
848 dev_err(&port
->dev
, "%s: resubmit intr urb "
849 "failed. (%d)\n", __func__
, err
);
853 static int sierra_write_room(struct tty_struct
*tty
)
855 struct usb_serial_port
*port
= tty
->driver_data
;
856 struct sierra_port_private
*portdata
= usb_get_serial_port_data(port
);
860 dev_dbg(&port
->dev
, "%s - port %d\n", __func__
, port
->number
);
862 /* try to give a good number back based on if we have any free urbs at
863 * this point in time */
864 retval
= MAX_TRANSFER
;
866 spin_lock_irqsave(&portdata
->lock
, flags
);
867 if (portdata
->outstanding_urbs
>= portdata
->num_out_urbs
) {
870 spin_unlock_irqrestore(&portdata
->lock
, flags
);
875 static void sierra_stop_rx_urbs(struct usb_serial_port
*port
)
878 struct sierra_port_private
*portdata
= usb_get_serial_port_data(port
);
880 for (i
= 0; i
< portdata
->num_in_urbs
; i
++)
881 usb_kill_urb(portdata
->in_urbs
[i
]);
883 usb_kill_urb(port
->interrupt_in_urb
);
886 static int sierra_submit_rx_urbs(struct usb_serial_port
*port
, gfp_t mem_flags
)
892 struct sierra_port_private
*portdata
= usb_get_serial_port_data(port
);
895 for (i
= 0; i
< portdata
->num_in_urbs
; i
++) {
896 urb
= portdata
->in_urbs
[i
];
899 urb
->transfer_flags
|= URB_FREE_BUFFER
;
900 err
= usb_submit_urb(urb
, mem_flags
);
902 dev_err(&port
->dev
, "%s: submit urb failed: %d\n",
909 if (ok_cnt
&& port
->interrupt_in_urb
) {
910 err
= usb_submit_urb(port
->interrupt_in_urb
, mem_flags
);
912 dev_err(&port
->dev
, "%s: submit intr urb failed: %d\n",
917 if (ok_cnt
> 0) /* at least one rx urb submitted */
923 static struct urb
*sierra_setup_urb(struct usb_serial
*serial
, int endpoint
,
924 int dir
, void *ctx
, int len
,
926 usb_complete_t callback
)
934 urb
= usb_alloc_urb(0, mem_flags
);
936 dev_dbg(&serial
->dev
->dev
, "%s: alloc for endpoint %d failed\n",
941 buf
= kmalloc(len
, mem_flags
);
943 /* Fill URB using supplied data */
944 usb_fill_bulk_urb(urb
, serial
->dev
,
945 usb_sndbulkpipe(serial
->dev
, endpoint
) | dir
,
946 buf
, len
, callback
, ctx
);
949 dev_dbg(&serial
->dev
->dev
, "%s %c u : %p d:%p\n", __func__
,
950 dir
== USB_DIR_IN
? 'i' : 'o', urb
, buf
);
952 dev_dbg(&serial
->dev
->dev
, "%s %c u:%p d:%p\n", __func__
,
953 dir
== USB_DIR_IN
? 'i' : 'o', urb
, buf
);
955 sierra_release_urb(urb
);
961 static void sierra_close(struct usb_serial_port
*port
)
965 struct usb_serial
*serial
= port
->serial
;
966 struct sierra_port_private
*portdata
;
967 struct sierra_intf_private
*intfdata
= port
->serial
->private;
969 dev_dbg(&port
->dev
, "%s\n", __func__
);
970 portdata
= usb_get_serial_port_data(port
);
972 portdata
->rts_state
= 0;
973 portdata
->dtr_state
= 0;
975 usb_autopm_get_interface(serial
->interface
);
978 mutex_lock(&serial
->disc_mutex
);
979 if (!serial
->disconnected
)
980 sierra_send_setup(port
);
981 mutex_unlock(&serial
->disc_mutex
);
982 spin_lock_irq(&intfdata
->susp_lock
);
983 portdata
->opened
= 0;
984 spin_unlock_irq(&intfdata
->susp_lock
);
986 /* Stop reading urbs */
987 sierra_stop_rx_urbs(port
);
988 /* .. and release them */
989 for (i
= 0; i
< portdata
->num_in_urbs
; i
++) {
990 sierra_release_urb(portdata
->in_urbs
[i
]);
991 portdata
->in_urbs
[i
] = NULL
;
993 while((urb
= usb_get_from_anchor(&portdata
->delayed
))) {
994 sierra_release_urb(urb
);
995 usb_autopm_put_interface(serial
->interface
);
997 /* wait for active to finish */
998 usb_wait_anchor_empty_timeout(&portdata
->active
, 500);
999 usb_kill_anchored_urbs(&portdata
->active
);
1004 static int sierra_open(struct tty_struct
*tty
, struct usb_serial_port
*port
)
1006 struct sierra_port_private
*portdata
;
1007 struct usb_serial
*serial
= port
->serial
;
1008 struct sierra_intf_private
*intfdata
= serial
->private;
1014 portdata
= usb_get_serial_port_data(port
);
1016 dev_dbg(&port
->dev
, "%s\n", __func__
);
1018 /* Set some sane defaults */
1019 portdata
->rts_state
= 1;
1020 portdata
->dtr_state
= 1;
1023 endpoint
= port
->bulk_in_endpointAddress
;
1024 for (i
= 0; i
< portdata
->num_in_urbs
; i
++) {
1025 urb
= sierra_setup_urb(serial
, endpoint
, USB_DIR_IN
, port
,
1026 IN_BUFLEN
, GFP_KERNEL
,
1027 sierra_indat_callback
);
1028 portdata
->in_urbs
[i
] = urb
;
1030 /* clear halt condition */
1031 usb_clear_halt(serial
->dev
,
1032 usb_sndbulkpipe(serial
->dev
, endpoint
) | USB_DIR_IN
);
1034 /* reset outstanding out urbs counter */
1035 spin_lock_irq(&portdata
->lock
);
1036 portdata
->outstanding_urbs
= 0;
1037 spin_unlock_irq(&portdata
->lock
);
1039 err
= sierra_submit_rx_urbs(port
, GFP_KERNEL
);
1041 /* do everything as in close() but do not call close() because
1042 * usbserial calls sierra_open() with mutex taken;
1043 * then if we call sierra_close() inside sierra_open() we
1044 * violate 'no nested mutexes' kernel condition
1046 portdata
->rts_state
= 0;
1047 portdata
->dtr_state
= 0;
1048 usb_autopm_get_interface(serial
->interface
);
1049 /* Stop reading urbs */
1050 sierra_stop_rx_urbs(port
);
1051 /* .. and release them */
1052 for (i
= 0; i
< portdata
->num_in_urbs
; i
++) {
1053 sierra_release_urb(portdata
->in_urbs
[i
]);
1054 portdata
->in_urbs
[i
] = NULL
;
1056 while((urb
= usb_get_from_anchor(&portdata
->delayed
))) {
1057 sierra_release_urb(urb
);
1058 usb_autopm_put_interface(serial
->interface
);
1060 /* wait for active to finish */
1061 usb_wait_anchor_empty_timeout(&portdata
->active
, 500);
1062 usb_kill_anchored_urbs(&portdata
->active
);
1063 /* restore balance for autopm */
1064 usb_autopm_put_interface(serial
->interface
);
1067 sierra_send_setup(port
);
1069 spin_lock_irq(&intfdata
->susp_lock
);
1070 portdata
->opened
= 1;
1071 spin_unlock_irq(&intfdata
->susp_lock
);
1072 usb_autopm_put_interface(serial
->interface
);
1077 static void sierra_dtr_rts(struct usb_serial_port
*port
, int on
)
1079 struct usb_serial
*serial
= port
->serial
;
1080 struct sierra_port_private
*portdata
;
1082 portdata
= usb_get_serial_port_data(port
);
1083 portdata
->rts_state
= on
;
1084 portdata
->dtr_state
= on
;
1087 mutex_lock(&serial
->disc_mutex
);
1088 if (!serial
->disconnected
)
1089 sierra_send_setup(port
);
1090 mutex_unlock(&serial
->disc_mutex
);
1094 static int sierra_startup(struct usb_serial
*serial
)
1096 struct usb_serial_port
*port
= NULL
;
1097 struct sierra_port_private
*portdata
= NULL
;
1098 struct sierra_iface_info
*himemoryp
= NULL
;
1104 dev_dbg(&serial
->dev
->dev
, "%s\n", __func__
);
1106 /* Set Device mode to D0 */
1107 sierra_set_power_state(serial
->dev
, 0x0000);
1109 /* Check NMEA and set */
1111 sierra_vsc_set_nmea(serial
->dev
, 1);
1113 if (serial
->num_ports
) {
1114 /* Note: One big piece of memory is allocated for all ports
1115 * private data in one shot. This memory is split into equal
1116 * pieces for each port.
1118 portdata
= (struct sierra_port_private
*)kzalloc
1119 (sizeof(*portdata
) * serial
->num_ports
, GFP_KERNEL
);
1121 dev_dbg(&serial
->dev
->dev
, "%s: No memory!\n", __func__
);
1126 /* Now setup per port private data */
1127 for (i
= 0; i
< serial
->num_ports
; i
++, portdata
++) {
1128 port
= serial
->port
[i
];
1129 /* Initialize selected members of private data because these
1130 * may be referred to right away */
1131 spin_lock_init(&portdata
->lock
);
1132 init_usb_anchor(&portdata
->active
);
1133 init_usb_anchor(&portdata
->delayed
);
1135 portdata
->cts_state
= 1;
1138 /* Assume low memory requirements */
1139 portdata
->num_out_urbs
= N_OUT_URB
;
1140 portdata
->num_in_urbs
= N_IN_URB
;
1142 /* Determine actual memory requirements */
1143 if (serial
->num_ports
== 1) {
1144 /* Get interface number for composite device */
1145 ifnum
= sierra_calc_interface(serial
);
1147 (struct sierra_iface_info
*)&typeB_interface_list
;
1148 if (is_himemory(ifnum
, himemoryp
)) {
1149 portdata
->num_out_urbs
= N_OUT_URB_HM
;
1150 portdata
->num_in_urbs
= N_IN_URB_HM
;
1155 (struct sierra_iface_info
*)&typeA_interface_list
;
1156 if (is_himemory(i
, himemoryp
)) {
1157 portdata
->num_out_urbs
= N_OUT_URB_HM
;
1158 portdata
->num_in_urbs
= N_IN_URB_HM
;
1161 dev_dbg(&serial
->dev
->dev
,
1162 "Memory usage (urbs) interface #%d, in=%d, out=%d\n",
1163 ifnum
,portdata
->num_in_urbs
, portdata
->num_out_urbs
);
1164 /* Set the port private data pointer */
1165 usb_set_serial_port_data(port
, portdata
);
1167 serial
->interface
->needs_remote_wakeup
= 1;
1169 result
= sierra_get_fw_attr(serial
->dev
, &fw_attr
);
1170 if (result
== sizeof(fw_attr
) && (fw_attr
& SWI_FW_ATTR_PM_MASK
) ) {
1171 dev_info(&serial
->dev
->dev
,
1172 "APM supported, enabling autosuspend.\n");
1173 /*******************************************************************************
1174 * If you want the default /sys/bus/usb/devices/.../.../power/level to be forced
1175 * to auto, the following needs to be compiled in.
1177 #ifdef POWER_LEVEL_AUTO
1178 /* make power level default be 'auto' */
1179 usb_enable_autosuspend(serial
->dev
);
1182 usb_disable_autosuspend(serial
->dev
);
1188 static void sierra_release(struct usb_serial
*serial
)
1191 struct usb_serial_port
*port
;
1192 struct sierra_intf_private
*intfdata
= serial
->private;
1194 dev_dbg(&serial
->dev
->dev
, "%s\n", __func__
);
1196 if (serial
->num_ports
> 0) {
1197 port
= serial
->port
[0];
1199 /* Note: The entire piece of memory that was allocated
1200 * in the startup routine can be released by passing
1201 * a pointer to the beginning of the piece.
1202 * This address corresponds to the address of the chunk
1203 * that was given to port 0.
1205 kfree(usb_get_serial_port_data(port
));
1208 for (i
= 0; i
< serial
->num_ports
; ++i
) {
1209 port
= serial
->port
[i
];
1212 usb_set_serial_port_data(port
, NULL
);
1218 static void stop_read_write_urbs(struct usb_serial
*serial
)
1221 struct usb_serial_port
*port
;
1222 struct sierra_port_private
*portdata
;
1224 /* Stop reading/writing urbs */
1225 for (i
= 0; i
< serial
->num_ports
; ++i
) {
1226 port
= serial
->port
[i
];
1227 portdata
= usb_get_serial_port_data(port
);
1228 sierra_stop_rx_urbs(port
);
1229 usb_kill_anchored_urbs(&portdata
->active
);
1233 static int sierra_suspend(struct usb_serial
*serial
, pm_message_t message
)
1235 struct sierra_intf_private
*intfdata
;
1237 dev_dbg(&serial
->dev
->dev
, "%s\n", __func__
);
1239 intfdata
= serial
->private;
1240 spin_lock_irq(&intfdata
->susp_lock
);
1242 if (message
.event
& PM_EVENT_AUTO
) {
1243 if (intfdata
->in_flight
) {
1244 spin_unlock_irq(&intfdata
->susp_lock
);
1248 intfdata
->suspended
= 1;
1249 spin_unlock_irq(&intfdata
->susp_lock
);
1251 stop_read_write_urbs(serial
);
1256 static int sierra_resume(struct usb_serial
*serial
)
1258 struct usb_serial_port
*port
;
1259 struct sierra_intf_private
*intfdata
= serial
->private;
1260 struct sierra_port_private
*portdata
;
1267 dev_dbg(&serial
->dev
->dev
, "%s\n", __func__
);
1269 spin_lock_irq(&intfdata
->susp_lock
);
1270 for (i
= 0; i
< serial
->num_ports
; i
++) {
1271 port
= serial
->port
[i
];
1272 portdata
= usb_get_serial_port_data(port
);
1274 while ((urb
= usb_get_from_anchor(&portdata
->delayed
))) {
1275 usb_anchor_urb(urb
, &portdata
->active
);
1276 intfdata
->in_flight
++;
1277 len
= urb
->transfer_buffer_length
;
1278 err
= usb_submit_urb(urb
, GFP_ATOMIC
);
1280 intfdata
->in_flight
--;
1281 usb_unanchor_urb(urb
);
1283 atomic_inc(&intfdata
->stats
.delayed_write_err
);
1284 /* fix pm_usage_cnt */
1285 usb_autopm_put_interface_async(
1286 port
->serial
->interface
);
1288 atomic_inc(&intfdata
->stats
.delayed_writes
);
1289 atomic_add(len
, &intfdata
->stats
.tx_bytes
);
1291 /* release urb - usb_get_from_anchor increased kref */
1295 if (portdata
->opened
) {
1296 err
= sierra_submit_rx_urbs(port
, GFP_ATOMIC
);
1300 if (failed_submits
) {
1301 /* fix outstanding_urbs counter */
1302 spin_lock(&portdata
->lock
); /* assuming irq disabled */
1303 portdata
->outstanding_urbs
-= failed_submits
;
1304 spin_unlock(&portdata
->lock
);
1305 /* unblock a writer */
1306 usb_serial_port_softint(port
);
1309 intfdata
->suspended
= 0;
1310 spin_unlock_irq(&intfdata
->susp_lock
);
1312 return ec
? -EIO
: 0;
1315 #define sierra_suspend NULL
1316 #define sierra_resume NULL
1319 static int sierra_reset_resume(struct usb_interface
*intf
)
1321 struct usb_serial
*serial
= usb_get_intfdata(intf
);
1322 dev_err(&serial
->dev
->dev
, "%s\n", __func__
);
1323 return usb_serial_resume(intf
);
1326 static struct usb_driver sierra_driver
= {
1328 .probe
= usb_serial_probe
,
1329 .disconnect
= usb_serial_disconnect
,
1330 .suspend
= usb_serial_suspend
,
1331 .resume
= usb_serial_resume
,
1332 .reset_resume
= sierra_reset_resume
,
1333 .id_table
= id_table
,
1336 .supports_autosuspend
= 1,
1340 static struct usb_serial_driver sierra_device
= {
1342 .owner
= THIS_MODULE
,
1345 .description
= "Sierra USB modem",
1346 .id_table
= id_table
,
1347 .usb_driver
= &sierra_driver
,
1348 .calc_num_ports
= sierra_calc_num_ports
,
1349 .probe
= sierra_probe
,
1350 .open
= sierra_open
,
1351 .close
= sierra_close
,
1352 .dtr_rts
= sierra_dtr_rts
,
1353 .write
= sierra_write
,
1354 .write_room
= sierra_write_room
,
1355 .set_termios
= sierra_set_termios
,
1356 .tiocmget
= sierra_tiocmget
,
1357 .tiocmset
= sierra_tiocmset
,
1358 .attach
= sierra_startup
,
1359 .release
= sierra_release
,
1360 .port_probe
= sierra_create_sysfs_attrs
,
1361 .port_remove
= sierra_remove_sysfs_attrs
,
1362 .suspend
= sierra_suspend
,
1363 .resume
= sierra_resume
,
1364 .read_int_callback
= sierra_instat_callback
,
1368 /* Functions used by new usb-serial code. */
1369 static int __init
sierra_init(void)
1372 retval
= usb_serial_register(&sierra_device
);
1374 goto failed_device_register
;
1376 retval
= usb_register(&sierra_driver
);
1378 goto failed_driver_register
;
1380 printk(KERN_INFO KBUILD_MODNAME
": " DRIVER_VERSION
":"
1385 failed_driver_register
:
1386 usb_serial_deregister(&sierra_device
);
1387 failed_device_register
:
1391 static void __exit
sierra_exit(void)
1393 usb_deregister(&sierra_driver
);
1394 usb_serial_deregister(&sierra_device
);
1397 module_init(sierra_init
);
1398 module_exit(sierra_exit
);
1400 MODULE_AUTHOR(DRIVER_AUTHOR
);
1401 MODULE_DESCRIPTION(DRIVER_DESC
);
1402 MODULE_VERSION(DRIVER_VERSION
);
1403 MODULE_LICENSE("GPL");
1405 module_param(nmea
, bool, S_IRUGO
| S_IWUSR
);
1406 MODULE_PARM_DESC(nmea
, "NMEA streaming");
1408 module_param(debug
, bool, S_IRUGO
| S_IWUSR
);
1409 MODULE_PARM_DESC(debug
, "Debug messages");