1 diff -Naur linux-2.4.35.4-old/drivers/usb/serial/sierra.c linux-2.4.35.4/drivers/usb/serial/sierra.c
2 --- linux-2.4.35.4-old/drivers/usb/serial/sierra.c 1969-12-31 17:00:00.000000000 -0700
3 +++ linux-2.4.35.4/drivers/usb/serial/sierra.c 2008-01-25 10:21:25.747868456 -0700
6 + * Sierra Wireless CDMA Wireless Serial USB drive
8 + * Current Copy modified by: Kevin Lloyd <linux@sierrawireless.com>
9 + * Original Copy written by: 2005 Greg Kroah-Hartman <gregkh <at> suse.de>
12 + * This program is free software; you can redistribute it and/or
13 + * modify it under the terms of the GNU General Public License version
14 + * 2 as published by the Free Software Foundation.
17 + Version 1.03 (Lloyd):
18 + Included support for DTR control and enhanced buffering (should help
22 +#include <linux/config.h>
23 +#include <linux/kernel.h>
24 +#include <linux/init.h>
25 +#include <linux/slab.h>
26 +#include <linux/tty.h>
27 +#include <linux/tty_driver.h>
28 +#include <linux/tty_flip.h>
29 +#include <linux/module.h>
30 +#include <linux/usb.h>
31 +#include <linux/mm.h>
32 +#include <asm/uaccess.h>
33 +#include <linux/errno.h>
34 +#include <linux/list.h>
35 +#include <linux/spinlock.h>
36 +#include <linux/smp_lock.h>
38 +#ifdef CONFIG_USB_SERIAL_DEBUG
39 + static int debug = 1;
44 +#include "usb-serial.h"
46 +#if defined(CONFIG_USB_SERIAL_PL2303) || defined(CONFIG_USB_SERIAL_PL2303_MODULE)
47 +#include "pl2303.h" // see /* BEGIN HORRIBLE HACK FOR PL2303 */ below
50 +#define DRIVER_VERSION "v1.03"
53 +#define USB_VENDER_REQUEST_SET_DEVICE_POWER_STATE 0
55 +#define USB_DEVICE_POWER_STATE_D0 0x0000
56 +#define USB_DEVICE_POWER_STATE_D1 0x0001
57 +#define USB_DEVICE_POWER_STATE_D2 0x0002
58 +#define USB_DEVICE_POWER_STATE_D3 0x0003
60 +#define SET_CONTROL_LINE_STATE 0x22
62 + * Output control lines.
65 +#define ACM_CTRL_DTR 0x01
66 +#define ACM_CTRL_RTS 0x02
69 +//static int sw_attach(struct usb_serial *serial);
70 +static void sw_usb_serial_generic_shutdown(struct usb_serial *serial);
72 +static int sw_usb_serial_generic_open(struct usb_serial_port *port, struct file *filp);
73 +static void sw_usb_serial_generic_close(struct usb_serial_port *port, struct file *filp);
76 +/*-----------------------------------------------------------*/
77 +static int serial_refcount;
78 +static struct tty_driver serial_tty_driver;
79 +static struct tty_struct * serial_tty[SERIAL_TTY_MINORS];
80 +static struct termios * serial_termios[SERIAL_TTY_MINORS];
81 +static struct termios * serial_termios_locked[SERIAL_TTY_MINORS];
82 +static struct usb_serial *serial_table[SERIAL_TTY_MINORS]; /* initially all NULL */
84 +static LIST_HEAD(usb_serial_driver_list);
85 +static struct usb_serial *get_free_serial (int num_ports, int *minor);
86 +static void generic_write_bulk_callback (struct urb *urb);
87 +static void * usb_serial_probe(struct usb_device *dev, unsigned int ifnum,const struct usb_device_id *id);
88 +static void usb_serial_disconnect(struct usb_device *dev, void *ptr);
89 +static void sw_usb_serial_generic_read_bulk_callback (struct urb *urb);
90 +static void port_softint(void *private);
91 +static void return_serial (struct usb_serial *serial);
92 +static struct usb_serial *get_free_serial (int num_ports, int *minor);
93 +static int serial_read_proc (char *page, char **start, off_t off, int count, int *eof, void *data);
94 +/*-----------------------------------------------------------*/
99 +static struct usb_device_id id_table [] = {
100 + { USB_DEVICE(0x1199, 0x0017) }, /* Sierra Wireless EM5625 */
101 + { USB_DEVICE(0x1199, 0x0018) }, /* Sierra Wireless MC5720 */
102 + { USB_DEVICE(0x1199, 0x0218) }, /* Sierra Wireless MC5720 */
103 + { USB_DEVICE(0x0f30, 0x1b1d) }, /* Sierra Wireless MC5720 */
104 + { USB_DEVICE(0x1199, 0x0020) }, /* Sierra Wireless MC5725 */
105 + { USB_DEVICE(0x1199, 0x0220) }, /* Sierra Wireless MC5725 */
106 + { USB_DEVICE(0x1199, 0x0019) }, /* Sierra Wireless AirCard 595 */
107 + { USB_DEVICE(0x1199, 0x0021) }, /* Sierra Wireless AirCard 597E */
108 + { USB_DEVICE(0x1199, 0x0120) }, /* Sierra Wireless USB Dongle 595U */
109 + { USB_DEVICE(0x1199, 0x0023) }, /* Sierra Wireless C597 */
111 + { USB_DEVICE(0x1199, 0x6802) }, /* Sierra Wireless MC8755 */
112 + { USB_DEVICE(0x1199, 0x6804) }, /* Sierra Wireless MC8755 */
113 + { USB_DEVICE(0x1199, 0x6803) }, /* Sierra Wireless MC8765 */
114 + { USB_DEVICE(0x1199, 0x6812) }, /* Sierra Wireless MC8775 & AC 875U */
115 + { USB_DEVICE(0x1199, 0x6813) }, /* Sierra Wireless MC8775 (Thinkpad internal) */
116 + { USB_DEVICE(0x1199, 0x6815) }, /* Sierra Wireless MC8775 */
117 + { USB_DEVICE(0x03f0, 0x1e1d) }, /* HP hs2300 a.k.a MC8775 */
118 + { USB_DEVICE(0x1199, 0x6820) }, /* Sierra Wireless AirCard 875 */
119 + { USB_DEVICE(0x1199, 0x6821) }, /* Sierra Wireless AirCard 875U */
120 + { USB_DEVICE(0x1199, 0x6832) }, /* Sierra Wireless MC8780*/
121 + { USB_DEVICE(0x1199, 0x6833) }, /* Sierra Wireless MC8781*/
122 + { USB_DEVICE(0x1199, 0x683B) }, /* Sierra Wireless MC8785 Composite*/
123 + { USB_DEVICE(0x1199, 0x6850) }, /* Sierra Wireless AirCard 880 */
124 + { USB_DEVICE(0x1199, 0x6851) }, /* Sierra Wireless AirCard 881 */
125 + { USB_DEVICE(0x1199, 0x6852) }, /* Sierra Wireless AirCard 880 E */
126 + { USB_DEVICE(0x1199, 0x6853) }, /* Sierra Wireless AirCard 881 E */
127 + { USB_DEVICE(0x1199, 0x6855) }, /* Sierra Wireless AirCard 880 U */
128 + { USB_DEVICE(0x1199, 0x6856) }, /* Sierra Wireless AirCard 881 U */
129 + { USB_DEVICE(0x1199, 0x6859) }, /* Sierra Wireless AirCard 885 E */
130 + { USB_DEVICE(0x1199, 0x685A) }, /* Sierra Wireless AirCard 885 E */
132 + { USB_DEVICE(0x1199, 0x6468) }, /* Sierra Wireless MP3G - EVDO */
133 + { USB_DEVICE(0x1199, 0x6469) }, /* Sierra Wireless MP3G - UMTS/HSPA */
135 + { USB_DEVICE(0x1199, 0x0112) }, /* Sierra Wireless AirCard 580 */
136 + { USB_DEVICE(0x0F3D, 0x0112) }, /* AirPrime/Sierra Wireless PC 5220 */
137 + { USB_DEVICE(0x05C6, 0x6613) }, /* Onda H600/ZTE MF330 */
141 +MODULE_DEVICE_TABLE(usb, id_table);
143 +static struct usb_driver sierra_driver = {
144 +// .owner = THIS_MODULE,
145 + .name = "Sierra wireless",
146 + .probe = usb_serial_probe,
147 + .disconnect = usb_serial_disconnect,
148 + .id_table = id_table,
151 +static struct usb_serial_device_type sierra_device = {
153 + .owner = THIS_MODULE,
154 + .name = "Sierra Wireless",
156 + .id_table = id_table,
157 + .num_interrupt_in = NUM_DONT_CARE,
158 + .num_bulk_in = NUM_DONT_CARE,
159 + .num_bulk_out = NUM_DONT_CARE,
161 + //.startup = sw_attach,
162 + .shutdown = sw_usb_serial_generic_shutdown,
163 + .open = sw_usb_serial_generic_open,
164 + .close = sw_usb_serial_generic_close,
167 +#define MAX_NUM_PORTS 8
169 +/* local function prototypes */
170 +static int serial_open (struct tty_struct *tty, struct file * filp);
171 +static void serial_close (struct tty_struct *tty, struct file * filp);
172 +static int serial_write (struct tty_struct * tty, int from_user, const unsigned char *buf, int count);
173 +static int serial_write_room (struct tty_struct *tty);
174 +static int serial_chars_in_buffer (struct tty_struct *tty);
175 +static void serial_throttle (struct tty_struct * tty);
176 +static void serial_unthrottle (struct tty_struct * tty);
177 +static int serial_ioctl (struct tty_struct *tty, struct file * file, unsigned int cmd, unsigned long arg);
178 +static void serial_set_termios (struct tty_struct *tty, struct termios * old);
179 +//static void serial_shutdown (struct usb_serial *serial);
180 +static void serial_break (struct tty_struct *tty, int break_state);
181 +static int generic_write (struct usb_serial_port *port, int from_user, const unsigned char *buf, int count);
182 +static int generic_write_room (struct usb_serial_port *port);
183 +static void generic_cleanup (struct usb_serial_port *port);
184 +static int generic_chars_in_buffer (struct usb_serial_port *port);
185 +//static void generic_shutdown (struct usb_serial *serial);
188 +static struct tty_driver serial_tty_driver = {
189 + .magic = TTY_DRIVER_MAGIC,
190 + .driver_name = "usb-serial",
191 +#ifndef CONFIG_DEVFS_FS
194 + .name = "usb/tts/%d",
196 + .major = SERIAL_TTY_MAJOR,
198 + .num = SERIAL_TTY_MINORS,
199 + .type = TTY_DRIVER_TYPE_SERIAL,
200 + .subtype = SERIAL_TYPE_NORMAL,
201 + .flags = TTY_DRIVER_REAL_RAW | TTY_DRIVER_NO_DEVFS,
203 + .refcount = &serial_refcount,
204 + .table = serial_tty,
205 + .termios = serial_termios,
206 + .termios_locked = serial_termios_locked,
208 + .open = serial_open,
209 + .close = serial_close,
210 + .write = serial_write,
211 + .write_room = serial_write_room,
212 + .ioctl = serial_ioctl,
213 + .set_termios = serial_set_termios,
214 + .throttle = serial_throttle,
215 + .unthrottle = serial_unthrottle,
216 + .break_ctl = serial_break,
217 + .chars_in_buffer = serial_chars_in_buffer,
218 + .read_proc = serial_read_proc,
223 +/*****************************************************************************
224 + * Driver tty interface functions
225 + *****************************************************************************/
226 +static struct usb_serial *get_serial_by_minor (unsigned int minor)
228 + return serial_table[minor];
231 +static int serial_open (struct tty_struct *tty, struct file * filp)
233 + struct usb_serial *serial;
234 + struct usb_serial_port *port;
235 + unsigned int portNumber;
238 + dbg("%s", __FUNCTION__);
240 + /* initialize the pointer incase something fails */
241 + tty->driver_data = NULL;
243 + /* get the serial object associated with this tty pointer */
244 + serial = get_serial_by_minor (MINOR(tty->device));
246 + if (serial_paranoia_check (serial, __FUNCTION__))
249 + /* set up our port structure making the tty driver remember our port object, and us it */
250 + portNumber = MINOR(tty->device) - serial->minor;
251 + port = &serial->port[portNumber];
252 + tty->driver_data = port;
257 + /* lock this module before we call it */
258 + if (serial->type->owner)
259 + __MOD_INC_USE_COUNT(serial->type->owner);
261 + ++port->open_count;
262 + if (port->open_count == 1) {
263 + /* only call the device specific open if this
264 + * is the first time the port is opened */
265 + if (serial->type->open)
266 + retval = serial->type->open(port, filp);
268 + retval = sw_usb_serial_generic_open(port, filp);//@.@
272 + port->open_count = 0;
273 + if (serial->type->owner)
274 + __MOD_DEC_USE_COUNT(serial->type->owner);
281 +static void __serial_close(struct usb_serial_port *port, struct file *filp)
283 + if (!port->open_count) {
284 + dbg ("%s - port not opened", __FUNCTION__);
288 + --port->open_count;
289 + if (port->open_count <= 0) {
290 + /* only call the device specific close if this
291 + * port is being closed by the last owner */
292 + if (port->serial->type->close)
293 + port->serial->type->close(port, filp);
295 + //generic_close(port, filp);
296 + sw_usb_serial_generic_close(port, filp);
297 + port->open_count = 0;
300 + if (port->serial->type->owner)
301 + __MOD_DEC_USE_COUNT(port->serial->type->owner);
304 +static void serial_close(struct tty_struct *tty, struct file * filp)
306 + struct usb_serial_port *port = (struct usb_serial_port *) tty->driver_data;
307 + struct usb_serial *serial = get_usb_serial (port, __FUNCTION__);
314 + dbg("%s - port %d", __FUNCTION__, port->number);
316 + /* if disconnect beat us to the punch here, there's nothing to do */
317 + if (tty->driver_data) {
318 + __serial_close(port, filp);
324 +static int serial_write (struct tty_struct * tty, int from_user, const unsigned char *buf, int count)
326 + struct usb_serial_port *port = (struct usb_serial_port *) tty->driver_data;
327 + struct usb_serial *serial = get_usb_serial (port, __FUNCTION__);
328 + int retval = -EINVAL;
335 + dbg("%s - port %d, %d byte(s)", __FUNCTION__, port->number, count);
337 + if (!port->open_count) {
338 + dbg("%s - port not opened", __FUNCTION__);
342 + /* pass on to the driver specific version of this function if it is available */
343 + if (serial->type->write)
344 + retval = serial->type->write(port, from_user, buf, count);
346 + retval = generic_write(port, from_user, buf, count);
353 +static int serial_write_room (struct tty_struct *tty)
355 + struct usb_serial_port *port = (struct usb_serial_port *) tty->driver_data;
356 + struct usb_serial *serial = get_usb_serial (port, __FUNCTION__);
357 + int retval = -EINVAL;
364 + dbg("%s - port %d", __FUNCTION__, port->number);
366 + if (!port->open_count) {
367 + dbg("%s - port not open", __FUNCTION__);
371 + /* pass on to the driver specific version of this function if it is available */
372 + if (serial->type->write_room)
373 + retval = serial->type->write_room(port);
375 + retval = generic_write_room(port);
382 +static int serial_chars_in_buffer (struct tty_struct *tty)
384 + struct usb_serial_port *port = (struct usb_serial_port *) tty->driver_data;
385 + struct usb_serial *serial = get_usb_serial (port, __FUNCTION__);
386 + int retval = -EINVAL;
393 + dbg("%s = port %d", __FUNCTION__, port->number);
395 + if (!port->open_count) {
396 + dbg("%s - port not open", __FUNCTION__);
400 + /* pass on to the driver specific version of this function if it is available */
401 + if (serial->type->chars_in_buffer)
402 + retval = serial->type->chars_in_buffer(port);
404 + retval = generic_chars_in_buffer(port);
411 +static void serial_throttle (struct tty_struct * tty)
413 + struct usb_serial_port *port = (struct usb_serial_port *) tty->driver_data;
414 + struct usb_serial *serial = get_usb_serial (port, __FUNCTION__);
421 + dbg("%s - port %d", __FUNCTION__, port->number);
423 + if (!port->open_count) {
424 + dbg ("%s - port not open", __FUNCTION__);
428 + /* pass on to the driver specific version of this function */
429 + if (serial->type->throttle)
430 + serial->type->throttle(port);
436 +static void serial_unthrottle (struct tty_struct * tty)
438 + struct usb_serial_port *port = (struct usb_serial_port *) tty->driver_data;
439 + struct usb_serial *serial = get_usb_serial (port, __FUNCTION__);
446 + dbg("%s - port %d", __FUNCTION__, port->number);
448 + if (!port->open_count) {
449 + dbg("%s - port not open", __FUNCTION__);
453 + /* pass on to the driver specific version of this function */
454 + if (serial->type->unthrottle)
455 + serial->type->unthrottle(port);
461 +static int serial_ioctl (struct tty_struct *tty, struct file * file, unsigned int cmd, unsigned long arg)
463 + struct usb_serial_port *port = (struct usb_serial_port *) tty->driver_data;
464 + struct usb_serial *serial = get_usb_serial (port, __FUNCTION__);
465 + int retval = -ENODEV;
472 + dbg("%s - port %d, cmd 0x%.4x", __FUNCTION__, port->number, cmd);
474 + if (!port->open_count) {
475 + dbg ("%s - port not open", __FUNCTION__);
479 + /* pass on to the driver specific version of this function if it is available */
480 + if (serial->type->ioctl)
481 + retval = serial->type->ioctl(port, file, cmd, arg);
483 + retval = -ENOIOCTLCMD;
490 +static void serial_set_termios (struct tty_struct *tty, struct termios * old)
492 + struct usb_serial_port *port = (struct usb_serial_port *) tty->driver_data;
493 + struct usb_serial *serial = get_usb_serial (port, __FUNCTION__);
500 + dbg("%s - port %d", __FUNCTION__, port->number);
502 + if (!port->open_count) {
503 + dbg("%s - port not open", __FUNCTION__);
507 + /* pass on to the driver specific version of this function if it is available */
508 + if (serial->type->set_termios)
509 + serial->type->set_termios(port, old);
515 +static void serial_break (struct tty_struct *tty, int break_state)
517 + struct usb_serial_port *port = (struct usb_serial_port *) tty->driver_data;
518 + struct usb_serial *serial = get_usb_serial (port, __FUNCTION__);
525 + dbg("%s - port %d", __FUNCTION__, port->number);
527 + if (!port->open_count) {
528 + dbg("%s - port not open", __FUNCTION__);
532 + /* pass on to the driver specific version of this function if it is available */
533 + if (serial->type->break_ctl)
534 + serial->type->break_ctl(port, break_state);
540 +static void serial_shutdown (struct usb_serial *serial)
542 + dbg ("%s", __FUNCTION__);
544 + if (serial->type->shutdown)
545 + serial->type->shutdown(serial);
547 + generic_shutdown(serial);
550 +static int serial_read_proc (char *page, char **start, off_t off, int count, int *eof, void *data)
552 + struct usb_serial *serial;
558 + dbg("%s", __FUNCTION__);
559 + length += sprintf (page, "usbserinfo:1.0 driver:%s\n", DRIVER_VERSION);
560 + for (i = 0; i < SERIAL_TTY_MINORS && length < PAGE_SIZE; ++i) {
561 + serial = get_serial_by_minor(i);
562 + if (serial == NULL)
565 + length += sprintf (page+length, "%d:", i);
566 + if (serial->type->owner)
567 + length += sprintf (page+length, " module:%s", serial->type->owner->name);
568 + length += sprintf (page+length, " name:\"%s\"", serial->type->name);
569 + length += sprintf (page+length, " vendor:%04x product:%04x", serial->vendor, serial->product);
570 + length += sprintf (page+length, " num_ports:%d", serial->num_ports);
571 + length += sprintf (page+length, " port:%d", i - serial->minor + 1);
573 + usb_make_path(serial->dev, tmp, sizeof(tmp));
574 + length += sprintf (page+length, " path:%s", tmp);
576 + length += sprintf (page+length, "\n");
577 + if ((length + begin) > (off + count))
579 + if ((length + begin) < off) {
586 + if (off >= (length + begin))
588 + *start = page + (off-begin);
589 + return ((count < begin+length-off) ? count : begin+length-off);
593 +/*-----------------------------------------------------------*/
594 +static int generic_write (struct usb_serial_port *port, int from_user, const unsigned char *buf, int count)
596 + struct usb_serial *serial = port->serial;
599 + dbg("%s - port %d", __FUNCTION__, port->number);
602 + dbg("%s - write request of 0 bytes", __FUNCTION__);
606 + /* only do something if we have a bulk out endpoint */
607 + if (serial->num_bulk_out) {
608 + if (port->write_urb->status == -EINPROGRESS) {
609 + dbg("%s - already writing", __FUNCTION__);
613 + count = (count > port->bulk_out_size) ? port->bulk_out_size : count;
616 + if (copy_from_user(port->write_urb->transfer_buffer, buf, count))
620 + memcpy (port->write_urb->transfer_buffer, buf, count);
623 + usb_serial_debug_data (__FILE__, __FUNCTION__, count, port->write_urb->transfer_buffer);
625 + /* set up our urb */
626 + usb_fill_bulk_urb (port->write_urb, serial->dev,
627 + usb_sndbulkpipe (serial->dev,
628 + port->bulk_out_endpointAddress),
629 + port->write_urb->transfer_buffer, count,
630 + ((serial->type->write_bulk_callback) ?
631 + serial->type->write_bulk_callback :
632 + generic_write_bulk_callback), port);
634 + /* send the data out the bulk port */
635 + result = usb_submit_urb(port->write_urb);
637 + err("%s - failed submitting write urb, error %d", __FUNCTION__, result);
644 + /* no bulk out, so return 0 bytes written */
648 +static int generic_write_room (struct usb_serial_port *port)
650 + struct usb_serial *serial = port->serial;
653 + dbg("%s - port %d", __FUNCTION__, port->number);
655 + if (serial->num_bulk_out) {
656 + if (port->write_urb->status != -EINPROGRESS)
657 + room = port->bulk_out_size;
660 + dbg("%s - returns %d", __FUNCTION__, room);
664 +static int generic_chars_in_buffer (struct usb_serial_port *port)
666 + struct usb_serial *serial = port->serial;
669 + dbg("%s - port %d", __FUNCTION__, port->number);
671 + if (serial->num_bulk_out) {
672 + if (port->write_urb->status == -EINPROGRESS)
673 + chars = port->write_urb->transfer_buffer_length;
676 + dbg("%s - returns %d", __FUNCTION__, chars);
680 +static void generic_shutdown (struct usb_serial *serial)
684 + dbg("%s", __FUNCTION__);
686 + /* stop reads and writes on all ports */
687 + for (i=0; i < serial->num_ports; ++i) {
688 + generic_cleanup (&serial->port[i]);
691 +static void generic_cleanup (struct usb_serial_port *port)
693 + struct usb_serial *serial = port->serial;
695 + dbg("%s - port %d", __FUNCTION__, port->number);
698 + /* shutdown any bulk reads that might be going on */
699 + if (serial->num_bulk_out)
700 + usb_unlink_urb (port->write_urb);
701 + if (serial->num_bulk_in)
702 + usb_unlink_urb (port->read_urb);
706 +/*----------------------------------------------------------*/
707 +static void generic_write_bulk_callback (struct urb *urb)
709 + struct usb_serial_port *port = (struct usb_serial_port *)urb->context;
710 + struct usb_serial *serial = get_usb_serial (port, __FUNCTION__);
712 + dbg("%s - port %d", __FUNCTION__, port->number);
715 + dbg("%s - bad serial pointer, exiting", __FUNCTION__);
720 + dbg("%s - nonzero write bulk status received: %d", __FUNCTION__, urb->status);
724 + queue_task(&port->tqueue, &tq_immediate);
725 + mark_bh(IMMEDIATE_BH);
730 +static struct usb_serial *get_free_serial (int num_ports, int *minor)
732 + struct usb_serial *serial = NULL;
736 + dbg("%s %d", __FUNCTION__, num_ports);
739 + for (i = 0; i < SERIAL_TTY_MINORS; ++i) {
740 + if (serial_table[i])
744 + for (j = 1; j <= num_ports-1; ++j)
745 + if (serial_table[i+j])
747 + if (good_spot == 0)
750 + if (!(serial = kmalloc(sizeof(struct usb_serial), GFP_KERNEL))) {
751 + err("%s - Out of memory", __FUNCTION__);
754 + memset(serial, 0, sizeof(struct usb_serial));
755 + serial->magic = USB_SERIAL_MAGIC;
756 + serial_table[i] = serial;
758 + dbg("%s - minor base = %d", __FUNCTION__, *minor);
759 + for (i = *minor+1; (i < (*minor + num_ports)) && (i < SERIAL_TTY_MINORS); ++i)
760 + serial_table[i] = serial;
766 +static void return_serial (struct usb_serial *serial)
770 + dbg("%s", __FUNCTION__);
772 + if (serial == NULL)
775 + for (i = 0; i < serial->num_ports; ++i) {
776 + serial_table[serial->minor + i] = NULL;
782 +static void port_softint(void *private)
784 + struct usb_serial_port *port = (struct usb_serial_port *)private;
785 + struct usb_serial *serial = get_usb_serial (port, __FUNCTION__);
786 + struct tty_struct *tty;
788 + dbg("%s - port %d", __FUNCTION__, port->number);
797 + if ((tty->flags & (1 << TTY_DO_WRITE_WAKEUP)) && tty->ldisc.write_wakeup) {
798 + dbg("%s - write wakeup call.", __FUNCTION__);
799 + (tty->ldisc.write_wakeup)(tty);
802 + wake_up_interruptible(&tty->write_wait);
806 +static void * usb_serial_probe(struct usb_device *dev, unsigned int ifnum,
807 + const struct usb_device_id *id)
809 + struct usb_serial *serial = NULL;
810 + struct usb_serial_port *port;
811 + struct usb_interface *interface;
812 + struct usb_interface_descriptor *iface_desc;
813 + struct usb_endpoint_descriptor *endpoint;
814 + struct usb_endpoint_descriptor *interrupt_in_endpoint[MAX_NUM_PORTS];
815 + struct usb_endpoint_descriptor *bulk_in_endpoint[MAX_NUM_PORTS];
816 + struct usb_endpoint_descriptor *bulk_out_endpoint[MAX_NUM_PORTS];
817 + struct usb_serial_device_type *type = NULL;
818 + struct list_head *tmp;
823 + int num_interrupt_in = 0;
824 + int num_bulk_in = 0;
825 + int num_bulk_out = 0;
828 + const struct usb_device_id *id_pattern = NULL;
830 + /* loop through our list of known serial converters, and see if this
833 + interface = &dev->actconfig->interface[ifnum];
834 + list_for_each (tmp, &usb_serial_driver_list) {
835 + type = list_entry(tmp, struct usb_serial_device_type, driver_list);
836 + id_pattern = usb_match_id(dev, interface, type->id_table);
837 + if (id_pattern != NULL) {
838 + dbg("descriptor matches");
845 + dbg("none matched");
848 + /* descriptor matches, let's find the endpoints needed */
849 + /* check out the endpoints */
850 + iface_desc = &interface->altsetting[0];
851 + for (i = 0; i < iface_desc->bNumEndpoints; ++i) {
852 + endpoint = &iface_desc->endpoint[i];
854 + if ((endpoint->bEndpointAddress & 0x80) &&
855 + ((endpoint->bmAttributes & 3) == 0x02)) {
856 + /* we found a bulk in endpoint */
857 + dbg("found bulk in");
858 + bulk_in_endpoint[num_bulk_in] = endpoint;
862 + if (((endpoint->bEndpointAddress & 0x80) == 0x00) &&
863 + ((endpoint->bmAttributes & 3) == 0x02)) {
864 + /* we found a bulk out endpoint */
865 + dbg("found bulk out");
866 + bulk_out_endpoint[num_bulk_out] = endpoint;
870 + if ((endpoint->bEndpointAddress & 0x80) &&
871 + ((endpoint->bmAttributes & 3) == 0x03)) {
872 + /* we found a interrupt in endpoint */
873 + dbg("found interrupt in");
874 + interrupt_in_endpoint[num_interrupt_in] = endpoint;
875 + ++num_interrupt_in;
879 +#if defined(CONFIG_USB_SERIAL_PL2303) || defined(CONFIG_USB_SERIAL_PL2303_MODULE)
880 + /* BEGIN HORRIBLE HACK FOR PL2303 */
881 + /* this is needed due to the looney way its endpoints are set up */
882 + if (((dev->descriptor.idVendor == PL2303_VENDOR_ID) &&
883 + (dev->descriptor.idProduct == PL2303_PRODUCT_ID)) ||
884 + ((dev->descriptor.idVendor == ATEN_VENDOR_ID) &&
885 + (dev->descriptor.idProduct == ATEN_PRODUCT_ID))) {
887 + /* check out the endpoints of the other interface*/
888 + interface = &dev->actconfig->interface[ifnum ^ 1];
889 + iface_desc = &interface->altsetting[0];
890 + for (i = 0; i < iface_desc->bNumEndpoints; ++i) {
891 + endpoint = &iface_desc->endpoint[i];
892 + if ((endpoint->bEndpointAddress & 0x80) &&
893 + ((endpoint->bmAttributes & 3) == 0x03)) {
894 + /* we found a interrupt in endpoint */
895 + dbg("found interrupt in for Prolific device on separate interface");
896 + interrupt_in_endpoint[num_interrupt_in] = endpoint;
897 + ++num_interrupt_in;
902 + /* Now make sure the PL-2303 is configured correctly.
903 + * If not, give up now and hope this hack will work
904 + * properly during a later invocation of usb_serial_probe
906 + if (num_bulk_in == 0 || num_bulk_out == 0) {
907 + info("PL-2303 hack: descriptors matched but endpoints did not");
911 + /* END HORRIBLE HACK FOR PL2303 */
914 + /* found all that we need */
915 + info("%s converter detected", type->name);
917 +#ifdef CONFIG_USB_SERIAL_SIERRAWIRELESS
918 + if (type == &sierra_driver) {
919 + num_ports = num_bulk_out;
920 + if (num_ports == 0) {
921 + err("Sierra 3G device with no bulk out, not allowed.");
926 + num_ports = type->num_ports;
928 + serial = get_free_serial (num_ports, &minor);
929 + if (serial == NULL) {
930 + err("No more free serial devices");
935 + serial->type = type;
936 + serial->interface = interface;
937 + serial->minor = minor;
938 + serial->num_ports = num_ports;
939 + serial->num_bulk_in = num_bulk_in;
940 + serial->num_bulk_out = num_bulk_out;
941 + serial->num_interrupt_in = num_interrupt_in;
942 + serial->vendor = dev->descriptor.idVendor;
943 + serial->product = dev->descriptor.idProduct;
945 + /* set up the endpoint information */
946 + for (i = 0; i < num_bulk_in; ++i) {
947 + endpoint = bulk_in_endpoint[i];
948 + port = &serial->port[i];
949 + port->read_urb = usb_alloc_urb (0);
950 + if (!port->read_urb) {
951 + err("No free urbs available");
954 +//Amin marked buffer_size = endpoint->wMaxPacketSize;
955 +// ===> 20060310 Amin modify for improve EVDO and HSDPA Card
956 + buffer_size = 2048;
957 + printk("KERNEL DEBUG => USBSERIAL.O buffer_size = 2048\n");
958 +// <=== 20060310 Amin modify for improve EVDO and HSDPA Card
959 + port->bulk_in_endpointAddress = endpoint->bEndpointAddress;
960 + port->bulk_in_buffer = kmalloc (buffer_size, GFP_KERNEL);
961 + if (!port->bulk_in_buffer) {
962 + err("Couldn't allocate bulk_in_buffer");
965 + usb_fill_bulk_urb (port->read_urb, dev,
966 + usb_rcvbulkpipe (dev,
967 + endpoint->bEndpointAddress),
968 + port->bulk_in_buffer, buffer_size,
969 + ((serial->type->read_bulk_callback) ?
970 + serial->type->read_bulk_callback :
971 + sw_usb_serial_generic_read_bulk_callback),
975 + for (i = 0; i < num_bulk_out; ++i) {
976 + endpoint = bulk_out_endpoint[i];
977 + port = &serial->port[i];
978 + port->write_urb = usb_alloc_urb(0);
979 + if (!port->write_urb) {
980 + err("No free urbs available");
983 + buffer_size = endpoint->wMaxPacketSize;
984 + port->bulk_out_size = buffer_size;
985 + port->bulk_out_endpointAddress = endpoint->bEndpointAddress;
986 + port->bulk_out_buffer = kmalloc (buffer_size, GFP_KERNEL);
987 + if (!port->bulk_out_buffer) {
988 + err("Couldn't allocate bulk_out_buffer");
991 + usb_fill_bulk_urb (port->write_urb, dev,
992 + usb_sndbulkpipe (dev,
993 + endpoint->bEndpointAddress),
994 + port->bulk_out_buffer, buffer_size,
995 + ((serial->type->write_bulk_callback) ?
996 + serial->type->write_bulk_callback :
997 + generic_write_bulk_callback),
1001 + for (i = 0; i < num_interrupt_in; ++i) {
1002 + endpoint = interrupt_in_endpoint[i];
1003 + port = &serial->port[i];
1004 + port->interrupt_in_urb = usb_alloc_urb(0);
1005 + if (!port->interrupt_in_urb) {
1006 + err("No free urbs available");
1009 + buffer_size = endpoint->wMaxPacketSize;
1010 + port->interrupt_in_endpointAddress = endpoint->bEndpointAddress;
1011 + port->interrupt_in_buffer = kmalloc (buffer_size, GFP_KERNEL);
1012 + if (!port->interrupt_in_buffer) {
1013 + err("Couldn't allocate interrupt_in_buffer");
1016 + usb_fill_int_urb (port->interrupt_in_urb, dev,
1017 + usb_rcvintpipe (dev,
1018 + endpoint->bEndpointAddress),
1019 + port->interrupt_in_buffer, buffer_size,
1020 + serial->type->read_int_callback, port,
1021 + endpoint->bInterval);
1024 + /* initialize some parts of the port structures */
1025 + /* we don't use num_ports here cauz some devices have more endpoint pairs than ports */
1026 + max_endpoints = max(num_bulk_in, num_bulk_out);
1027 + max_endpoints = max(max_endpoints, num_interrupt_in);
1028 + max_endpoints = max(max_endpoints, (int)serial->num_ports);
1029 + dbg("%s - setting up %d port structures for this device", __FUNCTION__, max_endpoints);
1030 + for (i = 0; i < max_endpoints; ++i) {
1031 + port = &serial->port[i];
1032 + port->number = i + serial->minor;
1033 + port->serial = serial;
1034 + port->magic = USB_SERIAL_PORT_MAGIC;
1035 + port->tqueue.routine = port_softint;
1036 + port->tqueue.data = port;
1037 + init_MUTEX (&port->sem);
1040 + /* if this device type has a startup function, call it */
1041 + if (type->startup) {
1042 + i = type->startup (serial);
1049 + /* initialize the devfs nodes for this device and let the user know what ports we are bound to */
1050 + for (i = 0; i < serial->num_ports; ++i) {
1051 + tty_register_devfs (&serial_tty_driver, 0, serial->port[i].number);
1052 + info("%s converter now attached to ttyUSB%d (or usb/tts/%d for devfs)",
1053 + type->name, serial->port[i].number, serial->port[i].number);
1056 + return serial; /* success */
1060 + for (i = 0; i < num_bulk_in; ++i) {
1061 + port = &serial->port[i];
1062 + if (port->read_urb)
1063 + usb_free_urb (port->read_urb);
1064 + if (port->bulk_in_buffer)
1065 + kfree (port->bulk_in_buffer);
1067 + for (i = 0; i < num_bulk_out; ++i) {
1068 + port = &serial->port[i];
1069 + if (port->write_urb)
1070 + usb_free_urb (port->write_urb);
1071 + if (port->bulk_out_buffer)
1072 + kfree (port->bulk_out_buffer);
1074 + for (i = 0; i < num_interrupt_in; ++i) {
1075 + port = &serial->port[i];
1076 + if (port->interrupt_in_urb)
1077 + usb_free_urb (port->interrupt_in_urb);
1078 + if (port->interrupt_in_buffer)
1079 + kfree (port->interrupt_in_buffer);
1082 + /* return the minor range that this device had */
1083 + return_serial (serial);
1085 + /* free up any memory that we allocated */
1090 +static void usb_serial_disconnect(struct usb_device *dev, void *ptr)
1092 + struct usb_serial *serial = (struct usb_serial *) ptr;
1093 + struct usb_serial_port *port;
1096 + dbg ("%s", __FUNCTION__);
1098 + /* fail all future close/read/write/ioctl/etc calls */
1099 + for (i = 0; i < serial->num_ports; ++i) {
1100 + port = &serial->port[i];
1101 + down (&port->sem);
1102 + if (port->tty != NULL) {
1103 + while (port->open_count > 0) {
1104 + //__serial_close(port, NULL);
1105 + sw_usb_serial_generic_close(port,NULL);
1107 + port->tty->driver_data = NULL;
1112 + serial->dev = NULL;
1113 + //serial_shutdown (serial);
1114 + sw_usb_serial_generic_shutdown(serial);
1116 + for (i = 0; i < serial->num_ports; ++i)
1117 + serial->port[i].open_count = 0;
1119 + for (i = 0; i < serial->num_bulk_in; ++i) {
1120 + port = &serial->port[i];
1121 + if (port->read_urb) {
1122 + usb_unlink_urb (port->read_urb);
1123 + usb_free_urb (port->read_urb);
1125 + if (port->bulk_in_buffer)
1126 + kfree (port->bulk_in_buffer);
1128 + for (i = 0; i < serial->num_bulk_out; ++i) {
1129 + port = &serial->port[i];
1130 + if (port->write_urb) {
1131 + usb_unlink_urb (port->write_urb);
1132 + usb_free_urb (port->write_urb);
1134 + if (port->bulk_out_buffer)
1135 + kfree (port->bulk_out_buffer);
1137 + for (i = 0; i < serial->num_interrupt_in; ++i) {
1138 + port = &serial->port[i];
1139 + if (port->interrupt_in_urb) {
1140 + usb_unlink_urb (port->interrupt_in_urb);
1141 + usb_free_urb (port->interrupt_in_urb);
1143 + if (port->interrupt_in_buffer)
1144 + kfree (port->interrupt_in_buffer);
1147 + for (i = 0; i < serial->num_ports; ++i) {
1148 + tty_unregister_devfs (&serial_tty_driver, serial->port[i].number);
1149 + info("%s converter now disconnected from ttyUSB%d", serial->type->name, serial->port[i].number);
1152 + /* return the minor range that this device had */
1153 + return_serial (serial);
1155 + /* free up any memory that we allocated */
1159 + info("device disconnected");
1165 +static int sw_attach(struct usb_serial *serial)
1167 + struct usb_device *hdev = serial->dev;
1170 + dbg("%s - serial(0x%p)", __FUNCTION__, serial);
1172 + rc = usb_control_msg(
1174 + usb_sndctrlpipe(hdev, 0),
1175 + USB_VENDER_REQUEST_SET_DEVICE_POWER_STATE, /* bRequest */
1176 + USB_TYPE_VENDOR|USB_RECIP_DEVICE, /* bmRequestType */
1177 + USB_DEVICE_POWER_STATE_D0, /* wValue */
1181 + 1000); /* Timeout */
1183 + err("%s - rc(%d)", __FUNCTION__, rc);
1187 +//void sw_usb_serial_generic_read_bulk_callback (struct urb *urb, struct pt_regs *regs)
1188 +static void sw_usb_serial_generic_read_bulk_callback (struct urb *urb)
1190 + struct usb_serial_port *port = (struct usb_serial_port *)urb->context;
1191 + struct usb_serial *serial = port->serial;
1192 + struct tty_struct *tty;
1193 + unsigned char *data = urb->transfer_buffer;
1197 + dbg("%s - port %d", __FUNCTION__, port->number);
1199 + if (urb->status) {
1200 + dbg("%s - nonzero read bulk status received: %d", __FUNCTION__, urb->status);
1204 + //usb_serial_dbg_data(__FILE__, __FUNCTION__, urb->actual_length, data);
1207 + if (tty && urb->actual_length) {
1209 + tty_buffer_request_room(tty, urb->actual_length);
1210 + tty_insert_flip_string(tty, data, urb->actual_length);
1211 + tty_flip_buffer_push(tty);
1214 + for (i = 0; i < urb->actual_length ; ++i) {
1215 + /* if we insert more than TTY_FLIPBUF_SIZE characters, we drop them. */
1216 + if(tty->flip.count >= TTY_FLIPBUF_SIZE) {
1217 + tty_flip_buffer_push(tty);
1219 + /* this doesn't actually push the data through unless tty->low_latency is set */
1220 + tty_insert_flip_char(tty, data[i], 0);
1222 + tty_flip_buffer_push(tty);
1227 + dbg("%s: empty read urb received", __FUNCTION__);
1229 + /* Continue trying to always read */
1230 + usb_fill_bulk_urb (port->read_urb, serial->dev,
1231 + usb_rcvbulkpipe (serial->dev,
1232 + port->bulk_in_endpointAddress),
1233 + port->read_urb->transfer_buffer,
1234 + port->read_urb->transfer_buffer_length,
1235 + ((serial->type->read_bulk_callback) ?
1236 + serial->type->read_bulk_callback :
1237 + sw_usb_serial_generic_read_bulk_callback), port);
1238 + result = usb_submit_urb(port->read_urb);
1239 + //result = usb_submit_urb(port->read_urb, GFP_ATOMIC); //for kernel 2.6
1241 + dbg("%s - failed resubmitting read urb, error %d\n", __FUNCTION__, result);
1244 +static int generic_open (struct usb_serial_port *port, struct file *filp)
1246 + struct usb_serial *serial = port->serial;
1249 + dbg("%s - port %d", __FUNCTION__, port->number);
1251 + /* force low_latency on so that our tty_push actually forces the data through,
1252 + otherwise it is scheduled, and with high data rates (like with OHCI) data
1255 + port->tty->low_latency = 1;
1257 + /* if we have a bulk interrupt, start reading from it */
1258 + if (serial->num_bulk_in) {
1259 + /* Start reading from the device */
1260 + usb_fill_bulk_urb (port->read_urb, serial->dev,
1261 + usb_rcvbulkpipe(serial->dev, port->bulk_in_endpointAddress),
1262 + port->read_urb->transfer_buffer,
1263 + port->read_urb->transfer_buffer_length,
1264 + ((serial->type->read_bulk_callback) ?
1265 + serial->type->read_bulk_callback :
1266 + sw_usb_serial_generic_read_bulk_callback),
1268 + result = usb_submit_urb(port->read_urb); //, GFP_KERNEL);
1270 + //dev_err(&port->dev, "%s - failed resubmitting read urb, error %d\n", __FUNCTION__, result);
1271 + dbg("%s - failed resubmitting read urb, error %d\n", __FUNCTION__, result);
1278 +int sw_usb_serial_generic_open (struct usb_serial_port *port, struct file *filp)
1281 + struct usb_serial *serial = port->serial;
1282 + struct usb_device *hdev = serial->dev;
1284 + dbg("%s - port %d", __FUNCTION__, port->number);
1286 + rc = generic_open(port, filp);
1287 + err("%s - rc(%d)", __FUNCTION__, rc);
1291 + rc = usb_control_msg(
1293 + usb_sndctrlpipe(hdev, 0),
1294 + SET_CONTROL_LINE_STATE, /* bRequest */
1295 + USB_TYPE_CLASS|USB_RECIP_INTERFACE, /* bmRequestType */
1296 + ACM_CTRL_DTR|ACM_CTRL_RTS, /* wValue */
1300 + 1000); /* Timeout */
1301 + err("%s - usb_control_msg: rc(%d)", __FUNCTION__, rc);
1307 +static void generic_cleanup (struct usb_serial_port *port)
1309 + struct usb_serial *serial = port->serial;
1311 + dbg("%s - port %d", __FUNCTION__, port->number);
1313 + if (serial->dev) {
1314 + /* shutdown any bulk reads that might be going on */
1315 + if (serial->num_bulk_out)
1316 + usb_unlink_urb(port->write_urb);
1317 + //usb_kill_urb(port->write_urb);
1318 + if (serial->num_bulk_in)
1319 + usb_unlink_urb(port->read_urb);
1320 + //usb_kill_urb(port->read_urb);
1324 +static void sw_usb_serial_generic_close (struct usb_serial_port *port, struct file * filp)
1327 + struct usb_serial *serial = port->serial;
1328 + struct usb_device *hdev = serial->dev;
1330 + dbg("%s - port %d", __FUNCTION__, port->number);
1332 + rc = usb_control_msg(
1334 + usb_sndctrlpipe(hdev, 0),
1335 + SET_CONTROL_LINE_STATE, /* bRequest */
1336 + USB_TYPE_CLASS|USB_RECIP_INTERFACE, /* bmRequestType */
1341 + 1000); /* Timeout */
1342 + err("%s - rc(%d)", __FUNCTION__, rc);
1344 + generic_cleanup (port);
1347 +static void sw_usb_serial_generic_shutdown(struct usb_serial *serial)
1350 + struct usb_device *hdev = serial->dev;
1352 + dbg("%s serial(0x%p)", __FUNCTION__, serial);
1356 + rc = usb_control_msg(
1358 + usb_sndctrlpipe(hdev, 0),
1359 + USB_VENDER_REQUEST_SET_DEVICE_POWER_STATE, /* bRequest */
1360 + USB_TYPE_VENDOR|USB_RECIP_DEVICE, /* bmRequestType */
1361 + USB_DEVICE_POWER_STATE_D3, /* wValue */
1365 + 1000); /* Timeout */
1366 + err("%s - rc(%d)", __FUNCTION__, rc);
1369 + /* stop reads and writes on all ports */
1370 + for (i=0; i < serial->num_ports; ++i) {
1371 + generic_cleanup(&serial->port[i]);
1374 +int usb_serial_register(struct usb_serial_device_type *new_device)
1376 + /* Add this device to our list of devices */
1377 + list_add(&new_device->driver_list, &usb_serial_driver_list);
1379 + info ("USB Serial support registered for %s", new_device->name);
1381 + usb_scan_devices();
1387 +void usb_serial_deregister(struct usb_serial_device_type *device)
1389 + struct usb_serial *serial;
1392 + info("USB Serial deregistering driver %s", device->name);
1394 + /* clear out the serial_table if the device is attached to a port */
1395 + for(i = 0; i < SERIAL_TTY_MINORS; ++i) {
1396 + serial = serial_table[i];
1397 + if ((serial != NULL) && (serial->type == device)) {
1398 + usb_driver_release_interface (&sierra_driver, serial->interface);
1399 + usb_serial_disconnect (NULL, serial);
1403 + list_del(&device->driver_list);
1406 +static int __init sierra_init(void)
1411 + /* Initalize our global data */
1412 + for (i = 0; i < SERIAL_TTY_MINORS; ++i) {
1413 + serial_table[i] = NULL;
1416 + /* register the tty driver */
1417 + serial_tty_driver.init_termios = tty_std_termios;
1418 + serial_tty_driver.init_termios.c_cflag = B9600 | CS8 | CREAD | HUPCL | CLOCAL;
1419 + if (tty_register_driver (&serial_tty_driver)) {
1420 + err("%s - failed to register tty driver", __FUNCTION__);
1424 + retval = usb_serial_register(&sierra_device);
1427 + tty_unregister_driver(&serial_tty_driver);
1428 + printk("%s return usb_serial_register. retval=[%d].\n",__FUNCTION__, retval);
1431 + retval = usb_register(&sierra_driver);
1433 + usb_serial_deregister(&sierra_device);
1434 + tty_unregister_driver(&serial_tty_driver);
1435 + err("usb_register failed for the Sierra 3G USB-Serial driver. Error number %d\n", retval);
1442 +static void __exit sierra_exit(void)
1444 + usb_deregister(&sierra_driver);
1445 + usb_serial_deregister(&sierra_device);
1448 +module_init(sierra_init);
1449 +module_exit(sierra_exit);
1450 +MODULE_LICENSE("GPL");
1451 diff -Naur linux-2.4.35.4-old/drivers/usb/serial/sierra.h linux-2.4.35.4/drivers/usb/serial/sierra.h
1452 --- linux-2.4.35.4-old/drivers/usb/serial/sierra.h 1969-12-31 17:00:00.000000000 -0700
1453 +++ linux-2.4.35.4/drivers/usb/serial/sierra.h 2008-01-25 10:15:35.640743578 -0700
1456 + * Sierra Wireless CDMA Wireless Serial USB drive
1458 + * Current Copy modified by: Kevin Lloyd <linux@sierrawireless.com>
1459 + * Original Copy written by: 2005 Greg Kroah-Hartman <gregkh <at> suse.de>
1462 + * This program is free software; you can redistribute it and/or
1463 + * modify it under the terms of the GNU General Public License version
1464 + * 2 as published by the Free Software Foundation.
1466 + * Version history:
1467 + Version 1.03 (Lloyd):
1468 + Included support for DTR control and enhanced buffering (should help
1472 +#define USB_VENDER_REQUEST_SET_DEVICE_POWER_STATE 0
1474 +#define USB_DEVICE_POWER_STATE_D0 0x0000
1475 +#define USB_DEVICE_POWER_STATE_D1 0x0001
1476 +#define USB_DEVICE_POWER_STATE_D2 0x0002
1477 +#define USB_DEVICE_POWER_STATE_D3 0x0003
1479 +#define SET_CONTROL_LINE_STATE 0x22
1481 + * Output control lines.
1484 +#define ACM_CTRL_DTR 0x01
1485 +#define ACM_CTRL_RTS 0x02