aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/usb/serial
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/usb/serial')
-rw-r--r--drivers/usb/serial/Kconfig19
-rw-r--r--drivers/usb/serial/Makefile2
-rw-r--r--drivers/usb/serial/aircable.c37
-rw-r--r--drivers/usb/serial/ark3116.c977
-rw-r--r--drivers/usb/serial/belkin_sa.c2
-rw-r--r--drivers/usb/serial/bus.c1
-rw-r--r--drivers/usb/serial/ch341.c28
-rw-r--r--drivers/usb/serial/console.c1
-rw-r--r--drivers/usb/serial/cp210x.c12
-rw-r--r--drivers/usb/serial/cyberjack.c5
-rw-r--r--drivers/usb/serial/cypress_m8.c84
-rw-r--r--drivers/usb/serial/digi_acceleport.c38
-rw-r--r--drivers/usb/serial/empeg.c3
-rw-r--r--drivers/usb/serial/ftdi_sio.c256
-rw-r--r--drivers/usb/serial/ftdi_sio.h951
-rw-r--r--drivers/usb/serial/ftdi_sio_ids.h1026
-rw-r--r--drivers/usb/serial/funsoft.c2
-rw-r--r--drivers/usb/serial/garmin_gps.c3
-rw-r--r--drivers/usb/serial/generic.c76
-rw-r--r--drivers/usb/serial/hp4x.c2
-rw-r--r--drivers/usb/serial/io_edgeport.c69
-rw-r--r--drivers/usb/serial/io_tables.h10
-rw-r--r--drivers/usb/serial/io_ti.c75
-rw-r--r--drivers/usb/serial/ipaq.c1
-rw-r--r--drivers/usb/serial/ipw.c3
-rw-r--r--drivers/usb/serial/ir-usb.c13
-rw-r--r--drivers/usb/serial/iuu_phoenix.c2
-rw-r--r--drivers/usb/serial/keyspan.c57
-rw-r--r--drivers/usb/serial/keyspan.h10
-rw-r--r--drivers/usb/serial/keyspan_pda.c60
-rw-r--r--drivers/usb/serial/kl5kusb105.c66
-rw-r--r--drivers/usb/serial/kobil_sct.c25
-rw-r--r--drivers/usb/serial/mct_u232.c57
-rw-r--r--drivers/usb/serial/mct_u232.h2
-rw-r--r--drivers/usb/serial/mos7720.c185
-rw-r--r--drivers/usb/serial/mos7840.c56
-rw-r--r--drivers/usb/serial/moto_modem.c2
-rw-r--r--drivers/usb/serial/navman.c4
-rw-r--r--drivers/usb/serial/omninet.c8
-rw-r--r--drivers/usb/serial/opticon.c27
-rw-r--r--drivers/usb/serial/option.c177
-rw-r--r--drivers/usb/serial/oti6858.c36
-rw-r--r--drivers/usb/serial/pl2303.c40
-rw-r--r--drivers/usb/serial/pl2303.h5
-rw-r--r--drivers/usb/serial/qcaux.c106
-rw-r--r--drivers/usb/serial/qcserial.c31
-rw-r--r--drivers/usb/serial/safe_serial.c2
-rw-r--r--drivers/usb/serial/siemens_mpi.c2
-rw-r--r--drivers/usb/serial/sierra.c153
-rw-r--r--drivers/usb/serial/spcp8x5.c27
-rw-r--r--drivers/usb/serial/symbolserial.c15
-rw-r--r--drivers/usb/serial/ti_usb_3410_5052.c29
-rw-r--r--drivers/usb/serial/ti_usb_3410_5052.h3
-rw-r--r--drivers/usb/serial/usb-serial.c105
-rw-r--r--drivers/usb/serial/usb_debug.c3
-rw-r--r--drivers/usb/serial/visor.c40
-rw-r--r--drivers/usb/serial/vivopay-serial.c76
-rw-r--r--drivers/usb/serial/whiteheat.c24
58 files changed, 3147 insertions, 1984 deletions
diff --git a/drivers/usb/serial/Kconfig b/drivers/usb/serial/Kconfig
index c480ea4c19f2..a0ecb42cb33a 100644
--- a/drivers/usb/serial/Kconfig
+++ b/drivers/usb/serial/Kconfig
@@ -472,6 +472,17 @@ config USB_SERIAL_OTI6858
472 To compile this driver as a module, choose M here: the 472 To compile this driver as a module, choose M here: the
473 module will be called oti6858. 473 module will be called oti6858.
474 474
475config USB_SERIAL_QCAUX
476 tristate "USB Qualcomm Auxiliary Serial Port Driver"
477 help
478 Say Y here if you want to use the auxiliary serial ports provided
479 by many modems based on Qualcomm chipsets. These ports often use
480 a proprietary protocol called DM and cannot be used for AT- or
481 PPP-based communication.
482
483 To compile this driver as a module, choose M here: the
484 module will be called qcaux. If unsure, choose N.
485
475config USB_SERIAL_QUALCOMM 486config USB_SERIAL_QUALCOMM
476 tristate "USB Qualcomm Serial modem" 487 tristate "USB Qualcomm Serial modem"
477 help 488 help
@@ -600,6 +611,14 @@ config USB_SERIAL_OPTICON
600 To compile this driver as a module, choose M here: the 611 To compile this driver as a module, choose M here: the
601 module will be called opticon. 612 module will be called opticon.
602 613
614config USB_SERIAL_VIVOPAY_SERIAL
615 tristate "USB ViVOpay serial interface driver"
616 help
617 Say Y here if you want to use a ViVOtech ViVOpay USB device.
618
619 To compile this driver as a module, choose M here: the
620 module will be called vivopay-serial.
621
603config USB_SERIAL_DEBUG 622config USB_SERIAL_DEBUG
604 tristate "USB Debugging Device" 623 tristate "USB Debugging Device"
605 help 624 help
diff --git a/drivers/usb/serial/Makefile b/drivers/usb/serial/Makefile
index 66619beb6cc0..83c9e431a568 100644
--- a/drivers/usb/serial/Makefile
+++ b/drivers/usb/serial/Makefile
@@ -45,6 +45,7 @@ obj-$(CONFIG_USB_SERIAL_OPTICON) += opticon.o
45obj-$(CONFIG_USB_SERIAL_OPTION) += option.o 45obj-$(CONFIG_USB_SERIAL_OPTION) += option.o
46obj-$(CONFIG_USB_SERIAL_OTI6858) += oti6858.o 46obj-$(CONFIG_USB_SERIAL_OTI6858) += oti6858.o
47obj-$(CONFIG_USB_SERIAL_PL2303) += pl2303.o 47obj-$(CONFIG_USB_SERIAL_PL2303) += pl2303.o
48obj-$(CONFIG_USB_SERIAL_QCAUX) += qcaux.o
48obj-$(CONFIG_USB_SERIAL_QUALCOMM) += qcserial.o 49obj-$(CONFIG_USB_SERIAL_QUALCOMM) += qcserial.o
49obj-$(CONFIG_USB_SERIAL_SAFE) += safe_serial.o 50obj-$(CONFIG_USB_SERIAL_SAFE) += safe_serial.o
50obj-$(CONFIG_USB_SERIAL_SIEMENS_MPI) += siemens_mpi.o 51obj-$(CONFIG_USB_SERIAL_SIEMENS_MPI) += siemens_mpi.o
@@ -55,4 +56,5 @@ obj-$(CONFIG_USB_SERIAL_TI) += ti_usb_3410_5052.o
55obj-$(CONFIG_USB_SERIAL_VISOR) += visor.o 56obj-$(CONFIG_USB_SERIAL_VISOR) += visor.o
56obj-$(CONFIG_USB_SERIAL_WHITEHEAT) += whiteheat.o 57obj-$(CONFIG_USB_SERIAL_WHITEHEAT) += whiteheat.o
57obj-$(CONFIG_USB_SERIAL_XIRCOM) += keyspan_pda.o 58obj-$(CONFIG_USB_SERIAL_XIRCOM) += keyspan_pda.o
59obj-$(CONFIG_USB_SERIAL_VIVOPAY_SERIAL) += vivopay-serial.o
58 60
diff --git a/drivers/usb/serial/aircable.c b/drivers/usb/serial/aircable.c
index b10ac8409411..4fd7af98b1ae 100644
--- a/drivers/usb/serial/aircable.c
+++ b/drivers/usb/serial/aircable.c
@@ -43,6 +43,7 @@
43 */ 43 */
44 44
45#include <linux/tty.h> 45#include <linux/tty.h>
46#include <linux/slab.h>
46#include <linux/tty_flip.h> 47#include <linux/tty_flip.h>
47#include <linux/circ_buf.h> 48#include <linux/circ_buf.h>
48#include <linux/usb.h> 49#include <linux/usb.h>
@@ -78,7 +79,7 @@ static int debug;
78#define DRIVER_DESC "AIRcable USB Driver" 79#define DRIVER_DESC "AIRcable USB Driver"
79 80
80/* ID table that will be registered with USB core */ 81/* ID table that will be registered with USB core */
81static struct usb_device_id id_table [] = { 82static const struct usb_device_id id_table[] = {
82 { USB_DEVICE(AIRCABLE_VID, AIRCABLE_USB_PID) }, 83 { USB_DEVICE(AIRCABLE_VID, AIRCABLE_USB_PID) },
83 { }, 84 { },
84}; 85};
@@ -468,10 +469,6 @@ static void aircable_read_bulk_callback(struct urb *urb)
468 469
469 if (status) { 470 if (status) {
470 dbg("%s - urb status = %d", __func__, status); 471 dbg("%s - urb status = %d", __func__, status);
471 if (!port->port.count) {
472 dbg("%s - port is closed, exiting.", __func__);
473 return;
474 }
475 if (status == -EPROTO) { 472 if (status == -EPROTO) {
476 dbg("%s - caught -EPROTO, resubmitting the urb", 473 dbg("%s - caught -EPROTO, resubmitting the urb",
477 __func__); 474 __func__);
@@ -530,23 +527,19 @@ static void aircable_read_bulk_callback(struct urb *urb)
530 } 527 }
531 tty_kref_put(tty); 528 tty_kref_put(tty);
532 529
533 /* Schedule the next read _if_ we are still open */ 530 /* Schedule the next read */
534 if (port->port.count) { 531 usb_fill_bulk_urb(port->read_urb, port->serial->dev,
535 usb_fill_bulk_urb(port->read_urb, port->serial->dev, 532 usb_rcvbulkpipe(port->serial->dev,
536 usb_rcvbulkpipe(port->serial->dev, 533 port->bulk_in_endpointAddress),
537 port->bulk_in_endpointAddress), 534 port->read_urb->transfer_buffer,
538 port->read_urb->transfer_buffer, 535 port->read_urb->transfer_buffer_length,
539 port->read_urb->transfer_buffer_length, 536 aircable_read_bulk_callback, port);
540 aircable_read_bulk_callback, port); 537
541 538 result = usb_submit_urb(urb, GFP_ATOMIC);
542 result = usb_submit_urb(urb, GFP_ATOMIC); 539 if (result && result != -EPERM)
543 if (result) 540 dev_err(&urb->dev->dev,
544 dev_err(&urb->dev->dev, 541 "%s - failed resubmitting read urb, error %d\n",
545 "%s - failed resubmitting read urb, error %d\n", 542 __func__, result);
546 __func__, result);
547 }
548
549 return;
550} 543}
551 544
552/* Based on ftdi_sio.c throttle */ 545/* Based on ftdi_sio.c throttle */
diff --git a/drivers/usb/serial/ark3116.c b/drivers/usb/serial/ark3116.c
index 131e61adaaf7..9b66bf19f751 100644
--- a/drivers/usb/serial/ark3116.c
+++ b/drivers/usb/serial/ark3116.c
@@ -1,4 +1,6 @@
1/* 1/*
2 * Copyright (C) 2009 by Bart Hartgers (bart.hartgers+ark3116@gmail.com)
3 * Original version:
2 * Copyright (C) 2006 4 * Copyright (C) 2006
3 * Simon Schulz (ark3116_driver <at> auctionant.de) 5 * Simon Schulz (ark3116_driver <at> auctionant.de)
4 * 6 *
@@ -6,10 +8,13 @@
6 * - implements a driver for the arkmicro ark3116 chipset (vendor=0x6547, 8 * - implements a driver for the arkmicro ark3116 chipset (vendor=0x6547,
7 * productid=0x0232) (used in a datacable called KQ-U8A) 9 * productid=0x0232) (used in a datacable called KQ-U8A)
8 * 10 *
9 * - based on code by krisfx -> thanks !! 11 * Supports full modem status lines, break, hardware flow control. Does not
10 * (see http://www.linuxquestions.org/questions/showthread.php?p=2184457#post2184457) 12 * support software flow control, since I do not know how to enable it in hw.
11 * 13 *
12 * - based on logs created by usbsnoopy 14 * This driver is a essentially new implementation. I initially dug
15 * into the old ark3116.c driver and suddenly realized the ark3116 is
16 * a 16450 with a USB interface glued to it. See comments at the
17 * bottom of this file.
13 * 18 *
14 * This program is free software; you can redistribute it and/or modify it 19 * This program is free software; you can redistribute it and/or modify it
15 * under the terms of the GNU General Public License as published by the 20 * under the terms of the GNU General Public License as published by the
@@ -19,17 +24,34 @@
19 24
20#include <linux/kernel.h> 25#include <linux/kernel.h>
21#include <linux/init.h> 26#include <linux/init.h>
27#include <linux/ioctl.h>
22#include <linux/tty.h> 28#include <linux/tty.h>
29#include <linux/slab.h>
30#include <linux/tty_flip.h>
23#include <linux/module.h> 31#include <linux/module.h>
24#include <linux/usb.h> 32#include <linux/usb.h>
25#include <linux/usb/serial.h> 33#include <linux/usb/serial.h>
26#include <linux/serial.h> 34#include <linux/serial.h>
35#include <linux/serial_reg.h>
27#include <linux/uaccess.h> 36#include <linux/uaccess.h>
28 37#include <linux/mutex.h>
38#include <linux/spinlock.h>
29 39
30static int debug; 40static int debug;
41/*
42 * Version information
43 */
31 44
32static struct usb_device_id id_table [] = { 45#define DRIVER_VERSION "v0.5"
46#define DRIVER_AUTHOR "Bart Hartgers <bart.hartgers+ark3116@gmail.com>"
47#define DRIVER_DESC "USB ARK3116 serial/IrDA driver"
48#define DRIVER_DEV_DESC "ARK3116 RS232/IrDA"
49#define DRIVER_NAME "ark3116"
50
51/* usb timeout of 1 second */
52#define ARK_TIMEOUT (1*HZ)
53
54static const struct usb_device_id id_table[] = {
33 { USB_DEVICE(0x6547, 0x0232) }, 55 { USB_DEVICE(0x6547, 0x0232) },
34 { USB_DEVICE(0x18ec, 0x3118) }, /* USB to IrDA adapter */ 56 { USB_DEVICE(0x18ec, 0x3118) }, /* USB to IrDA adapter */
35 { }, 57 { },
@@ -45,118 +67,152 @@ static int is_irda(struct usb_serial *serial)
45 return 0; 67 return 0;
46} 68}
47 69
48static inline void ARK3116_SND(struct usb_serial *serial, int seq, 70struct ark3116_private {
49 __u8 request, __u8 requesttype, 71 wait_queue_head_t delta_msr_wait;
50 __u16 value, __u16 index) 72 struct async_icount icount;
73 int irda; /* 1 for irda device */
74
75 /* protects hw register updates */
76 struct mutex hw_lock;
77
78 int quot; /* baudrate divisor */
79 __u32 lcr; /* line control register value */
80 __u32 hcr; /* handshake control register (0x8)
81 * value */
82 __u32 mcr; /* modem contol register value */
83
84 /* protects the status values below */
85 spinlock_t status_lock;
86 __u32 msr; /* modem status register value */
87 __u32 lsr; /* line status register value */
88};
89
90static int ark3116_write_reg(struct usb_serial *serial,
91 unsigned reg, __u8 val)
51{ 92{
52 int result; 93 int result;
94 /* 0xfe 0x40 are magic values taken from original driver */
53 result = usb_control_msg(serial->dev, 95 result = usb_control_msg(serial->dev,
54 usb_sndctrlpipe(serial->dev, 0), 96 usb_sndctrlpipe(serial->dev, 0),
55 request, requesttype, value, index, 97 0xfe, 0x40, val, reg,
56 NULL, 0x00, 1000); 98 NULL, 0, ARK_TIMEOUT);
57 dbg("%03d > ok", seq); 99 return result;
58} 100}
59 101
60static inline void ARK3116_RCV(struct usb_serial *serial, int seq, 102static int ark3116_read_reg(struct usb_serial *serial,
61 __u8 request, __u8 requesttype, 103 unsigned reg, unsigned char *buf)
62 __u16 value, __u16 index, __u8 expected,
63 char *buf)
64{ 104{
65 int result; 105 int result;
106 /* 0xfe 0xc0 are magic values taken from original driver */
66 result = usb_control_msg(serial->dev, 107 result = usb_control_msg(serial->dev,
67 usb_rcvctrlpipe(serial->dev, 0), 108 usb_rcvctrlpipe(serial->dev, 0),
68 request, requesttype, value, index, 109 0xfe, 0xc0, 0, reg,
69 buf, 0x0000001, 1000); 110 buf, 1, ARK_TIMEOUT);
70 if (result) 111 if (result < 0)
71 dbg("%03d < %d bytes [0x%02X]", seq, result, 112 return result;
72 ((unsigned char *)buf)[0]);
73 else 113 else
74 dbg("%03d < 0 bytes", seq); 114 return buf[0];
75} 115}
76 116
77static inline void ARK3116_RCV_QUIET(struct usb_serial *serial, 117static inline int calc_divisor(int bps)
78 __u8 request, __u8 requesttype,
79 __u16 value, __u16 index, char *buf)
80{ 118{
81 usb_control_msg(serial->dev, 119 /* Original ark3116 made some exceptions in rounding here
82 usb_rcvctrlpipe(serial->dev, 0), 120 * because windows did the same. Assume that is not really
83 request, requesttype, value, index, 121 * necessary.
84 buf, 0x0000001, 1000); 122 * Crystal is 12MHz, probably because of USB, but we divide by 4?
123 */
124 return (12000000 + 2*bps) / (4*bps);
85} 125}
86 126
87static int ark3116_attach(struct usb_serial *serial) 127static int ark3116_attach(struct usb_serial *serial)
88{ 128{
89 char *buf; 129 struct usb_serial_port *port = serial->port[0];
130 struct ark3116_private *priv;
131
132 /* make sure we have our end-points */
133 if ((serial->num_bulk_in == 0) ||
134 (serial->num_bulk_out == 0) ||
135 (serial->num_interrupt_in == 0)) {
136 dev_err(&serial->dev->dev,
137 "%s - missing endpoint - "
138 "bulk in: %d, bulk out: %d, int in %d\n",
139 KBUILD_MODNAME,
140 serial->num_bulk_in,
141 serial->num_bulk_out,
142 serial->num_interrupt_in);
143 return -EINVAL;
144 }
90 145
91 buf = kmalloc(1, GFP_KERNEL); 146 priv = kzalloc(sizeof(struct ark3116_private),
92 if (!buf) { 147 GFP_KERNEL);
93 dbg("error kmalloc -> out of mem?"); 148 if (!priv)
94 return -ENOMEM; 149 return -ENOMEM;
95 }
96 150
97 if (is_irda(serial)) 151 init_waitqueue_head(&priv->delta_msr_wait);
98 dbg("IrDA mode"); 152 mutex_init(&priv->hw_lock);
153 spin_lock_init(&priv->status_lock);
154
155 priv->irda = is_irda(serial);
99 156
100 /* 3 */ 157 usb_set_serial_port_data(port, priv);
101 ARK3116_SND(serial, 3, 0xFE, 0x40, 0x0008, 0x0002);
102 ARK3116_SND(serial, 4, 0xFE, 0x40, 0x0008, 0x0001);
103 ARK3116_SND(serial, 5, 0xFE, 0x40, 0x0000, 0x0008);
104 ARK3116_SND(serial, 6, 0xFE, 0x40, is_irda(serial) ? 0x0001 : 0x0000,
105 0x000B);
106 158
107 if (is_irda(serial)) { 159 /* setup the hardware */
108 ARK3116_SND(serial, 1001, 0xFE, 0x40, 0x0000, 0x000C); 160 ark3116_write_reg(serial, UART_IER, 0);
109 ARK3116_SND(serial, 1002, 0xFE, 0x40, 0x0041, 0x000D); 161 /* disable DMA */
110 ARK3116_SND(serial, 1003, 0xFE, 0x40, 0x0001, 0x000A); 162 ark3116_write_reg(serial, UART_FCR, 0);
163 /* handshake control */
164 priv->hcr = 0;
165 ark3116_write_reg(serial, 0x8 , 0);
166 /* modem control */
167 priv->mcr = 0;
168 ark3116_write_reg(serial, UART_MCR, 0);
169
170 if (!(priv->irda)) {
171 ark3116_write_reg(serial, 0xb , 0);
172 } else {
173 ark3116_write_reg(serial, 0xb , 1);
174 ark3116_write_reg(serial, 0xc , 0);
175 ark3116_write_reg(serial, 0xd , 0x41);
176 ark3116_write_reg(serial, 0xa , 1);
111 } 177 }
112 178
113 /* <-- seq7 */ 179 /* setup baudrate */
114 ARK3116_RCV(serial, 7, 0xFE, 0xC0, 0x0000, 0x0003, 0x00, buf); 180 ark3116_write_reg(serial, UART_LCR, UART_LCR_DLAB);
115 ARK3116_SND(serial, 8, 0xFE, 0x40, 0x0080, 0x0003);
116 ARK3116_SND(serial, 9, 0xFE, 0x40, 0x001A, 0x0000);
117 ARK3116_SND(serial, 10, 0xFE, 0x40, 0x0000, 0x0001);
118 ARK3116_SND(serial, 11, 0xFE, 0x40, 0x0000, 0x0003);
119
120 /* <-- seq12 */
121 ARK3116_RCV(serial, 12, 0xFE, 0xC0, 0x0000, 0x0004, 0x00, buf);
122 ARK3116_SND(serial, 13, 0xFE, 0x40, 0x0000, 0x0004);
123
124 /* 14 */
125 ARK3116_RCV(serial, 14, 0xFE, 0xC0, 0x0000, 0x0004, 0x00, buf);
126 ARK3116_SND(serial, 15, 0xFE, 0x40, 0x0000, 0x0004);
127
128 /* 16 */
129 ARK3116_RCV(serial, 16, 0xFE, 0xC0, 0x0000, 0x0004, 0x00, buf);
130 /* --> seq17 */
131 ARK3116_SND(serial, 17, 0xFE, 0x40, 0x0001, 0x0004);
132
133 /* <-- seq18 */
134 ARK3116_RCV(serial, 18, 0xFE, 0xC0, 0x0000, 0x0004, 0x01, buf);
135
136 /* --> seq19 */
137 ARK3116_SND(serial, 19, 0xFE, 0x40, 0x0003, 0x0004);
138
139 /* <-- seq20 */
140 /* seems like serial port status info (RTS, CTS, ...) */
141 /* returns modem control line status?! */
142 ARK3116_RCV(serial, 20, 0xFE, 0xC0, 0x0000, 0x0006, 0xFF, buf);
143
144 /* set 9600 baud & do some init?! */
145 ARK3116_SND(serial, 147, 0xFE, 0x40, 0x0083, 0x0003);
146 ARK3116_SND(serial, 148, 0xFE, 0x40, 0x0038, 0x0000);
147 ARK3116_SND(serial, 149, 0xFE, 0x40, 0x0001, 0x0001);
148 if (is_irda(serial))
149 ARK3116_SND(serial, 1004, 0xFE, 0x40, 0x0000, 0x0009);
150 ARK3116_SND(serial, 150, 0xFE, 0x40, 0x0003, 0x0003);
151 ARK3116_RCV(serial, 151, 0xFE, 0xC0, 0x0000, 0x0004, 0x03, buf);
152 ARK3116_SND(serial, 152, 0xFE, 0x40, 0x0000, 0x0003);
153 ARK3116_RCV(serial, 153, 0xFE, 0xC0, 0x0000, 0x0003, 0x00, buf);
154 ARK3116_SND(serial, 154, 0xFE, 0x40, 0x0003, 0x0003);
155 181
156 kfree(buf); 182 /* setup for 9600 8N1 */
183 priv->quot = calc_divisor(9600);
184 ark3116_write_reg(serial, UART_DLL, priv->quot & 0xff);
185 ark3116_write_reg(serial, UART_DLM, (priv->quot>>8) & 0xff);
186
187 priv->lcr = UART_LCR_WLEN8;
188 ark3116_write_reg(serial, UART_LCR, UART_LCR_WLEN8);
189
190 ark3116_write_reg(serial, 0xe, 0);
191
192 if (priv->irda)
193 ark3116_write_reg(serial, 0x9, 0);
194
195 dev_info(&serial->dev->dev,
196 "%s using %s mode\n",
197 KBUILD_MODNAME,
198 priv->irda ? "IrDA" : "RS232");
157 return 0; 199 return 0;
158} 200}
159 201
202static void ark3116_release(struct usb_serial *serial)
203{
204 struct usb_serial_port *port = serial->port[0];
205 struct ark3116_private *priv = usb_get_serial_port_data(port);
206
207 /* device is closed, so URBs and DMA should be down */
208
209 usb_set_serial_port_data(port, NULL);
210
211 mutex_destroy(&priv->hw_lock);
212
213 kfree(priv);
214}
215
160static void ark3116_init_termios(struct tty_struct *tty) 216static void ark3116_init_termios(struct tty_struct *tty)
161{ 217{
162 struct ktermios *termios = tty->termios; 218 struct ktermios *termios = tty->termios;
@@ -172,200 +228,189 @@ static void ark3116_set_termios(struct tty_struct *tty,
172 struct ktermios *old_termios) 228 struct ktermios *old_termios)
173{ 229{
174 struct usb_serial *serial = port->serial; 230 struct usb_serial *serial = port->serial;
231 struct ark3116_private *priv = usb_get_serial_port_data(port);
175 struct ktermios *termios = tty->termios; 232 struct ktermios *termios = tty->termios;
176 unsigned int cflag = termios->c_cflag; 233 unsigned int cflag = termios->c_cflag;
177 int baud; 234 int bps = tty_get_baud_rate(tty);
178 int ark3116_baud; 235 int quot;
179 char *buf; 236 __u8 lcr, hcr, eval;
180 char config; 237
181 238 /* set data bit count */
182 config = 0; 239 switch (cflag & CSIZE) {
183 240 case CS5:
184 dbg("%s - port %d", __func__, port->number); 241 lcr = UART_LCR_WLEN5;
242 break;
243 case CS6:
244 lcr = UART_LCR_WLEN6;
245 break;
246 case CS7:
247 lcr = UART_LCR_WLEN7;
248 break;
249 default:
250 case CS8:
251 lcr = UART_LCR_WLEN8;
252 break;
253 }
254 if (cflag & CSTOPB)
255 lcr |= UART_LCR_STOP;
256 if (cflag & PARENB)
257 lcr |= UART_LCR_PARITY;
258 if (!(cflag & PARODD))
259 lcr |= UART_LCR_EPAR;
260#ifdef CMSPAR
261 if (cflag & CMSPAR)
262 lcr |= UART_LCR_SPAR;
263#endif
264 /* handshake control */
265 hcr = (cflag & CRTSCTS) ? 0x03 : 0x00;
266
267 /* calc baudrate */
268 dbg("%s - setting bps to %d", __func__, bps);
269 eval = 0;
270 switch (bps) {
271 case 0:
272 quot = calc_divisor(9600);
273 break;
274 default:
275 if ((bps < 75) || (bps > 3000000))
276 bps = 9600;
277 quot = calc_divisor(bps);
278 break;
279 case 460800:
280 eval = 1;
281 quot = calc_divisor(bps);
282 break;
283 case 921600:
284 eval = 2;
285 quot = calc_divisor(bps);
286 break;
287 }
185 288
289 /* Update state: synchronize */
290 mutex_lock(&priv->hw_lock);
186 291
187 cflag = termios->c_cflag; 292 /* keep old LCR_SBC bit */
188 termios->c_cflag &= ~(CMSPAR|CRTSCTS); 293 lcr |= (priv->lcr & UART_LCR_SBC);
189 294
190 buf = kmalloc(1, GFP_KERNEL); 295 dbg("%s - setting hcr:0x%02x,lcr:0x%02x,quot:%d",
191 if (!buf) { 296 __func__, hcr, lcr, quot);
192 dbg("error kmalloc");
193 *termios = *old_termios;
194 return;
195 }
196 297
197 /* set data bit count (8/7/6/5) */ 298 /* handshake control */
198 if (cflag & CSIZE) { 299 if (priv->hcr != hcr) {
199 switch (cflag & CSIZE) { 300 priv->hcr = hcr;
200 case CS5: 301 ark3116_write_reg(serial, 0x8, hcr);
201 config |= 0x00;
202 dbg("setting CS5");
203 break;
204 case CS6:
205 config |= 0x01;
206 dbg("setting CS6");
207 break;
208 case CS7:
209 config |= 0x02;
210 dbg("setting CS7");
211 break;
212 default:
213 dbg("CSIZE was set but not CS5-CS8, using CS8!");
214 /* fall through */
215 case CS8:
216 config |= 0x03;
217 dbg("setting CS8");
218 break;
219 }
220 } 302 }
221 303
222 /* set parity (NONE/EVEN/ODD) */ 304 /* baudrate */
223 if (cflag & PARENB) { 305 if (priv->quot != quot) {
224 if (cflag & PARODD) { 306 priv->quot = quot;
225 config |= 0x08; 307 priv->lcr = lcr; /* need to write lcr anyway */
226 dbg("setting parity to ODD"); 308
227 } else { 309 /* disable DMA since transmit/receive is
228 config |= 0x18; 310 * shadowed by UART_DLL
229 dbg("setting parity to EVEN"); 311 */
230 } 312 ark3116_write_reg(serial, UART_FCR, 0);
231 } else { 313
232 dbg("setting parity to NONE"); 314 ark3116_write_reg(serial, UART_LCR,
315 lcr|UART_LCR_DLAB);
316 ark3116_write_reg(serial, UART_DLL, quot & 0xff);
317 ark3116_write_reg(serial, UART_DLM, (quot>>8) & 0xff);
318
319 /* restore lcr */
320 ark3116_write_reg(serial, UART_LCR, lcr);
321 /* magic baudrate thingy: not sure what it does,
322 * but windows does this as well.
323 */
324 ark3116_write_reg(serial, 0xe, eval);
325
326 /* enable DMA */
327 ark3116_write_reg(serial, UART_FCR, UART_FCR_DMA_SELECT);
328 } else if (priv->lcr != lcr) {
329 priv->lcr = lcr;
330 ark3116_write_reg(serial, UART_LCR, lcr);
233 } 331 }
234 332
235 /* set stop bit (1/2) */ 333 mutex_unlock(&priv->hw_lock);
236 if (cflag & CSTOPB) {
237 config |= 0x04;
238 dbg("setting 2 stop bits");
239 } else {
240 dbg("setting 1 stop bit");
241 }
242 334
243 /* set baudrate */ 335 /* check for software flow control */
244 baud = tty_get_baud_rate(tty); 336 if (I_IXOFF(tty) || I_IXON(tty)) {
245 337 dev_warn(&serial->dev->dev,
246 switch (baud) { 338 "%s: don't know how to do software flow control\n",
247 case 75: 339 KBUILD_MODNAME);
248 case 150:
249 case 300:
250 case 600:
251 case 1200:
252 case 1800:
253 case 2400:
254 case 4800:
255 case 9600:
256 case 19200:
257 case 38400:
258 case 57600:
259 case 115200:
260 case 230400:
261 case 460800:
262 /* Report the resulting rate back to the caller */
263 tty_encode_baud_rate(tty, baud, baud);
264 break;
265 /* set 9600 as default (if given baudrate is invalid for example) */
266 default:
267 tty_encode_baud_rate(tty, 9600, 9600);
268 case 0:
269 baud = 9600;
270 } 340 }
271 341
272 /* 342 /* Don't rewrite B0 */
273 * found by try'n'error, be careful, maybe there are other options 343 if (tty_termios_baud_rate(termios))
274 * for multiplicator etc! (3.5 for example) 344 tty_termios_encode_baud_rate(termios, bps, bps);
275 */ 345}
276 if (baud == 460800)
277 /* strange, for 460800 the formula is wrong
278 * if using round() then 9600baud is wrong) */
279 ark3116_baud = 7;
280 else
281 ark3116_baud = 3000000 / baud;
282
283 /* ? */
284 ARK3116_RCV(serial, 0, 0xFE, 0xC0, 0x0000, 0x0003, 0x03, buf);
285
286 /* offset = buf[0]; */
287 /* offset = 0x03; */
288 /* dbg("using 0x%04X as target for 0x0003:", 0x0080 + offset); */
289
290 /* set baudrate */
291 dbg("setting baudrate to %d (->reg=%d)", baud, ark3116_baud);
292 ARK3116_SND(serial, 147, 0xFE, 0x40, 0x0083, 0x0003);
293 ARK3116_SND(serial, 148, 0xFE, 0x40,
294 (ark3116_baud & 0x00FF), 0x0000);
295 ARK3116_SND(serial, 149, 0xFE, 0x40,
296 (ark3116_baud & 0xFF00) >> 8, 0x0001);
297 ARK3116_SND(serial, 150, 0xFE, 0x40, 0x0003, 0x0003);
298
299 /* ? */
300 ARK3116_RCV(serial, 151, 0xFE, 0xC0, 0x0000, 0x0004, 0x03, buf);
301 ARK3116_SND(serial, 152, 0xFE, 0x40, 0x0000, 0x0003);
302
303 /* set data bit count, stop bit count & parity: */
304 dbg("updating bit count, stop bit or parity (cfg=0x%02X)", config);
305 ARK3116_RCV(serial, 153, 0xFE, 0xC0, 0x0000, 0x0003, 0x00, buf);
306 ARK3116_SND(serial, 154, 0xFE, 0x40, config, 0x0003);
307 346
308 if (cflag & CRTSCTS) 347static void ark3116_close(struct usb_serial_port *port)
309 dbg("CRTSCTS not supported by chipset?!"); 348{
349 struct usb_serial *serial = port->serial;
310 350
311 /* TEST ARK3116_SND(154, 0xFE, 0x40, 0xFFFF, 0x0006); */ 351 if (serial->dev) {
352 /* disable DMA */
353 ark3116_write_reg(serial, UART_FCR, 0);
312 354
313 kfree(buf); 355 /* deactivate interrupts */
356 ark3116_write_reg(serial, UART_IER, 0);
314 357
315 return; 358 /* shutdown any bulk reads that might be going on */
359 if (serial->num_bulk_out)
360 usb_kill_urb(port->write_urb);
361 if (serial->num_bulk_in)
362 usb_kill_urb(port->read_urb);
363 if (serial->num_interrupt_in)
364 usb_kill_urb(port->interrupt_in_urb);
365 }
316} 366}
317 367
318static int ark3116_open(struct tty_struct *tty, struct usb_serial_port *port) 368static int ark3116_open(struct tty_struct *tty, struct usb_serial_port *port)
319{ 369{
320 struct ktermios tmp_termios; 370 struct ark3116_private *priv = usb_get_serial_port_data(port);
321 struct usb_serial *serial = port->serial; 371 struct usb_serial *serial = port->serial;
322 char *buf; 372 unsigned char *buf;
323 int result = 0; 373 int result;
324
325 dbg("%s - port %d", __func__, port->number);
326 374
327 buf = kmalloc(1, GFP_KERNEL); 375 buf = kmalloc(1, GFP_KERNEL);
328 if (!buf) { 376 if (buf == NULL)
329 dbg("error kmalloc -> out of mem?");
330 return -ENOMEM; 377 return -ENOMEM;
331 }
332 378
333 result = usb_serial_generic_open(tty, port); 379 result = usb_serial_generic_open(tty, port);
334 if (result) 380 if (result) {
381 dbg("%s - usb_serial_generic_open failed: %d",
382 __func__, result);
335 goto err_out; 383 goto err_out;
384 }
336 385
337 /* open */ 386 /* setup termios */
338 ARK3116_RCV(serial, 111, 0xFE, 0xC0, 0x0000, 0x0003, 0x02, buf); 387 if (tty)
339 388 ark3116_set_termios(tty, port, NULL);
340 ARK3116_SND(serial, 112, 0xFE, 0x40, 0x0082, 0x0003);
341 ARK3116_SND(serial, 113, 0xFE, 0x40, 0x001A, 0x0000);
342 ARK3116_SND(serial, 114, 0xFE, 0x40, 0x0000, 0x0001);
343 ARK3116_SND(serial, 115, 0xFE, 0x40, 0x0002, 0x0003);
344
345 ARK3116_RCV(serial, 116, 0xFE, 0xC0, 0x0000, 0x0004, 0x03, buf);
346 ARK3116_SND(serial, 117, 0xFE, 0x40, 0x0002, 0x0004);
347
348 ARK3116_RCV(serial, 118, 0xFE, 0xC0, 0x0000, 0x0004, 0x02, buf);
349 ARK3116_SND(serial, 119, 0xFE, 0x40, 0x0000, 0x0004);
350
351 ARK3116_RCV(serial, 120, 0xFE, 0xC0, 0x0000, 0x0004, 0x00, buf);
352 389
353 ARK3116_SND(serial, 121, 0xFE, 0x40, 0x0001, 0x0004); 390 /* remove any data still left: also clears error state */
391 ark3116_read_reg(serial, UART_RX, buf);
354 392
355 ARK3116_RCV(serial, 122, 0xFE, 0xC0, 0x0000, 0x0004, 0x01, buf); 393 /* read modem status */
394 priv->msr = ark3116_read_reg(serial, UART_MSR, buf);
395 /* read line status */
396 priv->lsr = ark3116_read_reg(serial, UART_LSR, buf);
356 397
357 ARK3116_SND(serial, 123, 0xFE, 0x40, 0x0003, 0x0004); 398 result = usb_submit_urb(port->interrupt_in_urb, GFP_KERNEL);
399 if (result) {
400 dev_err(&port->dev, "submit irq_in urb failed %d\n",
401 result);
402 ark3116_close(port);
403 goto err_out;
404 }
358 405
359 /* returns different values (control lines?!) */ 406 /* activate interrupts */
360 ARK3116_RCV(serial, 124, 0xFE, 0xC0, 0x0000, 0x0006, 0xFF, buf); 407 ark3116_write_reg(port->serial, UART_IER, UART_IER_MSI|UART_IER_RLSI);
361 408
362 /* initialise termios */ 409 /* enable DMA */
363 if (tty) 410 ark3116_write_reg(port->serial, UART_FCR, UART_FCR_DMA_SELECT);
364 ark3116_set_termios(tty, port, &tmp_termios);
365 411
366err_out: 412err_out:
367 kfree(buf); 413 kfree(buf);
368
369 return result; 414 return result;
370} 415}
371 416
@@ -373,6 +418,7 @@ static int ark3116_ioctl(struct tty_struct *tty, struct file *file,
373 unsigned int cmd, unsigned long arg) 418 unsigned int cmd, unsigned long arg)
374{ 419{
375 struct usb_serial_port *port = tty->driver_data; 420 struct usb_serial_port *port = tty->driver_data;
421 struct ark3116_private *priv = usb_get_serial_port_data(port);
376 struct serial_struct serstruct; 422 struct serial_struct serstruct;
377 void __user *user_arg = (void __user *)arg; 423 void __user *user_arg = (void __user *)arg;
378 424
@@ -394,9 +440,48 @@ static int ark3116_ioctl(struct tty_struct *tty, struct file *file,
394 if (copy_from_user(&serstruct, user_arg, sizeof(serstruct))) 440 if (copy_from_user(&serstruct, user_arg, sizeof(serstruct)))
395 return -EFAULT; 441 return -EFAULT;
396 return 0; 442 return 0;
397 default: 443 case TIOCMIWAIT:
398 dbg("%s cmd 0x%04x not supported", __func__, cmd); 444 for (;;) {
445 struct async_icount prev = priv->icount;
446 interruptible_sleep_on(&priv->delta_msr_wait);
447 /* see if a signal did it */
448 if (signal_pending(current))
449 return -ERESTARTSYS;
450 if ((prev.rng == priv->icount.rng) &&
451 (prev.dsr == priv->icount.dsr) &&
452 (prev.dcd == priv->icount.dcd) &&
453 (prev.cts == priv->icount.cts))
454 return -EIO;
455 if ((arg & TIOCM_RNG &&
456 (prev.rng != priv->icount.rng)) ||
457 (arg & TIOCM_DSR &&
458 (prev.dsr != priv->icount.dsr)) ||
459 (arg & TIOCM_CD &&
460 (prev.dcd != priv->icount.dcd)) ||
461 (arg & TIOCM_CTS &&
462 (prev.cts != priv->icount.cts)))
463 return 0;
464 }
399 break; 465 break;
466 case TIOCGICOUNT: {
467 struct serial_icounter_struct icount;
468 struct async_icount cnow = priv->icount;
469 memset(&icount, 0, sizeof(icount));
470 icount.cts = cnow.cts;
471 icount.dsr = cnow.dsr;
472 icount.rng = cnow.rng;
473 icount.dcd = cnow.dcd;
474 icount.rx = cnow.rx;
475 icount.tx = cnow.tx;
476 icount.frame = cnow.frame;
477 icount.overrun = cnow.overrun;
478 icount.parity = cnow.parity;
479 icount.brk = cnow.brk;
480 icount.buf_overrun = cnow.buf_overrun;
481 if (copy_to_user(user_arg, &icount, sizeof(icount)))
482 return -EFAULT;
483 return 0;
484 }
400 } 485 }
401 486
402 return -ENOIOCTLCMD; 487 return -ENOIOCTLCMD;
@@ -405,32 +490,272 @@ static int ark3116_ioctl(struct tty_struct *tty, struct file *file,
405static int ark3116_tiocmget(struct tty_struct *tty, struct file *file) 490static int ark3116_tiocmget(struct tty_struct *tty, struct file *file)
406{ 491{
407 struct usb_serial_port *port = tty->driver_data; 492 struct usb_serial_port *port = tty->driver_data;
408 struct usb_serial *serial = port->serial; 493 struct ark3116_private *priv = usb_get_serial_port_data(port);
409 char *buf; 494 __u32 status;
410 char temp; 495 __u32 ctrl;
496 unsigned long flags;
497
498 mutex_lock(&priv->hw_lock);
499 ctrl = priv->mcr;
500 mutex_unlock(&priv->hw_lock);
501
502 spin_lock_irqsave(&priv->status_lock, flags);
503 status = priv->msr;
504 spin_unlock_irqrestore(&priv->status_lock, flags);
505
506 return (status & UART_MSR_DSR ? TIOCM_DSR : 0) |
507 (status & UART_MSR_CTS ? TIOCM_CTS : 0) |
508 (status & UART_MSR_RI ? TIOCM_RI : 0) |
509 (status & UART_MSR_DCD ? TIOCM_CD : 0) |
510 (ctrl & UART_MCR_DTR ? TIOCM_DTR : 0) |
511 (ctrl & UART_MCR_RTS ? TIOCM_RTS : 0) |
512 (ctrl & UART_MCR_OUT1 ? TIOCM_OUT1 : 0) |
513 (ctrl & UART_MCR_OUT2 ? TIOCM_OUT2 : 0);
514}
411 515
412 /* seems like serial port status info (RTS, CTS, ...) is stored 516static int ark3116_tiocmset(struct tty_struct *tty, struct file *file,
413 * in reg(?) 0x0006 517 unsigned set, unsigned clr)
414 * pcb connection point 11 = GND -> sets bit4 of response 518{
415 * pcb connection point 7 = GND -> sets bit6 of response 519 struct usb_serial_port *port = tty->driver_data;
520 struct ark3116_private *priv = usb_get_serial_port_data(port);
521
522 /* we need to take the mutex here, to make sure that the value
523 * in priv->mcr is actually the one that is in the hardware
416 */ 524 */
417 525
418 buf = kmalloc(1, GFP_KERNEL); 526 mutex_lock(&priv->hw_lock);
419 if (!buf) { 527
420 dbg("error kmalloc"); 528 if (set & TIOCM_RTS)
421 return -ENOMEM; 529 priv->mcr |= UART_MCR_RTS;
530 if (set & TIOCM_DTR)
531 priv->mcr |= UART_MCR_DTR;
532 if (set & TIOCM_OUT1)
533 priv->mcr |= UART_MCR_OUT1;
534 if (set & TIOCM_OUT2)
535 priv->mcr |= UART_MCR_OUT2;
536 if (clr & TIOCM_RTS)
537 priv->mcr &= ~UART_MCR_RTS;
538 if (clr & TIOCM_DTR)
539 priv->mcr &= ~UART_MCR_DTR;
540 if (clr & TIOCM_OUT1)
541 priv->mcr &= ~UART_MCR_OUT1;
542 if (clr & TIOCM_OUT2)
543 priv->mcr &= ~UART_MCR_OUT2;
544
545 ark3116_write_reg(port->serial, UART_MCR, priv->mcr);
546
547 mutex_unlock(&priv->hw_lock);
548
549 return 0;
550}
551
552static void ark3116_break_ctl(struct tty_struct *tty, int break_state)
553{
554 struct usb_serial_port *port = tty->driver_data;
555 struct ark3116_private *priv = usb_get_serial_port_data(port);
556
557 /* LCR is also used for other things: protect access */
558 mutex_lock(&priv->hw_lock);
559
560 if (break_state)
561 priv->lcr |= UART_LCR_SBC;
562 else
563 priv->lcr &= ~UART_LCR_SBC;
564
565 ark3116_write_reg(port->serial, UART_LCR, priv->lcr);
566
567 mutex_unlock(&priv->hw_lock);
568}
569
570static void ark3116_update_msr(struct usb_serial_port *port, __u8 msr)
571{
572 struct ark3116_private *priv = usb_get_serial_port_data(port);
573 unsigned long flags;
574
575 spin_lock_irqsave(&priv->status_lock, flags);
576 priv->msr = msr;
577 spin_unlock_irqrestore(&priv->status_lock, flags);
578
579 if (msr & UART_MSR_ANY_DELTA) {
580 /* update input line counters */
581 if (msr & UART_MSR_DCTS)
582 priv->icount.cts++;
583 if (msr & UART_MSR_DDSR)
584 priv->icount.dsr++;
585 if (msr & UART_MSR_DDCD)
586 priv->icount.dcd++;
587 if (msr & UART_MSR_TERI)
588 priv->icount.rng++;
589 wake_up_interruptible(&priv->delta_msr_wait);
422 } 590 }
591}
423 592
424 /* read register */ 593static void ark3116_update_lsr(struct usb_serial_port *port, __u8 lsr)
425 ARK3116_RCV_QUIET(serial, 0xFE, 0xC0, 0x0000, 0x0006, buf); 594{
426 temp = buf[0]; 595 struct ark3116_private *priv = usb_get_serial_port_data(port);
427 kfree(buf); 596 unsigned long flags;
597
598 spin_lock_irqsave(&priv->status_lock, flags);
599 /* combine bits */
600 priv->lsr |= lsr;
601 spin_unlock_irqrestore(&priv->status_lock, flags);
602
603 if (lsr&UART_LSR_BRK_ERROR_BITS) {
604 if (lsr & UART_LSR_BI)
605 priv->icount.brk++;
606 if (lsr & UART_LSR_FE)
607 priv->icount.frame++;
608 if (lsr & UART_LSR_PE)
609 priv->icount.parity++;
610 if (lsr & UART_LSR_OE)
611 priv->icount.overrun++;
612 }
613}
428 614
429 /* i do not really know if bit4=CTS and bit6=DSR... just a 615static void ark3116_read_int_callback(struct urb *urb)
430 * quick guess! 616{
431 */ 617 struct usb_serial_port *port = urb->context;
432 return (temp & (1<<4) ? TIOCM_CTS : 0) 618 int status = urb->status;
433 | (temp & (1<<6) ? TIOCM_DSR : 0); 619 const __u8 *data = urb->transfer_buffer;
620 int result;
621
622 switch (status) {
623 case -ECONNRESET:
624 case -ENOENT:
625 case -ESHUTDOWN:
626 /* this urb is terminated, clean up */
627 dbg("%s - urb shutting down with status: %d",
628 __func__, status);
629 return;
630 default:
631 dbg("%s - nonzero urb status received: %d",
632 __func__, status);
633 break;
634 case 0: /* success */
635 /* discovered this by trail and error... */
636 if ((urb->actual_length == 4) && (data[0] == 0xe8)) {
637 const __u8 id = data[1]&UART_IIR_ID;
638 dbg("%s: iir=%02x", __func__, data[1]);
639 if (id == UART_IIR_MSI) {
640 dbg("%s: msr=%02x", __func__, data[3]);
641 ark3116_update_msr(port, data[3]);
642 break;
643 } else if (id == UART_IIR_RLSI) {
644 dbg("%s: lsr=%02x", __func__, data[2]);
645 ark3116_update_lsr(port, data[2]);
646 break;
647 }
648 }
649 /*
650 * Not sure what this data meant...
651 */
652 usb_serial_debug_data(debug, &port->dev,
653 __func__,
654 urb->actual_length,
655 urb->transfer_buffer);
656 break;
657 }
658
659 result = usb_submit_urb(urb, GFP_ATOMIC);
660 if (result)
661 dev_err(&urb->dev->dev,
662 "%s - Error %d submitting interrupt urb\n",
663 __func__, result);
664}
665
666
667/* Data comes in via the bulk (data) URB, erors/interrupts via the int URB.
668 * This means that we cannot be sure which data byte has an associated error
669 * condition, so we report an error for all data in the next bulk read.
670 *
671 * Actually, there might even be a window between the bulk data leaving the
672 * ark and reading/resetting the lsr in the read_bulk_callback where an
673 * interrupt for the next data block could come in.
674 * Without somekind of ordering on the ark, we would have to report the
675 * error for the next block of data as well...
676 * For now, let's pretend this can't happen.
677 */
678
679static void send_to_tty(struct tty_struct *tty,
680 const unsigned char *chars,
681 size_t size, char flag)
682{
683 if (size == 0)
684 return;
685 if (flag == TTY_NORMAL) {
686 tty_insert_flip_string(tty, chars, size);
687 } else {
688 int i;
689 for (i = 0; i < size; ++i)
690 tty_insert_flip_char(tty, chars[i], flag);
691 }
692}
693
694static void ark3116_read_bulk_callback(struct urb *urb)
695{
696 struct usb_serial_port *port = urb->context;
697 struct ark3116_private *priv = usb_get_serial_port_data(port);
698 const __u8 *data = urb->transfer_buffer;
699 int status = urb->status;
700 struct tty_struct *tty;
701 unsigned long flags;
702 int result;
703 char flag;
704 __u32 lsr;
705
706 switch (status) {
707 case -ECONNRESET:
708 case -ENOENT:
709 case -ESHUTDOWN:
710 /* this urb is terminated, clean up */
711 dbg("%s - urb shutting down with status: %d",
712 __func__, status);
713 return;
714 default:
715 dbg("%s - nonzero urb status received: %d",
716 __func__, status);
717 break;
718 case 0: /* success */
719
720 spin_lock_irqsave(&priv->status_lock, flags);
721 lsr = priv->lsr;
722 /* clear error bits */
723 priv->lsr &= ~UART_LSR_BRK_ERROR_BITS;
724 spin_unlock_irqrestore(&priv->status_lock, flags);
725
726 if (unlikely(lsr & UART_LSR_BI))
727 flag = TTY_BREAK;
728 else if (unlikely(lsr & UART_LSR_PE))
729 flag = TTY_PARITY;
730 else if (unlikely(lsr & UART_LSR_FE))
731 flag = TTY_FRAME;
732 else
733 flag = TTY_NORMAL;
734
735 tty = tty_port_tty_get(&port->port);
736 if (tty) {
737 /* overrun is special, not associated with a char */
738 if (unlikely(lsr & UART_LSR_OE))
739 tty_insert_flip_char(tty, 0, TTY_OVERRUN);
740 send_to_tty(tty, data, urb->actual_length, flag);
741 tty_flip_buffer_push(tty);
742 tty_kref_put(tty);
743 }
744
745 /* Throttle the device if requested by tty */
746 spin_lock_irqsave(&port->lock, flags);
747 port->throttled = port->throttle_req;
748 if (port->throttled) {
749 spin_unlock_irqrestore(&port->lock, flags);
750 return;
751 } else
752 spin_unlock_irqrestore(&port->lock, flags);
753 }
754 /* Continue reading from device */
755 result = usb_submit_urb(urb, GFP_ATOMIC);
756 if (result)
757 dev_err(&urb->dev->dev, "%s - failed resubmitting"
758 " read urb, error %d\n", __func__, result);
434} 759}
435 760
436static struct usb_driver ark3116_driver = { 761static struct usb_driver ark3116_driver = {
@@ -450,11 +775,17 @@ static struct usb_serial_driver ark3116_device = {
450 .usb_driver = &ark3116_driver, 775 .usb_driver = &ark3116_driver,
451 .num_ports = 1, 776 .num_ports = 1,
452 .attach = ark3116_attach, 777 .attach = ark3116_attach,
778 .release = ark3116_release,
453 .set_termios = ark3116_set_termios, 779 .set_termios = ark3116_set_termios,
454 .init_termios = ark3116_init_termios, 780 .init_termios = ark3116_init_termios,
455 .ioctl = ark3116_ioctl, 781 .ioctl = ark3116_ioctl,
456 .tiocmget = ark3116_tiocmget, 782 .tiocmget = ark3116_tiocmget,
783 .tiocmset = ark3116_tiocmset,
457 .open = ark3116_open, 784 .open = ark3116_open,
785 .close = ark3116_close,
786 .break_ctl = ark3116_break_ctl,
787 .read_int_callback = ark3116_read_int_callback,
788 .read_bulk_callback = ark3116_read_bulk_callback,
458}; 789};
459 790
460static int __init ark3116_init(void) 791static int __init ark3116_init(void)
@@ -465,7 +796,12 @@ static int __init ark3116_init(void)
465 if (retval) 796 if (retval)
466 return retval; 797 return retval;
467 retval = usb_register(&ark3116_driver); 798 retval = usb_register(&ark3116_driver);
468 if (retval) 799 if (retval == 0) {
800 printk(KERN_INFO "%s:"
801 DRIVER_VERSION ":"
802 DRIVER_DESC "\n",
803 KBUILD_MODNAME);
804 } else
469 usb_serial_deregister(&ark3116_device); 805 usb_serial_deregister(&ark3116_device);
470 return retval; 806 return retval;
471} 807}
@@ -480,6 +816,109 @@ module_init(ark3116_init);
480module_exit(ark3116_exit); 816module_exit(ark3116_exit);
481MODULE_LICENSE("GPL"); 817MODULE_LICENSE("GPL");
482 818
819MODULE_AUTHOR(DRIVER_AUTHOR);
820MODULE_DESCRIPTION(DRIVER_DESC);
821
483module_param(debug, bool, S_IRUGO | S_IWUSR); 822module_param(debug, bool, S_IRUGO | S_IWUSR);
484MODULE_PARM_DESC(debug, "Debug enabled or not"); 823MODULE_PARM_DESC(debug, "Enable debug");
485 824
825/*
826 * The following describes what I learned from studying the old
827 * ark3116.c driver, disassembling the windows driver, and some lucky
828 * guesses. Since I do not have any datasheet or other
829 * documentation, inaccuracies are almost guaranteed.
830 *
831 * Some specs for the ARK3116 can be found here:
832 * http://web.archive.org/web/20060318000438/
833 * www.arkmicro.com/en/products/view.php?id=10
834 * On that page, 2 GPIO pins are mentioned: I assume these are the
835 * OUT1 and OUT2 pins of the UART, so I added support for those
836 * through the MCR. Since the pins are not available on my hardware,
837 * I could not verify this.
838 * Also, it states there is "on-chip hardware flow control". I have
839 * discovered how to enable that. Unfortunately, I do not know how to
840 * enable XON/XOFF (software) flow control, which would need support
841 * from the chip as well to work. Because of the wording on the web
842 * page there is a real possibility the chip simply does not support
843 * software flow control.
844 *
845 * I got my ark3116 as part of a mobile phone adapter cable. On the
846 * PCB, the following numbered contacts are present:
847 *
848 * 1:- +5V
849 * 2:o DTR
850 * 3:i RX
851 * 4:i DCD
852 * 5:o RTS
853 * 6:o TX
854 * 7:i RI
855 * 8:i DSR
856 * 10:- 0V
857 * 11:i CTS
858 *
859 * On my chip, all signals seem to be 3.3V, but 5V tolerant. But that
860 * may be different for the one you have ;-).
861 *
862 * The windows driver limits the registers to 0-F, so I assume there
863 * are actually 16 present on the device.
864 *
865 * On an UART interrupt, 4 bytes of data come in on the interrupt
866 * endpoint. The bytes are 0xe8 IIR LSR MSR.
867 *
868 * The baudrate seems to be generated from the 12MHz crystal, using
869 * 4-times subsampling. So quot=12e6/(4*baud). Also see description
870 * of register E.
871 *
872 * Registers 0-7:
873 * These seem to be the same as for a regular 16450. The FCR is set
874 * to UART_FCR_DMA_SELECT (0x8), I guess to enable transfers between
875 * the UART and the USB bridge/DMA engine.
876 *
877 * Register 8:
878 * By trial and error, I found out that bit 0 enables hardware CTS,
879 * stopping TX when CTS is +5V. Bit 1 does the same for RTS, making
880 * RTS +5V when the 3116 cannot transfer the data to the USB bus
881 * (verified by disabling the reading URB). Note that as far as I can
882 * tell, the windows driver does NOT use this, so there might be some
883 * hardware bug or something.
884 *
885 * According to a patch provided here
886 * (http://lkml.org/lkml/2009/7/26/56), the ARK3116 can also be used
887 * as an IrDA dongle. Since I do not have such a thing, I could not
888 * investigate that aspect. However, I can speculate ;-).
889 *
890 * - IrDA encodes data differently than RS232. Most likely, one of
891 * the bits in registers 9..E enables the IR ENDEC (encoder/decoder).
892 * - Depending on the IR transceiver, the input and output need to be
893 * inverted, so there are probably bits for that as well.
894 * - IrDA is half-duplex, so there should be a bit for selecting that.
895 *
896 * This still leaves at least two registers unaccounted for. Perhaps
897 * The chip can do XON/XOFF or CRC in HW?
898 *
899 * Register 9:
900 * Set to 0x00 for IrDA, when the baudrate is initialised.
901 *
902 * Register A:
903 * Set to 0x01 for IrDA, at init.
904 *
905 * Register B:
906 * Set to 0x01 for IrDA, 0x00 for RS232, at init.
907 *
908 * Register C:
909 * Set to 00 for IrDA, at init.
910 *
911 * Register D:
912 * Set to 0x41 for IrDA, at init.
913 *
914 * Register E:
915 * Somekind of baudrate override. The windows driver seems to set
916 * this to 0x00 for normal baudrates, 0x01 for 460800, 0x02 for 921600.
917 * Since 460800 and 921600 cannot be obtained by dividing 3MHz by an integer,
918 * it could be somekind of subdivisor thingy.
919 * However,it does not seem to do anything: selecting 921600 (divisor 3,
920 * reg E=2), still gets 1 MHz. I also checked if registers 9, C or F would
921 * work, but they don't.
922 *
923 * Register F: unknown
924 */
diff --git a/drivers/usb/serial/belkin_sa.c b/drivers/usb/serial/belkin_sa.c
index a0467bc61627..1295e44e3f1c 100644
--- a/drivers/usb/serial/belkin_sa.c
+++ b/drivers/usb/serial/belkin_sa.c
@@ -103,7 +103,7 @@ static int belkin_sa_tiocmset(struct tty_struct *tty, struct file *file,
103 unsigned int set, unsigned int clear); 103 unsigned int set, unsigned int clear);
104 104
105 105
106static struct usb_device_id id_table_combined [] = { 106static const struct usb_device_id id_table_combined[] = {
107 { USB_DEVICE(BELKIN_SA_VID, BELKIN_SA_PID) }, 107 { USB_DEVICE(BELKIN_SA_VID, BELKIN_SA_PID) },
108 { USB_DEVICE(BELKIN_OLD_VID, BELKIN_OLD_PID) }, 108 { USB_DEVICE(BELKIN_OLD_VID, BELKIN_OLD_PID) },
109 { USB_DEVICE(PERACOM_VID, PERACOM_PID) }, 109 { USB_DEVICE(PERACOM_VID, PERACOM_PID) },
diff --git a/drivers/usb/serial/bus.c b/drivers/usb/serial/bus.c
index ba555c528cc6..7f547dc3a590 100644
--- a/drivers/usb/serial/bus.c
+++ b/drivers/usb/serial/bus.c
@@ -11,6 +11,7 @@
11#include <linux/kernel.h> 11#include <linux/kernel.h>
12#include <linux/errno.h> 12#include <linux/errno.h>
13#include <linux/tty.h> 13#include <linux/tty.h>
14#include <linux/slab.h>
14#include <linux/module.h> 15#include <linux/module.h>
15#include <linux/usb.h> 16#include <linux/usb.h>
16#include <linux/usb/serial.h> 17#include <linux/usb/serial.h>
diff --git a/drivers/usb/serial/ch341.c b/drivers/usb/serial/ch341.c
index 59eff721fcc5..7e8e39818414 100644
--- a/drivers/usb/serial/ch341.c
+++ b/drivers/usb/serial/ch341.c
@@ -19,9 +19,11 @@
19#include <linux/init.h> 19#include <linux/init.h>
20#include <linux/tty.h> 20#include <linux/tty.h>
21#include <linux/module.h> 21#include <linux/module.h>
22#include <linux/slab.h>
22#include <linux/usb.h> 23#include <linux/usb.h>
23#include <linux/usb/serial.h> 24#include <linux/usb/serial.h>
24#include <linux/serial.h> 25#include <linux/serial.h>
26#include <asm/unaligned.h>
25 27
26#define DEFAULT_BAUD_RATE 9600 28#define DEFAULT_BAUD_RATE 9600
27#define DEFAULT_TIMEOUT 1000 29#define DEFAULT_TIMEOUT 1000
@@ -70,7 +72,7 @@
70 72
71static int debug; 73static int debug;
72 74
73static struct usb_device_id id_table [] = { 75static const struct usb_device_id id_table[] = {
74 { USB_DEVICE(0x4348, 0x5523) }, 76 { USB_DEVICE(0x4348, 0x5523) },
75 { USB_DEVICE(0x1a86, 0x7523) }, 77 { USB_DEVICE(0x1a86, 0x7523) },
76 { }, 78 { },
@@ -392,16 +394,22 @@ static void ch341_break_ctl(struct tty_struct *tty, int break_state)
392 struct usb_serial_port *port = tty->driver_data; 394 struct usb_serial_port *port = tty->driver_data;
393 int r; 395 int r;
394 uint16_t reg_contents; 396 uint16_t reg_contents;
395 uint8_t break_reg[2]; 397 uint8_t *break_reg;
396 398
397 dbg("%s()", __func__); 399 dbg("%s()", __func__);
398 400
401 break_reg = kmalloc(2, GFP_KERNEL);
402 if (!break_reg) {
403 dev_err(&port->dev, "%s - kmalloc failed\n", __func__);
404 return;
405 }
406
399 r = ch341_control_in(port->serial->dev, CH341_REQ_READ_REG, 407 r = ch341_control_in(port->serial->dev, CH341_REQ_READ_REG,
400 ch341_break_reg, 0, break_reg, sizeof(break_reg)); 408 ch341_break_reg, 0, break_reg, 2);
401 if (r < 0) { 409 if (r < 0) {
402 printk(KERN_WARNING "%s: USB control read error whilst getting" 410 dev_err(&port->dev, "%s - USB control read error (%d)\n",
403 " break register contents.\n", __FILE__); 411 __func__, r);
404 return; 412 goto out;
405 } 413 }
406 dbg("%s - initial ch341 break register contents - reg1: %x, reg2: %x", 414 dbg("%s - initial ch341 break register contents - reg1: %x, reg2: %x",
407 __func__, break_reg[0], break_reg[1]); 415 __func__, break_reg[0], break_reg[1]);
@@ -416,12 +424,14 @@ static void ch341_break_ctl(struct tty_struct *tty, int break_state)
416 } 424 }
417 dbg("%s - New ch341 break register contents - reg1: %x, reg2: %x", 425 dbg("%s - New ch341 break register contents - reg1: %x, reg2: %x",
418 __func__, break_reg[0], break_reg[1]); 426 __func__, break_reg[0], break_reg[1]);
419 reg_contents = (uint16_t)break_reg[0] | ((uint16_t)break_reg[1] << 8); 427 reg_contents = get_unaligned_le16(break_reg);
420 r = ch341_control_out(port->serial->dev, CH341_REQ_WRITE_REG, 428 r = ch341_control_out(port->serial->dev, CH341_REQ_WRITE_REG,
421 ch341_break_reg, reg_contents); 429 ch341_break_reg, reg_contents);
422 if (r < 0) 430 if (r < 0)
423 printk(KERN_WARNING "%s: USB control write error whilst setting" 431 dev_err(&port->dev, "%s - USB control write error (%d)\n",
424 " break register contents.\n", __FILE__); 432 __func__, r);
433out:
434 kfree(break_reg);
425} 435}
426 436
427static int ch341_tiocmset(struct tty_struct *tty, struct file *file, 437static int ch341_tiocmset(struct tty_struct *tty, struct file *file,
diff --git a/drivers/usb/serial/console.c b/drivers/usb/serial/console.c
index b22ac3258523..f347da2ef00a 100644
--- a/drivers/usb/serial/console.c
+++ b/drivers/usb/serial/console.c
@@ -181,6 +181,7 @@ static int usb_console_setup(struct console *co, char *options)
181 /* The console is special in terms of closing the device so 181 /* The console is special in terms of closing the device so
182 * indicate this port is now acting as a system console. */ 182 * indicate this port is now acting as a system console. */
183 port->console = 1; 183 port->console = 1;
184 port->port.console = 1;
184 185
185 mutex_unlock(&serial->disc_mutex); 186 mutex_unlock(&serial->disc_mutex);
186 return retval; 187 return retval;
diff --git a/drivers/usb/serial/cp210x.c b/drivers/usb/serial/cp210x.c
index bd254ec97d14..ec9b0449ccf6 100644
--- a/drivers/usb/serial/cp210x.c
+++ b/drivers/usb/serial/cp210x.c
@@ -55,7 +55,7 @@ static int cp210x_carrier_raised(struct usb_serial_port *p);
55 55
56static int debug; 56static int debug;
57 57
58static struct usb_device_id id_table [] = { 58static const struct usb_device_id id_table[] = {
59 { USB_DEVICE(0x0471, 0x066A) }, /* AKTAKOM ACE-1001 cable */ 59 { USB_DEVICE(0x0471, 0x066A) }, /* AKTAKOM ACE-1001 cable */
60 { USB_DEVICE(0x0489, 0xE000) }, /* Pirelli Broadband S.p.A, DP-L10 SIP/GSM Mobile */ 60 { USB_DEVICE(0x0489, 0xE000) }, /* Pirelli Broadband S.p.A, DP-L10 SIP/GSM Mobile */
61 { USB_DEVICE(0x0745, 0x1000) }, /* CipherLab USB CCD Barcode Scanner 1000 */ 61 { USB_DEVICE(0x0745, 0x1000) }, /* CipherLab USB CCD Barcode Scanner 1000 */
@@ -91,11 +91,12 @@ static struct usb_device_id id_table [] = {
91 { USB_DEVICE(0x10C4, 0x81C8) }, /* Lipowsky Industrie Elektronik GmbH, Baby-JTAG */ 91 { USB_DEVICE(0x10C4, 0x81C8) }, /* Lipowsky Industrie Elektronik GmbH, Baby-JTAG */
92 { USB_DEVICE(0x10C4, 0x81E2) }, /* Lipowsky Industrie Elektronik GmbH, Baby-LIN */ 92 { USB_DEVICE(0x10C4, 0x81E2) }, /* Lipowsky Industrie Elektronik GmbH, Baby-LIN */
93 { USB_DEVICE(0x10C4, 0x81E7) }, /* Aerocomm Radio */ 93 { USB_DEVICE(0x10C4, 0x81E7) }, /* Aerocomm Radio */
94 { USB_DEVICE(0x10C4, 0x81E8) }, /* Zephyr Bioharness */
94 { USB_DEVICE(0x10C4, 0x81F2) }, /* C1007 HF band RFID controller */ 95 { USB_DEVICE(0x10C4, 0x81F2) }, /* C1007 HF band RFID controller */
95 { USB_DEVICE(0x10C4, 0x8218) }, /* Lipowsky Industrie Elektronik GmbH, HARP-1 */ 96 { USB_DEVICE(0x10C4, 0x8218) }, /* Lipowsky Industrie Elektronik GmbH, HARP-1 */
96 { USB_DEVICE(0x10C4, 0x822B) }, /* Modem EDGE(GSM) Comander 2 */ 97 { USB_DEVICE(0x10C4, 0x822B) }, /* Modem EDGE(GSM) Comander 2 */
97 { USB_DEVICE(0x10C4, 0x826B) }, /* Cygnal Integrated Products, Inc., Fasttrax GPS demostration module */ 98 { USB_DEVICE(0x10C4, 0x826B) }, /* Cygnal Integrated Products, Inc., Fasttrax GPS demostration module */
98 { USB_DEVICE(0x10c4, 0x8293) }, /* Telegesys ETRX2USB */ 99 { USB_DEVICE(0x10C4, 0x8293) }, /* Telegesys ETRX2USB */
99 { USB_DEVICE(0x10C4, 0x82F9) }, /* Procyon AVS */ 100 { USB_DEVICE(0x10C4, 0x82F9) }, /* Procyon AVS */
100 { USB_DEVICE(0x10C4, 0x8341) }, /* Siemens MC35PU GPRS Modem */ 101 { USB_DEVICE(0x10C4, 0x8341) }, /* Siemens MC35PU GPRS Modem */
101 { USB_DEVICE(0x10C4, 0x8382) }, /* Cygnal Integrated Products, Inc. */ 102 { USB_DEVICE(0x10C4, 0x8382) }, /* Cygnal Integrated Products, Inc. */
@@ -312,11 +313,6 @@ static int cp210x_set_config(struct usb_serial_port *port, u8 request,
312 return -EPROTO; 313 return -EPROTO;
313 } 314 }
314 315
315 /* Single data value */
316 result = usb_control_msg(serial->dev,
317 usb_sndctrlpipe(serial->dev, 0),
318 request, REQTYPE_HOST_TO_DEVICE, data[0],
319 0, NULL, 0, 300);
320 return 0; 316 return 0;
321} 317}
322 318
@@ -612,7 +608,7 @@ static void cp210x_set_termios(struct tty_struct *tty,
612 baud); 608 baud);
613 if (cp210x_set_config_single(port, CP210X_SET_BAUDDIV, 609 if (cp210x_set_config_single(port, CP210X_SET_BAUDDIV,
614 ((BAUD_RATE_GEN_FREQ + baud/2) / baud))) { 610 ((BAUD_RATE_GEN_FREQ + baud/2) / baud))) {
615 dbg("Baud rate requested not supported by device\n"); 611 dbg("Baud rate requested not supported by device");
616 baud = tty_termios_baud_rate(old_termios); 612 baud = tty_termios_baud_rate(old_termios);
617 } 613 }
618 } 614 }
diff --git a/drivers/usb/serial/cyberjack.c b/drivers/usb/serial/cyberjack.c
index b0f6402a91ca..f744ab7a3b19 100644
--- a/drivers/usb/serial/cyberjack.c
+++ b/drivers/usb/serial/cyberjack.c
@@ -70,7 +70,7 @@ static void cyberjack_read_int_callback(struct urb *urb);
70static void cyberjack_read_bulk_callback(struct urb *urb); 70static void cyberjack_read_bulk_callback(struct urb *urb);
71static void cyberjack_write_bulk_callback(struct urb *urb); 71static void cyberjack_write_bulk_callback(struct urb *urb);
72 72
73static struct usb_device_id id_table [] = { 73static const struct usb_device_id id_table[] = {
74 { USB_DEVICE(CYBERJACK_VENDOR_ID, CYBERJACK_PRODUCT_ID) }, 74 { USB_DEVICE(CYBERJACK_VENDOR_ID, CYBERJACK_PRODUCT_ID) },
75 { } /* Terminating entry */ 75 { } /* Terminating entry */
76}; 76};
@@ -391,11 +391,10 @@ static void cyberjack_read_bulk_callback(struct urb *urb)
391 391
392 tty = tty_port_tty_get(&port->port); 392 tty = tty_port_tty_get(&port->port);
393 if (!tty) { 393 if (!tty) {
394 dbg("%s - ignoring since device not open\n", __func__); 394 dbg("%s - ignoring since device not open", __func__);
395 return; 395 return;
396 } 396 }
397 if (urb->actual_length) { 397 if (urb->actual_length) {
398 tty_buffer_request_room(tty, urb->actual_length);
399 tty_insert_flip_string(tty, data, urb->actual_length); 398 tty_insert_flip_string(tty, data, urb->actual_length);
400 tty_flip_buffer_push(tty); 399 tty_flip_buffer_push(tty);
401 } 400 }
diff --git a/drivers/usb/serial/cypress_m8.c b/drivers/usb/serial/cypress_m8.c
index a591ebec0f89..e23c77925e7a 100644
--- a/drivers/usb/serial/cypress_m8.c
+++ b/drivers/usb/serial/cypress_m8.c
@@ -66,17 +66,15 @@
66#include <linux/serial.h> 66#include <linux/serial.h>
67#include <linux/delay.h> 67#include <linux/delay.h>
68#include <linux/uaccess.h> 68#include <linux/uaccess.h>
69#include <asm/unaligned.h>
69 70
70#include "cypress_m8.h" 71#include "cypress_m8.h"
71 72
72 73
73#ifdef CONFIG_USB_SERIAL_DEBUG 74static int debug;
74 static int debug = 1;
75#else
76 static int debug;
77#endif
78static int stats; 75static int stats;
79static int interval; 76static int interval;
77static int unstable_bauds;
80 78
81/* 79/*
82 * Version Information 80 * Version Information
@@ -89,24 +87,24 @@ static int interval;
89#define CYPRESS_BUF_SIZE 1024 87#define CYPRESS_BUF_SIZE 1024
90#define CYPRESS_CLOSING_WAIT (30*HZ) 88#define CYPRESS_CLOSING_WAIT (30*HZ)
91 89
92static struct usb_device_id id_table_earthmate [] = { 90static const struct usb_device_id id_table_earthmate[] = {
93 { USB_DEVICE(VENDOR_ID_DELORME, PRODUCT_ID_EARTHMATEUSB) }, 91 { USB_DEVICE(VENDOR_ID_DELORME, PRODUCT_ID_EARTHMATEUSB) },
94 { USB_DEVICE(VENDOR_ID_DELORME, PRODUCT_ID_EARTHMATEUSB_LT20) }, 92 { USB_DEVICE(VENDOR_ID_DELORME, PRODUCT_ID_EARTHMATEUSB_LT20) },
95 { } /* Terminating entry */ 93 { } /* Terminating entry */
96}; 94};
97 95
98static struct usb_device_id id_table_cyphidcomrs232 [] = { 96static const struct usb_device_id id_table_cyphidcomrs232[] = {
99 { USB_DEVICE(VENDOR_ID_CYPRESS, PRODUCT_ID_CYPHIDCOM) }, 97 { USB_DEVICE(VENDOR_ID_CYPRESS, PRODUCT_ID_CYPHIDCOM) },
100 { USB_DEVICE(VENDOR_ID_POWERCOM, PRODUCT_ID_UPS) }, 98 { USB_DEVICE(VENDOR_ID_POWERCOM, PRODUCT_ID_UPS) },
101 { } /* Terminating entry */ 99 { } /* Terminating entry */
102}; 100};
103 101
104static struct usb_device_id id_table_nokiaca42v2 [] = { 102static const struct usb_device_id id_table_nokiaca42v2[] = {
105 { USB_DEVICE(VENDOR_ID_DAZZLE, PRODUCT_ID_CA42) }, 103 { USB_DEVICE(VENDOR_ID_DAZZLE, PRODUCT_ID_CA42) },
106 { } /* Terminating entry */ 104 { } /* Terminating entry */
107}; 105};
108 106
109static struct usb_device_id id_table_combined [] = { 107static const struct usb_device_id id_table_combined[] = {
110 { USB_DEVICE(VENDOR_ID_DELORME, PRODUCT_ID_EARTHMATEUSB) }, 108 { USB_DEVICE(VENDOR_ID_DELORME, PRODUCT_ID_EARTHMATEUSB) },
111 { USB_DEVICE(VENDOR_ID_DELORME, PRODUCT_ID_EARTHMATEUSB_LT20) }, 109 { USB_DEVICE(VENDOR_ID_DELORME, PRODUCT_ID_EARTHMATEUSB_LT20) },
112 { USB_DEVICE(VENDOR_ID_CYPRESS, PRODUCT_ID_CYPHIDCOM) }, 110 { USB_DEVICE(VENDOR_ID_CYPRESS, PRODUCT_ID_CYPHIDCOM) },
@@ -154,7 +152,7 @@ struct cypress_private {
154 int isthrottled; /* if throttled, discard reads */ 152 int isthrottled; /* if throttled, discard reads */
155 wait_queue_head_t delta_msr_wait; /* used for TIOCMIWAIT */ 153 wait_queue_head_t delta_msr_wait; /* used for TIOCMIWAIT */
156 char prev_status, diff_status; /* used for TIOCMIWAIT */ 154 char prev_status, diff_status; /* used for TIOCMIWAIT */
157 /* we pass a pointer to this as the arguement sent to 155 /* we pass a pointer to this as the argument sent to
158 cypress_set_termios old_termios */ 156 cypress_set_termios old_termios */
159 struct ktermios tmp_termios; /* stores the old termios settings */ 157 struct ktermios tmp_termios; /* stores the old termios settings */
160}; 158};
@@ -295,6 +293,9 @@ static int analyze_baud_rate(struct usb_serial_port *port, speed_t new_rate)
295 struct cypress_private *priv; 293 struct cypress_private *priv;
296 priv = usb_get_serial_port_data(port); 294 priv = usb_get_serial_port_data(port);
297 295
296 if (unstable_bauds)
297 return new_rate;
298
298 /* 299 /*
299 * The general purpose firmware for the Cypress M8 allows for 300 * The general purpose firmware for the Cypress M8 allows for
300 * a maximum speed of 57600bps (I have no idea whether DeLorme 301 * a maximum speed of 57600bps (I have no idea whether DeLorme
@@ -344,7 +345,8 @@ static int cypress_serial_control(struct tty_struct *tty,
344{ 345{
345 int new_baudrate = 0, retval = 0, tries = 0; 346 int new_baudrate = 0, retval = 0, tries = 0;
346 struct cypress_private *priv; 347 struct cypress_private *priv;
347 __u8 feature_buffer[5]; 348 u8 *feature_buffer;
349 const unsigned int feature_len = 5;
348 unsigned long flags; 350 unsigned long flags;
349 351
350 dbg("%s", __func__); 352 dbg("%s", __func__);
@@ -354,17 +356,18 @@ static int cypress_serial_control(struct tty_struct *tty,
354 if (!priv->comm_is_ok) 356 if (!priv->comm_is_ok)
355 return -ENODEV; 357 return -ENODEV;
356 358
359 feature_buffer = kcalloc(feature_len, sizeof(u8), GFP_KERNEL);
360 if (!feature_buffer)
361 return -ENOMEM;
362
357 switch (cypress_request_type) { 363 switch (cypress_request_type) {
358 case CYPRESS_SET_CONFIG: 364 case CYPRESS_SET_CONFIG:
359 new_baudrate = priv->baud_rate;
360 /* 0 means 'Hang up' so doesn't change the true bit rate */ 365 /* 0 means 'Hang up' so doesn't change the true bit rate */
361 if (baud_rate == 0) 366 new_baudrate = priv->baud_rate;
362 new_baudrate = priv->baud_rate; 367 if (baud_rate && baud_rate != priv->baud_rate) {
363 /* Change of speed ? */
364 else if (baud_rate != priv->baud_rate) {
365 dbg("%s - baud rate is changing", __func__); 368 dbg("%s - baud rate is changing", __func__);
366 retval = analyze_baud_rate(port, baud_rate); 369 retval = analyze_baud_rate(port, baud_rate);
367 if (retval >= 0) { 370 if (retval >= 0) {
368 new_baudrate = retval; 371 new_baudrate = retval;
369 dbg("%s - New baud rate set to %d", 372 dbg("%s - New baud rate set to %d",
370 __func__, new_baudrate); 373 __func__, new_baudrate);
@@ -373,9 +376,8 @@ static int cypress_serial_control(struct tty_struct *tty,
373 dbg("%s - baud rate is being sent as %d", 376 dbg("%s - baud rate is being sent as %d",
374 __func__, new_baudrate); 377 __func__, new_baudrate);
375 378
376 memset(feature_buffer, 0, sizeof(feature_buffer));
377 /* fill the feature_buffer with new configuration */ 379 /* fill the feature_buffer with new configuration */
378 *((u_int32_t *)feature_buffer) = new_baudrate; 380 put_unaligned_le32(new_baudrate, feature_buffer);
379 feature_buffer[4] |= data_bits; /* assign data bits in 2 bit space ( max 3 ) */ 381 feature_buffer[4] |= data_bits; /* assign data bits in 2 bit space ( max 3 ) */
380 /* 1 bit gap */ 382 /* 1 bit gap */
381 feature_buffer[4] |= (stop_bits << 3); /* assign stop bits in 1 bit space */ 383 feature_buffer[4] |= (stop_bits << 3); /* assign stop bits in 1 bit space */
@@ -397,15 +399,15 @@ static int cypress_serial_control(struct tty_struct *tty,
397 HID_REQ_SET_REPORT, 399 HID_REQ_SET_REPORT,
398 USB_DIR_OUT | USB_RECIP_INTERFACE | USB_TYPE_CLASS, 400 USB_DIR_OUT | USB_RECIP_INTERFACE | USB_TYPE_CLASS,
399 0x0300, 0, feature_buffer, 401 0x0300, 0, feature_buffer,
400 sizeof(feature_buffer), 500); 402 feature_len, 500);
401 403
402 if (tries++ >= 3) 404 if (tries++ >= 3)
403 break; 405 break;
404 406
405 } while (retval != sizeof(feature_buffer) && 407 } while (retval != feature_len &&
406 retval != -ENODEV); 408 retval != -ENODEV);
407 409
408 if (retval != sizeof(feature_buffer)) { 410 if (retval != feature_len) {
409 dev_err(&port->dev, "%s - failed sending serial " 411 dev_err(&port->dev, "%s - failed sending serial "
410 "line settings - %d\n", __func__, retval); 412 "line settings - %d\n", __func__, retval);
411 cypress_set_dead(port); 413 cypress_set_dead(port);
@@ -425,43 +427,42 @@ static int cypress_serial_control(struct tty_struct *tty,
425 /* Not implemented for this device, 427 /* Not implemented for this device,
426 and if we try to do it we're likely 428 and if we try to do it we're likely
427 to crash the hardware. */ 429 to crash the hardware. */
428 return -ENOTTY; 430 retval = -ENOTTY;
431 goto out;
429 } 432 }
430 dbg("%s - retreiving serial line settings", __func__); 433 dbg("%s - retreiving serial line settings", __func__);
431 /* set initial values in feature buffer */
432 memset(feature_buffer, 0, sizeof(feature_buffer));
433
434 do { 434 do {
435 retval = usb_control_msg(port->serial->dev, 435 retval = usb_control_msg(port->serial->dev,
436 usb_rcvctrlpipe(port->serial->dev, 0), 436 usb_rcvctrlpipe(port->serial->dev, 0),
437 HID_REQ_GET_REPORT, 437 HID_REQ_GET_REPORT,
438 USB_DIR_IN | USB_RECIP_INTERFACE | USB_TYPE_CLASS, 438 USB_DIR_IN | USB_RECIP_INTERFACE | USB_TYPE_CLASS,
439 0x0300, 0, feature_buffer, 439 0x0300, 0, feature_buffer,
440 sizeof(feature_buffer), 500); 440 feature_len, 500);
441 441
442 if (tries++ >= 3) 442 if (tries++ >= 3)
443 break; 443 break;
444 } while (retval != sizeof(feature_buffer) 444 } while (retval != feature_len
445 && retval != -ENODEV); 445 && retval != -ENODEV);
446 446
447 if (retval != sizeof(feature_buffer)) { 447 if (retval != feature_len) {
448 dev_err(&port->dev, "%s - failed to retrieve serial " 448 dev_err(&port->dev, "%s - failed to retrieve serial "
449 "line settings - %d\n", __func__, retval); 449 "line settings - %d\n", __func__, retval);
450 cypress_set_dead(port); 450 cypress_set_dead(port);
451 return retval; 451 goto out;
452 } else { 452 } else {
453 spin_lock_irqsave(&priv->lock, flags); 453 spin_lock_irqsave(&priv->lock, flags);
454 /* store the config in one byte, and later 454 /* store the config in one byte, and later
455 use bit masks to check values */ 455 use bit masks to check values */
456 priv->current_config = feature_buffer[4]; 456 priv->current_config = feature_buffer[4];
457 priv->baud_rate = *((u_int32_t *)feature_buffer); 457 priv->baud_rate = get_unaligned_le32(feature_buffer);
458 spin_unlock_irqrestore(&priv->lock, flags); 458 spin_unlock_irqrestore(&priv->lock, flags);
459 } 459 }
460 } 460 }
461 spin_lock_irqsave(&priv->lock, flags); 461 spin_lock_irqsave(&priv->lock, flags);
462 ++priv->cmd_count; 462 ++priv->cmd_count;
463 spin_unlock_irqrestore(&priv->lock, flags); 463 spin_unlock_irqrestore(&priv->lock, flags);
464 464out:
465 kfree(feature_buffer);
465 return retval; 466 return retval;
466} /* cypress_serial_control */ 467} /* cypress_serial_control */
467 468
@@ -690,7 +691,6 @@ static void cypress_dtr_rts(struct usb_serial_port *port, int on)
690{ 691{
691 struct cypress_private *priv = usb_get_serial_port_data(port); 692 struct cypress_private *priv = usb_get_serial_port_data(port);
692 /* drop dtr and rts */ 693 /* drop dtr and rts */
693 priv = usb_get_serial_port_data(port);
694 spin_lock_irq(&priv->lock); 694 spin_lock_irq(&priv->lock);
695 if (on == 0) 695 if (on == 0)
696 priv->line_control = 0; 696 priv->line_control = 0;
@@ -1307,13 +1307,9 @@ static void cypress_read_int_callback(struct urb *urb)
1307 spin_unlock_irqrestore(&priv->lock, flags); 1307 spin_unlock_irqrestore(&priv->lock, flags);
1308 1308
1309 /* process read if there is data other than line status */ 1309 /* process read if there is data other than line status */
1310 if (tty && (bytes > i)) { 1310 if (tty && bytes > i) {
1311 bytes = tty_buffer_request_room(tty, bytes); 1311 tty_insert_flip_string_fixed_flag(tty, data + i,
1312 for (; i < bytes ; ++i) { 1312 bytes - i, tty_flag);
1313 dbg("pushing byte number %d - %d - %c", i, data[i],
1314 data[i]);
1315 tty_insert_flip_char(tty, data[i], tty_flag);
1316 }
1317 tty_flip_buffer_push(tty); 1313 tty_flip_buffer_push(tty);
1318 } 1314 }
1319 1315
@@ -1325,9 +1321,9 @@ static void cypress_read_int_callback(struct urb *urb)
1325continue_read: 1321continue_read:
1326 tty_kref_put(tty); 1322 tty_kref_put(tty);
1327 1323
1328 /* Continue trying to always read... unless the port has closed. */ 1324 /* Continue trying to always read */
1329 1325
1330 if (port->port.count > 0 && priv->comm_is_ok) { 1326 if (priv->comm_is_ok) {
1331 usb_fill_int_urb(port->interrupt_in_urb, port->serial->dev, 1327 usb_fill_int_urb(port->interrupt_in_urb, port->serial->dev,
1332 usb_rcvintpipe(port->serial->dev, 1328 usb_rcvintpipe(port->serial->dev,
1333 port->interrupt_in_endpointAddress), 1329 port->interrupt_in_endpointAddress),
@@ -1336,7 +1332,7 @@ continue_read:
1336 cypress_read_int_callback, port, 1332 cypress_read_int_callback, port,
1337 priv->read_urb_interval); 1333 priv->read_urb_interval);
1338 result = usb_submit_urb(port->interrupt_in_urb, GFP_ATOMIC); 1334 result = usb_submit_urb(port->interrupt_in_urb, GFP_ATOMIC);
1339 if (result) { 1335 if (result && result != -EPERM) {
1340 dev_err(&urb->dev->dev, "%s - failed resubmitting " 1336 dev_err(&urb->dev->dev, "%s - failed resubmitting "
1341 "read urb, error %d\n", __func__, 1337 "read urb, error %d\n", __func__,
1342 result); 1338 result);
@@ -1650,3 +1646,5 @@ module_param(stats, bool, S_IRUGO | S_IWUSR);
1650MODULE_PARM_DESC(stats, "Enable statistics or not"); 1646MODULE_PARM_DESC(stats, "Enable statistics or not");
1651module_param(interval, int, S_IRUGO | S_IWUSR); 1647module_param(interval, int, S_IRUGO | S_IWUSR);
1652MODULE_PARM_DESC(interval, "Overrides interrupt interval"); 1648MODULE_PARM_DESC(interval, "Overrides interrupt interval");
1649module_param(unstable_bauds, bool, S_IRUGO | S_IWUSR);
1650MODULE_PARM_DESC(unstable_bauds, "Allow unstable baud rates");
diff --git a/drivers/usb/serial/digi_acceleport.c b/drivers/usb/serial/digi_acceleport.c
index 68e80be6b9e1..68b0aa5e516c 100644
--- a/drivers/usb/serial/digi_acceleport.c
+++ b/drivers/usb/serial/digi_acceleport.c
@@ -470,18 +470,18 @@ static int digi_read_oob_callback(struct urb *urb);
470 470
471static int debug; 471static int debug;
472 472
473static struct usb_device_id id_table_combined [] = { 473static const struct usb_device_id id_table_combined[] = {
474 { USB_DEVICE(DIGI_VENDOR_ID, DIGI_2_ID) }, 474 { USB_DEVICE(DIGI_VENDOR_ID, DIGI_2_ID) },
475 { USB_DEVICE(DIGI_VENDOR_ID, DIGI_4_ID) }, 475 { USB_DEVICE(DIGI_VENDOR_ID, DIGI_4_ID) },
476 { } /* Terminating entry */ 476 { } /* Terminating entry */
477}; 477};
478 478
479static struct usb_device_id id_table_2 [] = { 479static const struct usb_device_id id_table_2[] = {
480 { USB_DEVICE(DIGI_VENDOR_ID, DIGI_2_ID) }, 480 { USB_DEVICE(DIGI_VENDOR_ID, DIGI_2_ID) },
481 { } /* Terminating entry */ 481 { } /* Terminating entry */
482}; 482};
483 483
484static struct usb_device_id id_table_4 [] = { 484static const struct usb_device_id id_table_4[] = {
485 { USB_DEVICE(DIGI_VENDOR_ID, DIGI_4_ID) }, 485 { USB_DEVICE(DIGI_VENDOR_ID, DIGI_4_ID) },
486 { } /* Terminating entry */ 486 { } /* Terminating entry */
487}; 487};
@@ -1262,10 +1262,10 @@ static void digi_write_bulk_callback(struct urb *urb)
1262 return; 1262 return;
1263 } 1263 }
1264 1264
1265 /* try to send any buffered data on this port, if it is open */ 1265 /* try to send any buffered data on this port */
1266 spin_lock(&priv->dp_port_lock); 1266 spin_lock(&priv->dp_port_lock);
1267 priv->dp_write_urb_in_use = 0; 1267 priv->dp_write_urb_in_use = 0;
1268 if (port->port.count && priv->dp_out_buf_len > 0) { 1268 if (priv->dp_out_buf_len > 0) {
1269 *((unsigned char *)(port->write_urb->transfer_buffer)) 1269 *((unsigned char *)(port->write_urb->transfer_buffer))
1270 = (unsigned char)DIGI_CMD_SEND_DATA; 1270 = (unsigned char)DIGI_CMD_SEND_DATA;
1271 *((unsigned char *)(port->write_urb->transfer_buffer) + 1) 1271 *((unsigned char *)(port->write_urb->transfer_buffer) + 1)
@@ -1288,7 +1288,7 @@ static void digi_write_bulk_callback(struct urb *urb)
1288 schedule_work(&priv->dp_wakeup_work); 1288 schedule_work(&priv->dp_wakeup_work);
1289 1289
1290 spin_unlock(&priv->dp_port_lock); 1290 spin_unlock(&priv->dp_port_lock);
1291 if (ret) 1291 if (ret && ret != -EPERM)
1292 dev_err(&port->dev, 1292 dev_err(&port->dev,
1293 "%s: usb_submit_urb failed, ret=%d, port=%d\n", 1293 "%s: usb_submit_urb failed, ret=%d, port=%d\n",
1294 __func__, ret, priv->dp_port_num); 1294 __func__, ret, priv->dp_port_num);
@@ -1353,8 +1353,7 @@ static int digi_open(struct tty_struct *tty, struct usb_serial_port *port)
1353 struct digi_port *priv = usb_get_serial_port_data(port); 1353 struct digi_port *priv = usb_get_serial_port_data(port);
1354 struct ktermios not_termios; 1354 struct ktermios not_termios;
1355 1355
1356 dbg("digi_open: TOP: port=%d, open_count=%d", 1356 dbg("digi_open: TOP: port=%d", priv->dp_port_num);
1357 priv->dp_port_num, port->port.count);
1358 1357
1359 /* be sure the device is started up */ 1358 /* be sure the device is started up */
1360 if (digi_startup_device(port->serial) != 0) 1359 if (digi_startup_device(port->serial) != 0)
@@ -1393,8 +1392,7 @@ static void digi_close(struct usb_serial_port *port)
1393 unsigned char buf[32]; 1392 unsigned char buf[32];
1394 struct digi_port *priv = usb_get_serial_port_data(port); 1393 struct digi_port *priv = usb_get_serial_port_data(port);
1395 1394
1396 dbg("digi_close: TOP: port=%d, open_count=%d", 1395 dbg("digi_close: TOP: port=%d", priv->dp_port_num);
1397 priv->dp_port_num, port->port.count);
1398 1396
1399 mutex_lock(&port->serial->disc_mutex); 1397 mutex_lock(&port->serial->disc_mutex);
1400 /* if disconnected, just clear flags */ 1398 /* if disconnected, just clear flags */
@@ -1629,7 +1627,7 @@ static void digi_read_bulk_callback(struct urb *urb)
1629 /* continue read */ 1627 /* continue read */
1630 urb->dev = port->serial->dev; 1628 urb->dev = port->serial->dev;
1631 ret = usb_submit_urb(urb, GFP_ATOMIC); 1629 ret = usb_submit_urb(urb, GFP_ATOMIC);
1632 if (ret != 0) { 1630 if (ret != 0 && ret != -EPERM) {
1633 dev_err(&port->dev, 1631 dev_err(&port->dev,
1634 "%s: failed resubmitting urb, ret=%d, port=%d\n", 1632 "%s: failed resubmitting urb, ret=%d, port=%d\n",
1635 __func__, ret, priv->dp_port_num); 1633 __func__, ret, priv->dp_port_num);
@@ -1658,12 +1656,11 @@ static int digi_read_inb_callback(struct urb *urb)
1658 int port_status = ((unsigned char *)urb->transfer_buffer)[2]; 1656 int port_status = ((unsigned char *)urb->transfer_buffer)[2];
1659 unsigned char *data = ((unsigned char *)urb->transfer_buffer) + 3; 1657 unsigned char *data = ((unsigned char *)urb->transfer_buffer) + 3;
1660 int flag, throttled; 1658 int flag, throttled;
1661 int i;
1662 int status = urb->status; 1659 int status = urb->status;
1663 1660
1664 /* do not process callbacks on closed ports */ 1661 /* do not process callbacks on closed ports */
1665 /* but do continue the read chain */ 1662 /* but do continue the read chain */
1666 if (port->port.count == 0) 1663 if (urb->status == -ENOENT)
1667 return 0; 1664 return 0;
1668 1665
1669 /* short/multiple packet check */ 1666 /* short/multiple packet check */
@@ -1705,17 +1702,9 @@ static int digi_read_inb_callback(struct urb *urb)
1705 1702
1706 /* data length is len-1 (one byte of len is port_status) */ 1703 /* data length is len-1 (one byte of len is port_status) */
1707 --len; 1704 --len;
1708
1709 len = tty_buffer_request_room(tty, len);
1710 if (len > 0) { 1705 if (len > 0) {
1711 /* Hot path */ 1706 tty_insert_flip_string_fixed_flag(tty, data, len,
1712 if (flag == TTY_NORMAL) 1707 flag);
1713 tty_insert_flip_string(tty, data, len);
1714 else {
1715 for (i = 0; i < len; i++)
1716 tty_insert_flip_char(tty,
1717 data[i], flag);
1718 }
1719 tty_flip_buffer_push(tty); 1708 tty_flip_buffer_push(tty);
1720 } 1709 }
1721 } 1710 }
@@ -1776,8 +1765,7 @@ static int digi_read_oob_callback(struct urb *urb)
1776 1765
1777 tty = tty_port_tty_get(&port->port); 1766 tty = tty_port_tty_get(&port->port);
1778 rts = 0; 1767 rts = 0;
1779 if (port->port.count) 1768 rts = tty->termios->c_cflag & CRTSCTS;
1780 rts = tty->termios->c_cflag & CRTSCTS;
1781 1769
1782 if (opcode == DIGI_CMD_READ_INPUT_SIGNALS) { 1770 if (opcode == DIGI_CMD_READ_INPUT_SIGNALS) {
1783 spin_lock(&priv->dp_port_lock); 1771 spin_lock(&priv->dp_port_lock);
diff --git a/drivers/usb/serial/empeg.c b/drivers/usb/serial/empeg.c
index 7dd0e3eadbe6..5f740a1eacab 100644
--- a/drivers/usb/serial/empeg.c
+++ b/drivers/usb/serial/empeg.c
@@ -93,7 +93,7 @@ static void empeg_init_termios(struct tty_struct *tty);
93static void empeg_write_bulk_callback(struct urb *urb); 93static void empeg_write_bulk_callback(struct urb *urb);
94static void empeg_read_bulk_callback(struct urb *urb); 94static void empeg_read_bulk_callback(struct urb *urb);
95 95
96static struct usb_device_id id_table [] = { 96static const struct usb_device_id id_table[] = {
97 { USB_DEVICE(EMPEG_VENDOR_ID, EMPEG_PRODUCT_ID) }, 97 { USB_DEVICE(EMPEG_VENDOR_ID, EMPEG_PRODUCT_ID) },
98 { } /* Terminating entry */ 98 { } /* Terminating entry */
99}; 99};
@@ -346,7 +346,6 @@ static void empeg_read_bulk_callback(struct urb *urb)
346 tty = tty_port_tty_get(&port->port); 346 tty = tty_port_tty_get(&port->port);
347 347
348 if (urb->actual_length) { 348 if (urb->actual_length) {
349 tty_buffer_request_room(tty, urb->actual_length);
350 tty_insert_flip_string(tty, data, urb->actual_length); 349 tty_insert_flip_string(tty, data, urb->actual_length);
351 tty_flip_buffer_push(tty); 350 tty_flip_buffer_push(tty);
352 bytes_in += urb->actual_length; 351 bytes_in += urb->actual_length;
diff --git a/drivers/usb/serial/ftdi_sio.c b/drivers/usb/serial/ftdi_sio.c
index ebcc6d0e2e91..1d7c4fac02e8 100644
--- a/drivers/usb/serial/ftdi_sio.c
+++ b/drivers/usb/serial/ftdi_sio.c
@@ -33,23 +33,24 @@
33#include <linux/errno.h> 33#include <linux/errno.h>
34#include <linux/init.h> 34#include <linux/init.h>
35#include <linux/slab.h> 35#include <linux/slab.h>
36#include <linux/smp_lock.h>
37#include <linux/tty.h> 36#include <linux/tty.h>
38#include <linux/tty_driver.h> 37#include <linux/tty_driver.h>
39#include <linux/tty_flip.h> 38#include <linux/tty_flip.h>
40#include <linux/module.h> 39#include <linux/module.h>
41#include <linux/spinlock.h> 40#include <linux/spinlock.h>
41#include <linux/mutex.h>
42#include <linux/uaccess.h> 42#include <linux/uaccess.h>
43#include <linux/usb.h> 43#include <linux/usb.h>
44#include <linux/serial.h> 44#include <linux/serial.h>
45#include <linux/usb/serial.h> 45#include <linux/usb/serial.h>
46#include "ftdi_sio.h" 46#include "ftdi_sio.h"
47#include "ftdi_sio_ids.h"
47 48
48/* 49/*
49 * Version Information 50 * Version Information
50 */ 51 */
51#define DRIVER_VERSION "v1.5.0" 52#define DRIVER_VERSION "v1.5.0"
52#define DRIVER_AUTHOR "Greg Kroah-Hartman <greg@kroah.com>, Bill Ryder <bryder@sgi.com>, Kuba Ober <kuba@mareimbrium.org>" 53#define DRIVER_AUTHOR "Greg Kroah-Hartman <greg@kroah.com>, Bill Ryder <bryder@sgi.com>, Kuba Ober <kuba@mareimbrium.org>, Andreas Mohr"
53#define DRIVER_DESC "USB FTDI Serial Converters Driver" 54#define DRIVER_DESC "USB FTDI Serial Converters Driver"
54 55
55static int debug; 56static int debug;
@@ -87,10 +88,10 @@ struct ftdi_private {
87 88
88 unsigned int latency; /* latency setting in use */ 89 unsigned int latency; /* latency setting in use */
89 spinlock_t tx_lock; /* spinlock for transmit state */ 90 spinlock_t tx_lock; /* spinlock for transmit state */
90 unsigned long tx_bytes;
91 unsigned long tx_outstanding_bytes; 91 unsigned long tx_outstanding_bytes;
92 unsigned long tx_outstanding_urbs; 92 unsigned long tx_outstanding_urbs;
93 unsigned short max_packet_size; 93 unsigned short max_packet_size;
94 struct mutex cfg_lock; /* Avoid mess by parallel calls of config ioctl() and change_speed() */
94}; 95};
95 96
96/* struct ftdi_sio_quirk is used by devices requiring special attention. */ 97/* struct ftdi_sio_quirk is used by devices requiring special attention. */
@@ -144,10 +145,15 @@ static struct ftdi_sio_quirk ftdi_HE_TIRA1_quirk = {
144 145
145 146
146 147
148/*
149 * Device ID not listed? Test via module params product/vendor or
150 * /sys/bus/usb/ftdi_sio/new_id, then send patch/report!
151 */
147static struct usb_device_id id_table_combined [] = { 152static struct usb_device_id id_table_combined [] = {
148 { USB_DEVICE(FTDI_VID, FTDI_AMC232_PID) }, 153 { USB_DEVICE(FTDI_VID, FTDI_AMC232_PID) },
149 { USB_DEVICE(FTDI_VID, FTDI_CANUSB_PID) }, 154 { USB_DEVICE(FTDI_VID, FTDI_CANUSB_PID) },
150 { USB_DEVICE(FTDI_VID, FTDI_CANDAPTER_PID) }, 155 { USB_DEVICE(FTDI_VID, FTDI_CANDAPTER_PID) },
156 { USB_DEVICE(FTDI_VID, FTDI_NXTCAM_PID) },
151 { USB_DEVICE(FTDI_VID, FTDI_SCS_DEVICE_0_PID) }, 157 { USB_DEVICE(FTDI_VID, FTDI_SCS_DEVICE_0_PID) },
152 { USB_DEVICE(FTDI_VID, FTDI_SCS_DEVICE_1_PID) }, 158 { USB_DEVICE(FTDI_VID, FTDI_SCS_DEVICE_1_PID) },
153 { USB_DEVICE(FTDI_VID, FTDI_SCS_DEVICE_2_PID) }, 159 { USB_DEVICE(FTDI_VID, FTDI_SCS_DEVICE_2_PID) },
@@ -551,9 +557,16 @@ static struct usb_device_id id_table_combined [] = {
551 { USB_DEVICE(FTDI_VID, FTDI_IBS_PEDO_PID) }, 557 { USB_DEVICE(FTDI_VID, FTDI_IBS_PEDO_PID) },
552 { USB_DEVICE(FTDI_VID, FTDI_IBS_PROD_PID) }, 558 { USB_DEVICE(FTDI_VID, FTDI_IBS_PROD_PID) },
553 /* 559 /*
554 * Due to many user requests for multiple ELV devices we enable 560 * ELV devices:
555 * them by default.
556 */ 561 */
562 { USB_DEVICE(FTDI_VID, FTDI_ELV_USR_PID) },
563 { USB_DEVICE(FTDI_VID, FTDI_ELV_MSM1_PID) },
564 { USB_DEVICE(FTDI_VID, FTDI_ELV_KL100_PID) },
565 { USB_DEVICE(FTDI_VID, FTDI_ELV_WS550_PID) },
566 { USB_DEVICE(FTDI_VID, FTDI_ELV_EC3000_PID) },
567 { USB_DEVICE(FTDI_VID, FTDI_ELV_WS888_PID) },
568 { USB_DEVICE(FTDI_VID, FTDI_ELV_TWS550_PID) },
569 { USB_DEVICE(FTDI_VID, FTDI_ELV_FEM_PID) },
557 { USB_DEVICE(FTDI_VID, FTDI_ELV_CLI7000_PID) }, 570 { USB_DEVICE(FTDI_VID, FTDI_ELV_CLI7000_PID) },
558 { USB_DEVICE(FTDI_VID, FTDI_ELV_PPS7330_PID) }, 571 { USB_DEVICE(FTDI_VID, FTDI_ELV_PPS7330_PID) },
559 { USB_DEVICE(FTDI_VID, FTDI_ELV_TFM100_PID) }, 572 { USB_DEVICE(FTDI_VID, FTDI_ELV_TFM100_PID) },
@@ -570,11 +583,17 @@ static struct usb_device_id id_table_combined [] = {
570 { USB_DEVICE(FTDI_VID, FTDI_ELV_PCK100_PID) }, 583 { USB_DEVICE(FTDI_VID, FTDI_ELV_PCK100_PID) },
571 { USB_DEVICE(FTDI_VID, FTDI_ELV_RFP500_PID) }, 584 { USB_DEVICE(FTDI_VID, FTDI_ELV_RFP500_PID) },
572 { USB_DEVICE(FTDI_VID, FTDI_ELV_FS20SIG_PID) }, 585 { USB_DEVICE(FTDI_VID, FTDI_ELV_FS20SIG_PID) },
586 { USB_DEVICE(FTDI_VID, FTDI_ELV_UTP8_PID) },
573 { USB_DEVICE(FTDI_VID, FTDI_ELV_WS300PC_PID) }, 587 { USB_DEVICE(FTDI_VID, FTDI_ELV_WS300PC_PID) },
588 { USB_DEVICE(FTDI_VID, FTDI_ELV_WS444PC_PID) },
574 { USB_DEVICE(FTDI_VID, FTDI_ELV_FHZ1300PC_PID) }, 589 { USB_DEVICE(FTDI_VID, FTDI_ELV_FHZ1300PC_PID) },
575 { USB_DEVICE(FTDI_VID, FTDI_ELV_EM1010PC_PID) }, 590 { USB_DEVICE(FTDI_VID, FTDI_ELV_EM1010PC_PID) },
576 { USB_DEVICE(FTDI_VID, FTDI_ELV_WS500_PID) }, 591 { USB_DEVICE(FTDI_VID, FTDI_ELV_WS500_PID) },
577 { USB_DEVICE(FTDI_VID, FTDI_ELV_HS485_PID) }, 592 { USB_DEVICE(FTDI_VID, FTDI_ELV_HS485_PID) },
593 { USB_DEVICE(FTDI_VID, FTDI_ELV_UMS100_PID) },
594 { USB_DEVICE(FTDI_VID, FTDI_ELV_TFD128_PID) },
595 { USB_DEVICE(FTDI_VID, FTDI_ELV_FM3RX_PID) },
596 { USB_DEVICE(FTDI_VID, FTDI_ELV_WS777_PID) },
578 { USB_DEVICE(FTDI_VID, LINX_SDMUSBQSS_PID) }, 597 { USB_DEVICE(FTDI_VID, LINX_SDMUSBQSS_PID) },
579 { USB_DEVICE(FTDI_VID, LINX_MASTERDEVEL2_PID) }, 598 { USB_DEVICE(FTDI_VID, LINX_MASTERDEVEL2_PID) },
580 { USB_DEVICE(FTDI_VID, LINX_FUTURE_0_PID) }, 599 { USB_DEVICE(FTDI_VID, LINX_FUTURE_0_PID) },
@@ -595,9 +614,24 @@ static struct usb_device_id id_table_combined [] = {
595 { USB_DEVICE(FTDI_VID, FTDI_OCEANIC_PID) }, 614 { USB_DEVICE(FTDI_VID, FTDI_OCEANIC_PID) },
596 { USB_DEVICE(TTI_VID, TTI_QL355P_PID) }, 615 { USB_DEVICE(TTI_VID, TTI_QL355P_PID) },
597 { USB_DEVICE(FTDI_VID, FTDI_RM_CANVIEW_PID) }, 616 { USB_DEVICE(FTDI_VID, FTDI_RM_CANVIEW_PID) },
617 { USB_DEVICE(CONTEC_VID, CONTEC_COM1USBH_PID) },
598 { USB_DEVICE(BANDB_VID, BANDB_USOTL4_PID) }, 618 { USB_DEVICE(BANDB_VID, BANDB_USOTL4_PID) },
599 { USB_DEVICE(BANDB_VID, BANDB_USTL4_PID) }, 619 { USB_DEVICE(BANDB_VID, BANDB_USTL4_PID) },
600 { USB_DEVICE(BANDB_VID, BANDB_USO9ML2_PID) }, 620 { USB_DEVICE(BANDB_VID, BANDB_USO9ML2_PID) },
621 { USB_DEVICE(BANDB_VID, BANDB_USOPTL4_PID) },
622 { USB_DEVICE(BANDB_VID, BANDB_USPTL4_PID) },
623 { USB_DEVICE(BANDB_VID, BANDB_USO9ML2DR_2_PID) },
624 { USB_DEVICE(BANDB_VID, BANDB_USO9ML2DR_PID) },
625 { USB_DEVICE(BANDB_VID, BANDB_USOPTL4DR2_PID) },
626 { USB_DEVICE(BANDB_VID, BANDB_USOPTL4DR_PID) },
627 { USB_DEVICE(BANDB_VID, BANDB_485USB9F_2W_PID) },
628 { USB_DEVICE(BANDB_VID, BANDB_485USB9F_4W_PID) },
629 { USB_DEVICE(BANDB_VID, BANDB_232USB9M_PID) },
630 { USB_DEVICE(BANDB_VID, BANDB_485USBTB_2W_PID) },
631 { USB_DEVICE(BANDB_VID, BANDB_485USBTB_4W_PID) },
632 { USB_DEVICE(BANDB_VID, BANDB_TTL5USB9M_PID) },
633 { USB_DEVICE(BANDB_VID, BANDB_TTL3USB9M_PID) },
634 { USB_DEVICE(BANDB_VID, BANDB_ZZ_PROG1_USB_PID) },
601 { USB_DEVICE(FTDI_VID, EVER_ECO_PRO_CDS) }, 635 { USB_DEVICE(FTDI_VID, EVER_ECO_PRO_CDS) },
602 { USB_DEVICE(FTDI_VID, FTDI_4N_GALAXY_DE_1_PID) }, 636 { USB_DEVICE(FTDI_VID, FTDI_4N_GALAXY_DE_1_PID) },
603 { USB_DEVICE(FTDI_VID, FTDI_4N_GALAXY_DE_2_PID) }, 637 { USB_DEVICE(FTDI_VID, FTDI_4N_GALAXY_DE_2_PID) },
@@ -624,6 +658,7 @@ static struct usb_device_id id_table_combined [] = {
624 { USB_DEVICE(EVOLUTION_VID, EVOLUTION_ER1_PID) }, 658 { USB_DEVICE(EVOLUTION_VID, EVOLUTION_ER1_PID) },
625 { USB_DEVICE(EVOLUTION_VID, EVO_HYBRID_PID) }, 659 { USB_DEVICE(EVOLUTION_VID, EVO_HYBRID_PID) },
626 { USB_DEVICE(EVOLUTION_VID, EVO_RCM4_PID) }, 660 { USB_DEVICE(EVOLUTION_VID, EVO_RCM4_PID) },
661 { USB_DEVICE(CONTEC_VID, CONTEC_COM1USBH_PID) },
627 { USB_DEVICE(FTDI_VID, FTDI_ARTEMIS_PID) }, 662 { USB_DEVICE(FTDI_VID, FTDI_ARTEMIS_PID) },
628 { USB_DEVICE(FTDI_VID, FTDI_ATIK_ATK16_PID) }, 663 { USB_DEVICE(FTDI_VID, FTDI_ATIK_ATK16_PID) },
629 { USB_DEVICE(FTDI_VID, FTDI_ATIK_ATK16C_PID) }, 664 { USB_DEVICE(FTDI_VID, FTDI_ATIK_ATK16C_PID) },
@@ -682,6 +717,7 @@ static struct usb_device_id id_table_combined [] = {
682 { USB_DEVICE(RATOC_VENDOR_ID, RATOC_PRODUCT_ID_USB60F) }, 717 { USB_DEVICE(RATOC_VENDOR_ID, RATOC_PRODUCT_ID_USB60F) },
683 { USB_DEVICE(FTDI_VID, FTDI_REU_TINY_PID) }, 718 { USB_DEVICE(FTDI_VID, FTDI_REU_TINY_PID) },
684 { USB_DEVICE(PAPOUCH_VID, PAPOUCH_QUIDO4x4_PID) }, 719 { USB_DEVICE(PAPOUCH_VID, PAPOUCH_QUIDO4x4_PID) },
720 { USB_DEVICE(PAPOUCH_VID, PAPOUCH_AD4USB_PID) },
685 { USB_DEVICE(FTDI_VID, FTDI_DOMINTELL_DGQG_PID) }, 721 { USB_DEVICE(FTDI_VID, FTDI_DOMINTELL_DGQG_PID) },
686 { USB_DEVICE(FTDI_VID, FTDI_DOMINTELL_DUSB_PID) }, 722 { USB_DEVICE(FTDI_VID, FTDI_DOMINTELL_DUSB_PID) },
687 { USB_DEVICE(ALTI2_VID, ALTI2_N3_PID) }, 723 { USB_DEVICE(ALTI2_VID, ALTI2_N3_PID) },
@@ -703,6 +739,10 @@ static struct usb_device_id id_table_combined [] = {
703 .driver_info = (kernel_ulong_t)&ftdi_jtag_quirk }, 739 .driver_info = (kernel_ulong_t)&ftdi_jtag_quirk },
704 { USB_DEVICE(FTDI_VID, HAMEG_HO820_PID) }, 740 { USB_DEVICE(FTDI_VID, HAMEG_HO820_PID) },
705 { USB_DEVICE(FTDI_VID, HAMEG_HO870_PID) }, 741 { USB_DEVICE(FTDI_VID, HAMEG_HO870_PID) },
742 { USB_DEVICE(FTDI_VID, MJSG_GENERIC_PID) },
743 { USB_DEVICE(FTDI_VID, MJSG_SR_RADIO_PID) },
744 { USB_DEVICE(FTDI_VID, MJSG_HD_RADIO_PID) },
745 { USB_DEVICE(FTDI_VID, MJSG_XM_RADIO_PID) },
706 { }, /* Optional parameter entry */ 746 { }, /* Optional parameter entry */
707 { } /* Terminating entry */ 747 { } /* Terminating entry */
708}; 748};
@@ -778,7 +818,7 @@ static struct usb_serial_driver ftdi_sio_device = {
778 .name = "ftdi_sio", 818 .name = "ftdi_sio",
779 }, 819 },
780 .description = "FTDI USB Serial Device", 820 .description = "FTDI USB Serial Device",
781 .usb_driver = &ftdi_driver , 821 .usb_driver = &ftdi_driver,
782 .id_table = id_table_combined, 822 .id_table = id_table_combined,
783 .num_ports = 1, 823 .num_ports = 1,
784 .probe = ftdi_sio_probe, 824 .probe = ftdi_sio_probe,
@@ -794,8 +834,8 @@ static struct usb_serial_driver ftdi_sio_device = {
794 .chars_in_buffer = ftdi_chars_in_buffer, 834 .chars_in_buffer = ftdi_chars_in_buffer,
795 .read_bulk_callback = ftdi_read_bulk_callback, 835 .read_bulk_callback = ftdi_read_bulk_callback,
796 .write_bulk_callback = ftdi_write_bulk_callback, 836 .write_bulk_callback = ftdi_write_bulk_callback,
797 .tiocmget = ftdi_tiocmget, 837 .tiocmget = ftdi_tiocmget,
798 .tiocmset = ftdi_tiocmset, 838 .tiocmset = ftdi_tiocmset,
799 .ioctl = ftdi_ioctl, 839 .ioctl = ftdi_ioctl,
800 .set_termios = ftdi_set_termios, 840 .set_termios = ftdi_set_termios,
801 .break_ctl = ftdi_break_ctl, 841 .break_ctl = ftdi_break_ctl,
@@ -901,7 +941,6 @@ static int update_mctrl(struct usb_serial_port *port, unsigned int set,
901 unsigned int clear) 941 unsigned int clear)
902{ 942{
903 struct ftdi_private *priv = usb_get_serial_port_data(port); 943 struct ftdi_private *priv = usb_get_serial_port_data(port);
904 char *buf;
905 unsigned urb_value; 944 unsigned urb_value;
906 int rv; 945 int rv;
907 946
@@ -910,10 +949,6 @@ static int update_mctrl(struct usb_serial_port *port, unsigned int set,
910 return 0; /* no change */ 949 return 0; /* no change */
911 } 950 }
912 951
913 buf = kmalloc(1, GFP_NOIO);
914 if (!buf)
915 return -ENOMEM;
916
917 clear &= ~set; /* 'set' takes precedence over 'clear' */ 952 clear &= ~set; /* 'set' takes precedence over 'clear' */
918 urb_value = 0; 953 urb_value = 0;
919 if (clear & TIOCM_DTR) 954 if (clear & TIOCM_DTR)
@@ -929,9 +964,7 @@ static int update_mctrl(struct usb_serial_port *port, unsigned int set,
929 FTDI_SIO_SET_MODEM_CTRL_REQUEST, 964 FTDI_SIO_SET_MODEM_CTRL_REQUEST,
930 FTDI_SIO_SET_MODEM_CTRL_REQUEST_TYPE, 965 FTDI_SIO_SET_MODEM_CTRL_REQUEST_TYPE,
931 urb_value, priv->interface, 966 urb_value, priv->interface,
932 buf, 0, WDR_TIMEOUT); 967 NULL, 0, WDR_TIMEOUT);
933
934 kfree(buf);
935 if (rv < 0) { 968 if (rv < 0) {
936 dbg("%s Error from MODEM_CTRL urb: DTR %s, RTS %s", 969 dbg("%s Error from MODEM_CTRL urb: DTR %s, RTS %s",
937 __func__, 970 __func__,
@@ -1090,16 +1123,11 @@ static __u32 get_ftdi_divisor(struct tty_struct *tty,
1090static int change_speed(struct tty_struct *tty, struct usb_serial_port *port) 1123static int change_speed(struct tty_struct *tty, struct usb_serial_port *port)
1091{ 1124{
1092 struct ftdi_private *priv = usb_get_serial_port_data(port); 1125 struct ftdi_private *priv = usb_get_serial_port_data(port);
1093 char *buf;
1094 __u16 urb_value; 1126 __u16 urb_value;
1095 __u16 urb_index; 1127 __u16 urb_index;
1096 __u32 urb_index_value; 1128 __u32 urb_index_value;
1097 int rv; 1129 int rv;
1098 1130
1099 buf = kmalloc(1, GFP_NOIO);
1100 if (!buf)
1101 return -ENOMEM;
1102
1103 urb_index_value = get_ftdi_divisor(tty, port); 1131 urb_index_value = get_ftdi_divisor(tty, port);
1104 urb_value = (__u16)urb_index_value; 1132 urb_value = (__u16)urb_index_value;
1105 urb_index = (__u16)(urb_index_value >> 16); 1133 urb_index = (__u16)(urb_index_value >> 16);
@@ -1112,9 +1140,7 @@ static int change_speed(struct tty_struct *tty, struct usb_serial_port *port)
1112 FTDI_SIO_SET_BAUDRATE_REQUEST, 1140 FTDI_SIO_SET_BAUDRATE_REQUEST,
1113 FTDI_SIO_SET_BAUDRATE_REQUEST_TYPE, 1141 FTDI_SIO_SET_BAUDRATE_REQUEST_TYPE,
1114 urb_value, urb_index, 1142 urb_value, urb_index,
1115 buf, 0, WDR_SHORT_TIMEOUT); 1143 NULL, 0, WDR_SHORT_TIMEOUT);
1116
1117 kfree(buf);
1118 return rv; 1144 return rv;
1119} 1145}
1120 1146
@@ -1122,8 +1148,7 @@ static int write_latency_timer(struct usb_serial_port *port)
1122{ 1148{
1123 struct ftdi_private *priv = usb_get_serial_port_data(port); 1149 struct ftdi_private *priv = usb_get_serial_port_data(port);
1124 struct usb_device *udev = port->serial->dev; 1150 struct usb_device *udev = port->serial->dev;
1125 char buf[1]; 1151 int rv;
1126 int rv = 0;
1127 int l = priv->latency; 1152 int l = priv->latency;
1128 1153
1129 if (priv->flags & ASYNC_LOW_LATENCY) 1154 if (priv->flags & ASYNC_LOW_LATENCY)
@@ -1136,8 +1161,7 @@ static int write_latency_timer(struct usb_serial_port *port)
1136 FTDI_SIO_SET_LATENCY_TIMER_REQUEST, 1161 FTDI_SIO_SET_LATENCY_TIMER_REQUEST,
1137 FTDI_SIO_SET_LATENCY_TIMER_REQUEST_TYPE, 1162 FTDI_SIO_SET_LATENCY_TIMER_REQUEST_TYPE,
1138 l, priv->interface, 1163 l, priv->interface,
1139 buf, 0, WDR_TIMEOUT); 1164 NULL, 0, WDR_TIMEOUT);
1140
1141 if (rv < 0) 1165 if (rv < 0)
1142 dev_err(&port->dev, "Unable to write latency timer: %i\n", rv); 1166 dev_err(&port->dev, "Unable to write latency timer: %i\n", rv);
1143 return rv; 1167 return rv;
@@ -1147,24 +1171,29 @@ static int read_latency_timer(struct usb_serial_port *port)
1147{ 1171{
1148 struct ftdi_private *priv = usb_get_serial_port_data(port); 1172 struct ftdi_private *priv = usb_get_serial_port_data(port);
1149 struct usb_device *udev = port->serial->dev; 1173 struct usb_device *udev = port->serial->dev;
1150 unsigned short latency = 0; 1174 unsigned char *buf;
1151 int rv = 0; 1175 int rv;
1152
1153 1176
1154 dbg("%s", __func__); 1177 dbg("%s", __func__);
1155 1178
1179 buf = kmalloc(1, GFP_KERNEL);
1180 if (!buf)
1181 return -ENOMEM;
1182
1156 rv = usb_control_msg(udev, 1183 rv = usb_control_msg(udev,
1157 usb_rcvctrlpipe(udev, 0), 1184 usb_rcvctrlpipe(udev, 0),
1158 FTDI_SIO_GET_LATENCY_TIMER_REQUEST, 1185 FTDI_SIO_GET_LATENCY_TIMER_REQUEST,
1159 FTDI_SIO_GET_LATENCY_TIMER_REQUEST_TYPE, 1186 FTDI_SIO_GET_LATENCY_TIMER_REQUEST_TYPE,
1160 0, priv->interface, 1187 0, priv->interface,
1161 (char *) &latency, 1, WDR_TIMEOUT); 1188 buf, 1, WDR_TIMEOUT);
1162 1189 if (rv < 0)
1163 if (rv < 0) {
1164 dev_err(&port->dev, "Unable to read latency timer: %i\n", rv); 1190 dev_err(&port->dev, "Unable to read latency timer: %i\n", rv);
1165 return -EIO; 1191 else
1166 } 1192 priv->latency = buf[0];
1167 return latency; 1193
1194 kfree(buf);
1195
1196 return rv;
1168} 1197}
1169 1198
1170static int get_serial_info(struct usb_serial_port *port, 1199static int get_serial_info(struct usb_serial_port *port,
@@ -1195,7 +1224,7 @@ static int set_serial_info(struct tty_struct *tty,
1195 if (copy_from_user(&new_serial, newinfo, sizeof(new_serial))) 1224 if (copy_from_user(&new_serial, newinfo, sizeof(new_serial)))
1196 return -EFAULT; 1225 return -EFAULT;
1197 1226
1198 lock_kernel(); 1227 mutex_lock(&priv->cfg_lock);
1199 old_priv = *priv; 1228 old_priv = *priv;
1200 1229
1201 /* Do error checking and permission checking */ 1230 /* Do error checking and permission checking */
@@ -1203,7 +1232,7 @@ static int set_serial_info(struct tty_struct *tty,
1203 if (!capable(CAP_SYS_ADMIN)) { 1232 if (!capable(CAP_SYS_ADMIN)) {
1204 if (((new_serial.flags & ~ASYNC_USR_MASK) != 1233 if (((new_serial.flags & ~ASYNC_USR_MASK) !=
1205 (priv->flags & ~ASYNC_USR_MASK))) { 1234 (priv->flags & ~ASYNC_USR_MASK))) {
1206 unlock_kernel(); 1235 mutex_unlock(&priv->cfg_lock);
1207 return -EPERM; 1236 return -EPERM;
1208 } 1237 }
1209 priv->flags = ((priv->flags & ~ASYNC_USR_MASK) | 1238 priv->flags = ((priv->flags & ~ASYNC_USR_MASK) |
@@ -1214,7 +1243,7 @@ static int set_serial_info(struct tty_struct *tty,
1214 1243
1215 if ((new_serial.baud_base != priv->baud_base) && 1244 if ((new_serial.baud_base != priv->baud_base) &&
1216 (new_serial.baud_base < 9600)) { 1245 (new_serial.baud_base < 9600)) {
1217 unlock_kernel(); 1246 mutex_unlock(&priv->cfg_lock);
1218 return -EINVAL; 1247 return -EINVAL;
1219 } 1248 }
1220 1249
@@ -1244,11 +1273,11 @@ check_and_exit:
1244 (priv->flags & ASYNC_SPD_MASK)) || 1273 (priv->flags & ASYNC_SPD_MASK)) ||
1245 (((priv->flags & ASYNC_SPD_MASK) == ASYNC_SPD_CUST) && 1274 (((priv->flags & ASYNC_SPD_MASK) == ASYNC_SPD_CUST) &&
1246 (old_priv.custom_divisor != priv->custom_divisor))) { 1275 (old_priv.custom_divisor != priv->custom_divisor))) {
1247 unlock_kernel();
1248 change_speed(tty, port); 1276 change_speed(tty, port);
1277 mutex_unlock(&priv->cfg_lock);
1249 } 1278 }
1250 else 1279 else
1251 unlock_kernel(); 1280 mutex_unlock(&priv->cfg_lock);
1252 return 0; 1281 return 0;
1253 1282
1254} /* set_serial_info */ 1283} /* set_serial_info */
@@ -1304,20 +1333,20 @@ static void ftdi_determine_type(struct usb_serial_port *port)
1304 __func__); 1333 __func__);
1305 } 1334 }
1306 } else if (version < 0x200) { 1335 } else if (version < 0x200) {
1307 /* Old device. Assume its the original SIO. */ 1336 /* Old device. Assume it's the original SIO. */
1308 priv->chip_type = SIO; 1337 priv->chip_type = SIO;
1309 priv->baud_base = 12000000 / 16; 1338 priv->baud_base = 12000000 / 16;
1310 priv->write_offset = 1; 1339 priv->write_offset = 1;
1311 } else if (version < 0x400) { 1340 } else if (version < 0x400) {
1312 /* Assume its an FT8U232AM (or FT8U245AM) */ 1341 /* Assume it's an FT8U232AM (or FT8U245AM) */
1313 /* (It might be a BM because of the iSerialNumber bug, 1342 /* (It might be a BM because of the iSerialNumber bug,
1314 * but it will still work as an AM device.) */ 1343 * but it will still work as an AM device.) */
1315 priv->chip_type = FT8U232AM; 1344 priv->chip_type = FT8U232AM;
1316 } else if (version < 0x600) { 1345 } else if (version < 0x600) {
1317 /* Assume its an FT232BM (or FT245BM) */ 1346 /* Assume it's an FT232BM (or FT245BM) */
1318 priv->chip_type = FT232BM; 1347 priv->chip_type = FT232BM;
1319 } else { 1348 } else {
1320 /* Assume its an FT232R */ 1349 /* Assume it's an FT232R */
1321 priv->chip_type = FT232RL; 1350 priv->chip_type = FT232RL;
1322 } 1351 }
1323 dev_info(&udev->dev, "Detected %s\n", ftdi_chip_name[priv->chip_type]); 1352 dev_info(&udev->dev, "Detected %s\n", ftdi_chip_name[priv->chip_type]);
@@ -1337,7 +1366,7 @@ static void ftdi_set_max_packet_size(struct usb_serial_port *port)
1337 struct usb_endpoint_descriptor *ep_desc = &interface->cur_altsetting->endpoint[1].desc; 1366 struct usb_endpoint_descriptor *ep_desc = &interface->cur_altsetting->endpoint[1].desc;
1338 1367
1339 unsigned num_endpoints; 1368 unsigned num_endpoints;
1340 int i = 0; 1369 int i;
1341 1370
1342 num_endpoints = interface->cur_altsetting->desc.bNumEndpoints; 1371 num_endpoints = interface->cur_altsetting->desc.bNumEndpoints;
1343 dev_info(&udev->dev, "Number of endpoints %d\n", num_endpoints); 1372 dev_info(&udev->dev, "Number of endpoints %d\n", num_endpoints);
@@ -1389,7 +1418,7 @@ static ssize_t store_latency_timer(struct device *dev,
1389 struct usb_serial_port *port = to_usb_serial_port(dev); 1418 struct usb_serial_port *port = to_usb_serial_port(dev);
1390 struct ftdi_private *priv = usb_get_serial_port_data(port); 1419 struct ftdi_private *priv = usb_get_serial_port_data(port);
1391 int v = simple_strtoul(valbuf, NULL, 10); 1420 int v = simple_strtoul(valbuf, NULL, 10);
1392 int rv = 0; 1421 int rv;
1393 1422
1394 priv->latency = v; 1423 priv->latency = v;
1395 rv = write_latency_timer(port); 1424 rv = write_latency_timer(port);
@@ -1406,9 +1435,8 @@ static ssize_t store_event_char(struct device *dev,
1406 struct usb_serial_port *port = to_usb_serial_port(dev); 1435 struct usb_serial_port *port = to_usb_serial_port(dev);
1407 struct ftdi_private *priv = usb_get_serial_port_data(port); 1436 struct ftdi_private *priv = usb_get_serial_port_data(port);
1408 struct usb_device *udev = port->serial->dev; 1437 struct usb_device *udev = port->serial->dev;
1409 char buf[1];
1410 int v = simple_strtoul(valbuf, NULL, 10); 1438 int v = simple_strtoul(valbuf, NULL, 10);
1411 int rv = 0; 1439 int rv;
1412 1440
1413 dbg("%s: setting event char = %i", __func__, v); 1441 dbg("%s: setting event char = %i", __func__, v);
1414 1442
@@ -1417,8 +1445,7 @@ static ssize_t store_event_char(struct device *dev,
1417 FTDI_SIO_SET_EVENT_CHAR_REQUEST, 1445 FTDI_SIO_SET_EVENT_CHAR_REQUEST,
1418 FTDI_SIO_SET_EVENT_CHAR_REQUEST_TYPE, 1446 FTDI_SIO_SET_EVENT_CHAR_REQUEST_TYPE,
1419 v, priv->interface, 1447 v, priv->interface,
1420 buf, 0, WDR_TIMEOUT); 1448 NULL, 0, WDR_TIMEOUT);
1421
1422 if (rv < 0) { 1449 if (rv < 0) {
1423 dbg("Unable to write event character: %i", rv); 1450 dbg("Unable to write event character: %i", rv);
1424 return -EIO; 1451 return -EIO;
@@ -1517,9 +1544,9 @@ static int ftdi_sio_port_probe(struct usb_serial_port *port)
1517 1544
1518 kref_init(&priv->kref); 1545 kref_init(&priv->kref);
1519 spin_lock_init(&priv->tx_lock); 1546 spin_lock_init(&priv->tx_lock);
1547 mutex_init(&priv->cfg_lock);
1520 init_waitqueue_head(&priv->delta_msr_wait); 1548 init_waitqueue_head(&priv->delta_msr_wait);
1521 /* This will push the characters through immediately rather 1549
1522 than queue a task to deliver them */
1523 priv->flags = ASYNC_LOW_LATENCY; 1550 priv->flags = ASYNC_LOW_LATENCY;
1524 1551
1525 if (quirk && quirk->port_probe) 1552 if (quirk && quirk->port_probe)
@@ -1551,7 +1578,8 @@ static int ftdi_sio_port_probe(struct usb_serial_port *port)
1551 1578
1552 ftdi_determine_type(port); 1579 ftdi_determine_type(port);
1553 ftdi_set_max_packet_size(port); 1580 ftdi_set_max_packet_size(port);
1554 read_latency_timer(port); 1581 if (read_latency_timer(port) < 0)
1582 priv->latency = 16;
1555 create_sysfs_attrs(port); 1583 create_sysfs_attrs(port);
1556 return 0; 1584 return 0;
1557} 1585}
@@ -1596,8 +1624,6 @@ static int ftdi_NDI_device_setup(struct usb_serial *serial)
1596{ 1624{
1597 struct usb_device *udev = serial->dev; 1625 struct usb_device *udev = serial->dev;
1598 int latency = ndi_latency_timer; 1626 int latency = ndi_latency_timer;
1599 int rv = 0;
1600 char buf[1];
1601 1627
1602 if (latency == 0) 1628 if (latency == 0)
1603 latency = 1; 1629 latency = 1;
@@ -1607,10 +1633,11 @@ static int ftdi_NDI_device_setup(struct usb_serial *serial)
1607 dbg("%s setting NDI device latency to %d", __func__, latency); 1633 dbg("%s setting NDI device latency to %d", __func__, latency);
1608 dev_info(&udev->dev, "NDI device with a latency value of %d", latency); 1634 dev_info(&udev->dev, "NDI device with a latency value of %d", latency);
1609 1635
1610 rv = usb_control_msg(udev, usb_sndctrlpipe(udev, 0), 1636 /* FIXME: errors are not returned */
1637 usb_control_msg(udev, usb_sndctrlpipe(udev, 0),
1611 FTDI_SIO_SET_LATENCY_TIMER_REQUEST, 1638 FTDI_SIO_SET_LATENCY_TIMER_REQUEST,
1612 FTDI_SIO_SET_LATENCY_TIMER_REQUEST_TYPE, 1639 FTDI_SIO_SET_LATENCY_TIMER_REQUEST_TYPE,
1613 latency, 0, buf, 0, WDR_TIMEOUT); 1640 latency, 0, NULL, 0, WDR_TIMEOUT);
1614 return 0; 1641 return 0;
1615} 1642}
1616 1643
@@ -1686,7 +1713,7 @@ static int ftdi_submit_read_urb(struct usb_serial_port *port, gfp_t mem_flags)
1686 urb->transfer_buffer_length, 1713 urb->transfer_buffer_length,
1687 ftdi_read_bulk_callback, port); 1714 ftdi_read_bulk_callback, port);
1688 result = usb_submit_urb(urb, mem_flags); 1715 result = usb_submit_urb(urb, mem_flags);
1689 if (result) 1716 if (result && result != -EPERM)
1690 dev_err(&port->dev, 1717 dev_err(&port->dev,
1691 "%s - failed submitting read urb, error %d\n", 1718 "%s - failed submitting read urb, error %d\n",
1692 __func__, result); 1719 __func__, result);
@@ -1698,16 +1725,10 @@ static int ftdi_open(struct tty_struct *tty, struct usb_serial_port *port)
1698 struct usb_device *dev = port->serial->dev; 1725 struct usb_device *dev = port->serial->dev;
1699 struct ftdi_private *priv = usb_get_serial_port_data(port); 1726 struct ftdi_private *priv = usb_get_serial_port_data(port);
1700 unsigned long flags; 1727 unsigned long flags;
1701 1728 int result;
1702 int result = 0;
1703 char buf[1]; /* Needed for the usb_control_msg I think */
1704 1729
1705 dbg("%s", __func__); 1730 dbg("%s", __func__);
1706 1731
1707 spin_lock_irqsave(&priv->tx_lock, flags);
1708 priv->tx_bytes = 0;
1709 spin_unlock_irqrestore(&priv->tx_lock, flags);
1710
1711 write_latency_timer(port); 1732 write_latency_timer(port);
1712 1733
1713 /* No error checking for this (will get errors later anyway) */ 1734 /* No error checking for this (will get errors later anyway) */
@@ -1715,7 +1736,7 @@ static int ftdi_open(struct tty_struct *tty, struct usb_serial_port *port)
1715 usb_control_msg(dev, usb_sndctrlpipe(dev, 0), 1736 usb_control_msg(dev, usb_sndctrlpipe(dev, 0),
1716 FTDI_SIO_RESET_REQUEST, FTDI_SIO_RESET_REQUEST_TYPE, 1737 FTDI_SIO_RESET_REQUEST, FTDI_SIO_RESET_REQUEST_TYPE,
1717 FTDI_SIO_RESET_SIO, 1738 FTDI_SIO_RESET_SIO,
1718 priv->interface, buf, 0, WDR_TIMEOUT); 1739 priv->interface, NULL, 0, WDR_TIMEOUT);
1719 1740
1720 /* Termios defaults are set by usb_serial_init. We don't change 1741 /* Termios defaults are set by usb_serial_init. We don't change
1721 port->tty->termios - this would lose speed settings, etc. 1742 port->tty->termios - this would lose speed settings, etc.
@@ -1743,7 +1764,6 @@ static int ftdi_open(struct tty_struct *tty, struct usb_serial_port *port)
1743static void ftdi_dtr_rts(struct usb_serial_port *port, int on) 1764static void ftdi_dtr_rts(struct usb_serial_port *port, int on)
1744{ 1765{
1745 struct ftdi_private *priv = usb_get_serial_port_data(port); 1766 struct ftdi_private *priv = usb_get_serial_port_data(port);
1746 char buf[1];
1747 1767
1748 mutex_lock(&port->serial->disc_mutex); 1768 mutex_lock(&port->serial->disc_mutex);
1749 if (!port->serial->disconnected) { 1769 if (!port->serial->disconnected) {
@@ -1752,7 +1772,7 @@ static void ftdi_dtr_rts(struct usb_serial_port *port, int on)
1752 usb_sndctrlpipe(port->serial->dev, 0), 1772 usb_sndctrlpipe(port->serial->dev, 0),
1753 FTDI_SIO_SET_FLOW_CTRL_REQUEST, 1773 FTDI_SIO_SET_FLOW_CTRL_REQUEST,
1754 FTDI_SIO_SET_FLOW_CTRL_REQUEST_TYPE, 1774 FTDI_SIO_SET_FLOW_CTRL_REQUEST_TYPE,
1755 0, priv->interface, buf, 0, 1775 0, priv->interface, NULL, 0,
1756 WDR_TIMEOUT) < 0) { 1776 WDR_TIMEOUT) < 0) {
1757 dev_err(&port->dev, "error from flowcontrol urb\n"); 1777 dev_err(&port->dev, "error from flowcontrol urb\n");
1758 } 1778 }
@@ -1813,7 +1833,7 @@ static int ftdi_write(struct tty_struct *tty, struct usb_serial_port *port,
1813 spin_lock_irqsave(&priv->tx_lock, flags); 1833 spin_lock_irqsave(&priv->tx_lock, flags);
1814 if (priv->tx_outstanding_urbs > URB_UPPER_LIMIT) { 1834 if (priv->tx_outstanding_urbs > URB_UPPER_LIMIT) {
1815 spin_unlock_irqrestore(&priv->tx_lock, flags); 1835 spin_unlock_irqrestore(&priv->tx_lock, flags);
1816 dbg("%s - write limit hit\n", __func__); 1836 dbg("%s - write limit hit", __func__);
1817 return 0; 1837 return 0;
1818 } 1838 }
1819 priv->tx_outstanding_urbs++; 1839 priv->tx_outstanding_urbs++;
@@ -1893,7 +1913,6 @@ static int ftdi_write(struct tty_struct *tty, struct usb_serial_port *port,
1893 } else { 1913 } else {
1894 spin_lock_irqsave(&priv->tx_lock, flags); 1914 spin_lock_irqsave(&priv->tx_lock, flags);
1895 priv->tx_outstanding_bytes += count; 1915 priv->tx_outstanding_bytes += count;
1896 priv->tx_bytes += count;
1897 spin_unlock_irqrestore(&priv->tx_lock, flags); 1916 spin_unlock_irqrestore(&priv->tx_lock, flags);
1898 } 1917 }
1899 1918
@@ -2120,8 +2139,7 @@ static void ftdi_break_ctl(struct tty_struct *tty, int break_state)
2120{ 2139{
2121 struct usb_serial_port *port = tty->driver_data; 2140 struct usb_serial_port *port = tty->driver_data;
2122 struct ftdi_private *priv = usb_get_serial_port_data(port); 2141 struct ftdi_private *priv = usb_get_serial_port_data(port);
2123 __u16 urb_value = 0; 2142 __u16 urb_value;
2124 char buf[1];
2125 2143
2126 /* break_state = -1 to turn on break, and 0 to turn off break */ 2144 /* break_state = -1 to turn on break, and 0 to turn off break */
2127 /* see drivers/char/tty_io.c to see it used */ 2145 /* see drivers/char/tty_io.c to see it used */
@@ -2137,7 +2155,7 @@ static void ftdi_break_ctl(struct tty_struct *tty, int break_state)
2137 FTDI_SIO_SET_DATA_REQUEST, 2155 FTDI_SIO_SET_DATA_REQUEST,
2138 FTDI_SIO_SET_DATA_REQUEST_TYPE, 2156 FTDI_SIO_SET_DATA_REQUEST_TYPE,
2139 urb_value , priv->interface, 2157 urb_value , priv->interface,
2140 buf, 0, WDR_TIMEOUT) < 0) { 2158 NULL, 0, WDR_TIMEOUT) < 0) {
2141 dev_err(&port->dev, "%s FAILED to enable/disable break state " 2159 dev_err(&port->dev, "%s FAILED to enable/disable break state "
2142 "(state was %d)\n", __func__, break_state); 2160 "(state was %d)\n", __func__, break_state);
2143 } 2161 }
@@ -2161,7 +2179,6 @@ static void ftdi_set_termios(struct tty_struct *tty,
2161 struct ktermios *termios = tty->termios; 2179 struct ktermios *termios = tty->termios;
2162 unsigned int cflag = termios->c_cflag; 2180 unsigned int cflag = termios->c_cflag;
2163 __u16 urb_value; /* will hold the new flags */ 2181 __u16 urb_value; /* will hold the new flags */
2164 char buf[1]; /* Perhaps I should dynamically alloc this? */
2165 2182
2166 /* Added for xon/xoff support */ 2183 /* Added for xon/xoff support */
2167 unsigned int iflag = termios->c_iflag; 2184 unsigned int iflag = termios->c_iflag;
@@ -2195,23 +2212,27 @@ static void ftdi_set_termios(struct tty_struct *tty,
2195 2212
2196 /* Set number of data bits, parity, stop bits */ 2213 /* Set number of data bits, parity, stop bits */
2197 2214
2198 termios->c_cflag &= ~CMSPAR;
2199
2200 urb_value = 0; 2215 urb_value = 0;
2201 urb_value |= (cflag & CSTOPB ? FTDI_SIO_SET_DATA_STOP_BITS_2 : 2216 urb_value |= (cflag & CSTOPB ? FTDI_SIO_SET_DATA_STOP_BITS_2 :
2202 FTDI_SIO_SET_DATA_STOP_BITS_1); 2217 FTDI_SIO_SET_DATA_STOP_BITS_1);
2203 urb_value |= (cflag & PARENB ? 2218 if (cflag & PARENB) {
2204 (cflag & PARODD ? FTDI_SIO_SET_DATA_PARITY_ODD : 2219 if (cflag & CMSPAR)
2205 FTDI_SIO_SET_DATA_PARITY_EVEN) : 2220 urb_value |= cflag & PARODD ?
2206 FTDI_SIO_SET_DATA_PARITY_NONE); 2221 FTDI_SIO_SET_DATA_PARITY_MARK :
2222 FTDI_SIO_SET_DATA_PARITY_SPACE;
2223 else
2224 urb_value |= cflag & PARODD ?
2225 FTDI_SIO_SET_DATA_PARITY_ODD :
2226 FTDI_SIO_SET_DATA_PARITY_EVEN;
2227 } else {
2228 urb_value |= FTDI_SIO_SET_DATA_PARITY_NONE;
2229 }
2207 if (cflag & CSIZE) { 2230 if (cflag & CSIZE) {
2208 switch (cflag & CSIZE) { 2231 switch (cflag & CSIZE) {
2209 case CS5: urb_value |= 5; dbg("Setting CS5"); break;
2210 case CS6: urb_value |= 6; dbg("Setting CS6"); break;
2211 case CS7: urb_value |= 7; dbg("Setting CS7"); break; 2232 case CS7: urb_value |= 7; dbg("Setting CS7"); break;
2212 case CS8: urb_value |= 8; dbg("Setting CS8"); break; 2233 case CS8: urb_value |= 8; dbg("Setting CS8"); break;
2213 default: 2234 default:
2214 dev_err(&port->dev, "CSIZE was set but not CS5-CS8\n"); 2235 dev_err(&port->dev, "CSIZE was set but not CS7-CS8\n");
2215 } 2236 }
2216 } 2237 }
2217 2238
@@ -2223,7 +2244,7 @@ static void ftdi_set_termios(struct tty_struct *tty,
2223 FTDI_SIO_SET_DATA_REQUEST, 2244 FTDI_SIO_SET_DATA_REQUEST,
2224 FTDI_SIO_SET_DATA_REQUEST_TYPE, 2245 FTDI_SIO_SET_DATA_REQUEST_TYPE,
2225 urb_value , priv->interface, 2246 urb_value , priv->interface,
2226 buf, 0, WDR_SHORT_TIMEOUT) < 0) { 2247 NULL, 0, WDR_SHORT_TIMEOUT) < 0) {
2227 dev_err(&port->dev, "%s FAILED to set " 2248 dev_err(&port->dev, "%s FAILED to set "
2228 "databits/stopbits/parity\n", __func__); 2249 "databits/stopbits/parity\n", __func__);
2229 } 2250 }
@@ -2235,7 +2256,7 @@ static void ftdi_set_termios(struct tty_struct *tty,
2235 FTDI_SIO_SET_FLOW_CTRL_REQUEST, 2256 FTDI_SIO_SET_FLOW_CTRL_REQUEST,
2236 FTDI_SIO_SET_FLOW_CTRL_REQUEST_TYPE, 2257 FTDI_SIO_SET_FLOW_CTRL_REQUEST_TYPE,
2237 0, priv->interface, 2258 0, priv->interface,
2238 buf, 0, WDR_TIMEOUT) < 0) { 2259 NULL, 0, WDR_TIMEOUT) < 0) {
2239 dev_err(&port->dev, 2260 dev_err(&port->dev,
2240 "%s error from disable flowcontrol urb\n", 2261 "%s error from disable flowcontrol urb\n",
2241 __func__); 2262 __func__);
@@ -2244,9 +2265,11 @@ static void ftdi_set_termios(struct tty_struct *tty,
2244 clear_mctrl(port, TIOCM_DTR | TIOCM_RTS); 2265 clear_mctrl(port, TIOCM_DTR | TIOCM_RTS);
2245 } else { 2266 } else {
2246 /* set the baudrate determined before */ 2267 /* set the baudrate determined before */
2268 mutex_lock(&priv->cfg_lock);
2247 if (change_speed(tty, port)) 2269 if (change_speed(tty, port))
2248 dev_err(&port->dev, "%s urb failed to set baudrate\n", 2270 dev_err(&port->dev, "%s urb failed to set baudrate\n",
2249 __func__); 2271 __func__);
2272 mutex_unlock(&priv->cfg_lock);
2250 /* Ensure RTS and DTR are raised when baudrate changed from 0 */ 2273 /* Ensure RTS and DTR are raised when baudrate changed from 0 */
2251 if (!old_termios || (old_termios->c_cflag & CBAUD) == B0) 2274 if (!old_termios || (old_termios->c_cflag & CBAUD) == B0)
2252 set_mctrl(port, TIOCM_DTR | TIOCM_RTS); 2275 set_mctrl(port, TIOCM_DTR | TIOCM_RTS);
@@ -2261,7 +2284,7 @@ static void ftdi_set_termios(struct tty_struct *tty,
2261 FTDI_SIO_SET_FLOW_CTRL_REQUEST, 2284 FTDI_SIO_SET_FLOW_CTRL_REQUEST,
2262 FTDI_SIO_SET_FLOW_CTRL_REQUEST_TYPE, 2285 FTDI_SIO_SET_FLOW_CTRL_REQUEST_TYPE,
2263 0 , (FTDI_SIO_RTS_CTS_HS | priv->interface), 2286 0 , (FTDI_SIO_RTS_CTS_HS | priv->interface),
2264 buf, 0, WDR_TIMEOUT) < 0) { 2287 NULL, 0, WDR_TIMEOUT) < 0) {
2265 dev_err(&port->dev, 2288 dev_err(&port->dev,
2266 "urb failed to set to rts/cts flow control\n"); 2289 "urb failed to set to rts/cts flow control\n");
2267 } 2290 }
@@ -2293,7 +2316,7 @@ static void ftdi_set_termios(struct tty_struct *tty,
2293 FTDI_SIO_SET_FLOW_CTRL_REQUEST_TYPE, 2316 FTDI_SIO_SET_FLOW_CTRL_REQUEST_TYPE,
2294 urb_value , (FTDI_SIO_XON_XOFF_HS 2317 urb_value , (FTDI_SIO_XON_XOFF_HS
2295 | priv->interface), 2318 | priv->interface),
2296 buf, 0, WDR_TIMEOUT) < 0) { 2319 NULL, 0, WDR_TIMEOUT) < 0) {
2297 dev_err(&port->dev, "urb failed to set to " 2320 dev_err(&port->dev, "urb failed to set to "
2298 "xon/xoff flow control\n"); 2321 "xon/xoff flow control\n");
2299 } 2322 }
@@ -2307,7 +2330,7 @@ static void ftdi_set_termios(struct tty_struct *tty,
2307 FTDI_SIO_SET_FLOW_CTRL_REQUEST, 2330 FTDI_SIO_SET_FLOW_CTRL_REQUEST,
2308 FTDI_SIO_SET_FLOW_CTRL_REQUEST_TYPE, 2331 FTDI_SIO_SET_FLOW_CTRL_REQUEST_TYPE,
2309 0, priv->interface, 2332 0, priv->interface,
2310 buf, 0, WDR_TIMEOUT) < 0) { 2333 NULL, 0, WDR_TIMEOUT) < 0) {
2311 dev_err(&port->dev, 2334 dev_err(&port->dev,
2312 "urb failed to clear flow control\n"); 2335 "urb failed to clear flow control\n");
2313 } 2336 }
@@ -2321,21 +2344,22 @@ static int ftdi_tiocmget(struct tty_struct *tty, struct file *file)
2321{ 2344{
2322 struct usb_serial_port *port = tty->driver_data; 2345 struct usb_serial_port *port = tty->driver_data;
2323 struct ftdi_private *priv = usb_get_serial_port_data(port); 2346 struct ftdi_private *priv = usb_get_serial_port_data(port);
2324 unsigned char buf[2]; 2347 unsigned char *buf;
2348 int len;
2325 int ret; 2349 int ret;
2326 2350
2327 dbg("%s TIOCMGET", __func__); 2351 dbg("%s TIOCMGET", __func__);
2352
2353 buf = kmalloc(2, GFP_KERNEL);
2354 if (!buf)
2355 return -ENOMEM;
2356 /*
2357 * The 8U232AM returns a two byte value (the SIO a 1 byte value) in
2358 * the same format as the data returned from the in point.
2359 */
2328 switch (priv->chip_type) { 2360 switch (priv->chip_type) {
2329 case SIO: 2361 case SIO:
2330 /* Request the status from the device */ 2362 len = 1;
2331 ret = usb_control_msg(port->serial->dev,
2332 usb_rcvctrlpipe(port->serial->dev, 0),
2333 FTDI_SIO_GET_MODEM_STATUS_REQUEST,
2334 FTDI_SIO_GET_MODEM_STATUS_REQUEST_TYPE,
2335 0, 0,
2336 buf, 1, WDR_TIMEOUT);
2337 if (ret < 0)
2338 return ret;
2339 break; 2363 break;
2340 case FT8U232AM: 2364 case FT8U232AM:
2341 case FT232BM: 2365 case FT232BM:
@@ -2343,27 +2367,30 @@ static int ftdi_tiocmget(struct tty_struct *tty, struct file *file)
2343 case FT232RL: 2367 case FT232RL:
2344 case FT2232H: 2368 case FT2232H:
2345 case FT4232H: 2369 case FT4232H:
2346 /* the 8U232AM returns a two byte value (the sio is a 1 byte 2370 len = 2;
2347 value) - in the same format as the data returned from the in
2348 point */
2349 ret = usb_control_msg(port->serial->dev,
2350 usb_rcvctrlpipe(port->serial->dev, 0),
2351 FTDI_SIO_GET_MODEM_STATUS_REQUEST,
2352 FTDI_SIO_GET_MODEM_STATUS_REQUEST_TYPE,
2353 0, priv->interface,
2354 buf, 2, WDR_TIMEOUT);
2355 if (ret < 0)
2356 return ret;
2357 break; 2371 break;
2358 default: 2372 default:
2359 return -EFAULT; 2373 ret = -EFAULT;
2374 goto out;
2360 } 2375 }
2361 2376
2362 return (buf[0] & FTDI_SIO_DSR_MASK ? TIOCM_DSR : 0) | 2377 ret = usb_control_msg(port->serial->dev,
2378 usb_rcvctrlpipe(port->serial->dev, 0),
2379 FTDI_SIO_GET_MODEM_STATUS_REQUEST,
2380 FTDI_SIO_GET_MODEM_STATUS_REQUEST_TYPE,
2381 0, priv->interface,
2382 buf, len, WDR_TIMEOUT);
2383 if (ret < 0)
2384 goto out;
2385
2386 ret = (buf[0] & FTDI_SIO_DSR_MASK ? TIOCM_DSR : 0) |
2363 (buf[0] & FTDI_SIO_CTS_MASK ? TIOCM_CTS : 0) | 2387 (buf[0] & FTDI_SIO_CTS_MASK ? TIOCM_CTS : 0) |
2364 (buf[0] & FTDI_SIO_RI_MASK ? TIOCM_RI : 0) | 2388 (buf[0] & FTDI_SIO_RI_MASK ? TIOCM_RI : 0) |
2365 (buf[0] & FTDI_SIO_RLSD_MASK ? TIOCM_CD : 0) | 2389 (buf[0] & FTDI_SIO_RLSD_MASK ? TIOCM_CD : 0) |
2366 priv->last_dtr_rts; 2390 priv->last_dtr_rts;
2391out:
2392 kfree(buf);
2393 return ret;
2367} 2394}
2368 2395
2369static int ftdi_tiocmset(struct tty_struct *tty, struct file *file, 2396static int ftdi_tiocmset(struct tty_struct *tty, struct file *file,
@@ -2468,8 +2495,7 @@ void ftdi_unthrottle(struct tty_struct *tty)
2468 port->throttled = port->throttle_req = 0; 2495 port->throttled = port->throttle_req = 0;
2469 spin_unlock_irqrestore(&port->lock, flags); 2496 spin_unlock_irqrestore(&port->lock, flags);
2470 2497
2471 /* Resubmit urb if throttled and open. */ 2498 if (was_throttled)
2472 if (was_throttled && test_bit(ASYNCB_INITIALIZED, &port->port.flags))
2473 ftdi_submit_read_urb(port, GFP_KERNEL); 2499 ftdi_submit_read_urb(port, GFP_KERNEL);
2474} 2500}
2475 2501
diff --git a/drivers/usb/serial/ftdi_sio.h b/drivers/usb/serial/ftdi_sio.h
index 6f31e0d71898..ff9bf80327a3 100644
--- a/drivers/usb/serial/ftdi_sio.h
+++ b/drivers/usb/serial/ftdi_sio.h
@@ -1,7 +1,10 @@
1/* 1/*
2 * Definitions for the FTDI USB Single Port Serial Converter - 2 * Driver definitions for the FTDI USB Single Port Serial Converter -
3 * known as FTDI_SIO (Serial Input/Output application of the chipset) 3 * known as FTDI_SIO (Serial Input/Output application of the chipset)
4 * 4 *
5 * For USB vendor/product IDs (VID/PID), please see ftdi_sio_ids.h
6 *
7 *
5 * The example I have is known as the USC-1000 which is available from 8 * The example I have is known as the USC-1000 which is available from
6 * http://www.dse.co.nz - cat no XH4214 It looks similar to this: 9 * http://www.dse.co.nz - cat no XH4214 It looks similar to this:
7 * http://www.dansdata.com/usbser.htm but I can't be sure There are other 10 * http://www.dansdata.com/usbser.htm but I can't be sure There are other
@@ -17,866 +20,7 @@
17 * Bill Ryder - bryder@sgi.com formerly of Silicon Graphics, Inc.- wrote the 20 * Bill Ryder - bryder@sgi.com formerly of Silicon Graphics, Inc.- wrote the
18 * FTDI_SIO implementation. 21 * FTDI_SIO implementation.
19 * 22 *
20 * Philipp Gühring - pg@futureware.at - added the Device ID of the USB relais
21 * from Rudolf Gugler
22 *
23 */
24
25#define FTDI_VID 0x0403 /* Vendor Id */
26#define FTDI_SIO_PID 0x8372 /* Product Id SIO application of 8U100AX */
27#define FTDI_8U232AM_PID 0x6001 /* Similar device to SIO above */
28#define FTDI_8U232AM_ALT_PID 0x6006 /* FTDI's alternate PID for above */
29#define FTDI_8U2232C_PID 0x6010 /* Dual channel device */
30#define FTDI_232RL_PID 0xFBFA /* Product ID for FT232RL */
31#define FTDI_4232H_PID 0x6011 /* Quad channel hi-speed device */
32#define FTDI_RELAIS_PID 0xFA10 /* Relais device from Rudolf Gugler */
33#define FTDI_NF_RIC_VID 0x0DCD /* Vendor Id */
34#define FTDI_NF_RIC_PID 0x0001 /* Product Id */
35#define FTDI_USBX_707_PID 0xF857 /* ADSTech IR Blaster USBX-707 */
36
37/* Larsen and Brusgaard AltiTrack/USBtrack */
38#define LARSENBRUSGAARD_VID 0x0FD8
39#define LB_ALTITRACK_PID 0x0001
40
41/* www.canusb.com Lawicel CANUSB device */
42#define FTDI_CANUSB_PID 0xFFA8 /* Product Id */
43
44/* AlphaMicro Components AMC-232USB01 device */
45#define FTDI_AMC232_PID 0xFF00 /* Product Id */
46
47/* www.candapter.com Ewert Energy Systems CANdapter device */
48#define FTDI_CANDAPTER_PID 0x9F80 /* Product Id */
49
50/* SCS HF Radio Modems PID's (http://www.scs-ptc.com) */
51/* the VID is the standard ftdi vid (FTDI_VID) */
52#define FTDI_SCS_DEVICE_0_PID 0xD010 /* SCS PTC-IIusb */
53#define FTDI_SCS_DEVICE_1_PID 0xD011 /* SCS Tracker / DSP TNC */
54#define FTDI_SCS_DEVICE_2_PID 0xD012
55#define FTDI_SCS_DEVICE_3_PID 0xD013
56#define FTDI_SCS_DEVICE_4_PID 0xD014
57#define FTDI_SCS_DEVICE_5_PID 0xD015
58#define FTDI_SCS_DEVICE_6_PID 0xD016
59#define FTDI_SCS_DEVICE_7_PID 0xD017
60
61/* ACT Solutions HomePro ZWave interface (http://www.act-solutions.com/HomePro.htm) */
62#define FTDI_ACTZWAVE_PID 0xF2D0
63
64
65/* www.starting-point-systems.com µChameleon device */
66#define FTDI_MICRO_CHAMELEON_PID 0xCAA0 /* Product Id */
67
68/* www.irtrans.de device */
69#define FTDI_IRTRANS_PID 0xFC60 /* Product Id */
70
71
72/* www.thoughttechnology.com/ TT-USB provide with procomp use ftdi_sio */
73#define FTDI_TTUSB_PID 0xFF20 /* Product Id */
74
75/* iPlus device */
76#define FTDI_IPLUS_PID 0xD070 /* Product Id */
77#define FTDI_IPLUS2_PID 0xD071 /* Product Id */
78
79/* DMX4ALL DMX Interfaces */
80#define FTDI_DMX4ALL 0xC850
81
82/* OpenDCC (www.opendcc.de) product id */
83#define FTDI_OPENDCC_PID 0xBFD8
84#define FTDI_OPENDCC_SNIFFER_PID 0xBFD9
85#define FTDI_OPENDCC_THROTTLE_PID 0xBFDA
86#define FTDI_OPENDCC_GATEWAY_PID 0xBFDB
87
88/* Sprog II (Andrew Crosland's SprogII DCC interface) */
89#define FTDI_SPROG_II 0xF0C8
90
91/* www.crystalfontz.com devices - thanx for providing free devices for evaluation ! */
92/* they use the ftdi chipset for the USB interface and the vendor id is the same */
93#define FTDI_XF_632_PID 0xFC08 /* 632: 16x2 Character Display */
94#define FTDI_XF_634_PID 0xFC09 /* 634: 20x4 Character Display */
95#define FTDI_XF_547_PID 0xFC0A /* 547: Two line Display */
96#define FTDI_XF_633_PID 0xFC0B /* 633: 16x2 Character Display with Keys */
97#define FTDI_XF_631_PID 0xFC0C /* 631: 20x2 Character Display */
98#define FTDI_XF_635_PID 0xFC0D /* 635: 20x4 Character Display */
99#define FTDI_XF_640_PID 0xFC0E /* 640: Two line Display */
100#define FTDI_XF_642_PID 0xFC0F /* 642: Two line Display */
101
102/* Video Networks Limited / Homechoice in the UK use an ftdi-based device for their 1Mb */
103/* broadband internet service. The following PID is exhibited by the usb device supplied */
104/* (the VID is the standard ftdi vid (FTDI_VID) */
105#define FTDI_VNHCPCUSB_D_PID 0xfe38 /* Product Id */
106
107/*
108 * PCDJ use ftdi based dj-controllers. The following PID is for their DAC-2 device
109 * http://www.pcdjhardware.com/DAC2.asp (PID sent by Wouter Paesen)
110 * (the VID is the standard ftdi vid (FTDI_VID) */
111#define FTDI_PCDJ_DAC2_PID 0xFA88
112
113/*
114 * The following are the values for the Matrix Orbital LCD displays,
115 * which are the FT232BM ( similar to the 8U232AM )
116 */
117#define FTDI_MTXORB_0_PID 0xFA00 /* Matrix Orbital Product Id */
118#define FTDI_MTXORB_1_PID 0xFA01 /* Matrix Orbital Product Id */
119#define FTDI_MTXORB_2_PID 0xFA02 /* Matrix Orbital Product Id */
120#define FTDI_MTXORB_3_PID 0xFA03 /* Matrix Orbital Product Id */
121#define FTDI_MTXORB_4_PID 0xFA04 /* Matrix Orbital Product Id */
122#define FTDI_MTXORB_5_PID 0xFA05 /* Matrix Orbital Product Id */
123#define FTDI_MTXORB_6_PID 0xFA06 /* Matrix Orbital Product Id */
124
125/* OOCDlink by Joern Kaipf <joernk@web.de>
126 * (http://www.joernonline.de/dw/doku.php?id=start&idx=projects:oocdlink) */
127#define FTDI_OOCDLINK_PID 0xbaf8 /* Amontec JTAGkey */
128
129/*
130 * The following are the values for the Matrix Orbital FTDI Range
131 * Anything in this range will use an FT232RL.
132 */
133#define MTXORB_VID 0x1B3D
134#define MTXORB_FTDI_RANGE_0100_PID 0x0100
135#define MTXORB_FTDI_RANGE_0101_PID 0x0101
136#define MTXORB_FTDI_RANGE_0102_PID 0x0102
137#define MTXORB_FTDI_RANGE_0103_PID 0x0103
138#define MTXORB_FTDI_RANGE_0104_PID 0x0104
139#define MTXORB_FTDI_RANGE_0105_PID 0x0105
140#define MTXORB_FTDI_RANGE_0106_PID 0x0106
141#define MTXORB_FTDI_RANGE_0107_PID 0x0107
142#define MTXORB_FTDI_RANGE_0108_PID 0x0108
143#define MTXORB_FTDI_RANGE_0109_PID 0x0109
144#define MTXORB_FTDI_RANGE_010A_PID 0x010A
145#define MTXORB_FTDI_RANGE_010B_PID 0x010B
146#define MTXORB_FTDI_RANGE_010C_PID 0x010C
147#define MTXORB_FTDI_RANGE_010D_PID 0x010D
148#define MTXORB_FTDI_RANGE_010E_PID 0x010E
149#define MTXORB_FTDI_RANGE_010F_PID 0x010F
150#define MTXORB_FTDI_RANGE_0110_PID 0x0110
151#define MTXORB_FTDI_RANGE_0111_PID 0x0111
152#define MTXORB_FTDI_RANGE_0112_PID 0x0112
153#define MTXORB_FTDI_RANGE_0113_PID 0x0113
154#define MTXORB_FTDI_RANGE_0114_PID 0x0114
155#define MTXORB_FTDI_RANGE_0115_PID 0x0115
156#define MTXORB_FTDI_RANGE_0116_PID 0x0116
157#define MTXORB_FTDI_RANGE_0117_PID 0x0117
158#define MTXORB_FTDI_RANGE_0118_PID 0x0118
159#define MTXORB_FTDI_RANGE_0119_PID 0x0119
160#define MTXORB_FTDI_RANGE_011A_PID 0x011A
161#define MTXORB_FTDI_RANGE_011B_PID 0x011B
162#define MTXORB_FTDI_RANGE_011C_PID 0x011C
163#define MTXORB_FTDI_RANGE_011D_PID 0x011D
164#define MTXORB_FTDI_RANGE_011E_PID 0x011E
165#define MTXORB_FTDI_RANGE_011F_PID 0x011F
166#define MTXORB_FTDI_RANGE_0120_PID 0x0120
167#define MTXORB_FTDI_RANGE_0121_PID 0x0121
168#define MTXORB_FTDI_RANGE_0122_PID 0x0122
169#define MTXORB_FTDI_RANGE_0123_PID 0x0123
170#define MTXORB_FTDI_RANGE_0124_PID 0x0124
171#define MTXORB_FTDI_RANGE_0125_PID 0x0125
172#define MTXORB_FTDI_RANGE_0126_PID 0x0126
173#define MTXORB_FTDI_RANGE_0127_PID 0x0127
174#define MTXORB_FTDI_RANGE_0128_PID 0x0128
175#define MTXORB_FTDI_RANGE_0129_PID 0x0129
176#define MTXORB_FTDI_RANGE_012A_PID 0x012A
177#define MTXORB_FTDI_RANGE_012B_PID 0x012B
178#define MTXORB_FTDI_RANGE_012C_PID 0x012C
179#define MTXORB_FTDI_RANGE_012D_PID 0x012D
180#define MTXORB_FTDI_RANGE_012E_PID 0x012E
181#define MTXORB_FTDI_RANGE_012F_PID 0x012F
182#define MTXORB_FTDI_RANGE_0130_PID 0x0130
183#define MTXORB_FTDI_RANGE_0131_PID 0x0131
184#define MTXORB_FTDI_RANGE_0132_PID 0x0132
185#define MTXORB_FTDI_RANGE_0133_PID 0x0133
186#define MTXORB_FTDI_RANGE_0134_PID 0x0134
187#define MTXORB_FTDI_RANGE_0135_PID 0x0135
188#define MTXORB_FTDI_RANGE_0136_PID 0x0136
189#define MTXORB_FTDI_RANGE_0137_PID 0x0137
190#define MTXORB_FTDI_RANGE_0138_PID 0x0138
191#define MTXORB_FTDI_RANGE_0139_PID 0x0139
192#define MTXORB_FTDI_RANGE_013A_PID 0x013A
193#define MTXORB_FTDI_RANGE_013B_PID 0x013B
194#define MTXORB_FTDI_RANGE_013C_PID 0x013C
195#define MTXORB_FTDI_RANGE_013D_PID 0x013D
196#define MTXORB_FTDI_RANGE_013E_PID 0x013E
197#define MTXORB_FTDI_RANGE_013F_PID 0x013F
198#define MTXORB_FTDI_RANGE_0140_PID 0x0140
199#define MTXORB_FTDI_RANGE_0141_PID 0x0141
200#define MTXORB_FTDI_RANGE_0142_PID 0x0142
201#define MTXORB_FTDI_RANGE_0143_PID 0x0143
202#define MTXORB_FTDI_RANGE_0144_PID 0x0144
203#define MTXORB_FTDI_RANGE_0145_PID 0x0145
204#define MTXORB_FTDI_RANGE_0146_PID 0x0146
205#define MTXORB_FTDI_RANGE_0147_PID 0x0147
206#define MTXORB_FTDI_RANGE_0148_PID 0x0148
207#define MTXORB_FTDI_RANGE_0149_PID 0x0149
208#define MTXORB_FTDI_RANGE_014A_PID 0x014A
209#define MTXORB_FTDI_RANGE_014B_PID 0x014B
210#define MTXORB_FTDI_RANGE_014C_PID 0x014C
211#define MTXORB_FTDI_RANGE_014D_PID 0x014D
212#define MTXORB_FTDI_RANGE_014E_PID 0x014E
213#define MTXORB_FTDI_RANGE_014F_PID 0x014F
214#define MTXORB_FTDI_RANGE_0150_PID 0x0150
215#define MTXORB_FTDI_RANGE_0151_PID 0x0151
216#define MTXORB_FTDI_RANGE_0152_PID 0x0152
217#define MTXORB_FTDI_RANGE_0153_PID 0x0153
218#define MTXORB_FTDI_RANGE_0154_PID 0x0154
219#define MTXORB_FTDI_RANGE_0155_PID 0x0155
220#define MTXORB_FTDI_RANGE_0156_PID 0x0156
221#define MTXORB_FTDI_RANGE_0157_PID 0x0157
222#define MTXORB_FTDI_RANGE_0158_PID 0x0158
223#define MTXORB_FTDI_RANGE_0159_PID 0x0159
224#define MTXORB_FTDI_RANGE_015A_PID 0x015A
225#define MTXORB_FTDI_RANGE_015B_PID 0x015B
226#define MTXORB_FTDI_RANGE_015C_PID 0x015C
227#define MTXORB_FTDI_RANGE_015D_PID 0x015D
228#define MTXORB_FTDI_RANGE_015E_PID 0x015E
229#define MTXORB_FTDI_RANGE_015F_PID 0x015F
230#define MTXORB_FTDI_RANGE_0160_PID 0x0160
231#define MTXORB_FTDI_RANGE_0161_PID 0x0161
232#define MTXORB_FTDI_RANGE_0162_PID 0x0162
233#define MTXORB_FTDI_RANGE_0163_PID 0x0163
234#define MTXORB_FTDI_RANGE_0164_PID 0x0164
235#define MTXORB_FTDI_RANGE_0165_PID 0x0165
236#define MTXORB_FTDI_RANGE_0166_PID 0x0166
237#define MTXORB_FTDI_RANGE_0167_PID 0x0167
238#define MTXORB_FTDI_RANGE_0168_PID 0x0168
239#define MTXORB_FTDI_RANGE_0169_PID 0x0169
240#define MTXORB_FTDI_RANGE_016A_PID 0x016A
241#define MTXORB_FTDI_RANGE_016B_PID 0x016B
242#define MTXORB_FTDI_RANGE_016C_PID 0x016C
243#define MTXORB_FTDI_RANGE_016D_PID 0x016D
244#define MTXORB_FTDI_RANGE_016E_PID 0x016E
245#define MTXORB_FTDI_RANGE_016F_PID 0x016F
246#define MTXORB_FTDI_RANGE_0170_PID 0x0170
247#define MTXORB_FTDI_RANGE_0171_PID 0x0171
248#define MTXORB_FTDI_RANGE_0172_PID 0x0172
249#define MTXORB_FTDI_RANGE_0173_PID 0x0173
250#define MTXORB_FTDI_RANGE_0174_PID 0x0174
251#define MTXORB_FTDI_RANGE_0175_PID 0x0175
252#define MTXORB_FTDI_RANGE_0176_PID 0x0176
253#define MTXORB_FTDI_RANGE_0177_PID 0x0177
254#define MTXORB_FTDI_RANGE_0178_PID 0x0178
255#define MTXORB_FTDI_RANGE_0179_PID 0x0179
256#define MTXORB_FTDI_RANGE_017A_PID 0x017A
257#define MTXORB_FTDI_RANGE_017B_PID 0x017B
258#define MTXORB_FTDI_RANGE_017C_PID 0x017C
259#define MTXORB_FTDI_RANGE_017D_PID 0x017D
260#define MTXORB_FTDI_RANGE_017E_PID 0x017E
261#define MTXORB_FTDI_RANGE_017F_PID 0x017F
262#define MTXORB_FTDI_RANGE_0180_PID 0x0180
263#define MTXORB_FTDI_RANGE_0181_PID 0x0181
264#define MTXORB_FTDI_RANGE_0182_PID 0x0182
265#define MTXORB_FTDI_RANGE_0183_PID 0x0183
266#define MTXORB_FTDI_RANGE_0184_PID 0x0184
267#define MTXORB_FTDI_RANGE_0185_PID 0x0185
268#define MTXORB_FTDI_RANGE_0186_PID 0x0186
269#define MTXORB_FTDI_RANGE_0187_PID 0x0187
270#define MTXORB_FTDI_RANGE_0188_PID 0x0188
271#define MTXORB_FTDI_RANGE_0189_PID 0x0189
272#define MTXORB_FTDI_RANGE_018A_PID 0x018A
273#define MTXORB_FTDI_RANGE_018B_PID 0x018B
274#define MTXORB_FTDI_RANGE_018C_PID 0x018C
275#define MTXORB_FTDI_RANGE_018D_PID 0x018D
276#define MTXORB_FTDI_RANGE_018E_PID 0x018E
277#define MTXORB_FTDI_RANGE_018F_PID 0x018F
278#define MTXORB_FTDI_RANGE_0190_PID 0x0190
279#define MTXORB_FTDI_RANGE_0191_PID 0x0191
280#define MTXORB_FTDI_RANGE_0192_PID 0x0192
281#define MTXORB_FTDI_RANGE_0193_PID 0x0193
282#define MTXORB_FTDI_RANGE_0194_PID 0x0194
283#define MTXORB_FTDI_RANGE_0195_PID 0x0195
284#define MTXORB_FTDI_RANGE_0196_PID 0x0196
285#define MTXORB_FTDI_RANGE_0197_PID 0x0197
286#define MTXORB_FTDI_RANGE_0198_PID 0x0198
287#define MTXORB_FTDI_RANGE_0199_PID 0x0199
288#define MTXORB_FTDI_RANGE_019A_PID 0x019A
289#define MTXORB_FTDI_RANGE_019B_PID 0x019B
290#define MTXORB_FTDI_RANGE_019C_PID 0x019C
291#define MTXORB_FTDI_RANGE_019D_PID 0x019D
292#define MTXORB_FTDI_RANGE_019E_PID 0x019E
293#define MTXORB_FTDI_RANGE_019F_PID 0x019F
294#define MTXORB_FTDI_RANGE_01A0_PID 0x01A0
295#define MTXORB_FTDI_RANGE_01A1_PID 0x01A1
296#define MTXORB_FTDI_RANGE_01A2_PID 0x01A2
297#define MTXORB_FTDI_RANGE_01A3_PID 0x01A3
298#define MTXORB_FTDI_RANGE_01A4_PID 0x01A4
299#define MTXORB_FTDI_RANGE_01A5_PID 0x01A5
300#define MTXORB_FTDI_RANGE_01A6_PID 0x01A6
301#define MTXORB_FTDI_RANGE_01A7_PID 0x01A7
302#define MTXORB_FTDI_RANGE_01A8_PID 0x01A8
303#define MTXORB_FTDI_RANGE_01A9_PID 0x01A9
304#define MTXORB_FTDI_RANGE_01AA_PID 0x01AA
305#define MTXORB_FTDI_RANGE_01AB_PID 0x01AB
306#define MTXORB_FTDI_RANGE_01AC_PID 0x01AC
307#define MTXORB_FTDI_RANGE_01AD_PID 0x01AD
308#define MTXORB_FTDI_RANGE_01AE_PID 0x01AE
309#define MTXORB_FTDI_RANGE_01AF_PID 0x01AF
310#define MTXORB_FTDI_RANGE_01B0_PID 0x01B0
311#define MTXORB_FTDI_RANGE_01B1_PID 0x01B1
312#define MTXORB_FTDI_RANGE_01B2_PID 0x01B2
313#define MTXORB_FTDI_RANGE_01B3_PID 0x01B3
314#define MTXORB_FTDI_RANGE_01B4_PID 0x01B4
315#define MTXORB_FTDI_RANGE_01B5_PID 0x01B5
316#define MTXORB_FTDI_RANGE_01B6_PID 0x01B6
317#define MTXORB_FTDI_RANGE_01B7_PID 0x01B7
318#define MTXORB_FTDI_RANGE_01B8_PID 0x01B8
319#define MTXORB_FTDI_RANGE_01B9_PID 0x01B9
320#define MTXORB_FTDI_RANGE_01BA_PID 0x01BA
321#define MTXORB_FTDI_RANGE_01BB_PID 0x01BB
322#define MTXORB_FTDI_RANGE_01BC_PID 0x01BC
323#define MTXORB_FTDI_RANGE_01BD_PID 0x01BD
324#define MTXORB_FTDI_RANGE_01BE_PID 0x01BE
325#define MTXORB_FTDI_RANGE_01BF_PID 0x01BF
326#define MTXORB_FTDI_RANGE_01C0_PID 0x01C0
327#define MTXORB_FTDI_RANGE_01C1_PID 0x01C1
328#define MTXORB_FTDI_RANGE_01C2_PID 0x01C2
329#define MTXORB_FTDI_RANGE_01C3_PID 0x01C3
330#define MTXORB_FTDI_RANGE_01C4_PID 0x01C4
331#define MTXORB_FTDI_RANGE_01C5_PID 0x01C5
332#define MTXORB_FTDI_RANGE_01C6_PID 0x01C6
333#define MTXORB_FTDI_RANGE_01C7_PID 0x01C7
334#define MTXORB_FTDI_RANGE_01C8_PID 0x01C8
335#define MTXORB_FTDI_RANGE_01C9_PID 0x01C9
336#define MTXORB_FTDI_RANGE_01CA_PID 0x01CA
337#define MTXORB_FTDI_RANGE_01CB_PID 0x01CB
338#define MTXORB_FTDI_RANGE_01CC_PID 0x01CC
339#define MTXORB_FTDI_RANGE_01CD_PID 0x01CD
340#define MTXORB_FTDI_RANGE_01CE_PID 0x01CE
341#define MTXORB_FTDI_RANGE_01CF_PID 0x01CF
342#define MTXORB_FTDI_RANGE_01D0_PID 0x01D0
343#define MTXORB_FTDI_RANGE_01D1_PID 0x01D1
344#define MTXORB_FTDI_RANGE_01D2_PID 0x01D2
345#define MTXORB_FTDI_RANGE_01D3_PID 0x01D3
346#define MTXORB_FTDI_RANGE_01D4_PID 0x01D4
347#define MTXORB_FTDI_RANGE_01D5_PID 0x01D5
348#define MTXORB_FTDI_RANGE_01D6_PID 0x01D6
349#define MTXORB_FTDI_RANGE_01D7_PID 0x01D7
350#define MTXORB_FTDI_RANGE_01D8_PID 0x01D8
351#define MTXORB_FTDI_RANGE_01D9_PID 0x01D9
352#define MTXORB_FTDI_RANGE_01DA_PID 0x01DA
353#define MTXORB_FTDI_RANGE_01DB_PID 0x01DB
354#define MTXORB_FTDI_RANGE_01DC_PID 0x01DC
355#define MTXORB_FTDI_RANGE_01DD_PID 0x01DD
356#define MTXORB_FTDI_RANGE_01DE_PID 0x01DE
357#define MTXORB_FTDI_RANGE_01DF_PID 0x01DF
358#define MTXORB_FTDI_RANGE_01E0_PID 0x01E0
359#define MTXORB_FTDI_RANGE_01E1_PID 0x01E1
360#define MTXORB_FTDI_RANGE_01E2_PID 0x01E2
361#define MTXORB_FTDI_RANGE_01E3_PID 0x01E3
362#define MTXORB_FTDI_RANGE_01E4_PID 0x01E4
363#define MTXORB_FTDI_RANGE_01E5_PID 0x01E5
364#define MTXORB_FTDI_RANGE_01E6_PID 0x01E6
365#define MTXORB_FTDI_RANGE_01E7_PID 0x01E7
366#define MTXORB_FTDI_RANGE_01E8_PID 0x01E8
367#define MTXORB_FTDI_RANGE_01E9_PID 0x01E9
368#define MTXORB_FTDI_RANGE_01EA_PID 0x01EA
369#define MTXORB_FTDI_RANGE_01EB_PID 0x01EB
370#define MTXORB_FTDI_RANGE_01EC_PID 0x01EC
371#define MTXORB_FTDI_RANGE_01ED_PID 0x01ED
372#define MTXORB_FTDI_RANGE_01EE_PID 0x01EE
373#define MTXORB_FTDI_RANGE_01EF_PID 0x01EF
374#define MTXORB_FTDI_RANGE_01F0_PID 0x01F0
375#define MTXORB_FTDI_RANGE_01F1_PID 0x01F1
376#define MTXORB_FTDI_RANGE_01F2_PID 0x01F2
377#define MTXORB_FTDI_RANGE_01F3_PID 0x01F3
378#define MTXORB_FTDI_RANGE_01F4_PID 0x01F4
379#define MTXORB_FTDI_RANGE_01F5_PID 0x01F5
380#define MTXORB_FTDI_RANGE_01F6_PID 0x01F6
381#define MTXORB_FTDI_RANGE_01F7_PID 0x01F7
382#define MTXORB_FTDI_RANGE_01F8_PID 0x01F8
383#define MTXORB_FTDI_RANGE_01F9_PID 0x01F9
384#define MTXORB_FTDI_RANGE_01FA_PID 0x01FA
385#define MTXORB_FTDI_RANGE_01FB_PID 0x01FB
386#define MTXORB_FTDI_RANGE_01FC_PID 0x01FC
387#define MTXORB_FTDI_RANGE_01FD_PID 0x01FD
388#define MTXORB_FTDI_RANGE_01FE_PID 0x01FE
389#define MTXORB_FTDI_RANGE_01FF_PID 0x01FF
390
391
392
393/* Interbiometrics USB I/O Board */
394/* Developed for Interbiometrics by Rudolf Gugler */
395#define INTERBIOMETRICS_VID 0x1209
396#define INTERBIOMETRICS_IOBOARD_PID 0x1002
397#define INTERBIOMETRICS_MINI_IOBOARD_PID 0x1006
398
399/*
400 * The following are the values for the Perle Systems
401 * UltraPort USB serial converters
402 */
403#define FTDI_PERLE_ULTRAPORT_PID 0xF0C0 /* Perle UltraPort Product Id */
404
405/*
406 * The following are the values for the Sealevel SeaLINK+ adapters.
407 * (Original list sent by Tuan Hoang. Ian Abbott renamed the macros and
408 * removed some PIDs that don't seem to match any existing products.)
409 */
410#define SEALEVEL_VID 0x0c52 /* Sealevel Vendor ID */
411#define SEALEVEL_2101_PID 0x2101 /* SeaLINK+232 (2101/2105) */
412#define SEALEVEL_2102_PID 0x2102 /* SeaLINK+485 (2102) */
413#define SEALEVEL_2103_PID 0x2103 /* SeaLINK+232I (2103) */
414#define SEALEVEL_2104_PID 0x2104 /* SeaLINK+485I (2104) */
415#define SEALEVEL_2106_PID 0x9020 /* SeaLINK+422 (2106) */
416#define SEALEVEL_2201_1_PID 0x2211 /* SeaPORT+2/232 (2201) Port 1 */
417#define SEALEVEL_2201_2_PID 0x2221 /* SeaPORT+2/232 (2201) Port 2 */
418#define SEALEVEL_2202_1_PID 0x2212 /* SeaPORT+2/485 (2202) Port 1 */
419#define SEALEVEL_2202_2_PID 0x2222 /* SeaPORT+2/485 (2202) Port 2 */
420#define SEALEVEL_2203_1_PID 0x2213 /* SeaPORT+2 (2203) Port 1 */
421#define SEALEVEL_2203_2_PID 0x2223 /* SeaPORT+2 (2203) Port 2 */
422#define SEALEVEL_2401_1_PID 0x2411 /* SeaPORT+4/232 (2401) Port 1 */
423#define SEALEVEL_2401_2_PID 0x2421 /* SeaPORT+4/232 (2401) Port 2 */
424#define SEALEVEL_2401_3_PID 0x2431 /* SeaPORT+4/232 (2401) Port 3 */
425#define SEALEVEL_2401_4_PID 0x2441 /* SeaPORT+4/232 (2401) Port 4 */
426#define SEALEVEL_2402_1_PID 0x2412 /* SeaPORT+4/485 (2402) Port 1 */
427#define SEALEVEL_2402_2_PID 0x2422 /* SeaPORT+4/485 (2402) Port 2 */
428#define SEALEVEL_2402_3_PID 0x2432 /* SeaPORT+4/485 (2402) Port 3 */
429#define SEALEVEL_2402_4_PID 0x2442 /* SeaPORT+4/485 (2402) Port 4 */
430#define SEALEVEL_2403_1_PID 0x2413 /* SeaPORT+4 (2403) Port 1 */
431#define SEALEVEL_2403_2_PID 0x2423 /* SeaPORT+4 (2403) Port 2 */
432#define SEALEVEL_2403_3_PID 0x2433 /* SeaPORT+4 (2403) Port 3 */
433#define SEALEVEL_2403_4_PID 0x2443 /* SeaPORT+4 (2403) Port 4 */
434#define SEALEVEL_2801_1_PID 0X2811 /* SeaLINK+8/232 (2801) Port 1 */
435#define SEALEVEL_2801_2_PID 0X2821 /* SeaLINK+8/232 (2801) Port 2 */
436#define SEALEVEL_2801_3_PID 0X2831 /* SeaLINK+8/232 (2801) Port 3 */
437#define SEALEVEL_2801_4_PID 0X2841 /* SeaLINK+8/232 (2801) Port 4 */
438#define SEALEVEL_2801_5_PID 0X2851 /* SeaLINK+8/232 (2801) Port 5 */
439#define SEALEVEL_2801_6_PID 0X2861 /* SeaLINK+8/232 (2801) Port 6 */
440#define SEALEVEL_2801_7_PID 0X2871 /* SeaLINK+8/232 (2801) Port 7 */
441#define SEALEVEL_2801_8_PID 0X2881 /* SeaLINK+8/232 (2801) Port 8 */
442#define SEALEVEL_2802_1_PID 0X2812 /* SeaLINK+8/485 (2802) Port 1 */
443#define SEALEVEL_2802_2_PID 0X2822 /* SeaLINK+8/485 (2802) Port 2 */
444#define SEALEVEL_2802_3_PID 0X2832 /* SeaLINK+8/485 (2802) Port 3 */
445#define SEALEVEL_2802_4_PID 0X2842 /* SeaLINK+8/485 (2802) Port 4 */
446#define SEALEVEL_2802_5_PID 0X2852 /* SeaLINK+8/485 (2802) Port 5 */
447#define SEALEVEL_2802_6_PID 0X2862 /* SeaLINK+8/485 (2802) Port 6 */
448#define SEALEVEL_2802_7_PID 0X2872 /* SeaLINK+8/485 (2802) Port 7 */
449#define SEALEVEL_2802_8_PID 0X2882 /* SeaLINK+8/485 (2802) Port 8 */
450#define SEALEVEL_2803_1_PID 0X2813 /* SeaLINK+8 (2803) Port 1 */
451#define SEALEVEL_2803_2_PID 0X2823 /* SeaLINK+8 (2803) Port 2 */
452#define SEALEVEL_2803_3_PID 0X2833 /* SeaLINK+8 (2803) Port 3 */
453#define SEALEVEL_2803_4_PID 0X2843 /* SeaLINK+8 (2803) Port 4 */
454#define SEALEVEL_2803_5_PID 0X2853 /* SeaLINK+8 (2803) Port 5 */
455#define SEALEVEL_2803_6_PID 0X2863 /* SeaLINK+8 (2803) Port 6 */
456#define SEALEVEL_2803_7_PID 0X2873 /* SeaLINK+8 (2803) Port 7 */
457#define SEALEVEL_2803_8_PID 0X2883 /* SeaLINK+8 (2803) Port 8 */
458
459/*
460 * The following are the values for two KOBIL chipcard terminals.
461 */
462#define KOBIL_VID 0x0d46 /* KOBIL Vendor ID */
463#define KOBIL_CONV_B1_PID 0x2020 /* KOBIL Konverter for B1 */
464#define KOBIL_CONV_KAAN_PID 0x2021 /* KOBIL_Konverter for KAAN */
465
466/*
467 * Icom ID-1 digital transceiver
468 */
469
470#define ICOM_ID1_VID 0x0C26
471#define ICOM_ID1_PID 0x0004
472
473/*
474 * ASK.fr devices
475 */
476#define FTDI_ASK_RDR400_PID 0xC991 /* ASK RDR 400 series card reader */
477
478/*
479 * FTDI USB UART chips used in construction projects from the
480 * Elektor Electronics magazine (http://elektor-electronics.co.uk)
481 */
482#define ELEKTOR_VID 0x0C7D
483#define ELEKTOR_FT323R_PID 0x0005 /* RFID-Reader, issue 09-2006 */
484
485/*
486 * DSS-20 Sync Station for Sony Ericsson P800
487 */
488#define FTDI_DSS20_PID 0xFC82
489
490/*
491 * Home Electronics (www.home-electro.com) USB gadgets
492 */
493#define FTDI_HE_TIRA1_PID 0xFA78 /* Tira-1 IR transceiver */
494
495/* USB-UIRT - An infrared receiver and transmitter using the 8U232AM chip */
496/* http://home.earthlink.net/~jrhees/USBUIRT/index.htm */
497#define FTDI_USB_UIRT_PID 0xF850 /* Product Id */
498
499/* TNC-X USB-to-packet-radio adapter, versions prior to 3.0 (DLP module) */
500
501#define FTDI_TNC_X_PID 0xEBE0
502
503/*
504 * ELV USB devices submitted by Christian Abt of ELV (www.elv.de).
505 * All of these devices use FTDI's vendor ID (0x0403).
506 *
507 * The previously included PID for the UO 100 module was incorrect.
508 * In fact, that PID was for ELV's UR 100 USB-RS232 converter (0xFB58).
509 *
510 * Armin Laeuger originally sent the PID for the UM 100 module.
511 */
512#define FTDI_R2000KU_TRUE_RNG 0xFB80 /* R2000KU TRUE RNG */
513#define FTDI_ELV_UR100_PID 0xFB58 /* USB-RS232-Umsetzer (UR 100) */
514#define FTDI_ELV_UM100_PID 0xFB5A /* USB-Modul UM 100 */
515#define FTDI_ELV_UO100_PID 0xFB5B /* USB-Modul UO 100 */
516#define FTDI_ELV_ALC8500_PID 0xF06E /* ALC 8500 Expert */
517/* Additional ELV PIDs that default to using the FTDI D2XX drivers on
518 * MS Windows, rather than the FTDI Virtual Com Port drivers.
519 * Maybe these will be easier to use with the libftdi/libusb user-space
520 * drivers, or possibly the Comedi drivers in some cases. */
521#define FTDI_ELV_CLI7000_PID 0xFB59 /* Computer-Light-Interface (CLI 7000) */
522#define FTDI_ELV_PPS7330_PID 0xFB5C /* Processor-Power-Supply (PPS 7330) */
523#define FTDI_ELV_TFM100_PID 0xFB5D /* Temperartur-Feuchte Messgeraet (TFM 100) */
524#define FTDI_ELV_UDF77_PID 0xFB5E /* USB DCF Funkurh (UDF 77) */
525#define FTDI_ELV_UIO88_PID 0xFB5F /* USB-I/O Interface (UIO 88) */
526#define FTDI_ELV_UAD8_PID 0xF068 /* USB-AD-Wandler (UAD 8) */
527#define FTDI_ELV_UDA7_PID 0xF069 /* USB-DA-Wandler (UDA 7) */
528#define FTDI_ELV_USI2_PID 0xF06A /* USB-Schrittmotoren-Interface (USI 2) */
529#define FTDI_ELV_T1100_PID 0xF06B /* Thermometer (T 1100) */
530#define FTDI_ELV_PCD200_PID 0xF06C /* PC-Datenlogger (PCD 200) */
531#define FTDI_ELV_ULA200_PID 0xF06D /* USB-LCD-Ansteuerung (ULA 200) */
532#define FTDI_ELV_FHZ1000PC_PID 0xF06F /* FHZ 1000 PC */
533#define FTDI_ELV_CSI8_PID 0xE0F0 /* Computer-Schalt-Interface (CSI 8) */
534#define FTDI_ELV_EM1000DL_PID 0xE0F1 /* PC-Datenlogger fuer Energiemonitor (EM 1000 DL) */
535#define FTDI_ELV_PCK100_PID 0xE0F2 /* PC-Kabeltester (PCK 100) */
536#define FTDI_ELV_RFP500_PID 0xE0F3 /* HF-Leistungsmesser (RFP 500) */
537#define FTDI_ELV_FS20SIG_PID 0xE0F4 /* Signalgeber (FS 20 SIG) */
538#define FTDI_ELV_WS300PC_PID 0xE0F6 /* PC-Wetterstation (WS 300 PC) */
539#define FTDI_ELV_FHZ1300PC_PID 0xE0E8 /* FHZ 1300 PC */
540#define FTDI_ELV_WS500_PID 0xE0E9 /* PC-Wetterstation (WS 500) */
541#define FTDI_ELV_HS485_PID 0xE0EA /* USB to RS-485 adapter */
542#define FTDI_ELV_EM1010PC_PID 0xE0EF /* Engery monitor EM 1010 PC */
543#define FTDI_PHI_FISCO_PID 0xE40B /* PHI Fisco USB to Serial cable */
544
545/*
546 * Definitions for ID TECH (www.idt-net.com) devices
547 */
548#define IDTECH_VID 0x0ACD /* ID TECH Vendor ID */
549#define IDTECH_IDT1221U_PID 0x0300 /* IDT1221U USB to RS-232 adapter */
550
551/*
552 * Definitions for Omnidirectional Control Technology, Inc. devices
553 */
554#define OCT_VID 0x0B39 /* OCT vendor ID */
555/* Note: OCT US101 is also rebadged as Dick Smith Electronics (NZ) XH6381 */
556/* Also rebadged as Dick Smith Electronics (Aus) XH6451 */
557/* Also rebadged as SIIG Inc. model US2308 hardware version 1 */
558#define OCT_US101_PID 0x0421 /* OCT US101 USB to RS-232 */
559
560/* an infrared receiver for user access control with IR tags */
561#define FTDI_PIEGROUP_PID 0xF208 /* Product Id */
562
563/*
564 * Definitions for Artemis astronomical USB based cameras
565 * Check it at http://www.artemisccd.co.uk/
566 */
567#define FTDI_ARTEMIS_PID 0xDF28 /* All Artemis Cameras */
568
569/*
570 * Definitions for ATIK Instruments astronomical USB based cameras
571 * Check it at http://www.atik-instruments.com/
572 */
573#define FTDI_ATIK_ATK16_PID 0xDF30 /* ATIK ATK-16 Grayscale Camera */
574#define FTDI_ATIK_ATK16C_PID 0xDF32 /* ATIK ATK-16C Colour Camera */
575#define FTDI_ATIK_ATK16HR_PID 0xDF31 /* ATIK ATK-16HR Grayscale Camera */
576#define FTDI_ATIK_ATK16HRC_PID 0xDF33 /* ATIK ATK-16HRC Colour Camera */
577#define FTDI_ATIK_ATK16IC_PID 0xDF35 /* ATIK ATK-16IC Grayscale Camera */
578
579/*
580 * Protego product ids
581 */
582#define PROTEGO_SPECIAL_1 0xFC70 /* special/unknown device */
583#define PROTEGO_R2X0 0xFC71 /* R200-USB TRNG unit (R210, R220, and R230) */
584#define PROTEGO_SPECIAL_3 0xFC72 /* special/unknown device */
585#define PROTEGO_SPECIAL_4 0xFC73 /* special/unknown device */
586
587/*
588 * Gude Analog- und Digitalsysteme GmbH
589 */
590#define FTDI_GUDEADS_E808_PID 0xE808
591#define FTDI_GUDEADS_E809_PID 0xE809
592#define FTDI_GUDEADS_E80A_PID 0xE80A
593#define FTDI_GUDEADS_E80B_PID 0xE80B
594#define FTDI_GUDEADS_E80C_PID 0xE80C
595#define FTDI_GUDEADS_E80D_PID 0xE80D
596#define FTDI_GUDEADS_E80E_PID 0xE80E
597#define FTDI_GUDEADS_E80F_PID 0xE80F
598#define FTDI_GUDEADS_E888_PID 0xE888 /* Expert ISDN Control USB */
599#define FTDI_GUDEADS_E889_PID 0xE889 /* USB RS-232 OptoBridge */
600#define FTDI_GUDEADS_E88A_PID 0xE88A
601#define FTDI_GUDEADS_E88B_PID 0xE88B
602#define FTDI_GUDEADS_E88C_PID 0xE88C
603#define FTDI_GUDEADS_E88D_PID 0xE88D
604#define FTDI_GUDEADS_E88E_PID 0xE88E
605#define FTDI_GUDEADS_E88F_PID 0xE88F
606
607/*
608 * Linx Technologies product ids
609 */
610#define LINX_SDMUSBQSS_PID 0xF448 /* Linx SDM-USB-QS-S */
611#define LINX_MASTERDEVEL2_PID 0xF449 /* Linx Master Development 2.0 */
612#define LINX_FUTURE_0_PID 0xF44A /* Linx future device */
613#define LINX_FUTURE_1_PID 0xF44B /* Linx future device */
614#define LINX_FUTURE_2_PID 0xF44C /* Linx future device */
615
616/* CCS Inc. ICDU/ICDU40 product ID - the FT232BM is used in an in-circuit-debugger */
617/* unit for PIC16's/PIC18's */
618#define FTDI_CCSICDU20_0_PID 0xF9D0
619#define FTDI_CCSICDU40_1_PID 0xF9D1
620#define FTDI_CCSMACHX_2_PID 0xF9D2
621#define FTDI_CCSLOAD_N_GO_3_PID 0xF9D3
622#define FTDI_CCSICDU64_4_PID 0xF9D4
623#define FTDI_CCSPRIME8_5_PID 0xF9D5
624
625/* Inside Accesso contactless reader (http://www.insidefr.com) */
626#define INSIDE_ACCESSO 0xFAD0
627
628/*
629 * Intrepid Control Systems (http://www.intrepidcs.com/) ValueCAN and NeoVI
630 */
631#define INTREPID_VID 0x093C
632#define INTREPID_VALUECAN_PID 0x0601
633#define INTREPID_NEOVI_PID 0x0701
634
635/*
636 * Falcom Wireless Communications GmbH
637 */
638#define FALCOM_VID 0x0F94 /* Vendor Id */
639#define FALCOM_TWIST_PID 0x0001 /* Falcom Twist USB GPRS modem */
640#define FALCOM_SAMBA_PID 0x0005 /* Falcom Samba USB GPRS modem */
641
642/*
643 * SUUNTO product ids
644 */
645#define FTDI_SUUNTO_SPORTS_PID 0xF680 /* Suunto Sports instrument */
646
647/*
648 * Oceanic product ids
649 */
650#define FTDI_OCEANIC_PID 0xF460 /* Oceanic dive instrument */
651
652/*
653 * TTi (Thurlby Thandar Instruments)
654 */
655#define TTI_VID 0x103E /* Vendor Id */
656#define TTI_QL355P_PID 0x03E8 /* TTi QL355P power supply */
657
658/*
659 * Definitions for B&B Electronics products.
660 */
661#define BANDB_VID 0x0856 /* B&B Electronics Vendor ID */
662#define BANDB_USOTL4_PID 0xAC01 /* USOTL4 Isolated RS-485 Converter */
663#define BANDB_USTL4_PID 0xAC02 /* USTL4 RS-485 Converter */
664#define BANDB_USO9ML2_PID 0xAC03 /* USO9ML2 Isolated RS-232 Converter */
665
666/*
667 * RM Michaelides CANview USB (http://www.rmcan.com)
668 * CAN fieldbus interface adapter, added by port GmbH www.port.de)
669 * Ian Abbott changed the macro names for consistency.
670 */
671#define FTDI_RM_CANVIEW_PID 0xfd60 /* Product Id */
672
673/*
674 * EVER Eco Pro UPS (http://www.ever.com.pl/)
675 */
676
677#define EVER_ECO_PRO_CDS 0xe520 /* RS-232 converter */
678
679/*
680 * 4N-GALAXY.DE PIDs for CAN-USB, USB-RS232, USB-RS422, USB-RS485,
681 * USB-TTY activ, USB-TTY passiv. Some PIDs are used by several devices
682 * and I'm not entirely sure which are used by which.
683 */
684#define FTDI_4N_GALAXY_DE_1_PID 0xF3C0
685#define FTDI_4N_GALAXY_DE_2_PID 0xF3C1
686
687/*
688 * Mobility Electronics products.
689 */
690#define MOBILITY_VID 0x1342
691#define MOBILITY_USB_SERIAL_PID 0x0202 /* EasiDock USB 200 serial */
692
693/*
694 * microHAM product IDs (http://www.microham.com).
695 * Submitted by Justin Burket (KL1RL) <zorton@jtan.com>
696 * and Mike Studer (K6EEP) <k6eep@hamsoftware.org>.
697 * Ian Abbott <abbotti@mev.co.uk> added a few more from the driver INF file.
698 */
699#define FTDI_MHAM_KW_PID 0xEEE8 /* USB-KW interface */
700#define FTDI_MHAM_YS_PID 0xEEE9 /* USB-YS interface */
701#define FTDI_MHAM_Y6_PID 0xEEEA /* USB-Y6 interface */
702#define FTDI_MHAM_Y8_PID 0xEEEB /* USB-Y8 interface */
703#define FTDI_MHAM_IC_PID 0xEEEC /* USB-IC interface */
704#define FTDI_MHAM_DB9_PID 0xEEED /* USB-DB9 interface */
705#define FTDI_MHAM_RS232_PID 0xEEEE /* USB-RS232 interface */
706#define FTDI_MHAM_Y9_PID 0xEEEF /* USB-Y9 interface */
707
708/*
709 * Active Robots product ids.
710 */
711#define FTDI_ACTIVE_ROBOTS_PID 0xE548 /* USB comms board */
712
713/*
714 * Xsens Technologies BV products (http://www.xsens.com).
715 */
716#define XSENS_CONVERTER_0_PID 0xD388
717#define XSENS_CONVERTER_1_PID 0xD389
718#define XSENS_CONVERTER_2_PID 0xD38A
719#define XSENS_CONVERTER_3_PID 0xD38B
720#define XSENS_CONVERTER_4_PID 0xD38C
721#define XSENS_CONVERTER_5_PID 0xD38D
722#define XSENS_CONVERTER_6_PID 0xD38E
723#define XSENS_CONVERTER_7_PID 0xD38F
724
725/*
726 * Teratronik product ids.
727 * Submitted by O. Wölfelschneider.
728 */
729#define FTDI_TERATRONIK_VCP_PID 0xEC88 /* Teratronik device (preferring VCP driver on windows) */
730#define FTDI_TERATRONIK_D2XX_PID 0xEC89 /* Teratronik device (preferring D2XX driver on windows) */
731
732/*
733 * Evolution Robotics products (http://www.evolution.com/).
734 * Submitted by Shawn M. Lavelle.
735 */
736#define EVOLUTION_VID 0xDEEE /* Vendor ID */
737#define EVOLUTION_ER1_PID 0x0300 /* ER1 Control Module */
738#define EVO_8U232AM_PID 0x02FF /* Evolution robotics RCM2 (FT232AM)*/
739#define EVO_HYBRID_PID 0x0302 /* Evolution robotics RCM4 PID (FT232BM)*/
740#define EVO_RCM4_PID 0x0303 /* Evolution robotics RCM4 PID */
741
742/* Pyramid Computer GmbH */
743#define FTDI_PYRAMID_PID 0xE6C8 /* Pyramid Appliance Display */
744
745/*
746 * NDI (www.ndigital.com) product ids
747 */
748#define FTDI_NDI_HUC_PID 0xDA70 /* NDI Host USB Converter */
749#define FTDI_NDI_SPECTRA_SCU_PID 0xDA71 /* NDI Spectra SCU */
750#define FTDI_NDI_FUTURE_2_PID 0xDA72 /* NDI future device #2 */
751#define FTDI_NDI_FUTURE_3_PID 0xDA73 /* NDI future device #3 */
752#define FTDI_NDI_AURORA_SCU_PID 0xDA74 /* NDI Aurora SCU */
753
754/*
755 * Posiflex inc retail equipment (http://www.posiflex.com.tw)
756 */
757#define POSIFLEX_VID 0x0d3a /* Vendor ID */
758#define POSIFLEX_PP7000_PID 0x0300 /* PP-7000II thermal printer */
759
760/*
761 * Westrex International devices submitted by Cory Lee
762 */
763#define FTDI_WESTREX_MODEL_777_PID 0xDC00 /* Model 777 */
764#define FTDI_WESTREX_MODEL_8900F_PID 0xDC01 /* Model 8900F */
765
766/*
767 * RR-CirKits LocoBuffer USB (http://www.rr-cirkits.com)
768 */
769#define FTDI_RRCIRKITS_LOCOBUFFER_PID 0xc7d0 /* LocoBuffer USB */
770
771/*
772 * Eclo (http://www.eclo.pt/) product IDs.
773 * PID 0xEA90 submitted by Martin Grill.
774 */
775#define FTDI_ECLO_COM_1WIRE_PID 0xEA90 /* COM to 1-Wire USB adaptor */
776
777/*
778 * Papouch products (http://www.papouch.com/)
779 * Submitted by Folkert van Heusden
780 */
781
782#define PAPOUCH_VID 0x5050 /* Vendor ID */
783#define PAPOUCH_TMU_PID 0x0400 /* TMU USB Thermometer */
784#define PAPOUCH_QUIDO4x4_PID 0x0900 /* Quido 4/4 Module */
785
786/*
787 * ACG Identification Technologies GmbH products (http://www.acg.de/).
788 * Submitted by anton -at- goto10 -dot- org.
789 */ 23 */
790#define FTDI_ACG_HFDUAL_PID 0xDD20 /* HF Dual ISO Reader (RFID) */
791
792/*
793 * Yost Engineering, Inc. products (www.yostengineering.com).
794 * PID 0xE050 submitted by Aaron Prose.
795 */
796#define FTDI_YEI_SERVOCENTER31_PID 0xE050 /* YEI ServoCenter3.1 USB */
797
798/*
799 * ThorLabs USB motor drivers
800 */
801#define FTDI_THORLABS_PID 0xfaf0 /* ThorLabs USB motor drivers */
802
803/*
804 * Testo products (http://www.testo.com/)
805 * Submitted by Colin Leroy
806 */
807#define TESTO_VID 0x128D
808#define TESTO_USB_INTERFACE_PID 0x0001
809
810/*
811 * Gamma Scout (http://gamma-scout.com/). Submitted by rsc@runtux.com.
812 */
813#define FTDI_GAMMA_SCOUT_PID 0xD678 /* Gamma Scout online */
814
815/*
816 * Tactrix OpenPort (ECU) devices.
817 * OpenPort 1.3M submitted by Donour Sizemore.
818 * OpenPort 1.3S and 1.3U submitted by Ian Abbott.
819 */
820#define FTDI_TACTRIX_OPENPORT_13M_PID 0xCC48 /* OpenPort 1.3 Mitsubishi */
821#define FTDI_TACTRIX_OPENPORT_13S_PID 0xCC49 /* OpenPort 1.3 Subaru */
822#define FTDI_TACTRIX_OPENPORT_13U_PID 0xCC4A /* OpenPort 1.3 Universal */
823
824/*
825 * Telldus Technologies
826 */
827#define TELLDUS_VID 0x1781 /* Vendor ID */
828#define TELLDUS_TELLSTICK_PID 0x0C30 /* RF control dongle 433 MHz using FT232RL */
829
830/*
831 * IBS elektronik product ids
832 * Submitted by Thomas Schleusener
833 */
834#define FTDI_IBS_US485_PID 0xff38 /* IBS US485 (USB<-->RS422/485 interface) */
835#define FTDI_IBS_PICPRO_PID 0xff39 /* IBS PIC-Programmer */
836#define FTDI_IBS_PCMCIA_PID 0xff3a /* IBS Card reader for PCMCIA SRAM-cards */
837#define FTDI_IBS_PK1_PID 0xff3b /* IBS PK1 - Particel counter */
838#define FTDI_IBS_RS232MON_PID 0xff3c /* IBS RS232 - Monitor */
839#define FTDI_IBS_APP70_PID 0xff3d /* APP 70 (dust monitoring system) */
840#define FTDI_IBS_PEDO_PID 0xff3e /* IBS PEDO-Modem (RF modem 868.35 MHz) */
841#define FTDI_IBS_PROD_PID 0xff3f /* future device */
842
843/*
844 * MaxStream devices www.maxstream.net
845 */
846#define FTDI_MAXSTREAM_PID 0xEE18 /* Xbee PKG-U Module */
847
848/* Olimex */
849#define OLIMEX_VID 0x15BA
850#define OLIMEX_ARM_USB_OCD_PID 0x0003
851
852/* Luminary Micro Stellaris Boards, VID = FTDI_VID */
853/* FTDI 2332C Dual channel device, side A=245 FIFO (JTAG), Side B=RS232 UART */
854#define LMI_LM3S_DEVEL_BOARD_PID 0xbcd8
855#define LMI_LM3S_EVAL_BOARD_PID 0xbcd9
856
857/* www.elsterelectricity.com Elster Unicom III Optical Probe */
858#define FTDI_ELSTER_UNICOM_PID 0xE700 /* Product Id */
859
860/*
861 * The Mobility Lab (TML)
862 * Submitted by Pierre Castella
863 */
864#define TML_VID 0x1B91 /* Vendor ID */
865#define TML_USB_SERIAL_PID 0x0064 /* USB - Serial Converter */
866
867/* Propox devices */
868#define FTDI_PROPOX_JTAGCABLEII_PID 0xD738
869
870/* Rig Expert Ukraine devices */
871#define FTDI_REU_TINY_PID 0xED22 /* RigExpert Tiny */
872
873/* Domintell products http://www.domintell.com */
874#define FTDI_DOMINTELL_DGQG_PID 0xEF50 /* Master */
875#define FTDI_DOMINTELL_DUSB_PID 0xEF51 /* DUSB01 module */
876
877/* Alti-2 products http://www.alti-2.com */
878#define ALTI2_VID 0x1BC9
879#define ALTI2_N3_PID 0x6001 /* Neptune 3 */
880 24
881/* Commands */ 25/* Commands */
882#define FTDI_SIO_RESET 0 /* Reset the port */ 26#define FTDI_SIO_RESET 0 /* Reset the port */
@@ -884,98 +28,18 @@
884#define FTDI_SIO_SET_FLOW_CTRL 2 /* Set flow control register */ 28#define FTDI_SIO_SET_FLOW_CTRL 2 /* Set flow control register */
885#define FTDI_SIO_SET_BAUD_RATE 3 /* Set baud rate */ 29#define FTDI_SIO_SET_BAUD_RATE 3 /* Set baud rate */
886#define FTDI_SIO_SET_DATA 4 /* Set the data characteristics of the port */ 30#define FTDI_SIO_SET_DATA 4 /* Set the data characteristics of the port */
887#define FTDI_SIO_GET_MODEM_STATUS 5 /* Retrieve current value of modern status register */ 31#define FTDI_SIO_GET_MODEM_STATUS 5 /* Retrieve current value of modem status register */
888#define FTDI_SIO_SET_EVENT_CHAR 6 /* Set the event character */ 32#define FTDI_SIO_SET_EVENT_CHAR 6 /* Set the event character */
889#define FTDI_SIO_SET_ERROR_CHAR 7 /* Set the error character */ 33#define FTDI_SIO_SET_ERROR_CHAR 7 /* Set the error character */
890#define FTDI_SIO_SET_LATENCY_TIMER 9 /* Set the latency timer */ 34#define FTDI_SIO_SET_LATENCY_TIMER 9 /* Set the latency timer */
891#define FTDI_SIO_GET_LATENCY_TIMER 10 /* Get the latency timer */ 35#define FTDI_SIO_GET_LATENCY_TIMER 10 /* Get the latency timer */
892 36
893/* Interface indicies for FT2232, FT2232H and FT4232H devices*/ 37/* Interface indices for FT2232, FT2232H and FT4232H devices */
894#define INTERFACE_A 1 38#define INTERFACE_A 1
895#define INTERFACE_B 2 39#define INTERFACE_B 2
896#define INTERFACE_C 3 40#define INTERFACE_C 3
897#define INTERFACE_D 4 41#define INTERFACE_D 4
898 42
899/*
900 * FIC / OpenMoko, Inc. http://wiki.openmoko.org/wiki/Neo1973_Debug_Board_v3
901 * Submitted by Harald Welte <laforge@openmoko.org>
902 */
903#define FIC_VID 0x1457
904#define FIC_NEO1973_DEBUG_PID 0x5118
905
906/*
907 * RATOC REX-USB60F
908 */
909#define RATOC_VENDOR_ID 0x0584
910#define RATOC_PRODUCT_ID_USB60F 0xb020
911
912/*
913 * DIEBOLD BCS SE923
914 */
915#define DIEBOLD_BCS_SE923_PID 0xfb99
916
917/*
918 * Atmel STK541
919 */
920#define ATMEL_VID 0x03eb /* Vendor ID */
921#define STK541_PID 0x2109 /* Zigbee Controller */
922
923/*
924 * Dresden Elektronic Sensor Terminal Board
925 */
926#define DE_VID 0x1cf1 /* Vendor ID */
927#define STB_PID 0x0001 /* Sensor Terminal Board */
928#define WHT_PID 0x0004 /* Wireless Handheld Terminal */
929
930/*
931 * Blackfin gnICE JTAG
932 * http://docs.blackfin.uclinux.org/doku.php?id=hw:jtag:gnice
933 */
934#define ADI_VID 0x0456
935#define ADI_GNICE_PID 0xF000
936#define ADI_GNICEPLUS_PID 0xF001
937
938/*
939 * JETI SPECTROMETER SPECBOS 1201
940 * http://www.jeti.com/products/sys/scb/scb1201.php
941 */
942#define JETI_VID 0x0c6c
943#define JETI_SPC1201_PID 0x04b2
944
945/*
946 * Marvell SheevaPlug
947 */
948#define MARVELL_VID 0x9e88
949#define MARVELL_SHEEVAPLUG_PID 0x9e8f
950
951#define FTDI_TURTELIZER_PID 0xBDC8 /* JTAG/RS-232 adapter by egnite GmBH */
952
953/*
954 * GN Otometrics (http://www.otometrics.com)
955 * Submitted by Ville Sundberg.
956 */
957#define GN_OTOMETRICS_VID 0x0c33 /* Vendor ID */
958#define AURICAL_USB_PID 0x0010 /* Aurical USB Audiometer */
959
960/*
961 * Bayer Ascensia Contour blood glucose meter USB-converter cable.
962 * http://winglucofacts.com/cables/
963 */
964#define BAYER_VID 0x1A79
965#define BAYER_CONTOUR_CABLE_PID 0x6001
966
967/*
968 * Marvell OpenRD Base, Client
969 * http://www.open-rd.org
970 * OpenRD Base, Client use VID 0x0403
971 */
972#define MARVELL_OPENRD_PID 0x9e90
973
974/*
975 * Hameg HO820 and HO870 interface (using VID 0x0403)
976 */
977#define HAMEG_HO820_PID 0xed74
978#define HAMEG_HO870_PID 0xed71
979 43
980/* 44/*
981 * BmRequestType: 1100 0000b 45 * BmRequestType: 1100 0000b
@@ -1206,7 +270,7 @@ typedef enum {
1206 * BmRequestType: 0100 0000b 270 * BmRequestType: 0100 0000b
1207 * bRequest: FTDI_SIO_SET_FLOW_CTRL 271 * bRequest: FTDI_SIO_SET_FLOW_CTRL
1208 * wValue: Xoff/Xon 272 * wValue: Xoff/Xon
1209 * wIndex: Protocol/Port - hIndex is protocl / lIndex is port 273 * wIndex: Protocol/Port - hIndex is protocol / lIndex is port
1210 * wLength: 0 274 * wLength: 0
1211 * Data: None 275 * Data: None
1212 * 276 *
@@ -1490,4 +554,3 @@ typedef enum {
1490 * B2..7 Length of message - (not including Byte 0) 554 * B2..7 Length of message - (not including Byte 0)
1491 * 555 *
1492 */ 556 */
1493
diff --git a/drivers/usb/serial/ftdi_sio_ids.h b/drivers/usb/serial/ftdi_sio_ids.h
new file mode 100644
index 000000000000..75482cbc3998
--- /dev/null
+++ b/drivers/usb/serial/ftdi_sio_ids.h
@@ -0,0 +1,1026 @@
1/*
2 * vendor/product IDs (VID/PID) of devices using FTDI USB serial converters.
3 * Please keep numerically sorted within individual areas, thanks!
4 *
5 * Philipp Gühring - pg@futureware.at - added the Device ID of the USB relais
6 * from Rudolf Gugler
7 *
8 */
9
10
11/**********************************/
12/***** devices using FTDI VID *****/
13/**********************************/
14
15
16#define FTDI_VID 0x0403 /* Vendor Id */
17
18
19/*** "original" FTDI device PIDs ***/
20
21#define FTDI_8U232AM_PID 0x6001 /* Similar device to SIO above */
22#define FTDI_8U232AM_ALT_PID 0x6006 /* FTDI's alternate PID for above */
23#define FTDI_8U2232C_PID 0x6010 /* Dual channel device */
24#define FTDI_4232H_PID 0x6011 /* Quad channel hi-speed device */
25#define FTDI_SIO_PID 0x8372 /* Product Id SIO application of 8U100AX */
26#define FTDI_232RL_PID 0xFBFA /* Product ID for FT232RL */
27
28
29/*** third-party PIDs (using FTDI_VID) ***/
30
31/*
32 * Marvell OpenRD Base, Client
33 * http://www.open-rd.org
34 * OpenRD Base, Client use VID 0x0403
35 */
36#define MARVELL_OPENRD_PID 0x9e90
37
38/* www.candapter.com Ewert Energy Systems CANdapter device */
39#define FTDI_CANDAPTER_PID 0x9F80 /* Product Id */
40
41#define FTDI_NXTCAM_PID 0xABB8 /* NXTCam for Mindstorms NXT */
42
43/* OOCDlink by Joern Kaipf <joernk@web.de>
44 * (http://www.joernonline.de/dw/doku.php?id=start&idx=projects:oocdlink) */
45#define FTDI_OOCDLINK_PID 0xbaf8 /* Amontec JTAGkey */
46
47/* Luminary Micro Stellaris Boards, VID = FTDI_VID */
48/* FTDI 2332C Dual channel device, side A=245 FIFO (JTAG), Side B=RS232 UART */
49#define LMI_LM3S_DEVEL_BOARD_PID 0xbcd8
50#define LMI_LM3S_EVAL_BOARD_PID 0xbcd9
51
52#define FTDI_TURTELIZER_PID 0xBDC8 /* JTAG/RS-232 adapter by egnite GmbH */
53
54/* OpenDCC (www.opendcc.de) product id */
55#define FTDI_OPENDCC_PID 0xBFD8
56#define FTDI_OPENDCC_SNIFFER_PID 0xBFD9
57#define FTDI_OPENDCC_THROTTLE_PID 0xBFDA
58#define FTDI_OPENDCC_GATEWAY_PID 0xBFDB
59
60/*
61 * RR-CirKits LocoBuffer USB (http://www.rr-cirkits.com)
62 */
63#define FTDI_RRCIRKITS_LOCOBUFFER_PID 0xc7d0 /* LocoBuffer USB */
64
65/* DMX4ALL DMX Interfaces */
66#define FTDI_DMX4ALL 0xC850
67
68/*
69 * ASK.fr devices
70 */
71#define FTDI_ASK_RDR400_PID 0xC991 /* ASK RDR 400 series card reader */
72
73/* www.starting-point-systems.com µChameleon device */
74#define FTDI_MICRO_CHAMELEON_PID 0xCAA0 /* Product Id */
75
76/*
77 * Tactrix OpenPort (ECU) devices.
78 * OpenPort 1.3M submitted by Donour Sizemore.
79 * OpenPort 1.3S and 1.3U submitted by Ian Abbott.
80 */
81#define FTDI_TACTRIX_OPENPORT_13M_PID 0xCC48 /* OpenPort 1.3 Mitsubishi */
82#define FTDI_TACTRIX_OPENPORT_13S_PID 0xCC49 /* OpenPort 1.3 Subaru */
83#define FTDI_TACTRIX_OPENPORT_13U_PID 0xCC4A /* OpenPort 1.3 Universal */
84
85/* SCS HF Radio Modems PID's (http://www.scs-ptc.com) */
86/* the VID is the standard ftdi vid (FTDI_VID) */
87#define FTDI_SCS_DEVICE_0_PID 0xD010 /* SCS PTC-IIusb */
88#define FTDI_SCS_DEVICE_1_PID 0xD011 /* SCS Tracker / DSP TNC */
89#define FTDI_SCS_DEVICE_2_PID 0xD012
90#define FTDI_SCS_DEVICE_3_PID 0xD013
91#define FTDI_SCS_DEVICE_4_PID 0xD014
92#define FTDI_SCS_DEVICE_5_PID 0xD015
93#define FTDI_SCS_DEVICE_6_PID 0xD016
94#define FTDI_SCS_DEVICE_7_PID 0xD017
95
96/* iPlus device */
97#define FTDI_IPLUS_PID 0xD070 /* Product Id */
98#define FTDI_IPLUS2_PID 0xD071 /* Product Id */
99
100/*
101 * Gamma Scout (http://gamma-scout.com/). Submitted by rsc@runtux.com.
102 */
103#define FTDI_GAMMA_SCOUT_PID 0xD678 /* Gamma Scout online */
104
105/* Propox devices */
106#define FTDI_PROPOX_JTAGCABLEII_PID 0xD738
107
108/*
109 * Xsens Technologies BV products (http://www.xsens.com).
110 */
111#define XSENS_CONVERTER_0_PID 0xD388
112#define XSENS_CONVERTER_1_PID 0xD389
113#define XSENS_CONVERTER_2_PID 0xD38A
114#define XSENS_CONVERTER_3_PID 0xD38B
115#define XSENS_CONVERTER_4_PID 0xD38C
116#define XSENS_CONVERTER_5_PID 0xD38D
117#define XSENS_CONVERTER_6_PID 0xD38E
118#define XSENS_CONVERTER_7_PID 0xD38F
119
120/*
121 * NDI (www.ndigital.com) product ids
122 */
123#define FTDI_NDI_HUC_PID 0xDA70 /* NDI Host USB Converter */
124#define FTDI_NDI_SPECTRA_SCU_PID 0xDA71 /* NDI Spectra SCU */
125#define FTDI_NDI_FUTURE_2_PID 0xDA72 /* NDI future device #2 */
126#define FTDI_NDI_FUTURE_3_PID 0xDA73 /* NDI future device #3 */
127#define FTDI_NDI_AURORA_SCU_PID 0xDA74 /* NDI Aurora SCU */
128
129/*
130 * Westrex International devices submitted by Cory Lee
131 */
132#define FTDI_WESTREX_MODEL_777_PID 0xDC00 /* Model 777 */
133#define FTDI_WESTREX_MODEL_8900F_PID 0xDC01 /* Model 8900F */
134
135/*
136 * ACG Identification Technologies GmbH products (http://www.acg.de/).
137 * Submitted by anton -at- goto10 -dot- org.
138 */
139#define FTDI_ACG_HFDUAL_PID 0xDD20 /* HF Dual ISO Reader (RFID) */
140
141/*
142 * Definitions for Artemis astronomical USB based cameras
143 * Check it at http://www.artemisccd.co.uk/
144 */
145#define FTDI_ARTEMIS_PID 0xDF28 /* All Artemis Cameras */
146
147/*
148 * Definitions for ATIK Instruments astronomical USB based cameras
149 * Check it at http://www.atik-instruments.com/
150 */
151#define FTDI_ATIK_ATK16_PID 0xDF30 /* ATIK ATK-16 Grayscale Camera */
152#define FTDI_ATIK_ATK16C_PID 0xDF32 /* ATIK ATK-16C Colour Camera */
153#define FTDI_ATIK_ATK16HR_PID 0xDF31 /* ATIK ATK-16HR Grayscale Camera */
154#define FTDI_ATIK_ATK16HRC_PID 0xDF33 /* ATIK ATK-16HRC Colour Camera */
155#define FTDI_ATIK_ATK16IC_PID 0xDF35 /* ATIK ATK-16IC Grayscale Camera */
156
157/*
158 * Yost Engineering, Inc. products (www.yostengineering.com).
159 * PID 0xE050 submitted by Aaron Prose.
160 */
161#define FTDI_YEI_SERVOCENTER31_PID 0xE050 /* YEI ServoCenter3.1 USB */
162
163/*
164 * ELV USB devices submitted by Christian Abt of ELV (www.elv.de).
165 * All of these devices use FTDI's vendor ID (0x0403).
166 * Further IDs taken from ELV Windows .inf file.
167 *
168 * The previously included PID for the UO 100 module was incorrect.
169 * In fact, that PID was for ELV's UR 100 USB-RS232 converter (0xFB58).
170 *
171 * Armin Laeuger originally sent the PID for the UM 100 module.
172 */
173#define FTDI_ELV_USR_PID 0xE000 /* ELV Universal-Sound-Recorder */
174#define FTDI_ELV_MSM1_PID 0xE001 /* ELV Mini-Sound-Modul */
175#define FTDI_ELV_KL100_PID 0xE002 /* ELV Kfz-Leistungsmesser KL 100 */
176#define FTDI_ELV_WS550_PID 0xE004 /* WS 550 */
177#define FTDI_ELV_EC3000_PID 0xE006 /* ENERGY CONTROL 3000 USB */
178#define FTDI_ELV_WS888_PID 0xE008 /* WS 888 */
179#define FTDI_ELV_TWS550_PID 0xE009 /* Technoline WS 550 */
180#define FTDI_ELV_FEM_PID 0xE00A /* Funk Energie Monitor */
181#define FTDI_ELV_FHZ1300PC_PID 0xE0E8 /* FHZ 1300 PC */
182#define FTDI_ELV_WS500_PID 0xE0E9 /* PC-Wetterstation (WS 500) */
183#define FTDI_ELV_HS485_PID 0xE0EA /* USB to RS-485 adapter */
184#define FTDI_ELV_UMS100_PID 0xE0EB /* ELV USB Master-Slave Schaltsteckdose UMS 100 */
185#define FTDI_ELV_TFD128_PID 0xE0EC /* ELV Temperatur-Feuchte-Datenlogger TFD 128 */
186#define FTDI_ELV_FM3RX_PID 0xE0ED /* ELV Messwertuebertragung FM3 RX */
187#define FTDI_ELV_WS777_PID 0xE0EE /* Conrad WS 777 */
188#define FTDI_ELV_EM1010PC_PID 0xE0EF /* Energy monitor EM 1010 PC */
189#define FTDI_ELV_CSI8_PID 0xE0F0 /* Computer-Schalt-Interface (CSI 8) */
190#define FTDI_ELV_EM1000DL_PID 0xE0F1 /* PC-Datenlogger fuer Energiemonitor (EM 1000 DL) */
191#define FTDI_ELV_PCK100_PID 0xE0F2 /* PC-Kabeltester (PCK 100) */
192#define FTDI_ELV_RFP500_PID 0xE0F3 /* HF-Leistungsmesser (RFP 500) */
193#define FTDI_ELV_FS20SIG_PID 0xE0F4 /* Signalgeber (FS 20 SIG) */
194#define FTDI_ELV_UTP8_PID 0xE0F5 /* ELV UTP 8 */
195#define FTDI_ELV_WS300PC_PID 0xE0F6 /* PC-Wetterstation (WS 300 PC) */
196#define FTDI_ELV_WS444PC_PID 0xE0F7 /* Conrad WS 444 PC */
197#define FTDI_PHI_FISCO_PID 0xE40B /* PHI Fisco USB to Serial cable */
198#define FTDI_ELV_UAD8_PID 0xF068 /* USB-AD-Wandler (UAD 8) */
199#define FTDI_ELV_UDA7_PID 0xF069 /* USB-DA-Wandler (UDA 7) */
200#define FTDI_ELV_USI2_PID 0xF06A /* USB-Schrittmotoren-Interface (USI 2) */
201#define FTDI_ELV_T1100_PID 0xF06B /* Thermometer (T 1100) */
202#define FTDI_ELV_PCD200_PID 0xF06C /* PC-Datenlogger (PCD 200) */
203#define FTDI_ELV_ULA200_PID 0xF06D /* USB-LCD-Ansteuerung (ULA 200) */
204#define FTDI_ELV_ALC8500_PID 0xF06E /* ALC 8500 Expert */
205#define FTDI_ELV_FHZ1000PC_PID 0xF06F /* FHZ 1000 PC */
206#define FTDI_ELV_UR100_PID 0xFB58 /* USB-RS232-Umsetzer (UR 100) */
207#define FTDI_ELV_UM100_PID 0xFB5A /* USB-Modul UM 100 */
208#define FTDI_ELV_UO100_PID 0xFB5B /* USB-Modul UO 100 */
209/* Additional ELV PIDs that default to using the FTDI D2XX drivers on
210 * MS Windows, rather than the FTDI Virtual Com Port drivers.
211 * Maybe these will be easier to use with the libftdi/libusb user-space
212 * drivers, or possibly the Comedi drivers in some cases. */
213#define FTDI_ELV_CLI7000_PID 0xFB59 /* Computer-Light-Interface (CLI 7000) */
214#define FTDI_ELV_PPS7330_PID 0xFB5C /* Processor-Power-Supply (PPS 7330) */
215#define FTDI_ELV_TFM100_PID 0xFB5D /* Temperatur-Feuchte-Messgeraet (TFM 100) */
216#define FTDI_ELV_UDF77_PID 0xFB5E /* USB DCF Funkuhr (UDF 77) */
217#define FTDI_ELV_UIO88_PID 0xFB5F /* USB-I/O Interface (UIO 88) */
218
219/*
220 * EVER Eco Pro UPS (http://www.ever.com.pl/)
221 */
222
223#define EVER_ECO_PRO_CDS 0xe520 /* RS-232 converter */
224
225/*
226 * Active Robots product ids.
227 */
228#define FTDI_ACTIVE_ROBOTS_PID 0xE548 /* USB comms board */
229
230/* Pyramid Computer GmbH */
231#define FTDI_PYRAMID_PID 0xE6C8 /* Pyramid Appliance Display */
232
233/* www.elsterelectricity.com Elster Unicom III Optical Probe */
234#define FTDI_ELSTER_UNICOM_PID 0xE700 /* Product Id */
235
236/*
237 * Gude Analog- und Digitalsysteme GmbH
238 */
239#define FTDI_GUDEADS_E808_PID 0xE808
240#define FTDI_GUDEADS_E809_PID 0xE809
241#define FTDI_GUDEADS_E80A_PID 0xE80A
242#define FTDI_GUDEADS_E80B_PID 0xE80B
243#define FTDI_GUDEADS_E80C_PID 0xE80C
244#define FTDI_GUDEADS_E80D_PID 0xE80D
245#define FTDI_GUDEADS_E80E_PID 0xE80E
246#define FTDI_GUDEADS_E80F_PID 0xE80F
247#define FTDI_GUDEADS_E888_PID 0xE888 /* Expert ISDN Control USB */
248#define FTDI_GUDEADS_E889_PID 0xE889 /* USB RS-232 OptoBridge */
249#define FTDI_GUDEADS_E88A_PID 0xE88A
250#define FTDI_GUDEADS_E88B_PID 0xE88B
251#define FTDI_GUDEADS_E88C_PID 0xE88C
252#define FTDI_GUDEADS_E88D_PID 0xE88D
253#define FTDI_GUDEADS_E88E_PID 0xE88E
254#define FTDI_GUDEADS_E88F_PID 0xE88F
255
256/*
257 * Eclo (http://www.eclo.pt/) product IDs.
258 * PID 0xEA90 submitted by Martin Grill.
259 */
260#define FTDI_ECLO_COM_1WIRE_PID 0xEA90 /* COM to 1-Wire USB adaptor */
261
262/* TNC-X USB-to-packet-radio adapter, versions prior to 3.0 (DLP module) */
263#define FTDI_TNC_X_PID 0xEBE0
264
265/*
266 * Teratronik product ids.
267 * Submitted by O. Wölfelschneider.
268 */
269#define FTDI_TERATRONIK_VCP_PID 0xEC88 /* Teratronik device (preferring VCP driver on windows) */
270#define FTDI_TERATRONIK_D2XX_PID 0xEC89 /* Teratronik device (preferring D2XX driver on windows) */
271
272/* Rig Expert Ukraine devices */
273#define FTDI_REU_TINY_PID 0xED22 /* RigExpert Tiny */
274
275/*
276 * Hameg HO820 and HO870 interface (using VID 0x0403)
277 */
278#define HAMEG_HO820_PID 0xed74
279#define HAMEG_HO870_PID 0xed71
280
281/*
282 * MaxStream devices www.maxstream.net
283 */
284#define FTDI_MAXSTREAM_PID 0xEE18 /* Xbee PKG-U Module */
285
286/*
287 * microHAM product IDs (http://www.microham.com).
288 * Submitted by Justin Burket (KL1RL) <zorton@jtan.com>
289 * and Mike Studer (K6EEP) <k6eep@hamsoftware.org>.
290 * Ian Abbott <abbotti@mev.co.uk> added a few more from the driver INF file.
291 */
292#define FTDI_MHAM_KW_PID 0xEEE8 /* USB-KW interface */
293#define FTDI_MHAM_YS_PID 0xEEE9 /* USB-YS interface */
294#define FTDI_MHAM_Y6_PID 0xEEEA /* USB-Y6 interface */
295#define FTDI_MHAM_Y8_PID 0xEEEB /* USB-Y8 interface */
296#define FTDI_MHAM_IC_PID 0xEEEC /* USB-IC interface */
297#define FTDI_MHAM_DB9_PID 0xEEED /* USB-DB9 interface */
298#define FTDI_MHAM_RS232_PID 0xEEEE /* USB-RS232 interface */
299#define FTDI_MHAM_Y9_PID 0xEEEF /* USB-Y9 interface */
300
301/* Domintell products http://www.domintell.com */
302#define FTDI_DOMINTELL_DGQG_PID 0xEF50 /* Master */
303#define FTDI_DOMINTELL_DUSB_PID 0xEF51 /* DUSB01 module */
304
305/*
306 * The following are the values for the Perle Systems
307 * UltraPort USB serial converters
308 */
309#define FTDI_PERLE_ULTRAPORT_PID 0xF0C0 /* Perle UltraPort Product Id */
310
311/* Sprog II (Andrew Crosland's SprogII DCC interface) */
312#define FTDI_SPROG_II 0xF0C8
313
314/* an infrared receiver for user access control with IR tags */
315#define FTDI_PIEGROUP_PID 0xF208 /* Product Id */
316
317/* ACT Solutions HomePro ZWave interface
318 (http://www.act-solutions.com/HomePro.htm) */
319#define FTDI_ACTZWAVE_PID 0xF2D0
320
321/*
322 * 4N-GALAXY.DE PIDs for CAN-USB, USB-RS232, USB-RS422, USB-RS485,
323 * USB-TTY aktiv, USB-TTY passiv. Some PIDs are used by several devices
324 * and I'm not entirely sure which are used by which.
325 */
326#define FTDI_4N_GALAXY_DE_1_PID 0xF3C0
327#define FTDI_4N_GALAXY_DE_2_PID 0xF3C1
328
329/*
330 * Linx Technologies product ids
331 */
332#define LINX_SDMUSBQSS_PID 0xF448 /* Linx SDM-USB-QS-S */
333#define LINX_MASTERDEVEL2_PID 0xF449 /* Linx Master Development 2.0 */
334#define LINX_FUTURE_0_PID 0xF44A /* Linx future device */
335#define LINX_FUTURE_1_PID 0xF44B /* Linx future device */
336#define LINX_FUTURE_2_PID 0xF44C /* Linx future device */
337
338/*
339 * Oceanic product ids
340 */
341#define FTDI_OCEANIC_PID 0xF460 /* Oceanic dive instrument */
342
343/*
344 * SUUNTO product ids
345 */
346#define FTDI_SUUNTO_SPORTS_PID 0xF680 /* Suunto Sports instrument */
347
348/* USB-UIRT - An infrared receiver and transmitter using the 8U232AM chip */
349/* http://home.earthlink.net/~jrhees/USBUIRT/index.htm */
350#define FTDI_USB_UIRT_PID 0xF850 /* Product Id */
351
352/* CCS Inc. ICDU/ICDU40 product ID -
353 * the FT232BM is used in an in-circuit-debugger unit for PIC16's/PIC18's */
354#define FTDI_CCSICDU20_0_PID 0xF9D0
355#define FTDI_CCSICDU40_1_PID 0xF9D1
356#define FTDI_CCSMACHX_2_PID 0xF9D2
357#define FTDI_CCSLOAD_N_GO_3_PID 0xF9D3
358#define FTDI_CCSICDU64_4_PID 0xF9D4
359#define FTDI_CCSPRIME8_5_PID 0xF9D5
360
361/*
362 * The following are the values for the Matrix Orbital LCD displays,
363 * which are the FT232BM ( similar to the 8U232AM )
364 */
365#define FTDI_MTXORB_0_PID 0xFA00 /* Matrix Orbital Product Id */
366#define FTDI_MTXORB_1_PID 0xFA01 /* Matrix Orbital Product Id */
367#define FTDI_MTXORB_2_PID 0xFA02 /* Matrix Orbital Product Id */
368#define FTDI_MTXORB_3_PID 0xFA03 /* Matrix Orbital Product Id */
369#define FTDI_MTXORB_4_PID 0xFA04 /* Matrix Orbital Product Id */
370#define FTDI_MTXORB_5_PID 0xFA05 /* Matrix Orbital Product Id */
371#define FTDI_MTXORB_6_PID 0xFA06 /* Matrix Orbital Product Id */
372
373/*
374 * Home Electronics (www.home-electro.com) USB gadgets
375 */
376#define FTDI_HE_TIRA1_PID 0xFA78 /* Tira-1 IR transceiver */
377
378/* Inside Accesso contactless reader (http://www.insidefr.com) */
379#define INSIDE_ACCESSO 0xFAD0
380
381/*
382 * ThorLabs USB motor drivers
383 */
384#define FTDI_THORLABS_PID 0xfaf0 /* ThorLabs USB motor drivers */
385
386/*
387 * Protego product ids
388 */
389#define PROTEGO_SPECIAL_1 0xFC70 /* special/unknown device */
390#define PROTEGO_R2X0 0xFC71 /* R200-USB TRNG unit (R210, R220, and R230) */
391#define PROTEGO_SPECIAL_3 0xFC72 /* special/unknown device */
392#define PROTEGO_SPECIAL_4 0xFC73 /* special/unknown device */
393
394/*
395 * DSS-20 Sync Station for Sony Ericsson P800
396 */
397#define FTDI_DSS20_PID 0xFC82
398
399/* www.irtrans.de device */
400#define FTDI_IRTRANS_PID 0xFC60 /* Product Id */
401
402/*
403 * RM Michaelides CANview USB (http://www.rmcan.com) (FTDI_VID)
404 * CAN fieldbus interface adapter, added by port GmbH www.port.de)
405 * Ian Abbott changed the macro names for consistency.
406 */
407#define FTDI_RM_CANVIEW_PID 0xfd60 /* Product Id */
408/* www.thoughttechnology.com/ TT-USB provide with procomp use ftdi_sio */
409#define FTDI_TTUSB_PID 0xFF20 /* Product Id */
410
411#define FTDI_USBX_707_PID 0xF857 /* ADSTech IR Blaster USBX-707 (FTDI_VID) */
412
413#define FTDI_RELAIS_PID 0xFA10 /* Relais device from Rudolf Gugler */
414
415/*
416 * PCDJ use ftdi based dj-controllers. The following PID is
417 * for their DAC-2 device http://www.pcdjhardware.com/DAC2.asp
418 * (the VID is the standard ftdi vid (FTDI_VID), PID sent by Wouter Paesen)
419 */
420#define FTDI_PCDJ_DAC2_PID 0xFA88
421
422#define FTDI_R2000KU_TRUE_RNG 0xFB80 /* R2000KU TRUE RNG (FTDI_VID) */
423
424/*
425 * DIEBOLD BCS SE923 (FTDI_VID)
426 */
427#define DIEBOLD_BCS_SE923_PID 0xfb99
428
429/* www.crystalfontz.com devices
430 * - thanx for providing free devices for evaluation !
431 * they use the ftdi chipset for the USB interface
432 * and the vendor id is the same
433 */
434#define FTDI_XF_632_PID 0xFC08 /* 632: 16x2 Character Display */
435#define FTDI_XF_634_PID 0xFC09 /* 634: 20x4 Character Display */
436#define FTDI_XF_547_PID 0xFC0A /* 547: Two line Display */
437#define FTDI_XF_633_PID 0xFC0B /* 633: 16x2 Character Display with Keys */
438#define FTDI_XF_631_PID 0xFC0C /* 631: 20x2 Character Display */
439#define FTDI_XF_635_PID 0xFC0D /* 635: 20x4 Character Display */
440#define FTDI_XF_640_PID 0xFC0E /* 640: Two line Display */
441#define FTDI_XF_642_PID 0xFC0F /* 642: Two line Display */
442
443/*
444 * Video Networks Limited / Homechoice in the UK use an ftdi-based device
445 * for their 1Mb broadband internet service. The following PID is exhibited
446 * by the usb device supplied (the VID is the standard ftdi vid (FTDI_VID)
447 */
448#define FTDI_VNHCPCUSB_D_PID 0xfe38 /* Product Id */
449
450/* AlphaMicro Components AMC-232USB01 device (FTDI_VID) */
451#define FTDI_AMC232_PID 0xFF00 /* Product Id */
452
453/*
454 * IBS elektronik product ids (FTDI_VID)
455 * Submitted by Thomas Schleusener
456 */
457#define FTDI_IBS_US485_PID 0xff38 /* IBS US485 (USB<-->RS422/485 interface) */
458#define FTDI_IBS_PICPRO_PID 0xff39 /* IBS PIC-Programmer */
459#define FTDI_IBS_PCMCIA_PID 0xff3a /* IBS Card reader for PCMCIA SRAM-cards */
460#define FTDI_IBS_PK1_PID 0xff3b /* IBS PK1 - Particel counter */
461#define FTDI_IBS_RS232MON_PID 0xff3c /* IBS RS232 - Monitor */
462#define FTDI_IBS_APP70_PID 0xff3d /* APP 70 (dust monitoring system) */
463#define FTDI_IBS_PEDO_PID 0xff3e /* IBS PEDO-Modem (RF modem 868.35 MHz) */
464#define FTDI_IBS_PROD_PID 0xff3f /* future device */
465/* www.canusb.com Lawicel CANUSB device (FTDI_VID) */
466#define FTDI_CANUSB_PID 0xFFA8 /* Product Id */
467
468
469
470/********************************/
471/** third-party VID/PID combos **/
472/********************************/
473
474
475
476/*
477 * Atmel STK541
478 */
479#define ATMEL_VID 0x03eb /* Vendor ID */
480#define STK541_PID 0x2109 /* Zigbee Controller */
481
482/*
483 * Blackfin gnICE JTAG
484 * http://docs.blackfin.uclinux.org/doku.php?id=hw:jtag:gnice
485 */
486#define ADI_VID 0x0456
487#define ADI_GNICE_PID 0xF000
488#define ADI_GNICEPLUS_PID 0xF001
489
490/*
491 * RATOC REX-USB60F
492 */
493#define RATOC_VENDOR_ID 0x0584
494#define RATOC_PRODUCT_ID_USB60F 0xb020
495
496/*
497 * Contec products (http://www.contec.com)
498 * Submitted by Daniel Sangorrin
499 */
500#define CONTEC_VID 0x06CE /* Vendor ID */
501#define CONTEC_COM1USBH_PID 0x8311 /* COM-1(USB)H */
502
503/*
504 * Contec products (http://www.contec.com)
505 * Submitted by Daniel Sangorrin
506 */
507#define CONTEC_VID 0x06CE /* Vendor ID */
508#define CONTEC_COM1USBH_PID 0x8311 /* COM-1(USB)H */
509
510/*
511 * Definitions for B&B Electronics products.
512 */
513#define BANDB_VID 0x0856 /* B&B Electronics Vendor ID */
514#define BANDB_USOTL4_PID 0xAC01 /* USOTL4 Isolated RS-485 Converter */
515#define BANDB_USTL4_PID 0xAC02 /* USTL4 RS-485 Converter */
516#define BANDB_USO9ML2_PID 0xAC03 /* USO9ML2 Isolated RS-232 Converter */
517#define BANDB_USOPTL4_PID 0xAC11
518#define BANDB_USPTL4_PID 0xAC12
519#define BANDB_USO9ML2DR_2_PID 0xAC16
520#define BANDB_USO9ML2DR_PID 0xAC17
521#define BANDB_USOPTL4DR2_PID 0xAC18 /* USOPTL4R-2 2-port Isolated RS-232 Converter */
522#define BANDB_USOPTL4DR_PID 0xAC19
523#define BANDB_485USB9F_2W_PID 0xAC25
524#define BANDB_485USB9F_4W_PID 0xAC26
525#define BANDB_232USB9M_PID 0xAC27
526#define BANDB_485USBTB_2W_PID 0xAC33
527#define BANDB_485USBTB_4W_PID 0xAC34
528#define BANDB_TTL5USB9M_PID 0xAC49
529#define BANDB_TTL3USB9M_PID 0xAC50
530#define BANDB_ZZ_PROG1_USB_PID 0xBA02
531
532/*
533 * Intrepid Control Systems (http://www.intrepidcs.com/) ValueCAN and NeoVI
534 */
535#define INTREPID_VID 0x093C
536#define INTREPID_VALUECAN_PID 0x0601
537#define INTREPID_NEOVI_PID 0x0701
538
539/*
540 * Definitions for ID TECH (www.idt-net.com) devices
541 */
542#define IDTECH_VID 0x0ACD /* ID TECH Vendor ID */
543#define IDTECH_IDT1221U_PID 0x0300 /* IDT1221U USB to RS-232 adapter */
544
545/*
546 * Definitions for Omnidirectional Control Technology, Inc. devices
547 */
548#define OCT_VID 0x0B39 /* OCT vendor ID */
549/* Note: OCT US101 is also rebadged as Dick Smith Electronics (NZ) XH6381 */
550/* Also rebadged as Dick Smith Electronics (Aus) XH6451 */
551/* Also rebadged as SIIG Inc. model US2308 hardware version 1 */
552#define OCT_US101_PID 0x0421 /* OCT US101 USB to RS-232 */
553
554/*
555 * Icom ID-1 digital transceiver
556 */
557
558#define ICOM_ID1_VID 0x0C26
559#define ICOM_ID1_PID 0x0004
560
561/*
562 * GN Otometrics (http://www.otometrics.com)
563 * Submitted by Ville Sundberg.
564 */
565#define GN_OTOMETRICS_VID 0x0c33 /* Vendor ID */
566#define AURICAL_USB_PID 0x0010 /* Aurical USB Audiometer */
567
568/*
569 * The following are the values for the Sealevel SeaLINK+ adapters.
570 * (Original list sent by Tuan Hoang. Ian Abbott renamed the macros and
571 * removed some PIDs that don't seem to match any existing products.)
572 */
573#define SEALEVEL_VID 0x0c52 /* Sealevel Vendor ID */
574#define SEALEVEL_2101_PID 0x2101 /* SeaLINK+232 (2101/2105) */
575#define SEALEVEL_2102_PID 0x2102 /* SeaLINK+485 (2102) */
576#define SEALEVEL_2103_PID 0x2103 /* SeaLINK+232I (2103) */
577#define SEALEVEL_2104_PID 0x2104 /* SeaLINK+485I (2104) */
578#define SEALEVEL_2106_PID 0x9020 /* SeaLINK+422 (2106) */
579#define SEALEVEL_2201_1_PID 0x2211 /* SeaPORT+2/232 (2201) Port 1 */
580#define SEALEVEL_2201_2_PID 0x2221 /* SeaPORT+2/232 (2201) Port 2 */
581#define SEALEVEL_2202_1_PID 0x2212 /* SeaPORT+2/485 (2202) Port 1 */
582#define SEALEVEL_2202_2_PID 0x2222 /* SeaPORT+2/485 (2202) Port 2 */
583#define SEALEVEL_2203_1_PID 0x2213 /* SeaPORT+2 (2203) Port 1 */
584#define SEALEVEL_2203_2_PID 0x2223 /* SeaPORT+2 (2203) Port 2 */
585#define SEALEVEL_2401_1_PID 0x2411 /* SeaPORT+4/232 (2401) Port 1 */
586#define SEALEVEL_2401_2_PID 0x2421 /* SeaPORT+4/232 (2401) Port 2 */
587#define SEALEVEL_2401_3_PID 0x2431 /* SeaPORT+4/232 (2401) Port 3 */
588#define SEALEVEL_2401_4_PID 0x2441 /* SeaPORT+4/232 (2401) Port 4 */
589#define SEALEVEL_2402_1_PID 0x2412 /* SeaPORT+4/485 (2402) Port 1 */
590#define SEALEVEL_2402_2_PID 0x2422 /* SeaPORT+4/485 (2402) Port 2 */
591#define SEALEVEL_2402_3_PID 0x2432 /* SeaPORT+4/485 (2402) Port 3 */
592#define SEALEVEL_2402_4_PID 0x2442 /* SeaPORT+4/485 (2402) Port 4 */
593#define SEALEVEL_2403_1_PID 0x2413 /* SeaPORT+4 (2403) Port 1 */
594#define SEALEVEL_2403_2_PID 0x2423 /* SeaPORT+4 (2403) Port 2 */
595#define SEALEVEL_2403_3_PID 0x2433 /* SeaPORT+4 (2403) Port 3 */
596#define SEALEVEL_2403_4_PID 0x2443 /* SeaPORT+4 (2403) Port 4 */
597#define SEALEVEL_2801_1_PID 0X2811 /* SeaLINK+8/232 (2801) Port 1 */
598#define SEALEVEL_2801_2_PID 0X2821 /* SeaLINK+8/232 (2801) Port 2 */
599#define SEALEVEL_2801_3_PID 0X2831 /* SeaLINK+8/232 (2801) Port 3 */
600#define SEALEVEL_2801_4_PID 0X2841 /* SeaLINK+8/232 (2801) Port 4 */
601#define SEALEVEL_2801_5_PID 0X2851 /* SeaLINK+8/232 (2801) Port 5 */
602#define SEALEVEL_2801_6_PID 0X2861 /* SeaLINK+8/232 (2801) Port 6 */
603#define SEALEVEL_2801_7_PID 0X2871 /* SeaLINK+8/232 (2801) Port 7 */
604#define SEALEVEL_2801_8_PID 0X2881 /* SeaLINK+8/232 (2801) Port 8 */
605#define SEALEVEL_2802_1_PID 0X2812 /* SeaLINK+8/485 (2802) Port 1 */
606#define SEALEVEL_2802_2_PID 0X2822 /* SeaLINK+8/485 (2802) Port 2 */
607#define SEALEVEL_2802_3_PID 0X2832 /* SeaLINK+8/485 (2802) Port 3 */
608#define SEALEVEL_2802_4_PID 0X2842 /* SeaLINK+8/485 (2802) Port 4 */
609#define SEALEVEL_2802_5_PID 0X2852 /* SeaLINK+8/485 (2802) Port 5 */
610#define SEALEVEL_2802_6_PID 0X2862 /* SeaLINK+8/485 (2802) Port 6 */
611#define SEALEVEL_2802_7_PID 0X2872 /* SeaLINK+8/485 (2802) Port 7 */
612#define SEALEVEL_2802_8_PID 0X2882 /* SeaLINK+8/485 (2802) Port 8 */
613#define SEALEVEL_2803_1_PID 0X2813 /* SeaLINK+8 (2803) Port 1 */
614#define SEALEVEL_2803_2_PID 0X2823 /* SeaLINK+8 (2803) Port 2 */
615#define SEALEVEL_2803_3_PID 0X2833 /* SeaLINK+8 (2803) Port 3 */
616#define SEALEVEL_2803_4_PID 0X2843 /* SeaLINK+8 (2803) Port 4 */
617#define SEALEVEL_2803_5_PID 0X2853 /* SeaLINK+8 (2803) Port 5 */
618#define SEALEVEL_2803_6_PID 0X2863 /* SeaLINK+8 (2803) Port 6 */
619#define SEALEVEL_2803_7_PID 0X2873 /* SeaLINK+8 (2803) Port 7 */
620#define SEALEVEL_2803_8_PID 0X2883 /* SeaLINK+8 (2803) Port 8 */
621
622/*
623 * JETI SPECTROMETER SPECBOS 1201
624 * http://www.jeti.com/products/sys/scb/scb1201.php
625 */
626#define JETI_VID 0x0c6c
627#define JETI_SPC1201_PID 0x04b2
628
629/*
630 * FTDI USB UART chips used in construction projects from the
631 * Elektor Electronics magazine (http://elektor-electronics.co.uk)
632 */
633#define ELEKTOR_VID 0x0C7D
634#define ELEKTOR_FT323R_PID 0x0005 /* RFID-Reader, issue 09-2006 */
635
636/*
637 * Posiflex inc retail equipment (http://www.posiflex.com.tw)
638 */
639#define POSIFLEX_VID 0x0d3a /* Vendor ID */
640#define POSIFLEX_PP7000_PID 0x0300 /* PP-7000II thermal printer */
641
642/*
643 * The following are the values for two KOBIL chipcard terminals.
644 */
645#define KOBIL_VID 0x0d46 /* KOBIL Vendor ID */
646#define KOBIL_CONV_B1_PID 0x2020 /* KOBIL Konverter for B1 */
647#define KOBIL_CONV_KAAN_PID 0x2021 /* KOBIL_Konverter for KAAN */
648
649#define FTDI_NF_RIC_VID 0x0DCD /* Vendor Id */
650#define FTDI_NF_RIC_PID 0x0001 /* Product Id */
651
652/*
653 * Falcom Wireless Communications GmbH
654 */
655#define FALCOM_VID 0x0F94 /* Vendor Id */
656#define FALCOM_TWIST_PID 0x0001 /* Falcom Twist USB GPRS modem */
657#define FALCOM_SAMBA_PID 0x0005 /* Falcom Samba USB GPRS modem */
658
659/* Larsen and Brusgaard AltiTrack/USBtrack */
660#define LARSENBRUSGAARD_VID 0x0FD8
661#define LB_ALTITRACK_PID 0x0001
662
663/*
664 * TTi (Thurlby Thandar Instruments)
665 */
666#define TTI_VID 0x103E /* Vendor Id */
667#define TTI_QL355P_PID 0x03E8 /* TTi QL355P power supply */
668
669/* Interbiometrics USB I/O Board */
670/* Developed for Interbiometrics by Rudolf Gugler */
671#define INTERBIOMETRICS_VID 0x1209
672#define INTERBIOMETRICS_IOBOARD_PID 0x1002
673#define INTERBIOMETRICS_MINI_IOBOARD_PID 0x1006
674
675/*
676 * Testo products (http://www.testo.com/)
677 * Submitted by Colin Leroy
678 */
679#define TESTO_VID 0x128D
680#define TESTO_USB_INTERFACE_PID 0x0001
681
682/*
683 * Mobility Electronics products.
684 */
685#define MOBILITY_VID 0x1342
686#define MOBILITY_USB_SERIAL_PID 0x0202 /* EasiDock USB 200 serial */
687
688/*
689 * FIC / OpenMoko, Inc. http://wiki.openmoko.org/wiki/Neo1973_Debug_Board_v3
690 * Submitted by Harald Welte <laforge@openmoko.org>
691 */
692#define FIC_VID 0x1457
693#define FIC_NEO1973_DEBUG_PID 0x5118
694
695/* Olimex */
696#define OLIMEX_VID 0x15BA
697#define OLIMEX_ARM_USB_OCD_PID 0x0003
698
699/*
700 * Telldus Technologies
701 */
702#define TELLDUS_VID 0x1781 /* Vendor ID */
703#define TELLDUS_TELLSTICK_PID 0x0C30 /* RF control dongle 433 MHz using FT232RL */
704
705/*
706 * Bayer Ascensia Contour blood glucose meter USB-converter cable.
707 * http://winglucofacts.com/cables/
708 */
709#define BAYER_VID 0x1A79
710#define BAYER_CONTOUR_CABLE_PID 0x6001
711
712/*
713 * The following are the values for the Matrix Orbital FTDI Range
714 * Anything in this range will use an FT232RL.
715 */
716#define MTXORB_VID 0x1B3D
717#define MTXORB_FTDI_RANGE_0100_PID 0x0100
718#define MTXORB_FTDI_RANGE_0101_PID 0x0101
719#define MTXORB_FTDI_RANGE_0102_PID 0x0102
720#define MTXORB_FTDI_RANGE_0103_PID 0x0103
721#define MTXORB_FTDI_RANGE_0104_PID 0x0104
722#define MTXORB_FTDI_RANGE_0105_PID 0x0105
723#define MTXORB_FTDI_RANGE_0106_PID 0x0106
724#define MTXORB_FTDI_RANGE_0107_PID 0x0107
725#define MTXORB_FTDI_RANGE_0108_PID 0x0108
726#define MTXORB_FTDI_RANGE_0109_PID 0x0109
727#define MTXORB_FTDI_RANGE_010A_PID 0x010A
728#define MTXORB_FTDI_RANGE_010B_PID 0x010B
729#define MTXORB_FTDI_RANGE_010C_PID 0x010C
730#define MTXORB_FTDI_RANGE_010D_PID 0x010D
731#define MTXORB_FTDI_RANGE_010E_PID 0x010E
732#define MTXORB_FTDI_RANGE_010F_PID 0x010F
733#define MTXORB_FTDI_RANGE_0110_PID 0x0110
734#define MTXORB_FTDI_RANGE_0111_PID 0x0111
735#define MTXORB_FTDI_RANGE_0112_PID 0x0112
736#define MTXORB_FTDI_RANGE_0113_PID 0x0113
737#define MTXORB_FTDI_RANGE_0114_PID 0x0114
738#define MTXORB_FTDI_RANGE_0115_PID 0x0115
739#define MTXORB_FTDI_RANGE_0116_PID 0x0116
740#define MTXORB_FTDI_RANGE_0117_PID 0x0117
741#define MTXORB_FTDI_RANGE_0118_PID 0x0118
742#define MTXORB_FTDI_RANGE_0119_PID 0x0119
743#define MTXORB_FTDI_RANGE_011A_PID 0x011A
744#define MTXORB_FTDI_RANGE_011B_PID 0x011B
745#define MTXORB_FTDI_RANGE_011C_PID 0x011C
746#define MTXORB_FTDI_RANGE_011D_PID 0x011D
747#define MTXORB_FTDI_RANGE_011E_PID 0x011E
748#define MTXORB_FTDI_RANGE_011F_PID 0x011F
749#define MTXORB_FTDI_RANGE_0120_PID 0x0120
750#define MTXORB_FTDI_RANGE_0121_PID 0x0121
751#define MTXORB_FTDI_RANGE_0122_PID 0x0122
752#define MTXORB_FTDI_RANGE_0123_PID 0x0123
753#define MTXORB_FTDI_RANGE_0124_PID 0x0124
754#define MTXORB_FTDI_RANGE_0125_PID 0x0125
755#define MTXORB_FTDI_RANGE_0126_PID 0x0126
756#define MTXORB_FTDI_RANGE_0127_PID 0x0127
757#define MTXORB_FTDI_RANGE_0128_PID 0x0128
758#define MTXORB_FTDI_RANGE_0129_PID 0x0129
759#define MTXORB_FTDI_RANGE_012A_PID 0x012A
760#define MTXORB_FTDI_RANGE_012B_PID 0x012B
761#define MTXORB_FTDI_RANGE_012C_PID 0x012C
762#define MTXORB_FTDI_RANGE_012D_PID 0x012D
763#define MTXORB_FTDI_RANGE_012E_PID 0x012E
764#define MTXORB_FTDI_RANGE_012F_PID 0x012F
765#define MTXORB_FTDI_RANGE_0130_PID 0x0130
766#define MTXORB_FTDI_RANGE_0131_PID 0x0131
767#define MTXORB_FTDI_RANGE_0132_PID 0x0132
768#define MTXORB_FTDI_RANGE_0133_PID 0x0133
769#define MTXORB_FTDI_RANGE_0134_PID 0x0134
770#define MTXORB_FTDI_RANGE_0135_PID 0x0135
771#define MTXORB_FTDI_RANGE_0136_PID 0x0136
772#define MTXORB_FTDI_RANGE_0137_PID 0x0137
773#define MTXORB_FTDI_RANGE_0138_PID 0x0138
774#define MTXORB_FTDI_RANGE_0139_PID 0x0139
775#define MTXORB_FTDI_RANGE_013A_PID 0x013A
776#define MTXORB_FTDI_RANGE_013B_PID 0x013B
777#define MTXORB_FTDI_RANGE_013C_PID 0x013C
778#define MTXORB_FTDI_RANGE_013D_PID 0x013D
779#define MTXORB_FTDI_RANGE_013E_PID 0x013E
780#define MTXORB_FTDI_RANGE_013F_PID 0x013F
781#define MTXORB_FTDI_RANGE_0140_PID 0x0140
782#define MTXORB_FTDI_RANGE_0141_PID 0x0141
783#define MTXORB_FTDI_RANGE_0142_PID 0x0142
784#define MTXORB_FTDI_RANGE_0143_PID 0x0143
785#define MTXORB_FTDI_RANGE_0144_PID 0x0144
786#define MTXORB_FTDI_RANGE_0145_PID 0x0145
787#define MTXORB_FTDI_RANGE_0146_PID 0x0146
788#define MTXORB_FTDI_RANGE_0147_PID 0x0147
789#define MTXORB_FTDI_RANGE_0148_PID 0x0148
790#define MTXORB_FTDI_RANGE_0149_PID 0x0149
791#define MTXORB_FTDI_RANGE_014A_PID 0x014A
792#define MTXORB_FTDI_RANGE_014B_PID 0x014B
793#define MTXORB_FTDI_RANGE_014C_PID 0x014C
794#define MTXORB_FTDI_RANGE_014D_PID 0x014D
795#define MTXORB_FTDI_RANGE_014E_PID 0x014E
796#define MTXORB_FTDI_RANGE_014F_PID 0x014F
797#define MTXORB_FTDI_RANGE_0150_PID 0x0150
798#define MTXORB_FTDI_RANGE_0151_PID 0x0151
799#define MTXORB_FTDI_RANGE_0152_PID 0x0152
800#define MTXORB_FTDI_RANGE_0153_PID 0x0153
801#define MTXORB_FTDI_RANGE_0154_PID 0x0154
802#define MTXORB_FTDI_RANGE_0155_PID 0x0155
803#define MTXORB_FTDI_RANGE_0156_PID 0x0156
804#define MTXORB_FTDI_RANGE_0157_PID 0x0157
805#define MTXORB_FTDI_RANGE_0158_PID 0x0158
806#define MTXORB_FTDI_RANGE_0159_PID 0x0159
807#define MTXORB_FTDI_RANGE_015A_PID 0x015A
808#define MTXORB_FTDI_RANGE_015B_PID 0x015B
809#define MTXORB_FTDI_RANGE_015C_PID 0x015C
810#define MTXORB_FTDI_RANGE_015D_PID 0x015D
811#define MTXORB_FTDI_RANGE_015E_PID 0x015E
812#define MTXORB_FTDI_RANGE_015F_PID 0x015F
813#define MTXORB_FTDI_RANGE_0160_PID 0x0160
814#define MTXORB_FTDI_RANGE_0161_PID 0x0161
815#define MTXORB_FTDI_RANGE_0162_PID 0x0162
816#define MTXORB_FTDI_RANGE_0163_PID 0x0163
817#define MTXORB_FTDI_RANGE_0164_PID 0x0164
818#define MTXORB_FTDI_RANGE_0165_PID 0x0165
819#define MTXORB_FTDI_RANGE_0166_PID 0x0166
820#define MTXORB_FTDI_RANGE_0167_PID 0x0167
821#define MTXORB_FTDI_RANGE_0168_PID 0x0168
822#define MTXORB_FTDI_RANGE_0169_PID 0x0169
823#define MTXORB_FTDI_RANGE_016A_PID 0x016A
824#define MTXORB_FTDI_RANGE_016B_PID 0x016B
825#define MTXORB_FTDI_RANGE_016C_PID 0x016C
826#define MTXORB_FTDI_RANGE_016D_PID 0x016D
827#define MTXORB_FTDI_RANGE_016E_PID 0x016E
828#define MTXORB_FTDI_RANGE_016F_PID 0x016F
829#define MTXORB_FTDI_RANGE_0170_PID 0x0170
830#define MTXORB_FTDI_RANGE_0171_PID 0x0171
831#define MTXORB_FTDI_RANGE_0172_PID 0x0172
832#define MTXORB_FTDI_RANGE_0173_PID 0x0173
833#define MTXORB_FTDI_RANGE_0174_PID 0x0174
834#define MTXORB_FTDI_RANGE_0175_PID 0x0175
835#define MTXORB_FTDI_RANGE_0176_PID 0x0176
836#define MTXORB_FTDI_RANGE_0177_PID 0x0177
837#define MTXORB_FTDI_RANGE_0178_PID 0x0178
838#define MTXORB_FTDI_RANGE_0179_PID 0x0179
839#define MTXORB_FTDI_RANGE_017A_PID 0x017A
840#define MTXORB_FTDI_RANGE_017B_PID 0x017B
841#define MTXORB_FTDI_RANGE_017C_PID 0x017C
842#define MTXORB_FTDI_RANGE_017D_PID 0x017D
843#define MTXORB_FTDI_RANGE_017E_PID 0x017E
844#define MTXORB_FTDI_RANGE_017F_PID 0x017F
845#define MTXORB_FTDI_RANGE_0180_PID 0x0180
846#define MTXORB_FTDI_RANGE_0181_PID 0x0181
847#define MTXORB_FTDI_RANGE_0182_PID 0x0182
848#define MTXORB_FTDI_RANGE_0183_PID 0x0183
849#define MTXORB_FTDI_RANGE_0184_PID 0x0184
850#define MTXORB_FTDI_RANGE_0185_PID 0x0185
851#define MTXORB_FTDI_RANGE_0186_PID 0x0186
852#define MTXORB_FTDI_RANGE_0187_PID 0x0187
853#define MTXORB_FTDI_RANGE_0188_PID 0x0188
854#define MTXORB_FTDI_RANGE_0189_PID 0x0189
855#define MTXORB_FTDI_RANGE_018A_PID 0x018A
856#define MTXORB_FTDI_RANGE_018B_PID 0x018B
857#define MTXORB_FTDI_RANGE_018C_PID 0x018C
858#define MTXORB_FTDI_RANGE_018D_PID 0x018D
859#define MTXORB_FTDI_RANGE_018E_PID 0x018E
860#define MTXORB_FTDI_RANGE_018F_PID 0x018F
861#define MTXORB_FTDI_RANGE_0190_PID 0x0190
862#define MTXORB_FTDI_RANGE_0191_PID 0x0191
863#define MTXORB_FTDI_RANGE_0192_PID 0x0192
864#define MTXORB_FTDI_RANGE_0193_PID 0x0193
865#define MTXORB_FTDI_RANGE_0194_PID 0x0194
866#define MTXORB_FTDI_RANGE_0195_PID 0x0195
867#define MTXORB_FTDI_RANGE_0196_PID 0x0196
868#define MTXORB_FTDI_RANGE_0197_PID 0x0197
869#define MTXORB_FTDI_RANGE_0198_PID 0x0198
870#define MTXORB_FTDI_RANGE_0199_PID 0x0199
871#define MTXORB_FTDI_RANGE_019A_PID 0x019A
872#define MTXORB_FTDI_RANGE_019B_PID 0x019B
873#define MTXORB_FTDI_RANGE_019C_PID 0x019C
874#define MTXORB_FTDI_RANGE_019D_PID 0x019D
875#define MTXORB_FTDI_RANGE_019E_PID 0x019E
876#define MTXORB_FTDI_RANGE_019F_PID 0x019F
877#define MTXORB_FTDI_RANGE_01A0_PID 0x01A0
878#define MTXORB_FTDI_RANGE_01A1_PID 0x01A1
879#define MTXORB_FTDI_RANGE_01A2_PID 0x01A2
880#define MTXORB_FTDI_RANGE_01A3_PID 0x01A3
881#define MTXORB_FTDI_RANGE_01A4_PID 0x01A4
882#define MTXORB_FTDI_RANGE_01A5_PID 0x01A5
883#define MTXORB_FTDI_RANGE_01A6_PID 0x01A6
884#define MTXORB_FTDI_RANGE_01A7_PID 0x01A7
885#define MTXORB_FTDI_RANGE_01A8_PID 0x01A8
886#define MTXORB_FTDI_RANGE_01A9_PID 0x01A9
887#define MTXORB_FTDI_RANGE_01AA_PID 0x01AA
888#define MTXORB_FTDI_RANGE_01AB_PID 0x01AB
889#define MTXORB_FTDI_RANGE_01AC_PID 0x01AC
890#define MTXORB_FTDI_RANGE_01AD_PID 0x01AD
891#define MTXORB_FTDI_RANGE_01AE_PID 0x01AE
892#define MTXORB_FTDI_RANGE_01AF_PID 0x01AF
893#define MTXORB_FTDI_RANGE_01B0_PID 0x01B0
894#define MTXORB_FTDI_RANGE_01B1_PID 0x01B1
895#define MTXORB_FTDI_RANGE_01B2_PID 0x01B2
896#define MTXORB_FTDI_RANGE_01B3_PID 0x01B3
897#define MTXORB_FTDI_RANGE_01B4_PID 0x01B4
898#define MTXORB_FTDI_RANGE_01B5_PID 0x01B5
899#define MTXORB_FTDI_RANGE_01B6_PID 0x01B6
900#define MTXORB_FTDI_RANGE_01B7_PID 0x01B7
901#define MTXORB_FTDI_RANGE_01B8_PID 0x01B8
902#define MTXORB_FTDI_RANGE_01B9_PID 0x01B9
903#define MTXORB_FTDI_RANGE_01BA_PID 0x01BA
904#define MTXORB_FTDI_RANGE_01BB_PID 0x01BB
905#define MTXORB_FTDI_RANGE_01BC_PID 0x01BC
906#define MTXORB_FTDI_RANGE_01BD_PID 0x01BD
907#define MTXORB_FTDI_RANGE_01BE_PID 0x01BE
908#define MTXORB_FTDI_RANGE_01BF_PID 0x01BF
909#define MTXORB_FTDI_RANGE_01C0_PID 0x01C0
910#define MTXORB_FTDI_RANGE_01C1_PID 0x01C1
911#define MTXORB_FTDI_RANGE_01C2_PID 0x01C2
912#define MTXORB_FTDI_RANGE_01C3_PID 0x01C3
913#define MTXORB_FTDI_RANGE_01C4_PID 0x01C4
914#define MTXORB_FTDI_RANGE_01C5_PID 0x01C5
915#define MTXORB_FTDI_RANGE_01C6_PID 0x01C6
916#define MTXORB_FTDI_RANGE_01C7_PID 0x01C7
917#define MTXORB_FTDI_RANGE_01C8_PID 0x01C8
918#define MTXORB_FTDI_RANGE_01C9_PID 0x01C9
919#define MTXORB_FTDI_RANGE_01CA_PID 0x01CA
920#define MTXORB_FTDI_RANGE_01CB_PID 0x01CB
921#define MTXORB_FTDI_RANGE_01CC_PID 0x01CC
922#define MTXORB_FTDI_RANGE_01CD_PID 0x01CD
923#define MTXORB_FTDI_RANGE_01CE_PID 0x01CE
924#define MTXORB_FTDI_RANGE_01CF_PID 0x01CF
925#define MTXORB_FTDI_RANGE_01D0_PID 0x01D0
926#define MTXORB_FTDI_RANGE_01D1_PID 0x01D1
927#define MTXORB_FTDI_RANGE_01D2_PID 0x01D2
928#define MTXORB_FTDI_RANGE_01D3_PID 0x01D3
929#define MTXORB_FTDI_RANGE_01D4_PID 0x01D4
930#define MTXORB_FTDI_RANGE_01D5_PID 0x01D5
931#define MTXORB_FTDI_RANGE_01D6_PID 0x01D6
932#define MTXORB_FTDI_RANGE_01D7_PID 0x01D7
933#define MTXORB_FTDI_RANGE_01D8_PID 0x01D8
934#define MTXORB_FTDI_RANGE_01D9_PID 0x01D9
935#define MTXORB_FTDI_RANGE_01DA_PID 0x01DA
936#define MTXORB_FTDI_RANGE_01DB_PID 0x01DB
937#define MTXORB_FTDI_RANGE_01DC_PID 0x01DC
938#define MTXORB_FTDI_RANGE_01DD_PID 0x01DD
939#define MTXORB_FTDI_RANGE_01DE_PID 0x01DE
940#define MTXORB_FTDI_RANGE_01DF_PID 0x01DF
941#define MTXORB_FTDI_RANGE_01E0_PID 0x01E0
942#define MTXORB_FTDI_RANGE_01E1_PID 0x01E1
943#define MTXORB_FTDI_RANGE_01E2_PID 0x01E2
944#define MTXORB_FTDI_RANGE_01E3_PID 0x01E3
945#define MTXORB_FTDI_RANGE_01E4_PID 0x01E4
946#define MTXORB_FTDI_RANGE_01E5_PID 0x01E5
947#define MTXORB_FTDI_RANGE_01E6_PID 0x01E6
948#define MTXORB_FTDI_RANGE_01E7_PID 0x01E7
949#define MTXORB_FTDI_RANGE_01E8_PID 0x01E8
950#define MTXORB_FTDI_RANGE_01E9_PID 0x01E9
951#define MTXORB_FTDI_RANGE_01EA_PID 0x01EA
952#define MTXORB_FTDI_RANGE_01EB_PID 0x01EB
953#define MTXORB_FTDI_RANGE_01EC_PID 0x01EC
954#define MTXORB_FTDI_RANGE_01ED_PID 0x01ED
955#define MTXORB_FTDI_RANGE_01EE_PID 0x01EE
956#define MTXORB_FTDI_RANGE_01EF_PID 0x01EF
957#define MTXORB_FTDI_RANGE_01F0_PID 0x01F0
958#define MTXORB_FTDI_RANGE_01F1_PID 0x01F1
959#define MTXORB_FTDI_RANGE_01F2_PID 0x01F2
960#define MTXORB_FTDI_RANGE_01F3_PID 0x01F3
961#define MTXORB_FTDI_RANGE_01F4_PID 0x01F4
962#define MTXORB_FTDI_RANGE_01F5_PID 0x01F5
963#define MTXORB_FTDI_RANGE_01F6_PID 0x01F6
964#define MTXORB_FTDI_RANGE_01F7_PID 0x01F7
965#define MTXORB_FTDI_RANGE_01F8_PID 0x01F8
966#define MTXORB_FTDI_RANGE_01F9_PID 0x01F9
967#define MTXORB_FTDI_RANGE_01FA_PID 0x01FA
968#define MTXORB_FTDI_RANGE_01FB_PID 0x01FB
969#define MTXORB_FTDI_RANGE_01FC_PID 0x01FC
970#define MTXORB_FTDI_RANGE_01FD_PID 0x01FD
971#define MTXORB_FTDI_RANGE_01FE_PID 0x01FE
972#define MTXORB_FTDI_RANGE_01FF_PID 0x01FF
973
974
975
976/*
977 * The Mobility Lab (TML)
978 * Submitted by Pierre Castella
979 */
980#define TML_VID 0x1B91 /* Vendor ID */
981#define TML_USB_SERIAL_PID 0x0064 /* USB - Serial Converter */
982
983/* Alti-2 products http://www.alti-2.com */
984#define ALTI2_VID 0x1BC9
985#define ALTI2_N3_PID 0x6001 /* Neptune 3 */
986
987/*
988 * Dresden Elektronik Sensor Terminal Board
989 */
990#define DE_VID 0x1cf1 /* Vendor ID */
991#define STB_PID 0x0001 /* Sensor Terminal Board */
992#define WHT_PID 0x0004 /* Wireless Handheld Terminal */
993
994/*
995 * Papouch products (http://www.papouch.com/)
996 * Submitted by Folkert van Heusden
997 */
998
999#define PAPOUCH_VID 0x5050 /* Vendor ID */
1000#define PAPOUCH_TMU_PID 0x0400 /* TMU USB Thermometer */
1001#define PAPOUCH_QUIDO4x4_PID 0x0900 /* Quido 4/4 Module */
1002#define PAPOUCH_AD4USB_PID 0x8003 /* AD4USB Measurement Module */
1003
1004/*
1005 * Marvell SheevaPlug
1006 */
1007#define MARVELL_VID 0x9e88
1008#define MARVELL_SHEEVAPLUG_PID 0x9e8f
1009
1010/*
1011 * Evolution Robotics products (http://www.evolution.com/).
1012 * Submitted by Shawn M. Lavelle.
1013 */
1014#define EVOLUTION_VID 0xDEEE /* Vendor ID */
1015#define EVOLUTION_ER1_PID 0x0300 /* ER1 Control Module */
1016#define EVO_8U232AM_PID 0x02FF /* Evolution robotics RCM2 (FT232AM)*/
1017#define EVO_HYBRID_PID 0x0302 /* Evolution robotics RCM4 PID (FT232BM)*/
1018#define EVO_RCM4_PID 0x0303 /* Evolution robotics RCM4 PID */
1019
1020/*
1021 * MJS Gadgets HD Radio / XM Radio / Sirius Radio interfaces (using VID 0x0403)
1022 */
1023#define MJSG_GENERIC_PID 0x9378
1024#define MJSG_SR_RADIO_PID 0x9379
1025#define MJSG_XM_RADIO_PID 0x937A
1026#define MJSG_HD_RADIO_PID 0x937C
diff --git a/drivers/usb/serial/funsoft.c b/drivers/usb/serial/funsoft.c
index d30f736d2cc5..e21ce9ddfc63 100644
--- a/drivers/usb/serial/funsoft.c
+++ b/drivers/usb/serial/funsoft.c
@@ -18,7 +18,7 @@
18 18
19static int debug; 19static int debug;
20 20
21static struct usb_device_id id_table [] = { 21static const struct usb_device_id id_table[] = {
22 { USB_DEVICE(0x1404, 0xcddc) }, 22 { USB_DEVICE(0x1404, 0xcddc) },
23 { }, 23 { },
24}; 24};
diff --git a/drivers/usb/serial/garmin_gps.c b/drivers/usb/serial/garmin_gps.c
index 5ac900e5a50e..a42b29a695b2 100644
--- a/drivers/usb/serial/garmin_gps.c
+++ b/drivers/usb/serial/garmin_gps.c
@@ -210,7 +210,7 @@ static unsigned char const PRIVATE_REQ[]
210 210
211 211
212 212
213static struct usb_device_id id_table [] = { 213static const struct usb_device_id id_table[] = {
214 /* the same device id seems to be used by all 214 /* the same device id seems to be used by all
215 usb enabled GPS devices */ 215 usb enabled GPS devices */
216 { USB_DEVICE(GARMIN_VENDOR_ID, 3) }, 216 { USB_DEVICE(GARMIN_VENDOR_ID, 3) },
@@ -271,7 +271,6 @@ static void send_to_tty(struct usb_serial_port *port,
271 usb_serial_debug_data(debug, &port->dev, 271 usb_serial_debug_data(debug, &port->dev,
272 __func__, actual_length, data); 272 __func__, actual_length, data);
273 273
274 tty_buffer_request_room(tty, actual_length);
275 tty_insert_flip_string(tty, data, actual_length); 274 tty_insert_flip_string(tty, data, actual_length);
276 tty_flip_buffer_push(tty); 275 tty_flip_buffer_push(tty);
277 } 276 }
diff --git a/drivers/usb/serial/generic.c b/drivers/usb/serial/generic.c
index bbe005cefcfb..f804acb138ec 100644
--- a/drivers/usb/serial/generic.c
+++ b/drivers/usb/serial/generic.c
@@ -20,6 +20,7 @@
20#include <linux/usb/serial.h> 20#include <linux/usb/serial.h>
21#include <linux/uaccess.h> 21#include <linux/uaccess.h>
22#include <linux/kfifo.h> 22#include <linux/kfifo.h>
23#include <linux/serial.h>
23 24
24static int debug; 25static int debug;
25 26
@@ -41,7 +42,7 @@ static struct usb_device_id generic_device_ids[2]; /* Initially all zeroes. */
41 42
42/* we want to look at all devices, as the vendor/product id can change 43/* we want to look at all devices, as the vendor/product id can change
43 * depending on the command line argument */ 44 * depending on the command line argument */
44static struct usb_device_id generic_serial_ids[] = { 45static const struct usb_device_id generic_serial_ids[] = {
45 {.driver_info = 42}, 46 {.driver_info = 42},
46 {} 47 {}
47}; 48};
@@ -129,7 +130,7 @@ int usb_serial_generic_open(struct tty_struct *tty, struct usb_serial_port *port
129 spin_unlock_irqrestore(&port->lock, flags); 130 spin_unlock_irqrestore(&port->lock, flags);
130 131
131 /* if we have a bulk endpoint, start reading from it */ 132 /* if we have a bulk endpoint, start reading from it */
132 if (serial->num_bulk_in) { 133 if (port->bulk_in_size) {
133 /* Start reading from the device */ 134 /* Start reading from the device */
134 usb_fill_bulk_urb(port->read_urb, serial->dev, 135 usb_fill_bulk_urb(port->read_urb, serial->dev,
135 usb_rcvbulkpipe(serial->dev, 136 usb_rcvbulkpipe(serial->dev,
@@ -158,10 +159,10 @@ static void generic_cleanup(struct usb_serial_port *port)
158 dbg("%s - port %d", __func__, port->number); 159 dbg("%s - port %d", __func__, port->number);
159 160
160 if (serial->dev) { 161 if (serial->dev) {
161 /* shutdown any bulk reads that might be going on */ 162 /* shutdown any bulk transfers that might be going on */
162 if (serial->num_bulk_out) 163 if (port->bulk_out_size)
163 usb_kill_urb(port->write_urb); 164 usb_kill_urb(port->write_urb);
164 if (serial->num_bulk_in) 165 if (port->bulk_in_size)
165 usb_kill_urb(port->read_urb); 166 usb_kill_urb(port->read_urb);
166 } 167 }
167} 168}
@@ -194,7 +195,7 @@ static int usb_serial_multi_urb_write(struct tty_struct *tty,
194 if (port->urbs_in_flight > 195 if (port->urbs_in_flight >
195 port->serial->type->max_in_flight_urbs) { 196 port->serial->type->max_in_flight_urbs) {
196 spin_unlock_irqrestore(&port->lock, flags); 197 spin_unlock_irqrestore(&port->lock, flags);
197 dbg("%s - write limit hit\n", __func__); 198 dbg("%s - write limit hit", __func__);
198 return bwrite; 199 return bwrite;
199 } 200 }
200 port->tx_bytes_flight += towrite; 201 port->tx_bytes_flight += towrite;
@@ -276,7 +277,7 @@ static int usb_serial_generic_write_start(struct usb_serial_port *port)
276 if (port->write_urb_busy) 277 if (port->write_urb_busy)
277 start_io = false; 278 start_io = false;
278 else { 279 else {
279 start_io = (__kfifo_len(port->write_fifo) != 0); 280 start_io = (kfifo_len(&port->write_fifo) != 0);
280 port->write_urb_busy = start_io; 281 port->write_urb_busy = start_io;
281 } 282 }
282 spin_unlock_irqrestore(&port->lock, flags); 283 spin_unlock_irqrestore(&port->lock, flags);
@@ -285,7 +286,7 @@ static int usb_serial_generic_write_start(struct usb_serial_port *port)
285 return 0; 286 return 0;
286 287
287 data = port->write_urb->transfer_buffer; 288 data = port->write_urb->transfer_buffer;
288 count = kfifo_get(port->write_fifo, data, port->bulk_out_size); 289 count = kfifo_out_locked(&port->write_fifo, data, port->bulk_out_size, &port->lock);
289 usb_serial_debug_data(debug, &port->dev, __func__, count, data); 290 usb_serial_debug_data(debug, &port->dev, __func__, count, data);
290 291
291 /* set up our urb */ 292 /* set up our urb */
@@ -332,20 +333,20 @@ int usb_serial_generic_write(struct tty_struct *tty,
332 333
333 dbg("%s - port %d", __func__, port->number); 334 dbg("%s - port %d", __func__, port->number);
334 335
336 /* only do something if we have a bulk out endpoint */
337 if (!port->bulk_out_size)
338 return -ENODEV;
339
335 if (count == 0) { 340 if (count == 0) {
336 dbg("%s - write request of 0 bytes", __func__); 341 dbg("%s - write request of 0 bytes", __func__);
337 return 0; 342 return 0;
338 } 343 }
339 344
340 /* only do something if we have a bulk out endpoint */
341 if (!serial->num_bulk_out)
342 return 0;
343
344 if (serial->type->max_in_flight_urbs) 345 if (serial->type->max_in_flight_urbs)
345 return usb_serial_multi_urb_write(tty, port, 346 return usb_serial_multi_urb_write(tty, port,
346 buf, count); 347 buf, count);
347 348
348 count = kfifo_put(port->write_fifo, buf, count); 349 count = kfifo_in_locked(&port->write_fifo, buf, count, &port->lock);
349 result = usb_serial_generic_write_start(port); 350 result = usb_serial_generic_write_start(port);
350 351
351 if (result >= 0) 352 if (result >= 0)
@@ -363,14 +364,19 @@ int usb_serial_generic_write_room(struct tty_struct *tty)
363 int room = 0; 364 int room = 0;
364 365
365 dbg("%s - port %d", __func__, port->number); 366 dbg("%s - port %d", __func__, port->number);
367
368 if (!port->bulk_out_size)
369 return 0;
370
366 spin_lock_irqsave(&port->lock, flags); 371 spin_lock_irqsave(&port->lock, flags);
367 if (serial->type->max_in_flight_urbs) { 372 if (serial->type->max_in_flight_urbs) {
368 if (port->urbs_in_flight < serial->type->max_in_flight_urbs) 373 if (port->urbs_in_flight < serial->type->max_in_flight_urbs)
369 room = port->bulk_out_size * 374 room = port->bulk_out_size *
370 (serial->type->max_in_flight_urbs - 375 (serial->type->max_in_flight_urbs -
371 port->urbs_in_flight); 376 port->urbs_in_flight);
372 } else if (serial->num_bulk_out) 377 } else {
373 room = port->write_fifo->size - __kfifo_len(port->write_fifo); 378 room = kfifo_avail(&port->write_fifo);
379 }
374 spin_unlock_irqrestore(&port->lock, flags); 380 spin_unlock_irqrestore(&port->lock, flags);
375 381
376 dbg("%s - returns %d", __func__, room); 382 dbg("%s - returns %d", __func__, room);
@@ -381,17 +387,20 @@ int usb_serial_generic_chars_in_buffer(struct tty_struct *tty)
381{ 387{
382 struct usb_serial_port *port = tty->driver_data; 388 struct usb_serial_port *port = tty->driver_data;
383 struct usb_serial *serial = port->serial; 389 struct usb_serial *serial = port->serial;
384 int chars = 0;
385 unsigned long flags; 390 unsigned long flags;
391 int chars;
386 392
387 dbg("%s - port %d", __func__, port->number); 393 dbg("%s - port %d", __func__, port->number);
388 394
389 if (serial->type->max_in_flight_urbs) { 395 if (!port->bulk_out_size)
390 spin_lock_irqsave(&port->lock, flags); 396 return 0;
397
398 spin_lock_irqsave(&port->lock, flags);
399 if (serial->type->max_in_flight_urbs)
391 chars = port->tx_bytes_flight; 400 chars = port->tx_bytes_flight;
392 spin_unlock_irqrestore(&port->lock, flags); 401 else
393 } else if (serial->num_bulk_out) 402 chars = kfifo_len(&port->write_fifo);
394 chars = kfifo_len(port->write_fifo); 403 spin_unlock_irqrestore(&port->lock, flags);
395 404
396 dbg("%s - returns %d", __func__, chars); 405 dbg("%s - returns %d", __func__, chars);
397 return chars; 406 return chars;
@@ -414,11 +423,13 @@ void usb_serial_generic_resubmit_read_urb(struct usb_serial_port *port,
414 ((serial->type->read_bulk_callback) ? 423 ((serial->type->read_bulk_callback) ?
415 serial->type->read_bulk_callback : 424 serial->type->read_bulk_callback :
416 usb_serial_generic_read_bulk_callback), port); 425 usb_serial_generic_read_bulk_callback), port);
426
417 result = usb_submit_urb(urb, mem_flags); 427 result = usb_submit_urb(urb, mem_flags);
418 if (result) 428 if (result && result != -EPERM) {
419 dev_err(&port->dev, 429 dev_err(&port->dev,
420 "%s - failed resubmitting read urb, error %d\n", 430 "%s - failed resubmitting read urb, error %d\n",
421 __func__, result); 431 __func__, result);
432 }
422} 433}
423EXPORT_SYMBOL_GPL(usb_serial_generic_resubmit_read_urb); 434EXPORT_SYMBOL_GPL(usb_serial_generic_resubmit_read_urb);
424 435
@@ -489,29 +500,26 @@ void usb_serial_generic_write_bulk_callback(struct urb *urb)
489 dbg("%s - port %d", __func__, port->number); 500 dbg("%s - port %d", __func__, port->number);
490 501
491 if (port->serial->type->max_in_flight_urbs) { 502 if (port->serial->type->max_in_flight_urbs) {
503 kfree(urb->transfer_buffer);
504
492 spin_lock_irqsave(&port->lock, flags); 505 spin_lock_irqsave(&port->lock, flags);
493 --port->urbs_in_flight; 506 --port->urbs_in_flight;
494 port->tx_bytes_flight -= urb->transfer_buffer_length; 507 port->tx_bytes_flight -= urb->transfer_buffer_length;
495 if (port->urbs_in_flight < 0) 508 if (port->urbs_in_flight < 0)
496 port->urbs_in_flight = 0; 509 port->urbs_in_flight = 0;
497 spin_unlock_irqrestore(&port->lock, flags); 510 spin_unlock_irqrestore(&port->lock, flags);
498
499 if (status) {
500 dbg("%s - nonzero multi-urb write bulk status "
501 "received: %d", __func__, status);
502 return;
503 }
504 } else { 511 } else {
505 port->write_urb_busy = 0; 512 port->write_urb_busy = 0;
506 513
507 if (status) { 514 if (status)
508 dbg("%s - nonzero multi-urb write bulk status " 515 kfifo_reset_out(&port->write_fifo);
509 "received: %d", __func__, status); 516 else
510 kfifo_reset(port->write_fifo);
511 } else
512 usb_serial_generic_write_start(port); 517 usb_serial_generic_write_start(port);
513 } 518 }
514 519
520 if (status)
521 dbg("%s - non-zero urb status: %d", __func__, status);
522
515 usb_serial_port_softint(port); 523 usb_serial_port_softint(port);
516} 524}
517EXPORT_SYMBOL_GPL(usb_serial_generic_write_bulk_callback); 525EXPORT_SYMBOL_GPL(usb_serial_generic_write_bulk_callback);
@@ -583,7 +591,7 @@ int usb_serial_generic_resume(struct usb_serial *serial)
583 591
584 for (i = 0; i < serial->num_ports; i++) { 592 for (i = 0; i < serial->num_ports; i++) {
585 port = serial->port[i]; 593 port = serial->port[i];
586 if (!port->port.count) 594 if (!test_bit(ASYNCB_INITIALIZED, &port->port.flags))
587 continue; 595 continue;
588 596
589 if (port->read_urb) { 597 if (port->read_urb) {
diff --git a/drivers/usb/serial/hp4x.c b/drivers/usb/serial/hp4x.c
index 431329275133..809379159b0e 100644
--- a/drivers/usb/serial/hp4x.c
+++ b/drivers/usb/serial/hp4x.c
@@ -29,7 +29,7 @@
29#define HP_VENDOR_ID 0x03f0 29#define HP_VENDOR_ID 0x03f0
30#define HP49GP_PRODUCT_ID 0x0121 30#define HP49GP_PRODUCT_ID 0x0121
31 31
32static struct usb_device_id id_table [] = { 32static const struct usb_device_id id_table[] = {
33 { USB_DEVICE(HP_VENDOR_ID, HP49GP_PRODUCT_ID) }, 33 { USB_DEVICE(HP_VENDOR_ID, HP49GP_PRODUCT_ID) },
34 { } /* Terminating entry */ 34 { } /* Terminating entry */
35}; 35};
diff --git a/drivers/usb/serial/io_edgeport.c b/drivers/usb/serial/io_edgeport.c
index b97960ac92f2..3ef8df0ef888 100644
--- a/drivers/usb/serial/io_edgeport.c
+++ b/drivers/usb/serial/io_edgeport.c
@@ -364,42 +364,6 @@ static void update_edgeport_E2PROM(struct edgeport_serial *edge_serial)
364 release_firmware(fw); 364 release_firmware(fw);
365} 365}
366 366
367
368/************************************************************************
369 * *
370 * Get string descriptor from device *
371 * *
372 ************************************************************************/
373static int get_string(struct usb_device *dev, int Id, char *string, int buflen)
374{
375 struct usb_string_descriptor StringDesc;
376 struct usb_string_descriptor *pStringDesc;
377
378 dbg("%s - USB String ID = %d", __func__, Id);
379
380 if (!usb_get_descriptor(dev, USB_DT_STRING, Id,
381 &StringDesc, sizeof(StringDesc)))
382 return 0;
383
384 pStringDesc = kmalloc(StringDesc.bLength, GFP_KERNEL);
385 if (!pStringDesc)
386 return 0;
387
388 if (!usb_get_descriptor(dev, USB_DT_STRING, Id,
389 pStringDesc, StringDesc.bLength)) {
390 kfree(pStringDesc);
391 return 0;
392 }
393
394 unicode_to_ascii(string, buflen,
395 pStringDesc->wData, pStringDesc->bLength/2);
396
397 kfree(pStringDesc);
398 dbg("%s - USB String %s", __func__, string);
399 return strlen(string);
400}
401
402
403#if 0 367#if 0
404/************************************************************************ 368/************************************************************************
405 * 369 *
@@ -2007,7 +1971,7 @@ static void process_rcvd_status(struct edgeport_serial *edge_serial,
2007 return; 1971 return;
2008 1972
2009 case IOSP_EXT_STATUS_RX_CHECK_RSP: 1973 case IOSP_EXT_STATUS_RX_CHECK_RSP:
2010 dbg("%s ========== Port %u CHECK_RSP Sequence = %02x =============\n", __func__, edge_serial->rxPort, byte3); 1974 dbg("%s ========== Port %u CHECK_RSP Sequence = %02x =============", __func__, edge_serial->rxPort, byte3);
2011 /* Port->RxCheckRsp = true; */ 1975 /* Port->RxCheckRsp = true; */
2012 return; 1976 return;
2013 } 1977 }
@@ -2075,7 +2039,7 @@ static void process_rcvd_status(struct edgeport_serial *edge_serial,
2075 break; 2039 break;
2076 2040
2077 default: 2041 default:
2078 dbg("%s - Unrecognized IOSP status code %u\n", __func__, code); 2042 dbg("%s - Unrecognized IOSP status code %u", __func__, code);
2079 break; 2043 break;
2080 } 2044 }
2081 return; 2045 return;
@@ -2091,18 +2055,13 @@ static void edge_tty_recv(struct device *dev, struct tty_struct *tty,
2091{ 2055{
2092 int cnt; 2056 int cnt;
2093 2057
2094 do { 2058 cnt = tty_insert_flip_string(tty, data, length);
2095 cnt = tty_buffer_request_room(tty, length); 2059 if (cnt < length) {
2096 if (cnt < length) { 2060 dev_err(dev, "%s - dropping data, %d bytes lost\n",
2097 dev_err(dev, "%s - dropping data, %d bytes lost\n", 2061 __func__, length - cnt);
2098 __func__, length - cnt); 2062 }
2099 if (cnt == 0) 2063 data += cnt;
2100 break; 2064 length -= cnt;
2101 }
2102 tty_insert_flip_string(tty, data, cnt);
2103 data += cnt;
2104 length -= cnt;
2105 } while (length > 0);
2106 2065
2107 tty_flip_buffer_push(tty); 2066 tty_flip_buffer_push(tty);
2108} 2067}
@@ -2530,7 +2489,7 @@ static int calc_baud_rate_divisor(int baudrate, int *divisor)
2530 2489
2531 *divisor = custom; 2490 *divisor = custom;
2532 2491
2533 dbg("%s - Baud %d = %d\n", __func__, baudrate, custom); 2492 dbg("%s - Baud %d = %d", __func__, baudrate, custom);
2534 return 0; 2493 return 0;
2535 } 2494 }
2536 2495
@@ -2915,7 +2874,7 @@ static void load_application_firmware(struct edgeport_serial *edge_serial)
2915 break; 2874 break;
2916 2875
2917 case EDGE_DOWNLOAD_FILE_NONE: 2876 case EDGE_DOWNLOAD_FILE_NONE:
2918 dbg ("No download file specified, skipping download\n"); 2877 dbg("No download file specified, skipping download");
2919 return; 2878 return;
2920 2879
2921 default: 2880 default:
@@ -2997,10 +2956,12 @@ static int edge_startup(struct usb_serial *serial)
2997 usb_set_serial_data(serial, edge_serial); 2956 usb_set_serial_data(serial, edge_serial);
2998 2957
2999 /* get the name for the device from the device */ 2958 /* get the name for the device from the device */
3000 i = get_string(dev, dev->descriptor.iManufacturer, 2959 i = usb_string(dev, dev->descriptor.iManufacturer,
3001 &edge_serial->name[0], MAX_NAME_LEN+1); 2960 &edge_serial->name[0], MAX_NAME_LEN+1);
2961 if (i < 0)
2962 i = 0;
3002 edge_serial->name[i++] = ' '; 2963 edge_serial->name[i++] = ' ';
3003 get_string(dev, dev->descriptor.iProduct, 2964 usb_string(dev, dev->descriptor.iProduct,
3004 &edge_serial->name[i], MAX_NAME_LEN+2 - i); 2965 &edge_serial->name[i], MAX_NAME_LEN+2 - i);
3005 2966
3006 dev_info(&serial->dev->dev, "%s detected\n", edge_serial->name); 2967 dev_info(&serial->dev->dev, "%s detected\n", edge_serial->name);
diff --git a/drivers/usb/serial/io_tables.h b/drivers/usb/serial/io_tables.h
index 9241d3147513..feb56a4ca799 100644
--- a/drivers/usb/serial/io_tables.h
+++ b/drivers/usb/serial/io_tables.h
@@ -14,7 +14,7 @@
14#ifndef IO_TABLES_H 14#ifndef IO_TABLES_H
15#define IO_TABLES_H 15#define IO_TABLES_H
16 16
17static struct usb_device_id edgeport_2port_id_table [] = { 17static const struct usb_device_id edgeport_2port_id_table[] = {
18 { USB_DEVICE(USB_VENDOR_ID_ION, ION_DEVICE_ID_EDGEPORT_2) }, 18 { USB_DEVICE(USB_VENDOR_ID_ION, ION_DEVICE_ID_EDGEPORT_2) },
19 { USB_DEVICE(USB_VENDOR_ID_ION, ION_DEVICE_ID_EDGEPORT_2I) }, 19 { USB_DEVICE(USB_VENDOR_ID_ION, ION_DEVICE_ID_EDGEPORT_2I) },
20 { USB_DEVICE(USB_VENDOR_ID_ION, ION_DEVICE_ID_EDGEPORT_421) }, 20 { USB_DEVICE(USB_VENDOR_ID_ION, ION_DEVICE_ID_EDGEPORT_421) },
@@ -23,7 +23,7 @@ static struct usb_device_id edgeport_2port_id_table [] = {
23 { } 23 { }
24}; 24};
25 25
26static struct usb_device_id edgeport_4port_id_table [] = { 26static const struct usb_device_id edgeport_4port_id_table[] = {
27 { USB_DEVICE(USB_VENDOR_ID_ION, ION_DEVICE_ID_EDGEPORT_4) }, 27 { USB_DEVICE(USB_VENDOR_ID_ION, ION_DEVICE_ID_EDGEPORT_4) },
28 { USB_DEVICE(USB_VENDOR_ID_ION, ION_DEVICE_ID_RAPIDPORT_4) }, 28 { USB_DEVICE(USB_VENDOR_ID_ION, ION_DEVICE_ID_RAPIDPORT_4) },
29 { USB_DEVICE(USB_VENDOR_ID_ION, ION_DEVICE_ID_EDGEPORT_4T) }, 29 { USB_DEVICE(USB_VENDOR_ID_ION, ION_DEVICE_ID_EDGEPORT_4T) },
@@ -37,7 +37,7 @@ static struct usb_device_id edgeport_4port_id_table [] = {
37 { } 37 { }
38}; 38};
39 39
40static struct usb_device_id edgeport_8port_id_table [] = { 40static const struct usb_device_id edgeport_8port_id_table[] = {
41 { USB_DEVICE(USB_VENDOR_ID_ION, ION_DEVICE_ID_EDGEPORT_8) }, 41 { USB_DEVICE(USB_VENDOR_ID_ION, ION_DEVICE_ID_EDGEPORT_8) },
42 { USB_DEVICE(USB_VENDOR_ID_ION, ION_DEVICE_ID_EDGEPORT_16_DUAL_CPU) }, 42 { USB_DEVICE(USB_VENDOR_ID_ION, ION_DEVICE_ID_EDGEPORT_16_DUAL_CPU) },
43 { USB_DEVICE(USB_VENDOR_ID_ION, ION_DEVICE_ID_EDGEPORT_8I) }, 43 { USB_DEVICE(USB_VENDOR_ID_ION, ION_DEVICE_ID_EDGEPORT_8I) },
@@ -47,7 +47,7 @@ static struct usb_device_id edgeport_8port_id_table [] = {
47 { } 47 { }
48}; 48};
49 49
50static struct usb_device_id Epic_port_id_table [] = { 50static const struct usb_device_id Epic_port_id_table[] = {
51 { USB_DEVICE(USB_VENDOR_ID_NCR, NCR_DEVICE_ID_EPIC_0202) }, 51 { USB_DEVICE(USB_VENDOR_ID_NCR, NCR_DEVICE_ID_EPIC_0202) },
52 { USB_DEVICE(USB_VENDOR_ID_NCR, NCR_DEVICE_ID_EPIC_0203) }, 52 { USB_DEVICE(USB_VENDOR_ID_NCR, NCR_DEVICE_ID_EPIC_0203) },
53 { USB_DEVICE(USB_VENDOR_ID_NCR, NCR_DEVICE_ID_EPIC_0310) }, 53 { USB_DEVICE(USB_VENDOR_ID_NCR, NCR_DEVICE_ID_EPIC_0310) },
@@ -60,7 +60,7 @@ static struct usb_device_id Epic_port_id_table [] = {
60}; 60};
61 61
62/* Devices that this driver supports */ 62/* Devices that this driver supports */
63static struct usb_device_id id_table_combined [] = { 63static const struct usb_device_id id_table_combined[] = {
64 { USB_DEVICE(USB_VENDOR_ID_ION, ION_DEVICE_ID_EDGEPORT_4) }, 64 { USB_DEVICE(USB_VENDOR_ID_ION, ION_DEVICE_ID_EDGEPORT_4) },
65 { USB_DEVICE(USB_VENDOR_ID_ION, ION_DEVICE_ID_RAPIDPORT_4) }, 65 { USB_DEVICE(USB_VENDOR_ID_ION, ION_DEVICE_ID_RAPIDPORT_4) },
66 { USB_DEVICE(USB_VENDOR_ID_ION, ION_DEVICE_ID_EDGEPORT_4T) }, 66 { USB_DEVICE(USB_VENDOR_ID_ION, ION_DEVICE_ID_EDGEPORT_4T) },
diff --git a/drivers/usb/serial/io_ti.c b/drivers/usb/serial/io_ti.c
index d4cc0f7af400..aa876f71f228 100644
--- a/drivers/usb/serial/io_ti.c
+++ b/drivers/usb/serial/io_ti.c
@@ -134,7 +134,7 @@ struct edgeport_serial {
134 134
135 135
136/* Devices that this driver supports */ 136/* Devices that this driver supports */
137static struct usb_device_id edgeport_1port_id_table [] = { 137static const struct usb_device_id edgeport_1port_id_table[] = {
138 { USB_DEVICE(USB_VENDOR_ID_ION, ION_DEVICE_ID_TI_EDGEPORT_1) }, 138 { USB_DEVICE(USB_VENDOR_ID_ION, ION_DEVICE_ID_TI_EDGEPORT_1) },
139 { USB_DEVICE(USB_VENDOR_ID_ION, ION_DEVICE_ID_TI_TI3410_EDGEPORT_1) }, 139 { USB_DEVICE(USB_VENDOR_ID_ION, ION_DEVICE_ID_TI_TI3410_EDGEPORT_1) },
140 { USB_DEVICE(USB_VENDOR_ID_ION, ION_DEVICE_ID_TI_TI3410_EDGEPORT_1I) }, 140 { USB_DEVICE(USB_VENDOR_ID_ION, ION_DEVICE_ID_TI_TI3410_EDGEPORT_1I) },
@@ -154,7 +154,7 @@ static struct usb_device_id edgeport_1port_id_table [] = {
154 { } 154 { }
155}; 155};
156 156
157static struct usb_device_id edgeport_2port_id_table [] = { 157static const struct usb_device_id edgeport_2port_id_table[] = {
158 { USB_DEVICE(USB_VENDOR_ID_ION, ION_DEVICE_ID_TI_EDGEPORT_2) }, 158 { USB_DEVICE(USB_VENDOR_ID_ION, ION_DEVICE_ID_TI_EDGEPORT_2) },
159 { USB_DEVICE(USB_VENDOR_ID_ION, ION_DEVICE_ID_TI_EDGEPORT_2C) }, 159 { USB_DEVICE(USB_VENDOR_ID_ION, ION_DEVICE_ID_TI_EDGEPORT_2C) },
160 { USB_DEVICE(USB_VENDOR_ID_ION, ION_DEVICE_ID_TI_EDGEPORT_2I) }, 160 { USB_DEVICE(USB_VENDOR_ID_ION, ION_DEVICE_ID_TI_EDGEPORT_2I) },
@@ -177,7 +177,7 @@ static struct usb_device_id edgeport_2port_id_table [] = {
177}; 177};
178 178
179/* Devices that this driver supports */ 179/* Devices that this driver supports */
180static struct usb_device_id id_table_combined [] = { 180static const struct usb_device_id id_table_combined[] = {
181 { USB_DEVICE(USB_VENDOR_ID_ION, ION_DEVICE_ID_TI_EDGEPORT_1) }, 181 { USB_DEVICE(USB_VENDOR_ID_ION, ION_DEVICE_ID_TI_EDGEPORT_1) },
182 { USB_DEVICE(USB_VENDOR_ID_ION, ION_DEVICE_ID_TI_TI3410_EDGEPORT_1) }, 182 { USB_DEVICE(USB_VENDOR_ID_ION, ION_DEVICE_ID_TI_TI3410_EDGEPORT_1) },
183 { USB_DEVICE(USB_VENDOR_ID_ION, ION_DEVICE_ID_TI_TI3410_EDGEPORT_1I) }, 183 { USB_DEVICE(USB_VENDOR_ID_ION, ION_DEVICE_ID_TI_TI3410_EDGEPORT_1I) },
@@ -413,11 +413,18 @@ static int write_boot_mem(struct edgeport_serial *serial,
413{ 413{
414 int status = 0; 414 int status = 0;
415 int i; 415 int i;
416 __u8 temp; 416 u8 *temp;
417 417
418 /* Must do a read before write */ 418 /* Must do a read before write */
419 if (!serial->TiReadI2C) { 419 if (!serial->TiReadI2C) {
420 status = read_boot_mem(serial, 0, 1, &temp); 420 temp = kmalloc(1, GFP_KERNEL);
421 if (!temp) {
422 dev_err(&serial->serial->dev->dev,
423 "%s - out of memory\n", __func__);
424 return -ENOMEM;
425 }
426 status = read_boot_mem(serial, 0, 1, temp);
427 kfree(temp);
421 if (status) 428 if (status)
422 return status; 429 return status;
423 } 430 }
@@ -935,37 +942,47 @@ static int build_i2c_fw_hdr(__u8 *header, struct device *dev)
935static int i2c_type_bootmode(struct edgeport_serial *serial) 942static int i2c_type_bootmode(struct edgeport_serial *serial)
936{ 943{
937 int status; 944 int status;
938 __u8 data; 945 u8 *data;
946
947 data = kmalloc(1, GFP_KERNEL);
948 if (!data) {
949 dev_err(&serial->serial->dev->dev,
950 "%s - out of memory\n", __func__);
951 return -ENOMEM;
952 }
939 953
940 /* Try to read type 2 */ 954 /* Try to read type 2 */
941 status = ti_vread_sync(serial->serial->dev, UMPC_MEMORY_READ, 955 status = ti_vread_sync(serial->serial->dev, UMPC_MEMORY_READ,
942 DTK_ADDR_SPACE_I2C_TYPE_II, 0, &data, 0x01); 956 DTK_ADDR_SPACE_I2C_TYPE_II, 0, data, 0x01);
943 if (status) 957 if (status)
944 dbg("%s - read 2 status error = %d", __func__, status); 958 dbg("%s - read 2 status error = %d", __func__, status);
945 else 959 else
946 dbg("%s - read 2 data = 0x%x", __func__, data); 960 dbg("%s - read 2 data = 0x%x", __func__, *data);
947 if ((!status) && (data == UMP5152 || data == UMP3410)) { 961 if ((!status) && (*data == UMP5152 || *data == UMP3410)) {
948 dbg("%s - ROM_TYPE_II", __func__); 962 dbg("%s - ROM_TYPE_II", __func__);
949 serial->TI_I2C_Type = DTK_ADDR_SPACE_I2C_TYPE_II; 963 serial->TI_I2C_Type = DTK_ADDR_SPACE_I2C_TYPE_II;
950 return 0; 964 goto out;
951 } 965 }
952 966
953 /* Try to read type 3 */ 967 /* Try to read type 3 */
954 status = ti_vread_sync(serial->serial->dev, UMPC_MEMORY_READ, 968 status = ti_vread_sync(serial->serial->dev, UMPC_MEMORY_READ,
955 DTK_ADDR_SPACE_I2C_TYPE_III, 0, &data, 0x01); 969 DTK_ADDR_SPACE_I2C_TYPE_III, 0, data, 0x01);
956 if (status) 970 if (status)
957 dbg("%s - read 3 status error = %d", __func__, status); 971 dbg("%s - read 3 status error = %d", __func__, status);
958 else 972 else
959 dbg("%s - read 2 data = 0x%x", __func__, data); 973 dbg("%s - read 2 data = 0x%x", __func__, *data);
960 if ((!status) && (data == UMP5152 || data == UMP3410)) { 974 if ((!status) && (*data == UMP5152 || *data == UMP3410)) {
961 dbg("%s - ROM_TYPE_III", __func__); 975 dbg("%s - ROM_TYPE_III", __func__);
962 serial->TI_I2C_Type = DTK_ADDR_SPACE_I2C_TYPE_III; 976 serial->TI_I2C_Type = DTK_ADDR_SPACE_I2C_TYPE_III;
963 return 0; 977 goto out;
964 } 978 }
965 979
966 dbg("%s - Unknown", __func__); 980 dbg("%s - Unknown", __func__);
967 serial->TI_I2C_Type = DTK_ADDR_SPACE_I2C_TYPE_II; 981 serial->TI_I2C_Type = DTK_ADDR_SPACE_I2C_TYPE_II;
968 return -ENODEV; 982 status = -ENODEV;
983out:
984 kfree(data);
985 return status;
969} 986}
970 987
971static int bulk_xfer(struct usb_serial *serial, void *buffer, 988static int bulk_xfer(struct usb_serial *serial, void *buffer,
@@ -1113,7 +1130,7 @@ static int download_fw(struct edgeport_serial *serial)
1113 I2C_DESC_TYPE_FIRMWARE_BASIC, rom_desc); 1130 I2C_DESC_TYPE_FIRMWARE_BASIC, rom_desc);
1114 if (start_address != 0) { 1131 if (start_address != 0) {
1115 struct ti_i2c_firmware_rec *firmware_version; 1132 struct ti_i2c_firmware_rec *firmware_version;
1116 __u8 record; 1133 u8 *record;
1117 1134
1118 dbg("%s - Found Type FIRMWARE (Type 2) record", 1135 dbg("%s - Found Type FIRMWARE (Type 2) record",
1119 __func__); 1136 __func__);
@@ -1165,6 +1182,15 @@ static int download_fw(struct edgeport_serial *serial)
1165 OperationalMajorVersion, 1182 OperationalMajorVersion,
1166 OperationalMinorVersion); 1183 OperationalMinorVersion);
1167 1184
1185 record = kmalloc(1, GFP_KERNEL);
1186 if (!record) {
1187 dev_err(dev, "%s - out of memory.\n",
1188 __func__);
1189 kfree(firmware_version);
1190 kfree(rom_desc);
1191 kfree(ti_manuf_desc);
1192 return -ENOMEM;
1193 }
1168 /* In order to update the I2C firmware we must 1194 /* In order to update the I2C firmware we must
1169 * change the type 2 record to type 0xF2. This 1195 * change the type 2 record to type 0xF2. This
1170 * will force the UMP to come up in Boot Mode. 1196 * will force the UMP to come up in Boot Mode.
@@ -1177,13 +1203,14 @@ static int download_fw(struct edgeport_serial *serial)
1177 * firmware will update the record type from 1203 * firmware will update the record type from
1178 * 0xf2 to 0x02. 1204 * 0xf2 to 0x02.
1179 */ 1205 */
1180 record = I2C_DESC_TYPE_FIRMWARE_BLANK; 1206 *record = I2C_DESC_TYPE_FIRMWARE_BLANK;
1181 1207
1182 /* Change the I2C Firmware record type to 1208 /* Change the I2C Firmware record type to
1183 0xf2 to trigger an update */ 1209 0xf2 to trigger an update */
1184 status = write_rom(serial, start_address, 1210 status = write_rom(serial, start_address,
1185 sizeof(record), &record); 1211 sizeof(*record), record);
1186 if (status) { 1212 if (status) {
1213 kfree(record);
1187 kfree(firmware_version); 1214 kfree(firmware_version);
1188 kfree(rom_desc); 1215 kfree(rom_desc);
1189 kfree(ti_manuf_desc); 1216 kfree(ti_manuf_desc);
@@ -1196,19 +1223,21 @@ static int download_fw(struct edgeport_serial *serial)
1196 */ 1223 */
1197 status = read_rom(serial, 1224 status = read_rom(serial,
1198 start_address, 1225 start_address,
1199 sizeof(record), 1226 sizeof(*record),
1200 &record); 1227 record);
1201 if (status) { 1228 if (status) {
1229 kfree(record);
1202 kfree(firmware_version); 1230 kfree(firmware_version);
1203 kfree(rom_desc); 1231 kfree(rom_desc);
1204 kfree(ti_manuf_desc); 1232 kfree(ti_manuf_desc);
1205 return status; 1233 return status;
1206 } 1234 }
1207 1235
1208 if (record != I2C_DESC_TYPE_FIRMWARE_BLANK) { 1236 if (*record != I2C_DESC_TYPE_FIRMWARE_BLANK) {
1209 dev_err(dev, 1237 dev_err(dev,
1210 "%s - error resetting device\n", 1238 "%s - error resetting device\n",
1211 __func__); 1239 __func__);
1240 kfree(record);
1212 kfree(firmware_version); 1241 kfree(firmware_version);
1213 kfree(rom_desc); 1242 kfree(rom_desc);
1214 kfree(ti_manuf_desc); 1243 kfree(ti_manuf_desc);
@@ -1226,6 +1255,7 @@ static int download_fw(struct edgeport_serial *serial)
1226 __func__, status); 1255 __func__, status);
1227 1256
1228 /* return an error on purpose. */ 1257 /* return an error on purpose. */
1258 kfree(record);
1229 kfree(firmware_version); 1259 kfree(firmware_version);
1230 kfree(rom_desc); 1260 kfree(rom_desc);
1231 kfree(ti_manuf_desc); 1261 kfree(ti_manuf_desc);
@@ -1686,7 +1716,7 @@ static void edge_interrupt_callback(struct urb *urb)
1686 case TIUMP_INTERRUPT_CODE_MSR: /* MSR */ 1716 case TIUMP_INTERRUPT_CODE_MSR: /* MSR */
1687 /* Copy MSR from UMP */ 1717 /* Copy MSR from UMP */
1688 msr = data[1]; 1718 msr = data[1];
1689 dbg("%s - ===== Port %u MSR Status = %02x ======\n", 1719 dbg("%s - ===== Port %u MSR Status = %02x ======",
1690 __func__, port_number, msr); 1720 __func__, port_number, msr);
1691 handle_new_msr(edge_port, msr); 1721 handle_new_msr(edge_port, msr);
1692 break; 1722 break;
@@ -1790,7 +1820,6 @@ static void edge_tty_recv(struct device *dev, struct tty_struct *tty,
1790{ 1820{
1791 int queued; 1821 int queued;
1792 1822
1793 tty_buffer_request_room(tty, length);
1794 queued = tty_insert_flip_string(tty, data, length); 1823 queued = tty_insert_flip_string(tty, data, length);
1795 if (queued < length) 1824 if (queued < length)
1796 dev_err(dev, "%s - dropping data, %d bytes lost\n", 1825 dev_err(dev, "%s - dropping data, %d bytes lost\n",
diff --git a/drivers/usb/serial/ipaq.c b/drivers/usb/serial/ipaq.c
index d6231c38813e..3fea9298eb15 100644
--- a/drivers/usb/serial/ipaq.c
+++ b/drivers/usb/serial/ipaq.c
@@ -747,7 +747,6 @@ static void ipaq_read_bulk_callback(struct urb *urb)
747 747
748 tty = tty_port_tty_get(&port->port); 748 tty = tty_port_tty_get(&port->port);
749 if (tty && urb->actual_length) { 749 if (tty && urb->actual_length) {
750 tty_buffer_request_room(tty, urb->actual_length);
751 tty_insert_flip_string(tty, data, urb->actual_length); 750 tty_insert_flip_string(tty, data, urb->actual_length);
752 tty_flip_buffer_push(tty); 751 tty_flip_buffer_push(tty);
753 bytes_in += urb->actual_length; 752 bytes_in += urb->actual_length;
diff --git a/drivers/usb/serial/ipw.c b/drivers/usb/serial/ipw.c
index 727d323f092a..e1d07840cee6 100644
--- a/drivers/usb/serial/ipw.c
+++ b/drivers/usb/serial/ipw.c
@@ -134,7 +134,7 @@ enum {
134 134
135#define IPW_WANTS_TO_SEND 0x30 135#define IPW_WANTS_TO_SEND 0x30
136 136
137static struct usb_device_id usb_ipw_ids[] = { 137static const struct usb_device_id usb_ipw_ids[] = {
138 { USB_DEVICE(IPW_VID, IPW_PID) }, 138 { USB_DEVICE(IPW_VID, IPW_PID) },
139 { }, 139 { },
140}; 140};
@@ -172,7 +172,6 @@ static void ipw_read_bulk_callback(struct urb *urb)
172 172
173 tty = tty_port_tty_get(&port->port); 173 tty = tty_port_tty_get(&port->port);
174 if (tty && urb->actual_length) { 174 if (tty && urb->actual_length) {
175 tty_buffer_request_room(tty, urb->actual_length);
176 tty_insert_flip_string(tty, data, urb->actual_length); 175 tty_insert_flip_string(tty, data, urb->actual_length);
177 tty_flip_buffer_push(tty); 176 tty_flip_buffer_push(tty);
178 } 177 }
diff --git a/drivers/usb/serial/ir-usb.c b/drivers/usb/serial/ir-usb.c
index 95d8d26b9a44..4a0f51974232 100644
--- a/drivers/usb/serial/ir-usb.c
+++ b/drivers/usb/serial/ir-usb.c
@@ -100,7 +100,7 @@ static u8 ir_baud;
100static u8 ir_xbof; 100static u8 ir_xbof;
101static u8 ir_add_bof; 101static u8 ir_add_bof;
102 102
103static struct usb_device_id ir_id_table[] = { 103static const struct usb_device_id ir_id_table[] = {
104 { USB_DEVICE(0x050f, 0x0180) }, /* KC Technology, KC-180 */ 104 { USB_DEVICE(0x050f, 0x0180) }, /* KC Technology, KC-180 */
105 { USB_DEVICE(0x08e9, 0x0100) }, /* XTNDAccess */ 105 { USB_DEVICE(0x08e9, 0x0100) }, /* XTNDAccess */
106 { USB_DEVICE(0x09c4, 0x0011) }, /* ACTiSys ACT-IR2000U */ 106 { USB_DEVICE(0x09c4, 0x0011) }, /* ACTiSys ACT-IR2000U */
@@ -445,11 +445,6 @@ static void ir_read_bulk_callback(struct urb *urb)
445 445
446 dbg("%s - port %d", __func__, port->number); 446 dbg("%s - port %d", __func__, port->number);
447 447
448 if (!port->port.count) {
449 dbg("%s - port closed.", __func__);
450 return;
451 }
452
453 switch (status) { 448 switch (status) {
454 case 0: /* Successful */ 449 case 0: /* Successful */
455 /* 450 /*
@@ -462,10 +457,8 @@ static void ir_read_bulk_callback(struct urb *urb)
462 usb_serial_debug_data(debug, &port->dev, __func__, 457 usb_serial_debug_data(debug, &port->dev, __func__,
463 urb->actual_length, data); 458 urb->actual_length, data);
464 tty = tty_port_tty_get(&port->port); 459 tty = tty_port_tty_get(&port->port);
465 if (tty_buffer_request_room(tty, urb->actual_length - 1)) { 460 tty_insert_flip_string(tty, data+1, urb->actual_length - 1);
466 tty_insert_flip_string(tty, data+1, urb->actual_length - 1); 461 tty_flip_buffer_push(tty);
467 tty_flip_buffer_push(tty);
468 }
469 tty_kref_put(tty); 462 tty_kref_put(tty);
470 463
471 /* 464 /*
diff --git a/drivers/usb/serial/iuu_phoenix.c b/drivers/usb/serial/iuu_phoenix.c
index e6e02b178d2b..43f13cf2f016 100644
--- a/drivers/usb/serial/iuu_phoenix.c
+++ b/drivers/usb/serial/iuu_phoenix.c
@@ -43,7 +43,7 @@ static int debug;
43#define DRIVER_VERSION "v0.11" 43#define DRIVER_VERSION "v0.11"
44#define DRIVER_DESC "Infinity USB Unlimited Phoenix driver" 44#define DRIVER_DESC "Infinity USB Unlimited Phoenix driver"
45 45
46static struct usb_device_id id_table[] = { 46static const struct usb_device_id id_table[] = {
47 {USB_DEVICE(IUU_USB_VENDOR_ID, IUU_USB_PRODUCT_ID)}, 47 {USB_DEVICE(IUU_USB_VENDOR_ID, IUU_USB_PRODUCT_ID)},
48 {} /* Terminating entry */ 48 {} /* Terminating entry */
49}; 49};
diff --git a/drivers/usb/serial/keyspan.c b/drivers/usb/serial/keyspan.c
index f8c4b07033ff..297163c3c610 100644
--- a/drivers/usb/serial/keyspan.c
+++ b/drivers/usb/serial/keyspan.c
@@ -464,13 +464,9 @@ static void usa26_indat_callback(struct urb *urb)
464 464
465 /* Resubmit urb so we continue receiving */ 465 /* Resubmit urb so we continue receiving */
466 urb->dev = port->serial->dev; 466 urb->dev = port->serial->dev;
467 if (port->port.count) { 467 err = usb_submit_urb(urb, GFP_ATOMIC);
468 err = usb_submit_urb(urb, GFP_ATOMIC); 468 if (err != 0)
469 if (err != 0) 469 dbg("%s - resubmit read urb failed. (%d)", __func__, err);
470 dbg("%s - resubmit read urb failed. (%d)",
471 __func__, err);
472 }
473 return;
474} 470}
475 471
476/* Outdat handling is common for all devices */ 472/* Outdat handling is common for all devices */
@@ -483,8 +479,7 @@ static void usa2x_outdat_callback(struct urb *urb)
483 p_priv = usb_get_serial_port_data(port); 479 p_priv = usb_get_serial_port_data(port);
484 dbg("%s - urb %d", __func__, urb == p_priv->out_urbs[1]); 480 dbg("%s - urb %d", __func__, urb == p_priv->out_urbs[1]);
485 481
486 if (port->port.count) 482 usb_serial_port_softint(port);
487 usb_serial_port_softint(port);
488} 483}
489 484
490static void usa26_inack_callback(struct urb *urb) 485static void usa26_inack_callback(struct urb *urb)
@@ -615,12 +610,10 @@ static void usa28_indat_callback(struct urb *urb)
615 610
616 /* Resubmit urb so we continue receiving */ 611 /* Resubmit urb so we continue receiving */
617 urb->dev = port->serial->dev; 612 urb->dev = port->serial->dev;
618 if (port->port.count) { 613 err = usb_submit_urb(urb, GFP_ATOMIC);
619 err = usb_submit_urb(urb, GFP_ATOMIC); 614 if (err != 0)
620 if (err != 0) 615 dbg("%s - resubmit read urb failed. (%d)",
621 dbg("%s - resubmit read urb failed. (%d)", 616 __func__, err);
622 __func__, err);
623 }
624 p_priv->in_flip ^= 1; 617 p_priv->in_flip ^= 1;
625 618
626 urb = p_priv->in_urbs[p_priv->in_flip]; 619 urb = p_priv->in_urbs[p_priv->in_flip];
@@ -856,12 +849,9 @@ static void usa49_indat_callback(struct urb *urb)
856 849
857 /* Resubmit urb so we continue receiving */ 850 /* Resubmit urb so we continue receiving */
858 urb->dev = port->serial->dev; 851 urb->dev = port->serial->dev;
859 if (port->port.count) { 852 err = usb_submit_urb(urb, GFP_ATOMIC);
860 err = usb_submit_urb(urb, GFP_ATOMIC); 853 if (err != 0)
861 if (err != 0) 854 dbg("%s - resubmit read urb failed. (%d)", __func__, err);
862 dbg("%s - resubmit read urb failed. (%d)",
863 __func__, err);
864 }
865} 855}
866 856
867static void usa49wg_indat_callback(struct urb *urb) 857static void usa49wg_indat_callback(struct urb *urb)
@@ -904,11 +894,7 @@ static void usa49wg_indat_callback(struct urb *urb)
904 /* no error on any byte */ 894 /* no error on any byte */
905 i++; 895 i++;
906 for (x = 1; x < len ; ++x) 896 for (x = 1; x < len ; ++x)
907 if (port->port.count) 897 tty_insert_flip_char(tty, data[i++], 0);
908 tty_insert_flip_char(tty,
909 data[i++], 0);
910 else
911 i++;
912 } else { 898 } else {
913 /* 899 /*
914 * some bytes had errors, every byte has status 900 * some bytes had errors, every byte has status
@@ -922,14 +908,12 @@ static void usa49wg_indat_callback(struct urb *urb)
922 if (stat & RXERROR_PARITY) 908 if (stat & RXERROR_PARITY)
923 flag |= TTY_PARITY; 909 flag |= TTY_PARITY;
924 /* XXX should handle break (0x10) */ 910 /* XXX should handle break (0x10) */
925 if (port->port.count) 911 tty_insert_flip_char(tty,
926 tty_insert_flip_char(tty,
927 data[i+1], flag); 912 data[i+1], flag);
928 i += 2; 913 i += 2;
929 } 914 }
930 } 915 }
931 if (port->port.count) 916 tty_flip_buffer_push(tty);
932 tty_flip_buffer_push(tty);
933 tty_kref_put(tty); 917 tty_kref_put(tty);
934 } 918 }
935 } 919 }
@@ -1013,13 +997,9 @@ static void usa90_indat_callback(struct urb *urb)
1013 997
1014 /* Resubmit urb so we continue receiving */ 998 /* Resubmit urb so we continue receiving */
1015 urb->dev = port->serial->dev; 999 urb->dev = port->serial->dev;
1016 if (port->port.count) { 1000 err = usb_submit_urb(urb, GFP_ATOMIC);
1017 err = usb_submit_urb(urb, GFP_ATOMIC); 1001 if (err != 0)
1018 if (err != 0) 1002 dbg("%s - resubmit read urb failed. (%d)", __func__, err);
1019 dbg("%s - resubmit read urb failed. (%d)",
1020 __func__, err);
1021 }
1022 return;
1023} 1003}
1024 1004
1025 1005
@@ -2418,8 +2398,7 @@ static int keyspan_usa90_send_setup(struct usb_serial *serial,
2418 msg.portEnabled = 0; 2398 msg.portEnabled = 0;
2419 /* Sending intermediate configs */ 2399 /* Sending intermediate configs */
2420 else { 2400 else {
2421 if (port->port.count) 2401 msg.portEnabled = 1;
2422 msg.portEnabled = 1;
2423 msg.txBreak = (p_priv->break_on); 2402 msg.txBreak = (p_priv->break_on);
2424 } 2403 }
2425 2404
diff --git a/drivers/usb/serial/keyspan.h b/drivers/usb/serial/keyspan.h
index 30771e5b3973..bf3297ddd186 100644
--- a/drivers/usb/serial/keyspan.h
+++ b/drivers/usb/serial/keyspan.h
@@ -456,7 +456,7 @@ static const struct keyspan_device_details *keyspan_devices[] = {
456 NULL, 456 NULL,
457}; 457};
458 458
459static struct usb_device_id keyspan_ids_combined[] = { 459static const struct usb_device_id keyspan_ids_combined[] = {
460 { USB_DEVICE(KEYSPAN_VENDOR_ID, keyspan_usa18x_pre_product_id) }, 460 { USB_DEVICE(KEYSPAN_VENDOR_ID, keyspan_usa18x_pre_product_id) },
461 { USB_DEVICE(KEYSPAN_VENDOR_ID, keyspan_usa19_pre_product_id) }, 461 { USB_DEVICE(KEYSPAN_VENDOR_ID, keyspan_usa19_pre_product_id) },
462 { USB_DEVICE(KEYSPAN_VENDOR_ID, keyspan_usa19w_pre_product_id) }, 462 { USB_DEVICE(KEYSPAN_VENDOR_ID, keyspan_usa19w_pre_product_id) },
@@ -497,7 +497,7 @@ static struct usb_driver keyspan_driver = {
497}; 497};
498 498
499/* usb_device_id table for the pre-firmware download keyspan devices */ 499/* usb_device_id table for the pre-firmware download keyspan devices */
500static struct usb_device_id keyspan_pre_ids[] = { 500static const struct usb_device_id keyspan_pre_ids[] = {
501 { USB_DEVICE(KEYSPAN_VENDOR_ID, keyspan_usa18x_pre_product_id) }, 501 { USB_DEVICE(KEYSPAN_VENDOR_ID, keyspan_usa18x_pre_product_id) },
502 { USB_DEVICE(KEYSPAN_VENDOR_ID, keyspan_usa19_pre_product_id) }, 502 { USB_DEVICE(KEYSPAN_VENDOR_ID, keyspan_usa19_pre_product_id) },
503 { USB_DEVICE(KEYSPAN_VENDOR_ID, keyspan_usa19qi_pre_product_id) }, 503 { USB_DEVICE(KEYSPAN_VENDOR_ID, keyspan_usa19qi_pre_product_id) },
@@ -513,7 +513,7 @@ static struct usb_device_id keyspan_pre_ids[] = {
513 { } /* Terminating entry */ 513 { } /* Terminating entry */
514}; 514};
515 515
516static struct usb_device_id keyspan_1port_ids[] = { 516static const struct usb_device_id keyspan_1port_ids[] = {
517 { USB_DEVICE(KEYSPAN_VENDOR_ID, keyspan_usa18x_product_id) }, 517 { USB_DEVICE(KEYSPAN_VENDOR_ID, keyspan_usa18x_product_id) },
518 { USB_DEVICE(KEYSPAN_VENDOR_ID, keyspan_usa19_product_id) }, 518 { USB_DEVICE(KEYSPAN_VENDOR_ID, keyspan_usa19_product_id) },
519 { USB_DEVICE(KEYSPAN_VENDOR_ID, keyspan_usa19qi_product_id) }, 519 { USB_DEVICE(KEYSPAN_VENDOR_ID, keyspan_usa19qi_product_id) },
@@ -524,7 +524,7 @@ static struct usb_device_id keyspan_1port_ids[] = {
524 { } /* Terminating entry */ 524 { } /* Terminating entry */
525}; 525};
526 526
527static struct usb_device_id keyspan_2port_ids[] = { 527static const struct usb_device_id keyspan_2port_ids[] = {
528 { USB_DEVICE(KEYSPAN_VENDOR_ID, keyspan_usa28_product_id) }, 528 { USB_DEVICE(KEYSPAN_VENDOR_ID, keyspan_usa28_product_id) },
529 { USB_DEVICE(KEYSPAN_VENDOR_ID, keyspan_usa28x_product_id) }, 529 { USB_DEVICE(KEYSPAN_VENDOR_ID, keyspan_usa28x_product_id) },
530 { USB_DEVICE(KEYSPAN_VENDOR_ID, keyspan_usa28xa_product_id) }, 530 { USB_DEVICE(KEYSPAN_VENDOR_ID, keyspan_usa28xa_product_id) },
@@ -532,7 +532,7 @@ static struct usb_device_id keyspan_2port_ids[] = {
532 { } /* Terminating entry */ 532 { } /* Terminating entry */
533}; 533};
534 534
535static struct usb_device_id keyspan_4port_ids[] = { 535static const struct usb_device_id keyspan_4port_ids[] = {
536 { USB_DEVICE(KEYSPAN_VENDOR_ID, keyspan_usa49w_product_id) }, 536 { USB_DEVICE(KEYSPAN_VENDOR_ID, keyspan_usa49w_product_id) },
537 { USB_DEVICE(KEYSPAN_VENDOR_ID, keyspan_usa49wlc_product_id)}, 537 { USB_DEVICE(KEYSPAN_VENDOR_ID, keyspan_usa49wlc_product_id)},
538 { USB_DEVICE(KEYSPAN_VENDOR_ID, keyspan_usa49wg_product_id)}, 538 { USB_DEVICE(KEYSPAN_VENDOR_ID, keyspan_usa49wg_product_id)},
diff --git a/drivers/usb/serial/keyspan_pda.c b/drivers/usb/serial/keyspan_pda.c
index 1296a097f5c3..185fe9a7d4e0 100644
--- a/drivers/usb/serial/keyspan_pda.c
+++ b/drivers/usb/serial/keyspan_pda.c
@@ -125,7 +125,7 @@ struct keyspan_pda_private {
125#define ENTREGRA_VENDOR_ID 0x1645 125#define ENTREGRA_VENDOR_ID 0x1645
126#define ENTREGRA_FAKE_ID 0x8093 126#define ENTREGRA_FAKE_ID 0x8093
127 127
128static struct usb_device_id id_table_combined [] = { 128static const struct usb_device_id id_table_combined[] = {
129#ifdef KEYSPAN 129#ifdef KEYSPAN
130 { USB_DEVICE(KEYSPAN_VENDOR_ID, KEYSPAN_PDA_FAKE_ID) }, 130 { USB_DEVICE(KEYSPAN_VENDOR_ID, KEYSPAN_PDA_FAKE_ID) },
131#endif 131#endif
@@ -147,20 +147,20 @@ static struct usb_driver keyspan_pda_driver = {
147 .no_dynamic_id = 1, 147 .no_dynamic_id = 1,
148}; 148};
149 149
150static struct usb_device_id id_table_std [] = { 150static const struct usb_device_id id_table_std[] = {
151 { USB_DEVICE(KEYSPAN_VENDOR_ID, KEYSPAN_PDA_ID) }, 151 { USB_DEVICE(KEYSPAN_VENDOR_ID, KEYSPAN_PDA_ID) },
152 { } /* Terminating entry */ 152 { } /* Terminating entry */
153}; 153};
154 154
155#ifdef KEYSPAN 155#ifdef KEYSPAN
156static struct usb_device_id id_table_fake [] = { 156static const struct usb_device_id id_table_fake[] = {
157 { USB_DEVICE(KEYSPAN_VENDOR_ID, KEYSPAN_PDA_FAKE_ID) }, 157 { USB_DEVICE(KEYSPAN_VENDOR_ID, KEYSPAN_PDA_FAKE_ID) },
158 { } /* Terminating entry */ 158 { } /* Terminating entry */
159}; 159};
160#endif 160#endif
161 161
162#ifdef XIRCOM 162#ifdef XIRCOM
163static struct usb_device_id id_table_fake_xircom [] = { 163static const struct usb_device_id id_table_fake_xircom[] = {
164 { USB_DEVICE(XIRCOM_VENDOR_ID, XIRCOM_FAKE_ID) }, 164 { USB_DEVICE(XIRCOM_VENDOR_ID, XIRCOM_FAKE_ID) },
165 { USB_DEVICE(ENTREGRA_VENDOR_ID, ENTREGRA_FAKE_ID) }, 165 { USB_DEVICE(ENTREGRA_VENDOR_ID, ENTREGRA_FAKE_ID) },
166 { } 166 { }
@@ -429,13 +429,20 @@ static int keyspan_pda_get_modem_info(struct usb_serial *serial,
429 unsigned char *value) 429 unsigned char *value)
430{ 430{
431 int rc; 431 int rc;
432 unsigned char data; 432 u8 *data;
433
434 data = kmalloc(1, GFP_KERNEL);
435 if (!data)
436 return -ENOMEM;
437
433 rc = usb_control_msg(serial->dev, usb_rcvctrlpipe(serial->dev, 0), 438 rc = usb_control_msg(serial->dev, usb_rcvctrlpipe(serial->dev, 0),
434 3, /* get pins */ 439 3, /* get pins */
435 USB_TYPE_VENDOR|USB_RECIP_INTERFACE|USB_DIR_IN, 440 USB_TYPE_VENDOR|USB_RECIP_INTERFACE|USB_DIR_IN,
436 0, 0, &data, 1, 2000); 441 0, 0, data, 1, 2000);
437 if (rc >= 0) 442 if (rc >= 0)
438 *value = data; 443 *value = *data;
444
445 kfree(data);
439 return rc; 446 return rc;
440} 447}
441 448
@@ -543,7 +550,14 @@ static int keyspan_pda_write(struct tty_struct *tty,
543 device how much room it really has. This is done only on 550 device how much room it really has. This is done only on
544 scheduler time, since usb_control_msg() sleeps. */ 551 scheduler time, since usb_control_msg() sleeps. */
545 if (count > priv->tx_room && !in_interrupt()) { 552 if (count > priv->tx_room && !in_interrupt()) {
546 unsigned char room; 553 u8 *room;
554
555 room = kmalloc(1, GFP_KERNEL);
556 if (!room) {
557 rc = -ENOMEM;
558 goto exit;
559 }
560
547 rc = usb_control_msg(serial->dev, 561 rc = usb_control_msg(serial->dev,
548 usb_rcvctrlpipe(serial->dev, 0), 562 usb_rcvctrlpipe(serial->dev, 0),
549 6, /* write_room */ 563 6, /* write_room */
@@ -551,9 +565,14 @@ static int keyspan_pda_write(struct tty_struct *tty,
551 | USB_DIR_IN, 565 | USB_DIR_IN,
552 0, /* value: 0 means "remaining room" */ 566 0, /* value: 0 means "remaining room" */
553 0, /* index */ 567 0, /* index */
554 &room, 568 room,
555 1, 569 1,
556 2000); 570 2000);
571 if (rc > 0) {
572 dbg(" roomquery says %d", *room);
573 priv->tx_room = *room;
574 }
575 kfree(room);
557 if (rc < 0) { 576 if (rc < 0) {
558 dbg(" roomquery failed"); 577 dbg(" roomquery failed");
559 goto exit; 578 goto exit;
@@ -563,8 +582,6 @@ static int keyspan_pda_write(struct tty_struct *tty,
563 rc = -EIO; /* device didn't return any data */ 582 rc = -EIO; /* device didn't return any data */
564 goto exit; 583 goto exit;
565 } 584 }
566 dbg(" roomquery says %d", room);
567 priv->tx_room = room;
568 } 585 }
569 if (count > priv->tx_room) { 586 if (count > priv->tx_room) {
570 /* we're about to completely fill the Tx buffer, so 587 /* we're about to completely fill the Tx buffer, so
@@ -684,18 +701,22 @@ static int keyspan_pda_open(struct tty_struct *tty,
684 struct usb_serial_port *port) 701 struct usb_serial_port *port)
685{ 702{
686 struct usb_serial *serial = port->serial; 703 struct usb_serial *serial = port->serial;
687 unsigned char room; 704 u8 *room;
688 int rc = 0; 705 int rc = 0;
689 struct keyspan_pda_private *priv; 706 struct keyspan_pda_private *priv;
690 707
691 /* find out how much room is in the Tx ring */ 708 /* find out how much room is in the Tx ring */
709 room = kmalloc(1, GFP_KERNEL);
710 if (!room)
711 return -ENOMEM;
712
692 rc = usb_control_msg(serial->dev, usb_rcvctrlpipe(serial->dev, 0), 713 rc = usb_control_msg(serial->dev, usb_rcvctrlpipe(serial->dev, 0),
693 6, /* write_room */ 714 6, /* write_room */
694 USB_TYPE_VENDOR | USB_RECIP_INTERFACE 715 USB_TYPE_VENDOR | USB_RECIP_INTERFACE
695 | USB_DIR_IN, 716 | USB_DIR_IN,
696 0, /* value */ 717 0, /* value */
697 0, /* index */ 718 0, /* index */
698 &room, 719 room,
699 1, 720 1,
700 2000); 721 2000);
701 if (rc < 0) { 722 if (rc < 0) {
@@ -708,8 +729,8 @@ static int keyspan_pda_open(struct tty_struct *tty,
708 goto error; 729 goto error;
709 } 730 }
710 priv = usb_get_serial_port_data(port); 731 priv = usb_get_serial_port_data(port);
711 priv->tx_room = room; 732 priv->tx_room = *room;
712 priv->tx_throttled = room ? 0 : 1; 733 priv->tx_throttled = *room ? 0 : 1;
713 734
714 /*Start reading from the device*/ 735 /*Start reading from the device*/
715 port->interrupt_in_urb->dev = serial->dev; 736 port->interrupt_in_urb->dev = serial->dev;
@@ -718,8 +739,8 @@ static int keyspan_pda_open(struct tty_struct *tty,
718 dbg("%s - usb_submit_urb(read int) failed", __func__); 739 dbg("%s - usb_submit_urb(read int) failed", __func__);
719 goto error; 740 goto error;
720 } 741 }
721
722error: 742error:
743 kfree(room);
723 return rc; 744 return rc;
724} 745}
725static void keyspan_pda_close(struct usb_serial_port *port) 746static void keyspan_pda_close(struct usb_serial_port *port)
@@ -789,6 +810,13 @@ static int keyspan_pda_fake_startup(struct usb_serial *serial)
789 return 1; 810 return 1;
790} 811}
791 812
813#ifdef KEYSPAN
814MODULE_FIRMWARE("keyspan_pda/keyspan_pda.fw");
815#endif
816#ifdef XIRCOM
817MODULE_FIRMWARE("keyspan_pda/xircom_pgs.fw");
818#endif
819
792static int keyspan_pda_startup(struct usb_serial *serial) 820static int keyspan_pda_startup(struct usb_serial *serial)
793{ 821{
794 822
diff --git a/drivers/usb/serial/kl5kusb105.c b/drivers/usb/serial/kl5kusb105.c
index 3a7873806f46..8eef91ba4b1c 100644
--- a/drivers/usb/serial/kl5kusb105.c
+++ b/drivers/usb/serial/kl5kusb105.c
@@ -94,7 +94,7 @@ static int klsi_105_tiocmset(struct tty_struct *tty, struct file *file,
94/* 94/*
95 * All of the device info needed for the KLSI converters. 95 * All of the device info needed for the KLSI converters.
96 */ 96 */
97static struct usb_device_id id_table [] = { 97static const struct usb_device_id id_table[] = {
98 { USB_DEVICE(PALMCONNECT_VID, PALMCONNECT_PID) }, 98 { USB_DEVICE(PALMCONNECT_VID, PALMCONNECT_PID) },
99 { USB_DEVICE(KLSI_VID, KLSI_KL5KUSB105D_PID) }, 99 { USB_DEVICE(KLSI_VID, KLSI_KL5KUSB105D_PID) },
100 { } /* Terminating entry */ 100 { } /* Terminating entry */
@@ -212,10 +212,19 @@ static int klsi_105_get_line_state(struct usb_serial_port *port,
212 unsigned long *line_state_p) 212 unsigned long *line_state_p)
213{ 213{
214 int rc; 214 int rc;
215 __u8 status_buf[KLSI_STATUSBUF_LEN] = { -1, -1}; 215 u8 *status_buf;
216 __u16 status; 216 __u16 status;
217 217
218 dev_info(&port->serial->dev->dev, "sending SIO Poll request\n"); 218 dev_info(&port->serial->dev->dev, "sending SIO Poll request\n");
219
220 status_buf = kmalloc(KLSI_STATUSBUF_LEN, GFP_KERNEL);
221 if (!status_buf) {
222 dev_err(&port->dev, "%s - out of memory for status buffer.\n",
223 __func__);
224 return -ENOMEM;
225 }
226 status_buf[0] = 0xff;
227 status_buf[1] = 0xff;
219 rc = usb_control_msg(port->serial->dev, 228 rc = usb_control_msg(port->serial->dev,
220 usb_rcvctrlpipe(port->serial->dev, 0), 229 usb_rcvctrlpipe(port->serial->dev, 0),
221 KL5KUSB105A_SIO_POLL, 230 KL5KUSB105A_SIO_POLL,
@@ -236,6 +245,8 @@ static int klsi_105_get_line_state(struct usb_serial_port *port,
236 245
237 *line_state_p = klsi_105_status2linestate(status); 246 *line_state_p = klsi_105_status2linestate(status);
238 } 247 }
248
249 kfree(status_buf);
239 return rc; 250 return rc;
240} 251}
241 252
@@ -364,7 +375,7 @@ static int klsi_105_open(struct tty_struct *tty, struct usb_serial_port *port)
364 int rc; 375 int rc;
365 int i; 376 int i;
366 unsigned long line_state; 377 unsigned long line_state;
367 struct klsi_105_port_settings cfg; 378 struct klsi_105_port_settings *cfg;
368 unsigned long flags; 379 unsigned long flags;
369 380
370 dbg("%s port %d", __func__, port->number); 381 dbg("%s port %d", __func__, port->number);
@@ -376,12 +387,18 @@ static int klsi_105_open(struct tty_struct *tty, struct usb_serial_port *port)
376 * Then read the modem line control and store values in 387 * Then read the modem line control and store values in
377 * priv->line_state. 388 * priv->line_state.
378 */ 389 */
379 cfg.pktlen = 5; 390 cfg = kmalloc(sizeof(*cfg), GFP_KERNEL);
380 cfg.baudrate = kl5kusb105a_sio_b9600; 391 if (!cfg) {
381 cfg.databits = kl5kusb105a_dtb_8; 392 dev_err(&port->dev, "%s - out of memory for config buffer.\n",
382 cfg.unknown1 = 0; 393 __func__);
383 cfg.unknown2 = 1; 394 return -ENOMEM;
384 klsi_105_chg_port_settings(port, &cfg); 395 }
396 cfg->pktlen = 5;
397 cfg->baudrate = kl5kusb105a_sio_b9600;
398 cfg->databits = kl5kusb105a_dtb_8;
399 cfg->unknown1 = 0;
400 cfg->unknown2 = 1;
401 klsi_105_chg_port_settings(port, cfg);
385 402
386 /* set up termios structure */ 403 /* set up termios structure */
387 spin_lock_irqsave(&priv->lock, flags); 404 spin_lock_irqsave(&priv->lock, flags);
@@ -391,11 +408,11 @@ static int klsi_105_open(struct tty_struct *tty, struct usb_serial_port *port)
391 priv->termios.c_lflag = tty->termios->c_lflag; 408 priv->termios.c_lflag = tty->termios->c_lflag;
392 for (i = 0; i < NCCS; i++) 409 for (i = 0; i < NCCS; i++)
393 priv->termios.c_cc[i] = tty->termios->c_cc[i]; 410 priv->termios.c_cc[i] = tty->termios->c_cc[i];
394 priv->cfg.pktlen = cfg.pktlen; 411 priv->cfg.pktlen = cfg->pktlen;
395 priv->cfg.baudrate = cfg.baudrate; 412 priv->cfg.baudrate = cfg->baudrate;
396 priv->cfg.databits = cfg.databits; 413 priv->cfg.databits = cfg->databits;
397 priv->cfg.unknown1 = cfg.unknown1; 414 priv->cfg.unknown1 = cfg->unknown1;
398 priv->cfg.unknown2 = cfg.unknown2; 415 priv->cfg.unknown2 = cfg->unknown2;
399 spin_unlock_irqrestore(&priv->lock, flags); 416 spin_unlock_irqrestore(&priv->lock, flags);
400 417
401 /* READ_ON and urb submission */ 418 /* READ_ON and urb submission */
@@ -441,6 +458,7 @@ static int klsi_105_open(struct tty_struct *tty, struct usb_serial_port *port)
441 retval = rc; 458 retval = rc;
442 459
443exit: 460exit:
461 kfree(cfg);
444 return retval; 462 return retval;
445} /* klsi_105_open */ 463} /* klsi_105_open */
446 464
@@ -681,7 +699,6 @@ static void klsi_105_read_bulk_callback(struct urb *urb)
681 bytes_sent = urb->actual_length - 2; 699 bytes_sent = urb->actual_length - 2;
682 } 700 }
683 701
684 tty_buffer_request_room(tty, bytes_sent);
685 tty_insert_flip_string(tty, data + 2, bytes_sent); 702 tty_insert_flip_string(tty, data + 2, bytes_sent);
686 tty_flip_buffer_push(tty); 703 tty_flip_buffer_push(tty);
687 tty_kref_put(tty); 704 tty_kref_put(tty);
@@ -714,10 +731,17 @@ static void klsi_105_set_termios(struct tty_struct *tty,
714 unsigned int old_iflag = old_termios->c_iflag; 731 unsigned int old_iflag = old_termios->c_iflag;
715 unsigned int cflag = tty->termios->c_cflag; 732 unsigned int cflag = tty->termios->c_cflag;
716 unsigned int old_cflag = old_termios->c_cflag; 733 unsigned int old_cflag = old_termios->c_cflag;
717 struct klsi_105_port_settings cfg; 734 struct klsi_105_port_settings *cfg;
718 unsigned long flags; 735 unsigned long flags;
719 speed_t baud; 736 speed_t baud;
720 737
738 cfg = kmalloc(sizeof(*cfg), GFP_KERNEL);
739 if (!cfg) {
740 dev_err(&port->dev, "%s - out of memory for config buffer.\n",
741 __func__);
742 return;
743 }
744
721 /* lock while we are modifying the settings */ 745 /* lock while we are modifying the settings */
722 spin_lock_irqsave(&priv->lock, flags); 746 spin_lock_irqsave(&priv->lock, flags);
723 747
@@ -793,11 +817,11 @@ static void klsi_105_set_termios(struct tty_struct *tty,
793 case CS5: 817 case CS5:
794 dbg("%s - 5 bits/byte not supported", __func__); 818 dbg("%s - 5 bits/byte not supported", __func__);
795 spin_unlock_irqrestore(&priv->lock, flags); 819 spin_unlock_irqrestore(&priv->lock, flags);
796 return ; 820 goto err;
797 case CS6: 821 case CS6:
798 dbg("%s - 6 bits/byte not supported", __func__); 822 dbg("%s - 6 bits/byte not supported", __func__);
799 spin_unlock_irqrestore(&priv->lock, flags); 823 spin_unlock_irqrestore(&priv->lock, flags);
800 return ; 824 goto err;
801 case CS7: 825 case CS7:
802 priv->cfg.databits = kl5kusb105a_dtb_7; 826 priv->cfg.databits = kl5kusb105a_dtb_7;
803 break; 827 break;
@@ -856,11 +880,13 @@ static void klsi_105_set_termios(struct tty_struct *tty,
856#endif 880#endif
857 ; 881 ;
858 } 882 }
859 memcpy(&cfg, &priv->cfg, sizeof(cfg)); 883 memcpy(cfg, &priv->cfg, sizeof(*cfg));
860 spin_unlock_irqrestore(&priv->lock, flags); 884 spin_unlock_irqrestore(&priv->lock, flags);
861 885
862 /* now commit changes to device */ 886 /* now commit changes to device */
863 klsi_105_chg_port_settings(port, &cfg); 887 klsi_105_chg_port_settings(port, cfg);
888err:
889 kfree(cfg);
864} /* klsi_105_set_termios */ 890} /* klsi_105_set_termios */
865 891
866 892
diff --git a/drivers/usb/serial/kobil_sct.c b/drivers/usb/serial/kobil_sct.c
index 45ea694b3ae6..c113a2a0e10c 100644
--- a/drivers/usb/serial/kobil_sct.c
+++ b/drivers/usb/serial/kobil_sct.c
@@ -86,7 +86,7 @@ static void kobil_set_termios(struct tty_struct *tty,
86 struct usb_serial_port *port, struct ktermios *old); 86 struct usb_serial_port *port, struct ktermios *old);
87static void kobil_init_termios(struct tty_struct *tty); 87static void kobil_init_termios(struct tty_struct *tty);
88 88
89static struct usb_device_id id_table [] = { 89static const struct usb_device_id id_table[] = {
90 { USB_DEVICE(KOBIL_VENDOR_ID, KOBIL_ADAPTER_B_PRODUCT_ID) }, 90 { USB_DEVICE(KOBIL_VENDOR_ID, KOBIL_ADAPTER_B_PRODUCT_ID) },
91 { USB_DEVICE(KOBIL_VENDOR_ID, KOBIL_ADAPTER_K_PRODUCT_ID) }, 91 { USB_DEVICE(KOBIL_VENDOR_ID, KOBIL_ADAPTER_K_PRODUCT_ID) },
92 { USB_DEVICE(KOBIL_VENDOR_ID, KOBIL_USBTWIN_PRODUCT_ID) }, 92 { USB_DEVICE(KOBIL_VENDOR_ID, KOBIL_USBTWIN_PRODUCT_ID) },
@@ -388,7 +388,6 @@ static void kobil_read_int_callback(struct urb *urb)
388 */ 388 */
389 /* END DEBUG */ 389 /* END DEBUG */
390 390
391 tty_buffer_request_room(tty, urb->actual_length);
392 tty_insert_flip_string(tty, data, urb->actual_length); 391 tty_insert_flip_string(tty, data, urb->actual_length);
393 tty_flip_buffer_push(tty); 392 tty_flip_buffer_push(tty);
394 } 393 }
@@ -624,7 +623,6 @@ static void kobil_set_termios(struct tty_struct *tty,
624 unsigned short urb_val = 0; 623 unsigned short urb_val = 0;
625 int c_cflag = tty->termios->c_cflag; 624 int c_cflag = tty->termios->c_cflag;
626 speed_t speed; 625 speed_t speed;
627 void *settings;
628 626
629 priv = usb_get_serial_port_data(port); 627 priv = usb_get_serial_port_data(port);
630 if (priv->device_type == KOBIL_USBTWIN_PRODUCT_ID || 628 if (priv->device_type == KOBIL_USBTWIN_PRODUCT_ID ||
@@ -647,25 +645,13 @@ static void kobil_set_termios(struct tty_struct *tty,
647 } 645 }
648 urb_val |= (c_cflag & CSTOPB) ? SUSBCR_SPASB_2StopBits : 646 urb_val |= (c_cflag & CSTOPB) ? SUSBCR_SPASB_2StopBits :
649 SUSBCR_SPASB_1StopBit; 647 SUSBCR_SPASB_1StopBit;
650
651 settings = kzalloc(50, GFP_KERNEL);
652 if (!settings)
653 return;
654
655 sprintf(settings, "%d ", speed);
656
657 if (c_cflag & PARENB) { 648 if (c_cflag & PARENB) {
658 if (c_cflag & PARODD) { 649 if (c_cflag & PARODD)
659 urb_val |= SUSBCR_SPASB_OddParity; 650 urb_val |= SUSBCR_SPASB_OddParity;
660 strcat(settings, "Odd Parity"); 651 else
661 } else {
662 urb_val |= SUSBCR_SPASB_EvenParity; 652 urb_val |= SUSBCR_SPASB_EvenParity;
663 strcat(settings, "Even Parity"); 653 } else
664 }
665 } else {
666 urb_val |= SUSBCR_SPASB_NoParity; 654 urb_val |= SUSBCR_SPASB_NoParity;
667 strcat(settings, "No Parity");
668 }
669 tty->termios->c_cflag &= ~CMSPAR; 655 tty->termios->c_cflag &= ~CMSPAR;
670 tty_encode_baud_rate(tty, speed, speed); 656 tty_encode_baud_rate(tty, speed, speed);
671 657
@@ -675,11 +661,10 @@ static void kobil_set_termios(struct tty_struct *tty,
675 USB_TYPE_VENDOR | USB_RECIP_ENDPOINT | USB_DIR_OUT, 661 USB_TYPE_VENDOR | USB_RECIP_ENDPOINT | USB_DIR_OUT,
676 urb_val, 662 urb_val,
677 0, 663 0,
678 settings, 664 NULL,
679 0, 665 0,
680 KOBIL_TIMEOUT 666 KOBIL_TIMEOUT
681 ); 667 );
682 kfree(settings);
683} 668}
684 669
685static int kobil_ioctl(struct tty_struct *tty, struct file *file, 670static int kobil_ioctl(struct tty_struct *tty, struct file *file,
diff --git a/drivers/usb/serial/mct_u232.c b/drivers/usb/serial/mct_u232.c
index cd009cb280a5..2849f8c32015 100644
--- a/drivers/usb/serial/mct_u232.c
+++ b/drivers/usb/serial/mct_u232.c
@@ -75,6 +75,7 @@
75#include <linux/module.h> 75#include <linux/module.h>
76#include <linux/spinlock.h> 76#include <linux/spinlock.h>
77#include <linux/uaccess.h> 77#include <linux/uaccess.h>
78#include <asm/unaligned.h>
78#include <linux/usb.h> 79#include <linux/usb.h>
79#include <linux/usb/serial.h> 80#include <linux/usb/serial.h>
80#include "mct_u232.h" 81#include "mct_u232.h"
@@ -110,7 +111,7 @@ static void mct_u232_unthrottle(struct tty_struct *tty);
110/* 111/*
111 * All of the device info needed for the MCT USB-RS232 converter. 112 * All of the device info needed for the MCT USB-RS232 converter.
112 */ 113 */
113static struct usb_device_id id_table_combined [] = { 114static const struct usb_device_id id_table_combined[] = {
114 { USB_DEVICE(MCT_U232_VID, MCT_U232_PID) }, 115 { USB_DEVICE(MCT_U232_VID, MCT_U232_PID) },
115 { USB_DEVICE(MCT_U232_VID, MCT_U232_SITECOM_PID) }, 116 { USB_DEVICE(MCT_U232_VID, MCT_U232_SITECOM_PID) },
116 { USB_DEVICE(MCT_U232_VID, MCT_U232_DU_H3SP_PID) }, 117 { USB_DEVICE(MCT_U232_VID, MCT_U232_DU_H3SP_PID) },
@@ -231,19 +232,22 @@ static int mct_u232_calculate_baud_rate(struct usb_serial *serial,
231static int mct_u232_set_baud_rate(struct tty_struct *tty, 232static int mct_u232_set_baud_rate(struct tty_struct *tty,
232 struct usb_serial *serial, struct usb_serial_port *port, speed_t value) 233 struct usb_serial *serial, struct usb_serial_port *port, speed_t value)
233{ 234{
234 __le32 divisor; 235 unsigned int divisor;
235 int rc; 236 int rc;
236 unsigned char zero_byte = 0; 237 unsigned char *buf;
237 unsigned char cts_enable_byte = 0; 238 unsigned char cts_enable_byte = 0;
238 speed_t speed; 239 speed_t speed;
239 240
240 divisor = cpu_to_le32(mct_u232_calculate_baud_rate(serial, value, 241 buf = kmalloc(MCT_U232_MAX_SIZE, GFP_KERNEL);
241 &speed)); 242 if (buf == NULL)
243 return -ENOMEM;
242 244
245 divisor = mct_u232_calculate_baud_rate(serial, value, &speed);
246 put_unaligned_le32(cpu_to_le32(divisor), buf);
243 rc = usb_control_msg(serial->dev, usb_sndctrlpipe(serial->dev, 0), 247 rc = usb_control_msg(serial->dev, usb_sndctrlpipe(serial->dev, 0),
244 MCT_U232_SET_BAUD_RATE_REQUEST, 248 MCT_U232_SET_BAUD_RATE_REQUEST,
245 MCT_U232_SET_REQUEST_TYPE, 249 MCT_U232_SET_REQUEST_TYPE,
246 0, 0, &divisor, MCT_U232_SET_BAUD_RATE_SIZE, 250 0, 0, buf, MCT_U232_SET_BAUD_RATE_SIZE,
247 WDR_TIMEOUT); 251 WDR_TIMEOUT);
248 if (rc < 0) /*FIXME: What value speed results */ 252 if (rc < 0) /*FIXME: What value speed results */
249 dev_err(&port->dev, "Set BAUD RATE %d failed (error = %d)\n", 253 dev_err(&port->dev, "Set BAUD RATE %d failed (error = %d)\n",
@@ -269,10 +273,11 @@ static int mct_u232_set_baud_rate(struct tty_struct *tty,
269 a device which is not asserting 'CTS'. 273 a device which is not asserting 'CTS'.
270 */ 274 */
271 275
276 buf[0] = 0;
272 rc = usb_control_msg(serial->dev, usb_sndctrlpipe(serial->dev, 0), 277 rc = usb_control_msg(serial->dev, usb_sndctrlpipe(serial->dev, 0),
273 MCT_U232_SET_UNKNOWN1_REQUEST, 278 MCT_U232_SET_UNKNOWN1_REQUEST,
274 MCT_U232_SET_REQUEST_TYPE, 279 MCT_U232_SET_REQUEST_TYPE,
275 0, 0, &zero_byte, MCT_U232_SET_UNKNOWN1_SIZE, 280 0, 0, buf, MCT_U232_SET_UNKNOWN1_SIZE,
276 WDR_TIMEOUT); 281 WDR_TIMEOUT);
277 if (rc < 0) 282 if (rc < 0)
278 dev_err(&port->dev, "Sending USB device request code %d " 283 dev_err(&port->dev, "Sending USB device request code %d "
@@ -284,30 +289,40 @@ static int mct_u232_set_baud_rate(struct tty_struct *tty,
284 289
285 dbg("set_baud_rate: send second control message, data = %02X", 290 dbg("set_baud_rate: send second control message, data = %02X",
286 cts_enable_byte); 291 cts_enable_byte);
292 buf[0] = cts_enable_byte;
287 rc = usb_control_msg(serial->dev, usb_sndctrlpipe(serial->dev, 0), 293 rc = usb_control_msg(serial->dev, usb_sndctrlpipe(serial->dev, 0),
288 MCT_U232_SET_CTS_REQUEST, 294 MCT_U232_SET_CTS_REQUEST,
289 MCT_U232_SET_REQUEST_TYPE, 295 MCT_U232_SET_REQUEST_TYPE,
290 0, 0, &cts_enable_byte, MCT_U232_SET_CTS_SIZE, 296 0, 0, buf, MCT_U232_SET_CTS_SIZE,
291 WDR_TIMEOUT); 297 WDR_TIMEOUT);
292 if (rc < 0) 298 if (rc < 0)
293 dev_err(&port->dev, "Sending USB device request code %d " 299 dev_err(&port->dev, "Sending USB device request code %d "
294 "failed (error = %d)\n", MCT_U232_SET_CTS_REQUEST, rc); 300 "failed (error = %d)\n", MCT_U232_SET_CTS_REQUEST, rc);
295 301
302 kfree(buf);
296 return rc; 303 return rc;
297} /* mct_u232_set_baud_rate */ 304} /* mct_u232_set_baud_rate */
298 305
299static int mct_u232_set_line_ctrl(struct usb_serial *serial, unsigned char lcr) 306static int mct_u232_set_line_ctrl(struct usb_serial *serial, unsigned char lcr)
300{ 307{
301 int rc; 308 int rc;
309 unsigned char *buf;
310
311 buf = kmalloc(MCT_U232_MAX_SIZE, GFP_KERNEL);
312 if (buf == NULL)
313 return -ENOMEM;
314
315 buf[0] = lcr;
302 rc = usb_control_msg(serial->dev, usb_sndctrlpipe(serial->dev, 0), 316 rc = usb_control_msg(serial->dev, usb_sndctrlpipe(serial->dev, 0),
303 MCT_U232_SET_LINE_CTRL_REQUEST, 317 MCT_U232_SET_LINE_CTRL_REQUEST,
304 MCT_U232_SET_REQUEST_TYPE, 318 MCT_U232_SET_REQUEST_TYPE,
305 0, 0, &lcr, MCT_U232_SET_LINE_CTRL_SIZE, 319 0, 0, buf, MCT_U232_SET_LINE_CTRL_SIZE,
306 WDR_TIMEOUT); 320 WDR_TIMEOUT);
307 if (rc < 0) 321 if (rc < 0)
308 dev_err(&serial->dev->dev, 322 dev_err(&serial->dev->dev,
309 "Set LINE CTRL 0x%x failed (error = %d)\n", lcr, rc); 323 "Set LINE CTRL 0x%x failed (error = %d)\n", lcr, rc);
310 dbg("set_line_ctrl: 0x%x", lcr); 324 dbg("set_line_ctrl: 0x%x", lcr);
325 kfree(buf);
311 return rc; 326 return rc;
312} /* mct_u232_set_line_ctrl */ 327} /* mct_u232_set_line_ctrl */
313 328
@@ -315,23 +330,31 @@ static int mct_u232_set_modem_ctrl(struct usb_serial *serial,
315 unsigned int control_state) 330 unsigned int control_state)
316{ 331{
317 int rc; 332 int rc;
318 unsigned char mcr = MCT_U232_MCR_NONE; 333 unsigned char mcr;
334 unsigned char *buf;
335
336 buf = kmalloc(MCT_U232_MAX_SIZE, GFP_KERNEL);
337 if (buf == NULL)
338 return -ENOMEM;
319 339
340 mcr = MCT_U232_MCR_NONE;
320 if (control_state & TIOCM_DTR) 341 if (control_state & TIOCM_DTR)
321 mcr |= MCT_U232_MCR_DTR; 342 mcr |= MCT_U232_MCR_DTR;
322 if (control_state & TIOCM_RTS) 343 if (control_state & TIOCM_RTS)
323 mcr |= MCT_U232_MCR_RTS; 344 mcr |= MCT_U232_MCR_RTS;
324 345
346 buf[0] = mcr;
325 rc = usb_control_msg(serial->dev, usb_sndctrlpipe(serial->dev, 0), 347 rc = usb_control_msg(serial->dev, usb_sndctrlpipe(serial->dev, 0),
326 MCT_U232_SET_MODEM_CTRL_REQUEST, 348 MCT_U232_SET_MODEM_CTRL_REQUEST,
327 MCT_U232_SET_REQUEST_TYPE, 349 MCT_U232_SET_REQUEST_TYPE,
328 0, 0, &mcr, MCT_U232_SET_MODEM_CTRL_SIZE, 350 0, 0, buf, MCT_U232_SET_MODEM_CTRL_SIZE,
329 WDR_TIMEOUT); 351 WDR_TIMEOUT);
330 if (rc < 0) 352 if (rc < 0)
331 dev_err(&serial->dev->dev, 353 dev_err(&serial->dev->dev,
332 "Set MODEM CTRL 0x%x failed (error = %d)\n", mcr, rc); 354 "Set MODEM CTRL 0x%x failed (error = %d)\n", mcr, rc);
333 dbg("set_modem_ctrl: state=0x%x ==> mcr=0x%x", control_state, mcr); 355 dbg("set_modem_ctrl: state=0x%x ==> mcr=0x%x", control_state, mcr);
334 356
357 kfree(buf);
335 return rc; 358 return rc;
336} /* mct_u232_set_modem_ctrl */ 359} /* mct_u232_set_modem_ctrl */
337 360
@@ -339,17 +362,27 @@ static int mct_u232_get_modem_stat(struct usb_serial *serial,
339 unsigned char *msr) 362 unsigned char *msr)
340{ 363{
341 int rc; 364 int rc;
365 unsigned char *buf;
366
367 buf = kmalloc(MCT_U232_MAX_SIZE, GFP_KERNEL);
368 if (buf == NULL) {
369 *msr = 0;
370 return -ENOMEM;
371 }
342 rc = usb_control_msg(serial->dev, usb_rcvctrlpipe(serial->dev, 0), 372 rc = usb_control_msg(serial->dev, usb_rcvctrlpipe(serial->dev, 0),
343 MCT_U232_GET_MODEM_STAT_REQUEST, 373 MCT_U232_GET_MODEM_STAT_REQUEST,
344 MCT_U232_GET_REQUEST_TYPE, 374 MCT_U232_GET_REQUEST_TYPE,
345 0, 0, msr, MCT_U232_GET_MODEM_STAT_SIZE, 375 0, 0, buf, MCT_U232_GET_MODEM_STAT_SIZE,
346 WDR_TIMEOUT); 376 WDR_TIMEOUT);
347 if (rc < 0) { 377 if (rc < 0) {
348 dev_err(&serial->dev->dev, 378 dev_err(&serial->dev->dev,
349 "Get MODEM STATus failed (error = %d)\n", rc); 379 "Get MODEM STATus failed (error = %d)\n", rc);
350 *msr = 0; 380 *msr = 0;
381 } else {
382 *msr = buf[0];
351 } 383 }
352 dbg("get_modem_stat: 0x%x", *msr); 384 dbg("get_modem_stat: 0x%x", *msr);
385 kfree(buf);
353 return rc; 386 return rc;
354} /* mct_u232_get_modem_stat */ 387} /* mct_u232_get_modem_stat */
355 388
diff --git a/drivers/usb/serial/mct_u232.h b/drivers/usb/serial/mct_u232.h
index 07b6bec31dc8..7417d5ce1e23 100644
--- a/drivers/usb/serial/mct_u232.h
+++ b/drivers/usb/serial/mct_u232.h
@@ -73,6 +73,8 @@
73#define MCT_U232_SET_CTS_REQUEST 12 73#define MCT_U232_SET_CTS_REQUEST 12
74#define MCT_U232_SET_CTS_SIZE 1 74#define MCT_U232_SET_CTS_SIZE 1
75 75
76#define MCT_U232_MAX_SIZE 4 /* of MCT_XXX_SIZE */
77
76/* 78/*
77 * Baud rate (divisor) 79 * Baud rate (divisor)
78 * Actually, there are two of them, MCT website calls them "Philips solution" 80 * Actually, there are two of them, MCT website calls them "Philips solution"
diff --git a/drivers/usb/serial/mos7720.c b/drivers/usb/serial/mos7720.c
index 763e32a44be0..0d47f2c4d59f 100644
--- a/drivers/usb/serial/mos7720.c
+++ b/drivers/usb/serial/mos7720.c
@@ -81,12 +81,15 @@ struct moschip_serial {
81 81
82static int debug; 82static int debug;
83 83
84static struct usb_serial_driver moschip7720_2port_driver;
85
84#define USB_VENDOR_ID_MOSCHIP 0x9710 86#define USB_VENDOR_ID_MOSCHIP 0x9710
85#define MOSCHIP_DEVICE_ID_7720 0x7720 87#define MOSCHIP_DEVICE_ID_7720 0x7720
86#define MOSCHIP_DEVICE_ID_7715 0x7715 88#define MOSCHIP_DEVICE_ID_7715 0x7715
87 89
88static struct usb_device_id moschip_port_id_table[] = { 90static const struct usb_device_id moschip_port_id_table[] = {
89 { USB_DEVICE(USB_VENDOR_ID_MOSCHIP, MOSCHIP_DEVICE_ID_7720) }, 91 { USB_DEVICE(USB_VENDOR_ID_MOSCHIP, MOSCHIP_DEVICE_ID_7720) },
92 { USB_DEVICE(USB_VENDOR_ID_MOSCHIP, MOSCHIP_DEVICE_ID_7715) },
90 { } /* terminating entry */ 93 { } /* terminating entry */
91}; 94};
92MODULE_DEVICE_TABLE(usb, moschip_port_id_table); 95MODULE_DEVICE_TABLE(usb, moschip_port_id_table);
@@ -106,7 +109,7 @@ static void mos7720_interrupt_callback(struct urb *urb)
106 __u8 sp1; 109 __u8 sp1;
107 __u8 sp2; 110 __u8 sp2;
108 111
109 dbg("%s", " : Entering\n"); 112 dbg(" : Entering");
110 113
111 switch (status) { 114 switch (status) {
112 case 0: 115 case 0:
@@ -186,6 +189,75 @@ exit:
186} 189}
187 190
188/* 191/*
192 * mos7715_interrupt_callback
193 * this is the 7715's callback function for when we have received data on
194 * the interrupt endpoint.
195 */
196static void mos7715_interrupt_callback(struct urb *urb)
197{
198 int result;
199 int length;
200 int status = urb->status;
201 __u8 *data;
202 __u8 iir;
203
204 switch (status) {
205 case 0:
206 /* success */
207 break;
208 case -ECONNRESET:
209 case -ENOENT:
210 case -ESHUTDOWN:
211 /* this urb is terminated, clean up */
212 dbg("%s - urb shutting down with status: %d", __func__,
213 status);
214 return;
215 default:
216 dbg("%s - nonzero urb status received: %d", __func__,
217 status);
218 goto exit;
219 }
220
221 length = urb->actual_length;
222 data = urb->transfer_buffer;
223
224 /* Structure of data from 7715 device:
225 * Byte 1: IIR serial Port
226 * Byte 2: unused
227 * Byte 2: DSR parallel port
228 * Byte 4: FIFO status for both */
229
230 if (unlikely(length != 4)) {
231 dbg("Wrong data !!!");
232 return;
233 }
234
235 iir = data[0];
236 if (!(iir & 0x01)) { /* serial port interrupt pending */
237 switch (iir & 0x0f) {
238 case SERIAL_IIR_RLS:
239 dbg("Serial Port: Receiver status error or address "
240 "bit detected in 9-bit mode\n");
241 break;
242 case SERIAL_IIR_CTI:
243 dbg("Serial Port: Receiver time out");
244 break;
245 case SERIAL_IIR_MS:
246 dbg("Serial Port: Modem status change");
247 break;
248 }
249 }
250
251exit:
252 result = usb_submit_urb(urb, GFP_ATOMIC);
253 if (result)
254 dev_err(&urb->dev->dev,
255 "%s - Error %d submitting control urb\n",
256 __func__, result);
257 return;
258}
259
260/*
189 * mos7720_bulk_in_callback 261 * mos7720_bulk_in_callback
190 * this is the callback function for when we have received data on the 262 * this is the callback function for when we have received data on the
191 * bulk in endpoint. 263 * bulk in endpoint.
@@ -206,7 +278,7 @@ static void mos7720_bulk_in_callback(struct urb *urb)
206 278
207 mos7720_port = urb->context; 279 mos7720_port = urb->context;
208 if (!mos7720_port) { 280 if (!mos7720_port) {
209 dbg("%s", "NULL mos7720_port pointer \n"); 281 dbg("NULL mos7720_port pointer");
210 return ; 282 return ;
211 } 283 }
212 284
@@ -218,7 +290,6 @@ static void mos7720_bulk_in_callback(struct urb *urb)
218 290
219 tty = tty_port_tty_get(&port->port); 291 tty = tty_port_tty_get(&port->port);
220 if (tty && urb->actual_length) { 292 if (tty && urb->actual_length) {
221 tty_buffer_request_room(tty, urb->actual_length);
222 tty_insert_flip_string(tty, data, urb->actual_length); 293 tty_insert_flip_string(tty, data, urb->actual_length);
223 tty_flip_buffer_push(tty); 294 tty_flip_buffer_push(tty);
224 } 295 }
@@ -275,17 +346,15 @@ static void mos7720_bulk_out_data_callback(struct urb *urb)
275 * this function will be used for sending command to device 346 * this function will be used for sending command to device
276 */ 347 */
277static int send_mos_cmd(struct usb_serial *serial, __u8 request, __u16 value, 348static int send_mos_cmd(struct usb_serial *serial, __u8 request, __u16 value,
278 __u16 index, void *data) 349 __u16 index, u8 *data)
279{ 350{
280 int status; 351 int status;
281 unsigned int pipe; 352 u8 *buf;
282 u16 product = le16_to_cpu(serial->dev->descriptor.idProduct); 353 u16 product = le16_to_cpu(serial->dev->descriptor.idProduct);
283 __u8 requesttype;
284 __u16 size = 0x0000;
285 354
286 if (value < MOS_MAX_PORT) { 355 if (value < MOS_MAX_PORT) {
287 if (product == MOSCHIP_DEVICE_ID_7715) 356 if (product == MOSCHIP_DEVICE_ID_7715)
288 value = value*0x100+0x100; 357 value = 0x0200; /* identifies the 7715's serial port */
289 else 358 else
290 value = value*0x100+0x200; 359 value = value*0x100+0x200;
291 } else { 360 } else {
@@ -298,27 +367,58 @@ static int send_mos_cmd(struct usb_serial *serial, __u8 request, __u16 value,
298 } 367 }
299 368
300 if (request == MOS_WRITE) { 369 if (request == MOS_WRITE) {
301 request = (__u8)MOS_WRITE; 370 value = value + *data;
302 requesttype = (__u8)0x40; 371 status = usb_control_msg(serial->dev,
303 value = value + (__u16)*((unsigned char *)data); 372 usb_sndctrlpipe(serial->dev, 0), MOS_WRITE,
304 data = NULL; 373 0x40, value, index, NULL, 0, MOS_WDR_TIMEOUT);
305 pipe = usb_sndctrlpipe(serial->dev, 0);
306 } else { 374 } else {
307 request = (__u8)MOS_READ; 375 buf = kmalloc(1, GFP_KERNEL);
308 requesttype = (__u8)0xC0; 376 if (!buf) {
309 size = 0x01; 377 status = -ENOMEM;
310 pipe = usb_rcvctrlpipe(serial->dev, 0); 378 goto out;
379 }
380 status = usb_control_msg(serial->dev,
381 usb_rcvctrlpipe(serial->dev, 0), MOS_READ,
382 0xc0, value, index, buf, 1, MOS_WDR_TIMEOUT);
383 *data = *buf;
384 kfree(buf);
311 } 385 }
312 386out:
313 status = usb_control_msg(serial->dev, pipe, request, requesttype,
314 value, index, data, size, MOS_WDR_TIMEOUT);
315
316 if (status < 0) 387 if (status < 0)
317 dbg("Command Write failed Value %x index %x\n", value, index); 388 dbg("Command Write failed Value %x index %x", value, index);
318 389
319 return status; 390 return status;
320} 391}
321 392
393
394/*
395 * mos77xx_probe
396 * this function installs the appropriate read interrupt endpoint callback
397 * depending on whether the device is a 7720 or 7715, thus avoiding costly
398 * run-time checks in the high-frequency callback routine itself.
399 */
400static int mos77xx_probe(struct usb_serial *serial,
401 const struct usb_device_id *id)
402{
403 if (id->idProduct == MOSCHIP_DEVICE_ID_7715)
404 moschip7720_2port_driver.read_int_callback =
405 mos7715_interrupt_callback;
406 else
407 moschip7720_2port_driver.read_int_callback =
408 mos7720_interrupt_callback;
409
410 return 0;
411}
412
413static int mos77xx_calc_num_ports(struct usb_serial *serial)
414{
415 u16 product = le16_to_cpu(serial->dev->descriptor.idProduct);
416 if (product == MOSCHIP_DEVICE_ID_7715)
417 return 1;
418
419 return 2;
420}
421
322static int mos7720_open(struct tty_struct *tty, struct usb_serial_port *port) 422static int mos7720_open(struct tty_struct *tty, struct usb_serial_port *port)
323{ 423{
324 struct usb_serial *serial; 424 struct usb_serial *serial;
@@ -390,7 +490,7 @@ static int mos7720_open(struct tty_struct *tty, struct usb_serial_port *port)
390 */ 490 */
391 port_number = port->number - port->serial->minor; 491 port_number = port->number - port->serial->minor;
392 send_mos_cmd(port->serial, MOS_READ, port_number, UART_LSR, &data); 492 send_mos_cmd(port->serial, MOS_READ, port_number, UART_LSR, &data);
393 dbg("SS::%p LSR:%x\n", mos7720_port, data); 493 dbg("SS::%p LSR:%x", mos7720_port, data);
394 494
395 dbg("Check:Sending Command .........."); 495 dbg("Check:Sending Command ..........");
396 496
@@ -729,7 +829,7 @@ static void mos7720_throttle(struct tty_struct *tty)
729 struct moschip_port *mos7720_port; 829 struct moschip_port *mos7720_port;
730 int status; 830 int status;
731 831
732 dbg("%s- port %d\n", __func__, port->number); 832 dbg("%s- port %d", __func__, port->number);
733 833
734 mos7720_port = usb_get_serial_port_data(port); 834 mos7720_port = usb_get_serial_port_data(port);
735 835
@@ -1208,7 +1308,7 @@ static void mos7720_set_termios(struct tty_struct *tty,
1208 return; 1308 return;
1209 } 1309 }
1210 1310
1211 dbg("%s\n", "setting termios - ASPIRE"); 1311 dbg("setting termios - ASPIRE");
1212 1312
1213 cflag = tty->termios->c_cflag; 1313 cflag = tty->termios->c_cflag;
1214 1314
@@ -1226,7 +1326,7 @@ static void mos7720_set_termios(struct tty_struct *tty,
1226 change_port_settings(tty, mos7720_port, old_termios); 1326 change_port_settings(tty, mos7720_port, old_termios);
1227 1327
1228 if (!port->read_urb) { 1328 if (!port->read_urb) {
1229 dbg("%s", "URB KILLED !!!!!\n"); 1329 dbg("URB KILLED !!!!!");
1230 return; 1330 return;
1231 } 1331 }
1232 1332
@@ -1495,6 +1595,7 @@ static int mos7720_startup(struct usb_serial *serial)
1495 struct usb_device *dev; 1595 struct usb_device *dev;
1496 int i; 1596 int i;
1497 char data; 1597 char data;
1598 u16 product = le16_to_cpu(serial->dev->descriptor.idProduct);
1498 1599
1499 dbg("%s: Entering ..........", __func__); 1600 dbg("%s: Entering ..........", __func__);
1500 1601
@@ -1514,6 +1615,29 @@ static int mos7720_startup(struct usb_serial *serial)
1514 1615
1515 usb_set_serial_data(serial, mos7720_serial); 1616 usb_set_serial_data(serial, mos7720_serial);
1516 1617
1618 /*
1619 * The 7715 uses the first bulk in/out endpoint pair for the parallel
1620 * port, and the second for the serial port. Because the usbserial core
1621 * assumes both pairs are serial ports, we must engage in a bit of
1622 * subterfuge and swap the pointers for ports 0 and 1 in order to make
1623 * port 0 point to the serial port. However, both moschip devices use a
1624 * single interrupt-in endpoint for both ports (as mentioned a little
1625 * further down), and this endpoint was assigned to port 0. So after
1626 * the swap, we must copy the interrupt endpoint elements from port 1
1627 * (as newly assigned) to port 0, and null out port 1 pointers.
1628 */
1629 if (product == MOSCHIP_DEVICE_ID_7715) {
1630 struct usb_serial_port *tmp = serial->port[0];
1631 serial->port[0] = serial->port[1];
1632 serial->port[1] = tmp;
1633 serial->port[0]->interrupt_in_urb = tmp->interrupt_in_urb;
1634 serial->port[0]->interrupt_in_buffer = tmp->interrupt_in_buffer;
1635 serial->port[0]->interrupt_in_endpointAddress =
1636 tmp->interrupt_in_endpointAddress;
1637 serial->port[1]->interrupt_in_urb = NULL;
1638 serial->port[1]->interrupt_in_buffer = NULL;
1639 }
1640
1517 /* we set up the pointers to the endpoints in the mos7720_open * 1641 /* we set up the pointers to the endpoints in the mos7720_open *
1518 * function, as the structures aren't created yet. */ 1642 * function, as the structures aren't created yet. */
1519 1643
@@ -1529,7 +1653,7 @@ static int mos7720_startup(struct usb_serial *serial)
1529 1653
1530 /* Initialize all port interrupt end point to port 0 int 1654 /* Initialize all port interrupt end point to port 0 int
1531 * endpoint. Our device has only one interrupt endpoint 1655 * endpoint. Our device has only one interrupt endpoint
1532 * comman to all ports */ 1656 * common to all ports */
1533 serial->port[i]->interrupt_in_endpointAddress = 1657 serial->port[i]->interrupt_in_endpointAddress =
1534 serial->port[0]->interrupt_in_endpointAddress; 1658 serial->port[0]->interrupt_in_endpointAddress;
1535 1659
@@ -1584,11 +1708,12 @@ static struct usb_serial_driver moschip7720_2port_driver = {
1584 .description = "Moschip 2 port adapter", 1708 .description = "Moschip 2 port adapter",
1585 .usb_driver = &usb_driver, 1709 .usb_driver = &usb_driver,
1586 .id_table = moschip_port_id_table, 1710 .id_table = moschip_port_id_table,
1587 .num_ports = 2, 1711 .calc_num_ports = mos77xx_calc_num_ports,
1588 .open = mos7720_open, 1712 .open = mos7720_open,
1589 .close = mos7720_close, 1713 .close = mos7720_close,
1590 .throttle = mos7720_throttle, 1714 .throttle = mos7720_throttle,
1591 .unthrottle = mos7720_unthrottle, 1715 .unthrottle = mos7720_unthrottle,
1716 .probe = mos77xx_probe,
1592 .attach = mos7720_startup, 1717 .attach = mos7720_startup,
1593 .release = mos7720_release, 1718 .release = mos7720_release,
1594 .ioctl = mos7720_ioctl, 1719 .ioctl = mos7720_ioctl,
@@ -1600,7 +1725,7 @@ static struct usb_serial_driver moschip7720_2port_driver = {
1600 .chars_in_buffer = mos7720_chars_in_buffer, 1725 .chars_in_buffer = mos7720_chars_in_buffer,
1601 .break_ctl = mos7720_break, 1726 .break_ctl = mos7720_break,
1602 .read_bulk_callback = mos7720_bulk_in_callback, 1727 .read_bulk_callback = mos7720_bulk_in_callback,
1603 .read_int_callback = mos7720_interrupt_callback, 1728 .read_int_callback = NULL /* dynamically assigned in probe() */
1604}; 1729};
1605 1730
1606static int __init moschip7720_init(void) 1731static int __init moschip7720_init(void)
diff --git a/drivers/usb/serial/mos7840.c b/drivers/usb/serial/mos7840.c
index f11abf52be7d..2fda1c0182b7 100644
--- a/drivers/usb/serial/mos7840.c
+++ b/drivers/usb/serial/mos7840.c
@@ -121,8 +121,15 @@
121 * moschip_id_table_combined 121 * moschip_id_table_combined
122 */ 122 */
123#define USB_VENDOR_ID_BANDB 0x0856 123#define USB_VENDOR_ID_BANDB 0x0856
124#define BANDB_DEVICE_ID_USOPTL4_4 0xAC44 124#define BANDB_DEVICE_ID_USO9ML2_2 0xAC22
125#define BANDB_DEVICE_ID_USOPTL4_2 0xAC42 125#define BANDB_DEVICE_ID_USO9ML2_4 0xAC24
126#define BANDB_DEVICE_ID_US9ML2_2 0xAC29
127#define BANDB_DEVICE_ID_US9ML2_4 0xAC30
128#define BANDB_DEVICE_ID_USPTL4_2 0xAC31
129#define BANDB_DEVICE_ID_USPTL4_4 0xAC32
130#define BANDB_DEVICE_ID_USOPTL4_2 0xAC42
131#define BANDB_DEVICE_ID_USOPTL4_4 0xAC44
132#define BANDB_DEVICE_ID_USOPTL2_4 0xAC24
126 133
127/* This driver also supports 134/* This driver also supports
128 * ATEN UC2324 device using Moschip MCS7840 135 * ATEN UC2324 device using Moschip MCS7840
@@ -174,21 +181,35 @@
174#define URB_TRANSFER_BUFFER_SIZE 32 /* URB Size */ 181#define URB_TRANSFER_BUFFER_SIZE 32 /* URB Size */
175 182
176 183
177static struct usb_device_id moschip_port_id_table[] = { 184static const struct usb_device_id moschip_port_id_table[] = {
178 {USB_DEVICE(USB_VENDOR_ID_MOSCHIP, MOSCHIP_DEVICE_ID_7840)}, 185 {USB_DEVICE(USB_VENDOR_ID_MOSCHIP, MOSCHIP_DEVICE_ID_7840)},
179 {USB_DEVICE(USB_VENDOR_ID_MOSCHIP, MOSCHIP_DEVICE_ID_7820)}, 186 {USB_DEVICE(USB_VENDOR_ID_MOSCHIP, MOSCHIP_DEVICE_ID_7820)},
180 {USB_DEVICE(USB_VENDOR_ID_BANDB, BANDB_DEVICE_ID_USOPTL4_4)}, 187 {USB_DEVICE(USB_VENDOR_ID_BANDB, BANDB_DEVICE_ID_USO9ML2_2)},
188 {USB_DEVICE(USB_VENDOR_ID_BANDB, BANDB_DEVICE_ID_USO9ML2_4)},
189 {USB_DEVICE(USB_VENDOR_ID_BANDB, BANDB_DEVICE_ID_US9ML2_2)},
190 {USB_DEVICE(USB_VENDOR_ID_BANDB, BANDB_DEVICE_ID_US9ML2_4)},
191 {USB_DEVICE(USB_VENDOR_ID_BANDB, BANDB_DEVICE_ID_USPTL4_2)},
192 {USB_DEVICE(USB_VENDOR_ID_BANDB, BANDB_DEVICE_ID_USPTL4_4)},
181 {USB_DEVICE(USB_VENDOR_ID_BANDB, BANDB_DEVICE_ID_USOPTL4_2)}, 193 {USB_DEVICE(USB_VENDOR_ID_BANDB, BANDB_DEVICE_ID_USOPTL4_2)},
194 {USB_DEVICE(USB_VENDOR_ID_BANDB, BANDB_DEVICE_ID_USOPTL4_4)},
195 {USB_DEVICE(USB_VENDOR_ID_BANDB, BANDB_DEVICE_ID_USOPTL2_4)},
182 {USB_DEVICE(USB_VENDOR_ID_ATENINTL, ATENINTL_DEVICE_ID_UC2324)}, 196 {USB_DEVICE(USB_VENDOR_ID_ATENINTL, ATENINTL_DEVICE_ID_UC2324)},
183 {USB_DEVICE(USB_VENDOR_ID_ATENINTL, ATENINTL_DEVICE_ID_UC2322)}, 197 {USB_DEVICE(USB_VENDOR_ID_ATENINTL, ATENINTL_DEVICE_ID_UC2322)},
184 {} /* terminating entry */ 198 {} /* terminating entry */
185}; 199};
186 200
187static __devinitdata struct usb_device_id moschip_id_table_combined[] = { 201static const struct usb_device_id moschip_id_table_combined[] __devinitconst = {
188 {USB_DEVICE(USB_VENDOR_ID_MOSCHIP, MOSCHIP_DEVICE_ID_7840)}, 202 {USB_DEVICE(USB_VENDOR_ID_MOSCHIP, MOSCHIP_DEVICE_ID_7840)},
189 {USB_DEVICE(USB_VENDOR_ID_MOSCHIP, MOSCHIP_DEVICE_ID_7820)}, 203 {USB_DEVICE(USB_VENDOR_ID_MOSCHIP, MOSCHIP_DEVICE_ID_7820)},
190 {USB_DEVICE(USB_VENDOR_ID_BANDB, BANDB_DEVICE_ID_USOPTL4_4)}, 204 {USB_DEVICE(USB_VENDOR_ID_BANDB, BANDB_DEVICE_ID_USO9ML2_2)},
205 {USB_DEVICE(USB_VENDOR_ID_BANDB, BANDB_DEVICE_ID_USO9ML2_4)},
206 {USB_DEVICE(USB_VENDOR_ID_BANDB, BANDB_DEVICE_ID_US9ML2_2)},
207 {USB_DEVICE(USB_VENDOR_ID_BANDB, BANDB_DEVICE_ID_US9ML2_4)},
208 {USB_DEVICE(USB_VENDOR_ID_BANDB, BANDB_DEVICE_ID_USPTL4_2)},
209 {USB_DEVICE(USB_VENDOR_ID_BANDB, BANDB_DEVICE_ID_USPTL4_4)},
191 {USB_DEVICE(USB_VENDOR_ID_BANDB, BANDB_DEVICE_ID_USOPTL4_2)}, 210 {USB_DEVICE(USB_VENDOR_ID_BANDB, BANDB_DEVICE_ID_USOPTL4_2)},
211 {USB_DEVICE(USB_VENDOR_ID_BANDB, BANDB_DEVICE_ID_USOPTL4_4)},
212 {USB_DEVICE(USB_VENDOR_ID_BANDB, BANDB_DEVICE_ID_USOPTL2_4)},
192 {USB_DEVICE(USB_VENDOR_ID_ATENINTL, ATENINTL_DEVICE_ID_UC2324)}, 213 {USB_DEVICE(USB_VENDOR_ID_ATENINTL, ATENINTL_DEVICE_ID_UC2324)},
193 {USB_DEVICE(USB_VENDOR_ID_ATENINTL, ATENINTL_DEVICE_ID_UC2322)}, 214 {USB_DEVICE(USB_VENDOR_ID_ATENINTL, ATENINTL_DEVICE_ID_UC2322)},
194 {} /* terminating entry */ 215 {} /* terminating entry */
@@ -262,12 +283,19 @@ static int mos7840_get_reg_sync(struct usb_serial_port *port, __u16 reg,
262{ 283{
263 struct usb_device *dev = port->serial->dev; 284 struct usb_device *dev = port->serial->dev;
264 int ret = 0; 285 int ret = 0;
286 u8 *buf;
287
288 buf = kmalloc(VENDOR_READ_LENGTH, GFP_KERNEL);
289 if (!buf)
290 return -ENOMEM;
265 291
266 ret = usb_control_msg(dev, usb_rcvctrlpipe(dev, 0), MCS_RDREQ, 292 ret = usb_control_msg(dev, usb_rcvctrlpipe(dev, 0), MCS_RDREQ,
267 MCS_RD_RTYPE, 0, reg, val, VENDOR_READ_LENGTH, 293 MCS_RD_RTYPE, 0, reg, buf, VENDOR_READ_LENGTH,
268 MOS_WDR_TIMEOUT); 294 MOS_WDR_TIMEOUT);
295 *val = buf[0];
269 dbg("mos7840_get_reg_sync offset is %x, return val %x", reg, *val); 296 dbg("mos7840_get_reg_sync offset is %x, return val %x", reg, *val);
270 *val = (*val) & 0x00ff; 297
298 kfree(buf);
271 return ret; 299 return ret;
272} 300}
273 301
@@ -320,6 +348,11 @@ static int mos7840_get_uart_reg(struct usb_serial_port *port, __u16 reg,
320 struct usb_device *dev = port->serial->dev; 348 struct usb_device *dev = port->serial->dev;
321 int ret = 0; 349 int ret = 0;
322 __u16 Wval; 350 __u16 Wval;
351 u8 *buf;
352
353 buf = kmalloc(VENDOR_READ_LENGTH, GFP_KERNEL);
354 if (!buf)
355 return -ENOMEM;
323 356
324 /* dbg("application number is %4x", 357 /* dbg("application number is %4x",
325 (((__u16)port->number - (__u16)(port->serial->minor))+1)<<8); */ 358 (((__u16)port->number - (__u16)(port->serial->minor))+1)<<8); */
@@ -343,9 +376,11 @@ static int mos7840_get_uart_reg(struct usb_serial_port *port, __u16 reg,
343 } 376 }
344 } 377 }
345 ret = usb_control_msg(dev, usb_rcvctrlpipe(dev, 0), MCS_RDREQ, 378 ret = usb_control_msg(dev, usb_rcvctrlpipe(dev, 0), MCS_RDREQ,
346 MCS_RD_RTYPE, Wval, reg, val, VENDOR_READ_LENGTH, 379 MCS_RD_RTYPE, Wval, reg, buf, VENDOR_READ_LENGTH,
347 MOS_WDR_TIMEOUT); 380 MOS_WDR_TIMEOUT);
348 *val = (*val) & 0x00ff; 381 *val = buf[0];
382
383 kfree(buf);
349 return ret; 384 return ret;
350} 385}
351 386
@@ -729,7 +764,6 @@ static void mos7840_bulk_in_callback(struct urb *urb)
729 if (urb->actual_length) { 764 if (urb->actual_length) {
730 tty = tty_port_tty_get(&mos7840_port->port->port); 765 tty = tty_port_tty_get(&mos7840_port->port->port);
731 if (tty) { 766 if (tty) {
732 tty_buffer_request_room(tty, urb->actual_length);
733 tty_insert_flip_string(tty, data, urb->actual_length); 767 tty_insert_flip_string(tty, data, urb->actual_length);
734 dbg(" %s ", data); 768 dbg(" %s ", data);
735 tty_flip_buffer_push(tty); 769 tty_flip_buffer_push(tty);
diff --git a/drivers/usb/serial/moto_modem.c b/drivers/usb/serial/moto_modem.c
index 99bd00f5188a..cf1718394e18 100644
--- a/drivers/usb/serial/moto_modem.c
+++ b/drivers/usb/serial/moto_modem.c
@@ -21,7 +21,7 @@
21#include <linux/usb.h> 21#include <linux/usb.h>
22#include <linux/usb/serial.h> 22#include <linux/usb/serial.h>
23 23
24static struct usb_device_id id_table [] = { 24static const struct usb_device_id id_table[] = {
25 { USB_DEVICE(0x05c6, 0x3197) }, /* unknown Motorola phone */ 25 { USB_DEVICE(0x05c6, 0x3197) }, /* unknown Motorola phone */
26 { USB_DEVICE(0x0c44, 0x0022) }, /* unknown Mororola phone */ 26 { USB_DEVICE(0x0c44, 0x0022) }, /* unknown Mororola phone */
27 { USB_DEVICE(0x22b8, 0x2a64) }, /* Motorola KRZR K1m */ 27 { USB_DEVICE(0x22b8, 0x2a64) }, /* Motorola KRZR K1m */
diff --git a/drivers/usb/serial/navman.c b/drivers/usb/serial/navman.c
index 5ceaa4c6be09..a6b207c84917 100644
--- a/drivers/usb/serial/navman.c
+++ b/drivers/usb/serial/navman.c
@@ -12,6 +12,7 @@
12 * flags as the navman is rx only so cannot echo. 12 * flags as the navman is rx only so cannot echo.
13 */ 13 */
14 14
15#include <linux/gfp.h>
15#include <linux/kernel.h> 16#include <linux/kernel.h>
16#include <linux/init.h> 17#include <linux/init.h>
17#include <linux/tty.h> 18#include <linux/tty.h>
@@ -22,7 +23,7 @@
22 23
23static int debug; 24static int debug;
24 25
25static struct usb_device_id id_table [] = { 26static const struct usb_device_id id_table[] = {
26 { USB_DEVICE(0x0a99, 0x0001) }, /* Talon Technology device */ 27 { USB_DEVICE(0x0a99, 0x0001) }, /* Talon Technology device */
27 { }, 28 { },
28}; 29};
@@ -66,7 +67,6 @@ static void navman_read_int_callback(struct urb *urb)
66 67
67 tty = tty_port_tty_get(&port->port); 68 tty = tty_port_tty_get(&port->port);
68 if (tty && urb->actual_length) { 69 if (tty && urb->actual_length) {
69 tty_buffer_request_room(tty, urb->actual_length);
70 tty_insert_flip_string(tty, data, urb->actual_length); 70 tty_insert_flip_string(tty, data, urb->actual_length);
71 tty_flip_buffer_push(tty); 71 tty_flip_buffer_push(tty);
72 } 72 }
diff --git a/drivers/usb/serial/omninet.c b/drivers/usb/serial/omninet.c
index 062265038bf0..89c724c0ac0a 100644
--- a/drivers/usb/serial/omninet.c
+++ b/drivers/usb/serial/omninet.c
@@ -75,7 +75,7 @@ static void omninet_disconnect(struct usb_serial *serial);
75static void omninet_release(struct usb_serial *serial); 75static void omninet_release(struct usb_serial *serial);
76static int omninet_attach(struct usb_serial *serial); 76static int omninet_attach(struct usb_serial *serial);
77 77
78static struct usb_device_id id_table[] = { 78static const struct usb_device_id id_table[] = {
79 { USB_DEVICE(ZYXEL_VENDOR_ID, ZYXEL_OMNINET_ID) }, 79 { USB_DEVICE(ZYXEL_VENDOR_ID, ZYXEL_OMNINET_ID) },
80 { USB_DEVICE(ZYXEL_VENDOR_ID, BT_IGNITIONPRO_ID) }, 80 { USB_DEVICE(ZYXEL_VENDOR_ID, BT_IGNITIONPRO_ID) },
81 { } /* Terminating entry */ 81 { } /* Terminating entry */
@@ -218,8 +218,8 @@ static void omninet_read_bulk_callback(struct urb *urb)
218 218
219 if (debug && header->oh_xxx != 0x30) { 219 if (debug && header->oh_xxx != 0x30) {
220 if (urb->actual_length) { 220 if (urb->actual_length) {
221 printk(KERN_DEBUG __FILE__ 221 printk(KERN_DEBUG "%s: omninet_read %d: ",
222 ": omninet_read %d: ", header->oh_len); 222 __FILE__, header->oh_len);
223 for (i = 0; i < (header->oh_len + 223 for (i = 0; i < (header->oh_len +
224 OMNINET_HEADERLEN); i++) 224 OMNINET_HEADERLEN); i++)
225 printk("%.2x ", data[i]); 225 printk("%.2x ", data[i]);
@@ -332,7 +332,7 @@ static void omninet_write_bulk_callback(struct urb *urb)
332 struct usb_serial_port *port = urb->context; 332 struct usb_serial_port *port = urb->context;
333 int status = urb->status; 333 int status = urb->status;
334 334
335 dbg("%s - port %0x\n", __func__, port->number); 335 dbg("%s - port %0x", __func__, port->number);
336 336
337 port->write_urb_busy = 0; 337 port->write_urb_busy = 0;
338 if (status) { 338 if (status) {
diff --git a/drivers/usb/serial/opticon.c b/drivers/usb/serial/opticon.c
index 80f59b6350cb..ed01f3b2de8c 100644
--- a/drivers/usb/serial/opticon.c
+++ b/drivers/usb/serial/opticon.c
@@ -13,6 +13,7 @@
13#include <linux/init.h> 13#include <linux/init.h>
14#include <linux/tty.h> 14#include <linux/tty.h>
15#include <linux/tty_driver.h> 15#include <linux/tty_driver.h>
16#include <linux/slab.h>
16#include <linux/tty_flip.h> 17#include <linux/tty_flip.h>
17#include <linux/serial.h> 18#include <linux/serial.h>
18#include <linux/module.h> 19#include <linux/module.h>
@@ -22,7 +23,7 @@
22 23
23static int debug; 24static int debug;
24 25
25static struct usb_device_id id_table[] = { 26static const struct usb_device_id id_table[] = {
26 { USB_DEVICE(0x065a, 0x0009) }, 27 { USB_DEVICE(0x065a, 0x0009) },
27 { }, 28 { },
28}; 29};
@@ -55,7 +56,6 @@ static void opticon_bulk_callback(struct urb *urb)
55 int status = urb->status; 56 int status = urb->status;
56 struct tty_struct *tty; 57 struct tty_struct *tty;
57 int result; 58 int result;
58 int available_room = 0;
59 int data_length; 59 int data_length;
60 60
61 dbg("%s - port %d", __func__, port->number); 61 dbg("%s - port %d", __func__, port->number);
@@ -96,13 +96,9 @@ static void opticon_bulk_callback(struct urb *urb)
96 /* real data, send it to the tty layer */ 96 /* real data, send it to the tty layer */
97 tty = tty_port_tty_get(&port->port); 97 tty = tty_port_tty_get(&port->port);
98 if (tty) { 98 if (tty) {
99 available_room = tty_buffer_request_room(tty, 99 tty_insert_flip_string(tty, data,
100 data_length); 100 data_length);
101 if (available_room) { 101 tty_flip_buffer_push(tty);
102 tty_insert_flip_string(tty, data,
103 available_room);
104 tty_flip_buffer_push(tty);
105 }
106 tty_kref_put(tty); 102 tty_kref_put(tty);
107 } 103 }
108 } else { 104 } else {
@@ -120,7 +116,7 @@ static void opticon_bulk_callback(struct urb *urb)
120 } 116 }
121 } else { 117 } else {
122 dev_dbg(&priv->udev->dev, 118 dev_dbg(&priv->udev->dev,
123 "Improper ammount of data received from the device, " 119 "Improper amount of data received from the device, "
124 "%d bytes", urb->actual_length); 120 "%d bytes", urb->actual_length);
125 } 121 }
126 122
@@ -217,7 +213,7 @@ static int opticon_write(struct tty_struct *tty, struct usb_serial_port *port,
217 spin_lock_irqsave(&priv->lock, flags); 213 spin_lock_irqsave(&priv->lock, flags);
218 if (priv->outstanding_urbs > URB_UPPER_LIMIT) { 214 if (priv->outstanding_urbs > URB_UPPER_LIMIT) {
219 spin_unlock_irqrestore(&priv->lock, flags); 215 spin_unlock_irqrestore(&priv->lock, flags);
220 dbg("%s - write limit hit\n", __func__); 216 dbg("%s - write limit hit", __func__);
221 return 0; 217 return 0;
222 } 218 }
223 priv->outstanding_urbs++; 219 priv->outstanding_urbs++;
@@ -288,7 +284,7 @@ static int opticon_write_room(struct tty_struct *tty)
288 spin_lock_irqsave(&priv->lock, flags); 284 spin_lock_irqsave(&priv->lock, flags);
289 if (priv->outstanding_urbs > URB_UPPER_LIMIT * 2 / 3) { 285 if (priv->outstanding_urbs > URB_UPPER_LIMIT * 2 / 3) {
290 spin_unlock_irqrestore(&priv->lock, flags); 286 spin_unlock_irqrestore(&priv->lock, flags);
291 dbg("%s - write limit hit\n", __func__); 287 dbg("%s - write limit hit", __func__);
292 return 0; 288 return 0;
293 } 289 }
294 spin_unlock_irqrestore(&priv->lock, flags); 290 spin_unlock_irqrestore(&priv->lock, flags);
@@ -501,12 +497,13 @@ static int opticon_resume(struct usb_interface *intf)
501 struct usb_serial_port *port = serial->port[0]; 497 struct usb_serial_port *port = serial->port[0];
502 int result; 498 int result;
503 499
504 mutex_lock(&port->mutex); 500 mutex_lock(&port->port.mutex);
505 if (port->port.count) 501 /* This is protected by the port mutex against close/open */
502 if (test_bit(ASYNCB_INITIALIZED, &port->port.flags))
506 result = usb_submit_urb(priv->bulk_read_urb, GFP_NOIO); 503 result = usb_submit_urb(priv->bulk_read_urb, GFP_NOIO);
507 else 504 else
508 result = 0; 505 result = 0;
509 mutex_unlock(&port->mutex); 506 mutex_unlock(&port->port.mutex);
510 return result; 507 return result;
511} 508}
512 509
diff --git a/drivers/usb/serial/option.c b/drivers/usb/serial/option.c
index 0577e4b61114..84d0edad8e4f 100644
--- a/drivers/usb/serial/option.c
+++ b/drivers/usb/serial/option.c
@@ -37,6 +37,7 @@
37#include <linux/errno.h> 37#include <linux/errno.h>
38#include <linux/tty.h> 38#include <linux/tty.h>
39#include <linux/tty_flip.h> 39#include <linux/tty_flip.h>
40#include <linux/slab.h>
40#include <linux/module.h> 41#include <linux/module.h>
41#include <linux/bitops.h> 42#include <linux/bitops.h>
42#include <linux/usb.h> 43#include <linux/usb.h>
@@ -288,7 +289,9 @@ static int option_resume(struct usb_serial *serial);
288 289
289#define QUALCOMM_VENDOR_ID 0x05C6 290#define QUALCOMM_VENDOR_ID 0x05C6
290 291
291#define MAXON_VENDOR_ID 0x16d8 292#define CMOTECH_VENDOR_ID 0x16d8
293#define CMOTECH_PRODUCT_6008 0x6008
294#define CMOTECH_PRODUCT_6280 0x6280
292 295
293#define TELIT_VENDOR_ID 0x1bc7 296#define TELIT_VENDOR_ID 0x1bc7
294#define TELIT_PRODUCT_UC864E 0x1003 297#define TELIT_PRODUCT_UC864E 0x1003
@@ -302,6 +305,11 @@ static int option_resume(struct usb_serial *serial);
302#define ZTE_PRODUCT_CDMA_TECH 0xfffe 305#define ZTE_PRODUCT_CDMA_TECH 0xfffe
303#define ZTE_PRODUCT_AC8710 0xfff1 306#define ZTE_PRODUCT_AC8710 0xfff1
304#define ZTE_PRODUCT_AC2726 0xfff5 307#define ZTE_PRODUCT_AC2726 0xfff5
308#define ZTE_PRODUCT_AC8710T 0xffff
309
310/* ZTE PRODUCTS -- alternate vendor ID */
311#define ZTE_VENDOR_ID2 0x1d6b
312#define ZTE_PRODUCT_MF_330 0x0002
305 313
306#define BENQ_VENDOR_ID 0x04a5 314#define BENQ_VENDOR_ID 0x04a5
307#define BENQ_PRODUCT_H10 0x4068 315#define BENQ_PRODUCT_H10 0x4068
@@ -309,6 +317,7 @@ static int option_resume(struct usb_serial *serial);
309#define DLINK_VENDOR_ID 0x1186 317#define DLINK_VENDOR_ID 0x1186
310#define DLINK_PRODUCT_DWM_652 0x3e04 318#define DLINK_PRODUCT_DWM_652 0x3e04
311#define DLINK_PRODUCT_DWM_652_U5 0xce16 319#define DLINK_PRODUCT_DWM_652_U5 0xce16
320#define DLINK_PRODUCT_DWM_652_U5A 0xce1e
312 321
313#define QISDA_VENDOR_ID 0x1da5 322#define QISDA_VENDOR_ID 0x1da5
314#define QISDA_PRODUCT_H21_4512 0x4512 323#define QISDA_PRODUCT_H21_4512 0x4512
@@ -332,15 +341,66 @@ static int option_resume(struct usb_serial *serial);
332#define ALCATEL_VENDOR_ID 0x1bbb 341#define ALCATEL_VENDOR_ID 0x1bbb
333#define ALCATEL_PRODUCT_X060S 0x0000 342#define ALCATEL_PRODUCT_X060S 0x0000
334 343
344#define PIRELLI_VENDOR_ID 0x1266
345#define PIRELLI_PRODUCT_C100_1 0x1002
346#define PIRELLI_PRODUCT_C100_2 0x1003
347#define PIRELLI_PRODUCT_1004 0x1004
348#define PIRELLI_PRODUCT_1005 0x1005
349#define PIRELLI_PRODUCT_1006 0x1006
350#define PIRELLI_PRODUCT_1007 0x1007
351#define PIRELLI_PRODUCT_1008 0x1008
352#define PIRELLI_PRODUCT_1009 0x1009
353#define PIRELLI_PRODUCT_100A 0x100a
354#define PIRELLI_PRODUCT_100B 0x100b
355#define PIRELLI_PRODUCT_100C 0x100c
356#define PIRELLI_PRODUCT_100D 0x100d
357#define PIRELLI_PRODUCT_100E 0x100e
358#define PIRELLI_PRODUCT_100F 0x100f
359#define PIRELLI_PRODUCT_1011 0x1011
360#define PIRELLI_PRODUCT_1012 0x1012
361
335/* Airplus products */ 362/* Airplus products */
336#define AIRPLUS_VENDOR_ID 0x1011 363#define AIRPLUS_VENDOR_ID 0x1011
337#define AIRPLUS_PRODUCT_MCD650 0x3198 364#define AIRPLUS_PRODUCT_MCD650 0x3198
338 365
366/* Longcheer/Longsung vendor ID; makes whitelabel devices that
367 * many other vendors like 4G Systems, Alcatel, ChinaBird,
368 * Mobidata, etc sell under their own brand names.
369 */
370#define LONGCHEER_VENDOR_ID 0x1c9e
371
339/* 4G Systems products */ 372/* 4G Systems products */
340#define FOUR_G_SYSTEMS_VENDOR_ID 0x1c9e 373/* This is the 4G XS Stick W14 a.k.a. Mobilcom Debitel Surf-Stick *
374 * It seems to contain a Qualcomm QSC6240/6290 chipset */
341#define FOUR_G_SYSTEMS_PRODUCT_W14 0x9603 375#define FOUR_G_SYSTEMS_PRODUCT_W14 0x9603
342 376
343static struct usb_device_id option_ids[] = { 377/* Haier products */
378#define HAIER_VENDOR_ID 0x201e
379#define HAIER_PRODUCT_CE100 0x2009
380
381#define CINTERION_VENDOR_ID 0x0681
382
383/* some devices interfaces need special handling due to a number of reasons */
384enum option_blacklist_reason {
385 OPTION_BLACKLIST_NONE = 0,
386 OPTION_BLACKLIST_SENDSETUP = 1,
387 OPTION_BLACKLIST_RESERVED_IF = 2
388};
389
390struct option_blacklist_info {
391 const u32 infolen; /* number of interface numbers on blacklist */
392 const u8 *ifaceinfo; /* pointer to the array holding the numbers */
393 enum option_blacklist_reason reason;
394};
395
396static const u8 four_g_w14_no_sendsetup[] = { 0, 1 };
397static const struct option_blacklist_info four_g_w14_blacklist = {
398 .infolen = ARRAY_SIZE(four_g_w14_no_sendsetup),
399 .ifaceinfo = four_g_w14_no_sendsetup,
400 .reason = OPTION_BLACKLIST_SENDSETUP
401};
402
403static const struct usb_device_id option_ids[] = {
344 { USB_DEVICE(OPTION_VENDOR_ID, OPTION_PRODUCT_COLT) }, 404 { USB_DEVICE(OPTION_VENDOR_ID, OPTION_PRODUCT_COLT) },
345 { USB_DEVICE(OPTION_VENDOR_ID, OPTION_PRODUCT_RICOLA) }, 405 { USB_DEVICE(OPTION_VENDOR_ID, OPTION_PRODUCT_RICOLA) },
346 { USB_DEVICE(OPTION_VENDOR_ID, OPTION_PRODUCT_RICOLA_LIGHT) }, 406 { USB_DEVICE(OPTION_VENDOR_ID, OPTION_PRODUCT_RICOLA_LIGHT) },
@@ -516,7 +576,8 @@ static struct usb_device_id option_ids[] = {
516 { USB_DEVICE(KYOCERA_VENDOR_ID, KYOCERA_PRODUCT_KPC680) }, 576 { USB_DEVICE(KYOCERA_VENDOR_ID, KYOCERA_PRODUCT_KPC680) },
517 { USB_DEVICE(QUALCOMM_VENDOR_ID, 0x6000)}, /* ZTE AC8700 */ 577 { USB_DEVICE(QUALCOMM_VENDOR_ID, 0x6000)}, /* ZTE AC8700 */
518 { USB_DEVICE(QUALCOMM_VENDOR_ID, 0x6613)}, /* Onda H600/ZTE MF330 */ 578 { USB_DEVICE(QUALCOMM_VENDOR_ID, 0x6613)}, /* Onda H600/ZTE MF330 */
519 { USB_DEVICE(MAXON_VENDOR_ID, 0x6280) }, /* BP3-USB & BP3-EXT HSDPA */ 579 { USB_DEVICE(CMOTECH_VENDOR_ID, CMOTECH_PRODUCT_6280) }, /* BP3-USB & BP3-EXT HSDPA */
580 { USB_DEVICE(CMOTECH_VENDOR_ID, CMOTECH_PRODUCT_6008) },
520 { USB_DEVICE(TELIT_VENDOR_ID, TELIT_PRODUCT_UC864E) }, 581 { USB_DEVICE(TELIT_VENDOR_ID, TELIT_PRODUCT_UC864E) },
521 { USB_DEVICE(TELIT_VENDOR_ID, TELIT_PRODUCT_UC864G) }, 582 { USB_DEVICE(TELIT_VENDOR_ID, TELIT_PRODUCT_UC864G) },
522 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, ZTE_PRODUCT_MF622, 0xff, 0xff, 0xff) }, /* ZTE WCDMA products */ 583 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, ZTE_PRODUCT_MF622, 0xff, 0xff, 0xff) }, /* ZTE WCDMA products */
@@ -580,18 +641,57 @@ static struct usb_device_id option_ids[] = {
580 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x0086, 0xff, 0xff, 0xff) }, 641 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x0086, 0xff, 0xff, 0xff) },
581 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x2002, 0xff, 0xff, 0xff) }, 642 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x2002, 0xff, 0xff, 0xff) },
582 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x2003, 0xff, 0xff, 0xff) }, 643 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x2003, 0xff, 0xff, 0xff) },
644 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x0104, 0xff, 0xff, 0xff) },
645 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x0106, 0xff, 0xff, 0xff) },
646 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x0108, 0xff, 0xff, 0xff) },
647 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x0113, 0xff, 0xff, 0xff) },
648 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x0117, 0xff, 0xff, 0xff) },
649 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x0118, 0xff, 0xff, 0xff) },
650 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x0121, 0xff, 0xff, 0xff) },
651 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x0122, 0xff, 0xff, 0xff) },
652 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x0123, 0xff, 0xff, 0xff) },
653 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x0124, 0xff, 0xff, 0xff) },
654 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x0125, 0xff, 0xff, 0xff) },
655 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x0126, 0xff, 0xff, 0xff) },
656 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x0128, 0xff, 0xff, 0xff) },
657 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x0142, 0xff, 0xff, 0xff) },
658 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x0143, 0xff, 0xff, 0xff) },
659 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x0144, 0xff, 0xff, 0xff) },
660 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x0145, 0xff, 0xff, 0xff) },
661 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x0146, 0xff, 0xff, 0xff) },
662 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x0147, 0xff, 0xff, 0xff) },
663 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x0148, 0xff, 0xff, 0xff) },
664 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x0149, 0xff, 0xff, 0xff) },
665 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x0150, 0xff, 0xff, 0xff) },
666 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x0151, 0xff, 0xff, 0xff) },
667 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x0152, 0xff, 0xff, 0xff) },
668 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x0153, 0xff, 0xff, 0xff) },
669 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x0154, 0xff, 0xff, 0xff) },
670 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x0155, 0xff, 0xff, 0xff) },
671 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x0156, 0xff, 0xff, 0xff) },
672 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x0157, 0xff, 0xff, 0xff) },
673 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x0158, 0xff, 0xff, 0xff) },
674 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x0159, 0xff, 0xff, 0xff) },
675 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x0160, 0xff, 0xff, 0xff) },
676 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x0161, 0xff, 0xff, 0xff) },
677 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x0162, 0xff, 0xff, 0xff) },
583 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x0014, 0xff, 0xff, 0xff) }, /* ZTE CDMA products */ 678 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x0014, 0xff, 0xff, 0xff) }, /* ZTE CDMA products */
584 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x0027, 0xff, 0xff, 0xff) }, 679 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x0027, 0xff, 0xff, 0xff) },
585 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x0059, 0xff, 0xff, 0xff) }, 680 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x0059, 0xff, 0xff, 0xff) },
586 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x0060, 0xff, 0xff, 0xff) }, 681 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x0060, 0xff, 0xff, 0xff) },
587 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x0070, 0xff, 0xff, 0xff) }, 682 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x0070, 0xff, 0xff, 0xff) },
588 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x0073, 0xff, 0xff, 0xff) }, 683 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x0073, 0xff, 0xff, 0xff) },
684 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x0130, 0xff, 0xff, 0xff) },
685 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x0141, 0xff, 0xff, 0xff) },
589 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, ZTE_PRODUCT_CDMA_TECH, 0xff, 0xff, 0xff) }, 686 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, ZTE_PRODUCT_CDMA_TECH, 0xff, 0xff, 0xff) },
590 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, ZTE_PRODUCT_AC8710, 0xff, 0xff, 0xff) }, 687 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, ZTE_PRODUCT_AC8710, 0xff, 0xff, 0xff) },
591 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, ZTE_PRODUCT_AC2726, 0xff, 0xff, 0xff) }, 688 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, ZTE_PRODUCT_AC2726, 0xff, 0xff, 0xff) },
689 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, ZTE_PRODUCT_AC8710T, 0xff, 0xff, 0xff) },
690 { USB_DEVICE(ZTE_VENDOR_ID2, ZTE_PRODUCT_MF_330) },
592 { USB_DEVICE(BENQ_VENDOR_ID, BENQ_PRODUCT_H10) }, 691 { USB_DEVICE(BENQ_VENDOR_ID, BENQ_PRODUCT_H10) },
593 { USB_DEVICE(DLINK_VENDOR_ID, DLINK_PRODUCT_DWM_652) }, 692 { USB_DEVICE(DLINK_VENDOR_ID, DLINK_PRODUCT_DWM_652) },
594 { USB_DEVICE(ALINK_VENDOR_ID, DLINK_PRODUCT_DWM_652_U5) }, /* Yes, ALINK_VENDOR_ID */ 693 { USB_DEVICE(ALINK_VENDOR_ID, DLINK_PRODUCT_DWM_652_U5) }, /* Yes, ALINK_VENDOR_ID */
694 { USB_DEVICE(ALINK_VENDOR_ID, DLINK_PRODUCT_DWM_652_U5A) },
595 { USB_DEVICE(QISDA_VENDOR_ID, QISDA_PRODUCT_H21_4512) }, 695 { USB_DEVICE(QISDA_VENDOR_ID, QISDA_PRODUCT_H21_4512) },
596 { USB_DEVICE(QISDA_VENDOR_ID, QISDA_PRODUCT_H21_4523) }, 696 { USB_DEVICE(QISDA_VENDOR_ID, QISDA_PRODUCT_H21_4523) },
597 { USB_DEVICE(QISDA_VENDOR_ID, QISDA_PRODUCT_H20_4515) }, 697 { USB_DEVICE(QISDA_VENDOR_ID, QISDA_PRODUCT_H20_4515) },
@@ -603,7 +703,29 @@ static struct usb_device_id option_ids[] = {
603 { USB_DEVICE(ALCATEL_VENDOR_ID, ALCATEL_PRODUCT_X060S) }, 703 { USB_DEVICE(ALCATEL_VENDOR_ID, ALCATEL_PRODUCT_X060S) },
604 { USB_DEVICE(AIRPLUS_VENDOR_ID, AIRPLUS_PRODUCT_MCD650) }, 704 { USB_DEVICE(AIRPLUS_VENDOR_ID, AIRPLUS_PRODUCT_MCD650) },
605 { USB_DEVICE(TLAYTECH_VENDOR_ID, TLAYTECH_PRODUCT_TEU800) }, 705 { USB_DEVICE(TLAYTECH_VENDOR_ID, TLAYTECH_PRODUCT_TEU800) },
606 { USB_DEVICE(FOUR_G_SYSTEMS_VENDOR_ID, FOUR_G_SYSTEMS_PRODUCT_W14) }, 706 { USB_DEVICE(LONGCHEER_VENDOR_ID, FOUR_G_SYSTEMS_PRODUCT_W14),
707 .driver_info = (kernel_ulong_t)&four_g_w14_blacklist
708 },
709 { USB_DEVICE(HAIER_VENDOR_ID, HAIER_PRODUCT_CE100) },
710 /* Pirelli */
711 { USB_DEVICE(PIRELLI_VENDOR_ID, PIRELLI_PRODUCT_C100_1)},
712 { USB_DEVICE(PIRELLI_VENDOR_ID, PIRELLI_PRODUCT_C100_2)},
713 { USB_DEVICE(PIRELLI_VENDOR_ID, PIRELLI_PRODUCT_1004)},
714 { USB_DEVICE(PIRELLI_VENDOR_ID, PIRELLI_PRODUCT_1005)},
715 { USB_DEVICE(PIRELLI_VENDOR_ID, PIRELLI_PRODUCT_1006)},
716 { USB_DEVICE(PIRELLI_VENDOR_ID, PIRELLI_PRODUCT_1007)},
717 { USB_DEVICE(PIRELLI_VENDOR_ID, PIRELLI_PRODUCT_1008)},
718 { USB_DEVICE(PIRELLI_VENDOR_ID, PIRELLI_PRODUCT_1009)},
719 { USB_DEVICE(PIRELLI_VENDOR_ID, PIRELLI_PRODUCT_100A)},
720 { USB_DEVICE(PIRELLI_VENDOR_ID, PIRELLI_PRODUCT_100B) },
721 { USB_DEVICE(PIRELLI_VENDOR_ID, PIRELLI_PRODUCT_100C) },
722 { USB_DEVICE(PIRELLI_VENDOR_ID, PIRELLI_PRODUCT_100D) },
723 { USB_DEVICE(PIRELLI_VENDOR_ID, PIRELLI_PRODUCT_100E) },
724 { USB_DEVICE(PIRELLI_VENDOR_ID, PIRELLI_PRODUCT_100F) },
725 { USB_DEVICE(PIRELLI_VENDOR_ID, PIRELLI_PRODUCT_1011)},
726 { USB_DEVICE(PIRELLI_VENDOR_ID, PIRELLI_PRODUCT_1012)},
727
728 { USB_DEVICE(CINTERION_VENDOR_ID, 0x0047) },
607 { } /* Terminating entry */ 729 { } /* Terminating entry */
608}; 730};
609MODULE_DEVICE_TABLE(usb, option_ids); 731MODULE_DEVICE_TABLE(usb, option_ids);
@@ -667,6 +789,7 @@ struct option_intf_private {
667 spinlock_t susp_lock; 789 spinlock_t susp_lock;
668 unsigned int suspended:1; 790 unsigned int suspended:1;
669 int in_flight; 791 int in_flight;
792 struct option_blacklist_info *blacklist_info;
670}; 793};
671 794
672struct option_port_private { 795struct option_port_private {
@@ -726,19 +849,44 @@ static int option_probe(struct usb_serial *serial,
726 const struct usb_device_id *id) 849 const struct usb_device_id *id)
727{ 850{
728 struct option_intf_private *data; 851 struct option_intf_private *data;
852
729 /* D-Link DWM 652 still exposes CD-Rom emulation interface in modem mode */ 853 /* D-Link DWM 652 still exposes CD-Rom emulation interface in modem mode */
730 if (serial->dev->descriptor.idVendor == DLINK_VENDOR_ID && 854 if (serial->dev->descriptor.idVendor == DLINK_VENDOR_ID &&
731 serial->dev->descriptor.idProduct == DLINK_PRODUCT_DWM_652 && 855 serial->dev->descriptor.idProduct == DLINK_PRODUCT_DWM_652 &&
732 serial->interface->cur_altsetting->desc.bInterfaceClass == 0x8) 856 serial->interface->cur_altsetting->desc.bInterfaceClass == 0x8)
733 return -ENODEV; 857 return -ENODEV;
734 858
859 /* Bandrich modem and AT command interface is 0xff */
860 if ((serial->dev->descriptor.idVendor == BANDRICH_VENDOR_ID ||
861 serial->dev->descriptor.idVendor == PIRELLI_VENDOR_ID) &&
862 serial->interface->cur_altsetting->desc.bInterfaceClass != 0xff)
863 return -ENODEV;
864
735 data = serial->private = kzalloc(sizeof(struct option_intf_private), GFP_KERNEL); 865 data = serial->private = kzalloc(sizeof(struct option_intf_private), GFP_KERNEL);
736 if (!data) 866 if (!data)
737 return -ENOMEM; 867 return -ENOMEM;
738 spin_lock_init(&data->susp_lock); 868 spin_lock_init(&data->susp_lock);
869 data->blacklist_info = (struct option_blacklist_info*) id->driver_info;
739 return 0; 870 return 0;
740} 871}
741 872
873static enum option_blacklist_reason is_blacklisted(const u8 ifnum,
874 const struct option_blacklist_info *blacklist)
875{
876 const u8 *info;
877 int i;
878
879 if (blacklist) {
880 info = blacklist->ifaceinfo;
881
882 for (i = 0; i < blacklist->infolen; i++) {
883 if (info[i] == ifnum)
884 return blacklist->reason;
885 }
886 }
887 return OPTION_BLACKLIST_NONE;
888}
889
742static void option_set_termios(struct tty_struct *tty, 890static void option_set_termios(struct tty_struct *tty,
743 struct usb_serial_port *port, struct ktermios *old_termios) 891 struct usb_serial_port *port, struct ktermios *old_termios)
744{ 892{
@@ -879,7 +1027,6 @@ static void option_indat_callback(struct urb *urb)
879 } else { 1027 } else {
880 tty = tty_port_tty_get(&port->port); 1028 tty = tty_port_tty_get(&port->port);
881 if (urb->actual_length) { 1029 if (urb->actual_length) {
882 tty_buffer_request_room(tty, urb->actual_length);
883 tty_insert_flip_string(tty, data, urb->actual_length); 1030 tty_insert_flip_string(tty, data, urb->actual_length);
884 tty_flip_buffer_push(tty); 1031 tty_flip_buffer_push(tty);
885 } else 1032 } else
@@ -887,9 +1034,9 @@ static void option_indat_callback(struct urb *urb)
887 tty_kref_put(tty); 1034 tty_kref_put(tty);
888 1035
889 /* Resubmit urb so we continue receiving */ 1036 /* Resubmit urb so we continue receiving */
890 if (port->port.count && status != -ESHUTDOWN) { 1037 if (status != -ESHUTDOWN) {
891 err = usb_submit_urb(urb, GFP_ATOMIC); 1038 err = usb_submit_urb(urb, GFP_ATOMIC);
892 if (err) 1039 if (err && err != -EPERM)
893 printk(KERN_ERR "%s: resubmit read urb failed. " 1040 printk(KERN_ERR "%s: resubmit read urb failed. "
894 "(%d)", __func__, err); 1041 "(%d)", __func__, err);
895 else 1042 else
@@ -943,7 +1090,7 @@ static void option_instat_callback(struct urb *urb)
943 (struct usb_ctrlrequest *)urb->transfer_buffer; 1090 (struct usb_ctrlrequest *)urb->transfer_buffer;
944 1091
945 if (!req_pkt) { 1092 if (!req_pkt) {
946 dbg("%s: NULL req_pkt\n", __func__); 1093 dbg("%s: NULL req_pkt", __func__);
947 return; 1094 return;
948 } 1095 }
949 if ((req_pkt->bRequestType == 0xA1) && 1096 if ((req_pkt->bRequestType == 0xA1) &&
@@ -1169,11 +1316,19 @@ static void option_setup_urbs(struct usb_serial *serial)
1169static int option_send_setup(struct usb_serial_port *port) 1316static int option_send_setup(struct usb_serial_port *port)
1170{ 1317{
1171 struct usb_serial *serial = port->serial; 1318 struct usb_serial *serial = port->serial;
1319 struct option_intf_private *intfdata =
1320 (struct option_intf_private *) serial->private;
1172 struct option_port_private *portdata; 1321 struct option_port_private *portdata;
1173 int ifNum = serial->interface->cur_altsetting->desc.bInterfaceNumber; 1322 int ifNum = serial->interface->cur_altsetting->desc.bInterfaceNumber;
1174 int val = 0; 1323 int val = 0;
1175 dbg("%s", __func__); 1324 dbg("%s", __func__);
1176 1325
1326 if (is_blacklisted(ifNum, intfdata->blacklist_info) ==
1327 OPTION_BLACKLIST_SENDSETUP) {
1328 dbg("No send_setup on blacklisted interface #%d\n", ifNum);
1329 return -EIO;
1330 }
1331
1177 portdata = usb_get_serial_port_data(port); 1332 portdata = usb_get_serial_port_data(port);
1178 1333
1179 if (portdata->dtr_state) 1334 if (portdata->dtr_state)
@@ -1312,7 +1467,7 @@ static int option_suspend(struct usb_serial *serial, pm_message_t message)
1312 1467
1313 dbg("%s entered", __func__); 1468 dbg("%s entered", __func__);
1314 1469
1315 if (serial->dev->auto_pm) { 1470 if (message.event & PM_EVENT_AUTO) {
1316 spin_lock_irq(&intfdata->susp_lock); 1471 spin_lock_irq(&intfdata->susp_lock);
1317 b = intfdata->in_flight; 1472 b = intfdata->in_flight;
1318 spin_unlock_irq(&intfdata->susp_lock); 1473 spin_unlock_irq(&intfdata->susp_lock);
@@ -1359,7 +1514,7 @@ static int option_resume(struct usb_serial *serial)
1359 for (i = 0; i < serial->num_ports; i++) { 1514 for (i = 0; i < serial->num_ports; i++) {
1360 port = serial->port[i]; 1515 port = serial->port[i];
1361 if (!port->interrupt_in_urb) { 1516 if (!port->interrupt_in_urb) {
1362 dbg("%s: No interrupt URB for port %d\n", __func__, i); 1517 dbg("%s: No interrupt URB for port %d", __func__, i);
1363 continue; 1518 continue;
1364 } 1519 }
1365 err = usb_submit_urb(port->interrupt_in_urb, GFP_NOIO); 1520 err = usb_submit_urb(port->interrupt_in_urb, GFP_NOIO);
diff --git a/drivers/usb/serial/oti6858.c b/drivers/usb/serial/oti6858.c
index c644e26394b4..deeacdea05db 100644
--- a/drivers/usb/serial/oti6858.c
+++ b/drivers/usb/serial/oti6858.c
@@ -58,7 +58,7 @@
58#define OTI6858_AUTHOR "Tomasz Michal Lukaszewski <FIXME@FIXME>" 58#define OTI6858_AUTHOR "Tomasz Michal Lukaszewski <FIXME@FIXME>"
59#define OTI6858_VERSION "0.1" 59#define OTI6858_VERSION "0.1"
60 60
61static struct usb_device_id id_table [] = { 61static const struct usb_device_id id_table[] = {
62 { USB_DEVICE(OTI6858_VENDOR_ID, OTI6858_PRODUCT_ID) }, 62 { USB_DEVICE(OTI6858_VENDOR_ID, OTI6858_PRODUCT_ID) },
63 { } 63 { }
64}; 64};
@@ -302,7 +302,7 @@ void send_data(struct work_struct *work)
302 struct usb_serial_port *port = priv->port; 302 struct usb_serial_port *port = priv->port;
303 int count = 0, result; 303 int count = 0, result;
304 unsigned long flags; 304 unsigned long flags;
305 unsigned char allow; 305 u8 *allow;
306 306
307 dbg("%s(port = %d)", __func__, port->number); 307 dbg("%s(port = %d)", __func__, port->number);
308 308
@@ -321,13 +321,20 @@ void send_data(struct work_struct *work)
321 count = port->bulk_out_size; 321 count = port->bulk_out_size;
322 322
323 if (count != 0) { 323 if (count != 0) {
324 allow = kmalloc(1, GFP_KERNEL);
325 if (!allow) {
326 dev_err(&port->dev, "%s(): kmalloc failed\n",
327 __func__);
328 return;
329 }
324 result = usb_control_msg(port->serial->dev, 330 result = usb_control_msg(port->serial->dev,
325 usb_rcvctrlpipe(port->serial->dev, 0), 331 usb_rcvctrlpipe(port->serial->dev, 0),
326 OTI6858_REQ_T_CHECK_TXBUFF, 332 OTI6858_REQ_T_CHECK_TXBUFF,
327 OTI6858_REQ_CHECK_TXBUFF, 333 OTI6858_REQ_CHECK_TXBUFF,
328 count, 0, &allow, 1, 100); 334 count, 0, allow, 1, 100);
329 if (result != 1 || allow != 0) 335 if (result != 1 || *allow != 0)
330 count = 0; 336 count = 0;
337 kfree(allow);
331 } 338 }
332 339
333 if (count == 0) { 340 if (count == 0) {
@@ -578,9 +585,6 @@ static int oti6858_open(struct tty_struct *tty, struct usb_serial_port *port)
578 usb_clear_halt(serial->dev, port->write_urb->pipe); 585 usb_clear_halt(serial->dev, port->write_urb->pipe);
579 usb_clear_halt(serial->dev, port->read_urb->pipe); 586 usb_clear_halt(serial->dev, port->read_urb->pipe);
580 587
581 if (port->port.count != 1)
582 return 0;
583
584 buf = kmalloc(OTI6858_CTRL_PKT_SIZE, GFP_KERNEL); 588 buf = kmalloc(OTI6858_CTRL_PKT_SIZE, GFP_KERNEL);
585 if (buf == NULL) { 589 if (buf == NULL) {
586 dev_err(&port->dev, "%s(): out of memory!\n", __func__); 590 dev_err(&port->dev, "%s(): out of memory!\n", __func__);
@@ -927,10 +931,6 @@ static void oti6858_read_bulk_callback(struct urb *urb)
927 spin_unlock_irqrestore(&priv->lock, flags); 931 spin_unlock_irqrestore(&priv->lock, flags);
928 932
929 if (status != 0) { 933 if (status != 0) {
930 if (!port->port.count) {
931 dbg("%s(): port is closed, exiting", __func__);
932 return;
933 }
934 /* 934 /*
935 if (status == -EPROTO) { 935 if (status == -EPROTO) {
936 * PL2303 mysteriously fails with -EPROTO reschedule 936 * PL2303 mysteriously fails with -EPROTO reschedule
@@ -954,14 +954,12 @@ static void oti6858_read_bulk_callback(struct urb *urb)
954 } 954 }
955 tty_kref_put(tty); 955 tty_kref_put(tty);
956 956
957 /* schedule the interrupt urb if we are still open */ 957 /* schedule the interrupt urb */
958 if (port->port.count != 0) { 958 port->interrupt_in_urb->dev = port->serial->dev;
959 port->interrupt_in_urb->dev = port->serial->dev; 959 result = usb_submit_urb(port->interrupt_in_urb, GFP_ATOMIC);
960 result = usb_submit_urb(port->interrupt_in_urb, GFP_ATOMIC); 960 if (result != 0 && result != -EPERM) {
961 if (result != 0) { 961 dev_err(&port->dev, "%s(): usb_submit_urb() failed,"
962 dev_err(&port->dev, "%s(): usb_submit_urb() failed," 962 " error %d\n", __func__, result);
963 " error %d\n", __func__, result);
964 }
965 } 963 }
966} 964}
967 965
diff --git a/drivers/usb/serial/pl2303.c b/drivers/usb/serial/pl2303.c
index 9ec1a49e2362..c28b1607eacc 100644
--- a/drivers/usb/serial/pl2303.c
+++ b/drivers/usb/serial/pl2303.c
@@ -50,7 +50,7 @@ struct pl2303_buf {
50 char *buf_put; 50 char *buf_put;
51}; 51};
52 52
53static struct usb_device_id id_table [] = { 53static const struct usb_device_id id_table[] = {
54 { USB_DEVICE(PL2303_VENDOR_ID, PL2303_PRODUCT_ID) }, 54 { USB_DEVICE(PL2303_VENDOR_ID, PL2303_PRODUCT_ID) },
55 { USB_DEVICE(PL2303_VENDOR_ID, PL2303_PRODUCT_ID_RSAQ2) }, 55 { USB_DEVICE(PL2303_VENDOR_ID, PL2303_PRODUCT_ID_RSAQ2) },
56 { USB_DEVICE(PL2303_VENDOR_ID, PL2303_PRODUCT_ID_DCU11) }, 56 { USB_DEVICE(PL2303_VENDOR_ID, PL2303_PRODUCT_ID_DCU11) },
@@ -59,6 +59,7 @@ static struct usb_device_id id_table [] = {
59 { USB_DEVICE(PL2303_VENDOR_ID, PL2303_PRODUCT_ID_ALDIGA) }, 59 { USB_DEVICE(PL2303_VENDOR_ID, PL2303_PRODUCT_ID_ALDIGA) },
60 { USB_DEVICE(PL2303_VENDOR_ID, PL2303_PRODUCT_ID_MMX) }, 60 { USB_DEVICE(PL2303_VENDOR_ID, PL2303_PRODUCT_ID_MMX) },
61 { USB_DEVICE(PL2303_VENDOR_ID, PL2303_PRODUCT_ID_GPRS) }, 61 { USB_DEVICE(PL2303_VENDOR_ID, PL2303_PRODUCT_ID_GPRS) },
62 { USB_DEVICE(PL2303_VENDOR_ID, PL2303_PRODUCT_ID_HCR331) },
62 { USB_DEVICE(IODATA_VENDOR_ID, IODATA_PRODUCT_ID) }, 63 { USB_DEVICE(IODATA_VENDOR_ID, IODATA_PRODUCT_ID) },
63 { USB_DEVICE(IODATA_VENDOR_ID, IODATA_PRODUCT_ID_RSAQ5) }, 64 { USB_DEVICE(IODATA_VENDOR_ID, IODATA_PRODUCT_ID_RSAQ5) },
64 { USB_DEVICE(ATEN_VENDOR_ID, ATEN_PRODUCT_ID) }, 65 { USB_DEVICE(ATEN_VENDOR_ID, ATEN_PRODUCT_ID) },
@@ -97,6 +98,7 @@ static struct usb_device_id id_table [] = {
97 { USB_DEVICE(CRESSI_VENDOR_ID, CRESSI_EDY_PRODUCT_ID) }, 98 { USB_DEVICE(CRESSI_VENDOR_ID, CRESSI_EDY_PRODUCT_ID) },
98 { USB_DEVICE(SONY_VENDOR_ID, SONY_QN3USB_PRODUCT_ID) }, 99 { USB_DEVICE(SONY_VENDOR_ID, SONY_QN3USB_PRODUCT_ID) },
99 { USB_DEVICE(SANWA_VENDOR_ID, SANWA_PRODUCT_ID) }, 100 { USB_DEVICE(SANWA_VENDOR_ID, SANWA_PRODUCT_ID) },
101 { USB_DEVICE(ADLINK_VENDOR_ID, ADLINK_ND6530_PRODUCT_ID) },
100 { } /* Terminating entry */ 102 { } /* Terminating entry */
101}; 103};
102 104
@@ -451,7 +453,6 @@ static void pl2303_send(struct usb_serial_port *port)
451 port->write_urb->transfer_buffer); 453 port->write_urb->transfer_buffer);
452 454
453 port->write_urb->transfer_buffer_length = count; 455 port->write_urb->transfer_buffer_length = count;
454 port->write_urb->dev = port->serial->dev;
455 result = usb_submit_urb(port->write_urb, GFP_ATOMIC); 456 result = usb_submit_urb(port->write_urb, GFP_ATOMIC);
456 if (result) { 457 if (result) {
457 dev_err(&port->dev, "%s - failed submitting write urb," 458 dev_err(&port->dev, "%s - failed submitting write urb,"
@@ -769,7 +770,6 @@ static int pl2303_open(struct tty_struct *tty, struct usb_serial_port *port)
769 pl2303_set_termios(tty, port, &tmp_termios); 770 pl2303_set_termios(tty, port, &tmp_termios);
770 771
771 dbg("%s - submitting read urb", __func__); 772 dbg("%s - submitting read urb", __func__);
772 port->read_urb->dev = serial->dev;
773 result = usb_submit_urb(port->read_urb, GFP_KERNEL); 773 result = usb_submit_urb(port->read_urb, GFP_KERNEL);
774 if (result) { 774 if (result) {
775 dev_err(&port->dev, "%s - failed submitting read urb," 775 dev_err(&port->dev, "%s - failed submitting read urb,"
@@ -779,7 +779,6 @@ static int pl2303_open(struct tty_struct *tty, struct usb_serial_port *port)
779 } 779 }
780 780
781 dbg("%s - submitting interrupt urb", __func__); 781 dbg("%s - submitting interrupt urb", __func__);
782 port->interrupt_in_urb->dev = serial->dev;
783 result = usb_submit_urb(port->interrupt_in_urb, GFP_KERNEL); 782 result = usb_submit_urb(port->interrupt_in_urb, GFP_KERNEL);
784 if (result) { 783 if (result) {
785 dev_err(&port->dev, "%s - failed submitting interrupt urb," 784 dev_err(&port->dev, "%s - failed submitting interrupt urb,"
@@ -895,10 +894,23 @@ static int wait_modem_info(struct usb_serial_port *port, unsigned int arg)
895static int pl2303_ioctl(struct tty_struct *tty, struct file *file, 894static int pl2303_ioctl(struct tty_struct *tty, struct file *file,
896 unsigned int cmd, unsigned long arg) 895 unsigned int cmd, unsigned long arg)
897{ 896{
897 struct serial_struct ser;
898 struct usb_serial_port *port = tty->driver_data; 898 struct usb_serial_port *port = tty->driver_data;
899 dbg("%s (%d) cmd = 0x%04x", __func__, port->number, cmd); 899 dbg("%s (%d) cmd = 0x%04x", __func__, port->number, cmd);
900 900
901 switch (cmd) { 901 switch (cmd) {
902 case TIOCGSERIAL:
903 memset(&ser, 0, sizeof ser);
904 ser.type = PORT_16654;
905 ser.line = port->serial->minor;
906 ser.port = port->number;
907 ser.baud_base = 460800;
908
909 if (copy_to_user((void __user *)arg, &ser, sizeof ser))
910 return -EFAULT;
911
912 return 0;
913
902 case TIOCMIWAIT: 914 case TIOCMIWAIT:
903 dbg("%s (%d) TIOCMIWAIT", __func__, port->number); 915 dbg("%s (%d) TIOCMIWAIT", __func__, port->number);
904 return wait_modem_info(port, arg); 916 return wait_modem_info(port, arg);
@@ -1042,7 +1054,6 @@ static void pl2303_push_data(struct tty_struct *tty,
1042 tty_flag = TTY_FRAME; 1054 tty_flag = TTY_FRAME;
1043 dbg("%s - tty_flag = %d", __func__, tty_flag); 1055 dbg("%s - tty_flag = %d", __func__, tty_flag);
1044 1056
1045 tty_buffer_request_room(tty, urb->actual_length + 1);
1046 /* overrun is special, not associated with a char */ 1057 /* overrun is special, not associated with a char */
1047 if (line_status & UART_OVERRUN_ERROR) 1058 if (line_status & UART_OVERRUN_ERROR)
1048 tty_insert_flip_char(tty, 0, TTY_OVERRUN); 1059 tty_insert_flip_char(tty, 0, TTY_OVERRUN);
@@ -1072,16 +1083,11 @@ static void pl2303_read_bulk_callback(struct urb *urb)
1072 1083
1073 if (status) { 1084 if (status) {
1074 dbg("%s - urb status = %d", __func__, status); 1085 dbg("%s - urb status = %d", __func__, status);
1075 if (!port->port.count) {
1076 dbg("%s - port is closed, exiting.", __func__);
1077 return;
1078 }
1079 if (status == -EPROTO) { 1086 if (status == -EPROTO) {
1080 /* PL2303 mysteriously fails with -EPROTO reschedule 1087 /* PL2303 mysteriously fails with -EPROTO reschedule
1081 * the read */ 1088 * the read */
1082 dbg("%s - caught -EPROTO, resubmitting the urb", 1089 dbg("%s - caught -EPROTO, resubmitting the urb",
1083 __func__); 1090 __func__);
1084 urb->dev = port->serial->dev;
1085 result = usb_submit_urb(urb, GFP_ATOMIC); 1091 result = usb_submit_urb(urb, GFP_ATOMIC);
1086 if (result) 1092 if (result)
1087 dev_err(&urb->dev->dev, "%s - failed" 1093 dev_err(&urb->dev->dev, "%s - failed"
@@ -1108,15 +1114,10 @@ static void pl2303_read_bulk_callback(struct urb *urb)
1108 } 1114 }
1109 tty_kref_put(tty); 1115 tty_kref_put(tty);
1110 /* Schedule the next read _if_ we are still open */ 1116 /* Schedule the next read _if_ we are still open */
1111 if (port->port.count) { 1117 result = usb_submit_urb(urb, GFP_ATOMIC);
1112 urb->dev = port->serial->dev; 1118 if (result && result != -EPERM)
1113 result = usb_submit_urb(urb, GFP_ATOMIC); 1119 dev_err(&urb->dev->dev, "%s - failed resubmitting"
1114 if (result) 1120 " read urb, error %d\n", __func__, result);
1115 dev_err(&urb->dev->dev, "%s - failed resubmitting"
1116 " read urb, error %d\n", __func__, result);
1117 }
1118
1119 return;
1120} 1121}
1121 1122
1122static void pl2303_write_bulk_callback(struct urb *urb) 1123static void pl2303_write_bulk_callback(struct urb *urb)
@@ -1146,7 +1147,6 @@ static void pl2303_write_bulk_callback(struct urb *urb)
1146 dbg("%s - nonzero write bulk status received: %d", __func__, 1147 dbg("%s - nonzero write bulk status received: %d", __func__,
1147 status); 1148 status);
1148 port->write_urb->transfer_buffer_length = 1; 1149 port->write_urb->transfer_buffer_length = 1;
1149 port->write_urb->dev = port->serial->dev;
1150 result = usb_submit_urb(port->write_urb, GFP_ATOMIC); 1150 result = usb_submit_urb(port->write_urb, GFP_ATOMIC);
1151 if (result) 1151 if (result)
1152 dev_err(&urb->dev->dev, "%s - failed resubmitting write" 1152 dev_err(&urb->dev->dev, "%s - failed resubmitting write"
diff --git a/drivers/usb/serial/pl2303.h b/drivers/usb/serial/pl2303.h
index d640dc951568..23c09b38b9ec 100644
--- a/drivers/usb/serial/pl2303.h
+++ b/drivers/usb/serial/pl2303.h
@@ -20,6 +20,7 @@
20#define PL2303_PRODUCT_ID_ALDIGA 0x0611 20#define PL2303_PRODUCT_ID_ALDIGA 0x0611
21#define PL2303_PRODUCT_ID_MMX 0x0612 21#define PL2303_PRODUCT_ID_MMX 0x0612
22#define PL2303_PRODUCT_ID_GPRS 0x0609 22#define PL2303_PRODUCT_ID_GPRS 0x0609
23#define PL2303_PRODUCT_ID_HCR331 0x331a
23 24
24#define ATEN_VENDOR_ID 0x0557 25#define ATEN_VENDOR_ID 0x0557
25#define ATEN_VENDOR_ID2 0x0547 26#define ATEN_VENDOR_ID2 0x0547
@@ -134,3 +135,7 @@
134/* Sanwa KB-USB2 multimeter cable (ID: 11ad:0001) */ 135/* Sanwa KB-USB2 multimeter cable (ID: 11ad:0001) */
135#define SANWA_VENDOR_ID 0x11ad 136#define SANWA_VENDOR_ID 0x11ad
136#define SANWA_PRODUCT_ID 0x0001 137#define SANWA_PRODUCT_ID 0x0001
138
139/* ADLINK ND-6530 RS232,RS485 and RS422 adapter */
140#define ADLINK_VENDOR_ID 0x0b63
141#define ADLINK_ND6530_PRODUCT_ID 0x6530
diff --git a/drivers/usb/serial/qcaux.c b/drivers/usb/serial/qcaux.c
new file mode 100644
index 000000000000..7e3bea23600b
--- /dev/null
+++ b/drivers/usb/serial/qcaux.c
@@ -0,0 +1,106 @@
1/*
2 * Qualcomm USB Auxiliary Serial Port driver
3 *
4 * Copyright (C) 2008 Greg Kroah-Hartman <greg@kroah.com>
5 * Copyright (C) 2010 Dan Williams <dcbw@redhat.com>
6 *
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License version 2 as
9 * published by the Free Software Foundation.
10 *
11 * Devices listed here usually provide a CDC ACM port on which normal modem
12 * AT commands and PPP can be used. But when that port is in-use by PPP it
13 * cannot be used simultaneously for status or signal strength. Instead, the
14 * ports here can be queried for that information using the Qualcomm DM
15 * protocol.
16 */
17
18#include <linux/kernel.h>
19#include <linux/init.h>
20#include <linux/tty.h>
21#include <linux/module.h>
22#include <linux/usb.h>
23#include <linux/usb/serial.h>
24
25/* NOTE: for now, only use this driver for devices that provide a CDC-ACM port
26 * for normal AT commands, but also provide secondary USB interfaces for the
27 * QCDM-capable ports. Devices that do not provide a CDC-ACM port should
28 * probably be driven by option.ko.
29 */
30
31/* UTStarcom/Pantech/Curitel devices */
32#define UTSTARCOM_VENDOR_ID 0x106c
33#define UTSTARCOM_PRODUCT_PC5740 0x3701
34#define UTSTARCOM_PRODUCT_PC5750 0x3702 /* aka Pantech PX-500 */
35#define UTSTARCOM_PRODUCT_UM150 0x3711
36#define UTSTARCOM_PRODUCT_UM175_V1 0x3712
37#define UTSTARCOM_PRODUCT_UM175_V2 0x3714
38#define UTSTARCOM_PRODUCT_UM175_ALLTEL 0x3715
39
40/* CMOTECH devices */
41#define CMOTECH_VENDOR_ID 0x16d8
42#define CMOTECH_PRODUCT_CDU550 0x5553
43#define CMOTECH_PRODUCT_CDX650 0x6512
44
45/* LG devices */
46#define LG_VENDOR_ID 0x1004
47#define LG_PRODUCT_VX4400_6000 0x6000 /* VX4400/VX6000/Rumor */
48
49/* Sanyo devices */
50#define SANYO_VENDOR_ID 0x0474
51#define SANYO_PRODUCT_KATANA_LX 0x0754 /* SCP-3800 (Katana LX) */
52
53static struct usb_device_id id_table[] = {
54 { USB_DEVICE_AND_INTERFACE_INFO(UTSTARCOM_VENDOR_ID, UTSTARCOM_PRODUCT_PC5740, 0xff, 0x00, 0x00) },
55 { USB_DEVICE_AND_INTERFACE_INFO(UTSTARCOM_VENDOR_ID, UTSTARCOM_PRODUCT_PC5750, 0xff, 0x00, 0x00) },
56 { USB_DEVICE_AND_INTERFACE_INFO(UTSTARCOM_VENDOR_ID, UTSTARCOM_PRODUCT_UM150, 0xff, 0x00, 0x00) },
57 { USB_DEVICE_AND_INTERFACE_INFO(UTSTARCOM_VENDOR_ID, UTSTARCOM_PRODUCT_UM175_V1, 0xff, 0x00, 0x00) },
58 { USB_DEVICE_AND_INTERFACE_INFO(UTSTARCOM_VENDOR_ID, UTSTARCOM_PRODUCT_UM175_V2, 0xff, 0x00, 0x00) },
59 { USB_DEVICE_AND_INTERFACE_INFO(UTSTARCOM_VENDOR_ID, UTSTARCOM_PRODUCT_UM175_ALLTEL, 0xff, 0x00, 0x00) },
60 { USB_DEVICE_AND_INTERFACE_INFO(CMOTECH_VENDOR_ID, CMOTECH_PRODUCT_CDU550, 0xff, 0xff, 0x00) },
61 { USB_DEVICE_AND_INTERFACE_INFO(CMOTECH_VENDOR_ID, CMOTECH_PRODUCT_CDX650, 0xff, 0xff, 0x00) },
62 { USB_DEVICE_AND_INTERFACE_INFO(LG_VENDOR_ID, LG_PRODUCT_VX4400_6000, 0xff, 0xff, 0x00) },
63 { USB_DEVICE_AND_INTERFACE_INFO(SANYO_VENDOR_ID, SANYO_PRODUCT_KATANA_LX, 0xff, 0xff, 0x00) },
64 { },
65};
66MODULE_DEVICE_TABLE(usb, id_table);
67
68static struct usb_driver qcaux_driver = {
69 .name = "qcaux",
70 .probe = usb_serial_probe,
71 .disconnect = usb_serial_disconnect,
72 .id_table = id_table,
73 .no_dynamic_id = 1,
74};
75
76static struct usb_serial_driver qcaux_device = {
77 .driver = {
78 .owner = THIS_MODULE,
79 .name = "qcaux",
80 },
81 .id_table = id_table,
82 .num_ports = 1,
83};
84
85static int __init qcaux_init(void)
86{
87 int retval;
88
89 retval = usb_serial_register(&qcaux_device);
90 if (retval)
91 return retval;
92 retval = usb_register(&qcaux_driver);
93 if (retval)
94 usb_serial_deregister(&qcaux_device);
95 return retval;
96}
97
98static void __exit qcaux_exit(void)
99{
100 usb_deregister(&qcaux_driver);
101 usb_serial_deregister(&qcaux_device);
102}
103
104module_init(qcaux_init);
105module_exit(qcaux_exit);
106MODULE_LICENSE("GPL");
diff --git a/drivers/usb/serial/qcserial.c b/drivers/usb/serial/qcserial.c
index 7528b8d57f1c..53a2d5a935a2 100644
--- a/drivers/usb/serial/qcserial.c
+++ b/drivers/usb/serial/qcserial.c
@@ -21,7 +21,7 @@
21 21
22static int debug; 22static int debug;
23 23
24static struct usb_device_id id_table[] = { 24static const struct usb_device_id id_table[] = {
25 {USB_DEVICE(0x05c6, 0x9211)}, /* Acer Gobi QDL device */ 25 {USB_DEVICE(0x05c6, 0x9211)}, /* Acer Gobi QDL device */
26 {USB_DEVICE(0x05c6, 0x9212)}, /* Acer Gobi Modem Device */ 26 {USB_DEVICE(0x05c6, 0x9212)}, /* Acer Gobi Modem Device */
27 {USB_DEVICE(0x03f0, 0x1f1d)}, /* HP un2400 Gobi Modem Device */ 27 {USB_DEVICE(0x03f0, 0x1f1d)}, /* HP un2400 Gobi Modem Device */
@@ -47,6 +47,35 @@ static struct usb_device_id id_table[] = {
47 {USB_DEVICE(0x05c6, 0x9221)}, /* Generic Gobi QDL device */ 47 {USB_DEVICE(0x05c6, 0x9221)}, /* Generic Gobi QDL device */
48 {USB_DEVICE(0x05c6, 0x9231)}, /* Generic Gobi QDL device */ 48 {USB_DEVICE(0x05c6, 0x9231)}, /* Generic Gobi QDL device */
49 {USB_DEVICE(0x1f45, 0x0001)}, /* Unknown Gobi QDL device */ 49 {USB_DEVICE(0x1f45, 0x0001)}, /* Unknown Gobi QDL device */
50 {USB_DEVICE(0x413c, 0x8185)}, /* Dell Gobi 2000 QDL device (N0218, VU936) */
51 {USB_DEVICE(0x413c, 0x8186)}, /* Dell Gobi 2000 Modem device (N0218, VU936) */
52 {USB_DEVICE(0x05c6, 0x9224)}, /* Sony Gobi 2000 QDL device (N0279, VU730) */
53 {USB_DEVICE(0x05c6, 0x9225)}, /* Sony Gobi 2000 Modem device (N0279, VU730) */
54 {USB_DEVICE(0x05c6, 0x9244)}, /* Samsung Gobi 2000 QDL device (VL176) */
55 {USB_DEVICE(0x05c6, 0x9245)}, /* Samsung Gobi 2000 Modem device (VL176) */
56 {USB_DEVICE(0x03f0, 0x241d)}, /* HP Gobi 2000 QDL device (VP412) */
57 {USB_DEVICE(0x03f0, 0x251d)}, /* HP Gobi 2000 Modem device (VP412) */
58 {USB_DEVICE(0x05c6, 0x9214)}, /* Acer Gobi 2000 QDL device (VP413) */
59 {USB_DEVICE(0x05c6, 0x9215)}, /* Acer Gobi 2000 Modem device (VP413) */
60 {USB_DEVICE(0x05c6, 0x9264)}, /* Asus Gobi 2000 QDL device (VR305) */
61 {USB_DEVICE(0x05c6, 0x9265)}, /* Asus Gobi 2000 Modem device (VR305) */
62 {USB_DEVICE(0x05c6, 0x9234)}, /* Top Global Gobi 2000 QDL device (VR306) */
63 {USB_DEVICE(0x05c6, 0x9235)}, /* Top Global Gobi 2000 Modem device (VR306) */
64 {USB_DEVICE(0x05c6, 0x9274)}, /* iRex Technologies Gobi 2000 QDL device (VR307) */
65 {USB_DEVICE(0x05c6, 0x9275)}, /* iRex Technologies Gobi 2000 Modem device (VR307) */
66 {USB_DEVICE(0x1199, 0x9000)}, /* Sierra Wireless Gobi 2000 QDL device (VT773) */
67 {USB_DEVICE(0x1199, 0x9001)}, /* Sierra Wireless Gobi 2000 Modem device (VT773) */
68 {USB_DEVICE(0x1199, 0x9002)}, /* Sierra Wireless Gobi 2000 Modem device (VT773) */
69 {USB_DEVICE(0x1199, 0x9003)}, /* Sierra Wireless Gobi 2000 Modem device (VT773) */
70 {USB_DEVICE(0x1199, 0x9004)}, /* Sierra Wireless Gobi 2000 Modem device (VT773) */
71 {USB_DEVICE(0x1199, 0x9005)}, /* Sierra Wireless Gobi 2000 Modem device (VT773) */
72 {USB_DEVICE(0x1199, 0x9006)}, /* Sierra Wireless Gobi 2000 Modem device (VT773) */
73 {USB_DEVICE(0x1199, 0x9007)}, /* Sierra Wireless Gobi 2000 Modem device (VT773) */
74 {USB_DEVICE(0x1199, 0x9008)}, /* Sierra Wireless Gobi 2000 Modem device (VT773) */
75 {USB_DEVICE(0x1199, 0x9009)}, /* Sierra Wireless Gobi 2000 Modem device (VT773) */
76 {USB_DEVICE(0x1199, 0x900a)}, /* Sierra Wireless Gobi 2000 Modem device (VT773) */
77 {USB_DEVICE(0x16d8, 0x8001)}, /* CMDTech Gobi 2000 QDL device (VU922) */
78 {USB_DEVICE(0x16d8, 0x8002)}, /* CMDTech Gobi 2000 Modem device (VU922) */
50 { } /* Terminating entry */ 79 { } /* Terminating entry */
51}; 80};
52MODULE_DEVICE_TABLE(usb, id_table); 81MODULE_DEVICE_TABLE(usb, id_table);
diff --git a/drivers/usb/serial/safe_serial.c b/drivers/usb/serial/safe_serial.c
index 4b463cd140ef..43a0cadd5782 100644
--- a/drivers/usb/serial/safe_serial.c
+++ b/drivers/usb/serial/safe_serial.c
@@ -64,8 +64,8 @@
64 64
65#include <linux/kernel.h> 65#include <linux/kernel.h>
66#include <linux/errno.h> 66#include <linux/errno.h>
67#include <linux/gfp.h>
67#include <linux/init.h> 68#include <linux/init.h>
68#include <linux/slab.h>
69#include <linux/tty.h> 69#include <linux/tty.h>
70#include <linux/tty_driver.h> 70#include <linux/tty_driver.h>
71#include <linux/tty_flip.h> 71#include <linux/tty_flip.h>
diff --git a/drivers/usb/serial/siemens_mpi.c b/drivers/usb/serial/siemens_mpi.c
index 951ea0c6ba77..cb8195cabfde 100644
--- a/drivers/usb/serial/siemens_mpi.c
+++ b/drivers/usb/serial/siemens_mpi.c
@@ -22,7 +22,7 @@
22#define DRIVER_DESC "Driver for Siemens USB/MPI adapter" 22#define DRIVER_DESC "Driver for Siemens USB/MPI adapter"
23 23
24 24
25static struct usb_device_id id_table[] = { 25static const struct usb_device_id id_table[] = {
26 /* Vendor and product id for 6ES7-972-0CB20-0XA0 */ 26 /* Vendor and product id for 6ES7-972-0CB20-0XA0 */
27 { USB_DEVICE(0x908, 0x0004) }, 27 { USB_DEVICE(0x908, 0x0004) },
28 { }, 28 { },
diff --git a/drivers/usb/serial/sierra.c b/drivers/usb/serial/sierra.c
index 5019325ba25d..ef0bdb08d788 100644
--- a/drivers/usb/serial/sierra.c
+++ b/drivers/usb/serial/sierra.c
@@ -16,8 +16,9 @@
16 Portions based on the option driver by Matthias Urlichs <smurf@smurf.noris.de> 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> 17 Whom based his on the Keyspan driver by Hugh Blemings <hugh@blemings.org>
18*/ 18*/
19 19/* Uncomment to log function calls */
20#define DRIVER_VERSION "v.1.3.8" 20/* #define DEBUG */
21#define DRIVER_VERSION "v.1.7.16"
21#define DRIVER_AUTHOR "Kevin Lloyd, Elina Pasheva, Matthew Safar, Rory Filer" 22#define DRIVER_AUTHOR "Kevin Lloyd, Elina Pasheva, Matthew Safar, Rory Filer"
22#define DRIVER_DESC "USB Driver for Sierra Wireless USB modems" 23#define DRIVER_DESC "USB Driver for Sierra Wireless USB modems"
23 24
@@ -25,6 +26,7 @@
25#include <linux/jiffies.h> 26#include <linux/jiffies.h>
26#include <linux/errno.h> 27#include <linux/errno.h>
27#include <linux/tty.h> 28#include <linux/tty.h>
29#include <linux/slab.h>
28#include <linux/tty_flip.h> 30#include <linux/tty_flip.h>
29#include <linux/module.h> 31#include <linux/module.h>
30#include <linux/usb.h> 32#include <linux/usb.h>
@@ -33,8 +35,10 @@
33#define SWIMS_USB_REQUEST_SetPower 0x00 35#define SWIMS_USB_REQUEST_SetPower 0x00
34#define SWIMS_USB_REQUEST_SetNmea 0x07 36#define SWIMS_USB_REQUEST_SetNmea 0x07
35 37
36#define N_IN_URB 8 38#define N_IN_URB_HM 8
37#define N_OUT_URB 64 39#define N_OUT_URB_HM 64
40#define N_IN_URB 4
41#define N_OUT_URB 4
38#define IN_BUFLEN 4096 42#define IN_BUFLEN 4096
39 43
40#define MAX_TRANSFER (PAGE_SIZE - 512) 44#define MAX_TRANSFER (PAGE_SIZE - 512)
@@ -124,6 +128,23 @@ static int is_blacklisted(const u8 ifnum,
124 return 0; 128 return 0;
125} 129}
126 130
131static int is_himemory(const u8 ifnum,
132 const struct sierra_iface_info *himemorylist)
133{
134 const u8 *info;
135 int i;
136
137 if (himemorylist) {
138 info = himemorylist->ifaceinfo;
139
140 for (i=0; i < himemorylist->infolen; i++) {
141 if (info[i] == ifnum)
142 return 1;
143 }
144 }
145 return 0;
146}
147
127static int sierra_calc_interface(struct usb_serial *serial) 148static int sierra_calc_interface(struct usb_serial *serial)
128{ 149{
129 int interface; 150 int interface;
@@ -186,15 +207,30 @@ static int sierra_probe(struct usb_serial *serial,
186 return result; 207 return result;
187} 208}
188 209
210/* interfaces with higher memory requirements */
211static const u8 hi_memory_typeA_ifaces[] = { 0, 2 };
212static const struct sierra_iface_info typeA_interface_list = {
213 .infolen = ARRAY_SIZE(hi_memory_typeA_ifaces),
214 .ifaceinfo = hi_memory_typeA_ifaces,
215};
216
217static const u8 hi_memory_typeB_ifaces[] = { 3, 4, 5, 6 };
218static const struct sierra_iface_info typeB_interface_list = {
219 .infolen = ARRAY_SIZE(hi_memory_typeB_ifaces),
220 .ifaceinfo = hi_memory_typeB_ifaces,
221};
222
223/* 'blacklist' of interfaces not served by this driver */
189static const u8 direct_ip_non_serial_ifaces[] = { 7, 8, 9, 10, 11 }; 224static const u8 direct_ip_non_serial_ifaces[] = { 7, 8, 9, 10, 11 };
190static const struct sierra_iface_info direct_ip_interface_blacklist = { 225static const struct sierra_iface_info direct_ip_interface_blacklist = {
191 .infolen = ARRAY_SIZE(direct_ip_non_serial_ifaces), 226 .infolen = ARRAY_SIZE(direct_ip_non_serial_ifaces),
192 .ifaceinfo = direct_ip_non_serial_ifaces, 227 .ifaceinfo = direct_ip_non_serial_ifaces,
193}; 228};
194 229
195static struct usb_device_id id_table [] = { 230static const struct usb_device_id id_table[] = {
196 { USB_DEVICE(0x0F3D, 0x0112) }, /* Airprime/Sierra PC 5220 */ 231 { USB_DEVICE(0x0F3D, 0x0112) }, /* Airprime/Sierra PC 5220 */
197 { USB_DEVICE(0x03F0, 0x1B1D) }, /* HP ev2200 a.k.a MC5720 */ 232 { USB_DEVICE(0x03F0, 0x1B1D) }, /* HP ev2200 a.k.a MC5720 */
233 { USB_DEVICE(0x03F0, 0x211D) }, /* HP ev2210 a.k.a MC5725 */
198 { USB_DEVICE(0x03F0, 0x1E1D) }, /* HP hs2300 a.k.a MC8775 */ 234 { USB_DEVICE(0x03F0, 0x1E1D) }, /* HP hs2300 a.k.a MC8775 */
199 235
200 { USB_DEVICE(0x1199, 0x0017) }, /* Sierra Wireless EM5625 */ 236 { USB_DEVICE(0x1199, 0x0017) }, /* Sierra Wireless EM5625 */
@@ -264,21 +300,12 @@ static struct usb_device_id id_table [] = {
264 { USB_DEVICE(0x1199, 0x68A3), /* Sierra Wireless Direct IP modems */ 300 { USB_DEVICE(0x1199, 0x68A3), /* Sierra Wireless Direct IP modems */
265 .driver_info = (kernel_ulong_t)&direct_ip_interface_blacklist 301 .driver_info = (kernel_ulong_t)&direct_ip_interface_blacklist
266 }, 302 },
303 { USB_DEVICE(0x413C, 0x08133) }, /* Dell Computer Corp. Wireless 5720 VZW Mobile Broadband (EVDO Rev-A) Minicard GPS Port */
267 304
268 { } 305 { }
269}; 306};
270MODULE_DEVICE_TABLE(usb, id_table); 307MODULE_DEVICE_TABLE(usb, id_table);
271 308
272static struct usb_driver sierra_driver = {
273 .name = "sierra",
274 .probe = usb_serial_probe,
275 .disconnect = usb_serial_disconnect,
276 .suspend = usb_serial_suspend,
277 .resume = usb_serial_resume,
278 .id_table = id_table,
279 .no_dynamic_id = 1,
280 .supports_autosuspend = 1,
281};
282 309
283struct sierra_port_private { 310struct sierra_port_private {
284 spinlock_t lock; /* lock the structure */ 311 spinlock_t lock; /* lock the structure */
@@ -286,8 +313,10 @@ struct sierra_port_private {
286 struct usb_anchor active; 313 struct usb_anchor active;
287 struct usb_anchor delayed; 314 struct usb_anchor delayed;
288 315
316 int num_out_urbs;
317 int num_in_urbs;
289 /* Input endpoints and buffers for this port */ 318 /* Input endpoints and buffers for this port */
290 struct urb *in_urbs[N_IN_URB]; 319 struct urb *in_urbs[N_IN_URB_HM];
291 320
292 /* Settings for the port */ 321 /* Settings for the port */
293 int rts_state; /* Handshaking pins (outputs) */ 322 int rts_state; /* Handshaking pins (outputs) */
@@ -440,7 +469,7 @@ static void sierra_outdat_callback(struct urb *urb)
440static int sierra_write(struct tty_struct *tty, struct usb_serial_port *port, 469static int sierra_write(struct tty_struct *tty, struct usb_serial_port *port,
441 const unsigned char *buf, int count) 470 const unsigned char *buf, int count)
442{ 471{
443 struct sierra_port_private *portdata = usb_get_serial_port_data(port); 472 struct sierra_port_private *portdata;
444 struct sierra_intf_private *intfdata; 473 struct sierra_intf_private *intfdata;
445 struct usb_serial *serial = port->serial; 474 struct usb_serial *serial = port->serial;
446 unsigned long flags; 475 unsigned long flags;
@@ -460,7 +489,7 @@ static int sierra_write(struct tty_struct *tty, struct usb_serial_port *port,
460 spin_lock_irqsave(&portdata->lock, flags); 489 spin_lock_irqsave(&portdata->lock, flags);
461 dev_dbg(&port->dev, "%s - outstanding_urbs: %d\n", __func__, 490 dev_dbg(&port->dev, "%s - outstanding_urbs: %d\n", __func__,
462 portdata->outstanding_urbs); 491 portdata->outstanding_urbs);
463 if (portdata->outstanding_urbs > N_OUT_URB) { 492 if (portdata->outstanding_urbs > portdata->num_out_urbs) {
464 spin_unlock_irqrestore(&portdata->lock, flags); 493 spin_unlock_irqrestore(&portdata->lock, flags);
465 dev_dbg(&port->dev, "%s - write limit hit\n", __func__); 494 dev_dbg(&port->dev, "%s - write limit hit\n", __func__);
466 return 0; 495 return 0;
@@ -567,14 +596,15 @@ static void sierra_indat_callback(struct urb *urb)
567 } else { 596 } else {
568 if (urb->actual_length) { 597 if (urb->actual_length) {
569 tty = tty_port_tty_get(&port->port); 598 tty = tty_port_tty_get(&port->port);
570 599 if (tty) {
571 tty_buffer_request_room(tty, urb->actual_length); 600 tty_insert_flip_string(tty, data,
572 tty_insert_flip_string(tty, data, urb->actual_length); 601 urb->actual_length);
573 tty_flip_buffer_push(tty); 602 tty_flip_buffer_push(tty);
574 603
575 tty_kref_put(tty); 604 tty_kref_put(tty);
576 usb_serial_debug_data(debug, &port->dev, __func__, 605 usb_serial_debug_data(debug, &port->dev,
577 urb->actual_length, data); 606 __func__, urb->actual_length, data);
607 }
578 } else { 608 } else {
579 dev_dbg(&port->dev, "%s: empty read urb" 609 dev_dbg(&port->dev, "%s: empty read urb"
580 " received\n", __func__); 610 " received\n", __func__);
@@ -582,10 +612,10 @@ static void sierra_indat_callback(struct urb *urb)
582 } 612 }
583 613
584 /* Resubmit urb so we continue receiving */ 614 /* Resubmit urb so we continue receiving */
585 if (port->port.count && status != -ESHUTDOWN && status != -EPERM) { 615 if (status != -ESHUTDOWN && status != -EPERM) {
586 usb_mark_last_busy(port->serial->dev); 616 usb_mark_last_busy(port->serial->dev);
587 err = usb_submit_urb(urb, GFP_ATOMIC); 617 err = usb_submit_urb(urb, GFP_ATOMIC);
588 if (err) 618 if (err && err != -EPERM)
589 dev_err(&port->dev, "resubmit read urb failed." 619 dev_err(&port->dev, "resubmit read urb failed."
590 "(%d)\n", err); 620 "(%d)\n", err);
591 } 621 }
@@ -644,11 +674,11 @@ static void sierra_instat_callback(struct urb *urb)
644 dev_dbg(&port->dev, "%s: error %d\n", __func__, status); 674 dev_dbg(&port->dev, "%s: error %d\n", __func__, status);
645 675
646 /* Resubmit urb so we continue receiving IRQ data */ 676 /* Resubmit urb so we continue receiving IRQ data */
647 if (port->port.count && status != -ESHUTDOWN && status != -ENOENT) { 677 if (status != -ESHUTDOWN && status != -ENOENT) {
648 usb_mark_last_busy(serial->dev); 678 usb_mark_last_busy(serial->dev);
649 urb->dev = serial->dev; 679 urb->dev = serial->dev;
650 err = usb_submit_urb(urb, GFP_ATOMIC); 680 err = usb_submit_urb(urb, GFP_ATOMIC);
651 if (err) 681 if (err && err != -EPERM)
652 dev_err(&port->dev, "%s: resubmit intr urb " 682 dev_err(&port->dev, "%s: resubmit intr urb "
653 "failed. (%d)\n", __func__, err); 683 "failed. (%d)\n", __func__, err);
654 } 684 }
@@ -665,7 +695,7 @@ static int sierra_write_room(struct tty_struct *tty)
665 /* try to give a good number back based on if we have any free urbs at 695 /* try to give a good number back based on if we have any free urbs at
666 * this point in time */ 696 * this point in time */
667 spin_lock_irqsave(&portdata->lock, flags); 697 spin_lock_irqsave(&portdata->lock, flags);
668 if (portdata->outstanding_urbs > N_OUT_URB * 2 / 3) { 698 if (portdata->outstanding_urbs > (portdata->num_out_urbs * 2) / 3) {
669 spin_unlock_irqrestore(&portdata->lock, flags); 699 spin_unlock_irqrestore(&portdata->lock, flags);
670 dev_dbg(&port->dev, "%s - write limit hit\n", __func__); 700 dev_dbg(&port->dev, "%s - write limit hit\n", __func__);
671 return 0; 701 return 0;
@@ -680,7 +710,7 @@ static void sierra_stop_rx_urbs(struct usb_serial_port *port)
680 int i; 710 int i;
681 struct sierra_port_private *portdata = usb_get_serial_port_data(port); 711 struct sierra_port_private *portdata = usb_get_serial_port_data(port);
682 712
683 for (i = 0; i < ARRAY_SIZE(portdata->in_urbs); i++) 713 for (i = 0; i < portdata->num_in_urbs; i++)
684 usb_kill_urb(portdata->in_urbs[i]); 714 usb_kill_urb(portdata->in_urbs[i]);
685 715
686 usb_kill_urb(port->interrupt_in_urb); 716 usb_kill_urb(port->interrupt_in_urb);
@@ -695,7 +725,7 @@ static int sierra_submit_rx_urbs(struct usb_serial_port *port, gfp_t mem_flags)
695 struct sierra_port_private *portdata = usb_get_serial_port_data(port); 725 struct sierra_port_private *portdata = usb_get_serial_port_data(port);
696 726
697 ok_cnt = 0; 727 ok_cnt = 0;
698 for (i = 0; i < ARRAY_SIZE(portdata->in_urbs); i++) { 728 for (i = 0; i < portdata->num_in_urbs; i++) {
699 urb = portdata->in_urbs[i]; 729 urb = portdata->in_urbs[i];
700 if (!urb) 730 if (!urb)
701 continue; 731 continue;
@@ -791,7 +821,7 @@ static void sierra_close(struct usb_serial_port *port)
791 /* Stop reading urbs */ 821 /* Stop reading urbs */
792 sierra_stop_rx_urbs(port); 822 sierra_stop_rx_urbs(port);
793 /* .. and release them */ 823 /* .. and release them */
794 for (i = 0; i < N_IN_URB; i++) { 824 for (i = 0; i < portdata->num_in_urbs; i++) {
795 sierra_release_urb(portdata->in_urbs[i]); 825 sierra_release_urb(portdata->in_urbs[i]);
796 portdata->in_urbs[i] = NULL; 826 portdata->in_urbs[i] = NULL;
797 } 827 }
@@ -818,7 +848,7 @@ static int sierra_open(struct tty_struct *tty, struct usb_serial_port *port)
818 848
819 849
820 endpoint = port->bulk_in_endpointAddress; 850 endpoint = port->bulk_in_endpointAddress;
821 for (i = 0; i < ARRAY_SIZE(portdata->in_urbs); i++) { 851 for (i = 0; i < portdata->num_in_urbs; i++) {
822 urb = sierra_setup_urb(serial, endpoint, USB_DIR_IN, port, 852 urb = sierra_setup_urb(serial, endpoint, USB_DIR_IN, port,
823 IN_BUFLEN, GFP_KERNEL, 853 IN_BUFLEN, GFP_KERNEL,
824 sierra_indat_callback); 854 sierra_indat_callback);
@@ -869,7 +899,9 @@ static int sierra_startup(struct usb_serial *serial)
869{ 899{
870 struct usb_serial_port *port; 900 struct usb_serial_port *port;
871 struct sierra_port_private *portdata; 901 struct sierra_port_private *portdata;
902 struct sierra_iface_info *himemoryp = NULL;
872 int i; 903 int i;
904 u8 ifnum;
873 905
874 dev_dbg(&serial->dev->dev, "%s\n", __func__); 906 dev_dbg(&serial->dev->dev, "%s\n", __func__);
875 907
@@ -886,13 +918,40 @@ static int sierra_startup(struct usb_serial *serial)
886 portdata = kzalloc(sizeof(*portdata), GFP_KERNEL); 918 portdata = kzalloc(sizeof(*portdata), GFP_KERNEL);
887 if (!portdata) { 919 if (!portdata) {
888 dev_dbg(&port->dev, "%s: kmalloc for " 920 dev_dbg(&port->dev, "%s: kmalloc for "
889 "sierra_port_private (%d) failed!.\n", 921 "sierra_port_private (%d) failed!\n",
890 __func__, i); 922 __func__, i);
891 return -ENOMEM; 923 return -ENOMEM;
892 } 924 }
893 spin_lock_init(&portdata->lock); 925 spin_lock_init(&portdata->lock);
894 init_usb_anchor(&portdata->active); 926 init_usb_anchor(&portdata->active);
895 init_usb_anchor(&portdata->delayed); 927 init_usb_anchor(&portdata->delayed);
928 ifnum = i;
929 /* Assume low memory requirements */
930 portdata->num_out_urbs = N_OUT_URB;
931 portdata->num_in_urbs = N_IN_URB;
932
933 /* Determine actual memory requirements */
934 if (serial->num_ports == 1) {
935 /* Get interface number for composite device */
936 ifnum = sierra_calc_interface(serial);
937 himemoryp =
938 (struct sierra_iface_info *)&typeB_interface_list;
939 if (is_himemory(ifnum, himemoryp)) {
940 portdata->num_out_urbs = N_OUT_URB_HM;
941 portdata->num_in_urbs = N_IN_URB_HM;
942 }
943 }
944 else {
945 himemoryp =
946 (struct sierra_iface_info *)&typeA_interface_list;
947 if (is_himemory(i, himemoryp)) {
948 portdata->num_out_urbs = N_OUT_URB_HM;
949 portdata->num_in_urbs = N_IN_URB_HM;
950 }
951 }
952 dev_dbg(&serial->dev->dev,
953 "Memory usage (urbs) interface #%d, in=%d, out=%d\n",
954 ifnum,portdata->num_in_urbs, portdata->num_out_urbs );
896 /* Set the port private data pointer */ 955 /* Set the port private data pointer */
897 usb_set_serial_port_data(port, portdata); 956 usb_set_serial_port_data(port, portdata);
898 } 957 }
@@ -940,7 +999,7 @@ static int sierra_suspend(struct usb_serial *serial, pm_message_t message)
940 struct sierra_intf_private *intfdata; 999 struct sierra_intf_private *intfdata;
941 int b; 1000 int b;
942 1001
943 if (serial->dev->auto_pm) { 1002 if (message.event & PM_EVENT_AUTO) {
944 intfdata = serial->private; 1003 intfdata = serial->private;
945 spin_lock_irq(&intfdata->susp_lock); 1004 spin_lock_irq(&intfdata->susp_lock);
946 b = intfdata->in_flight; 1005 b = intfdata->in_flight;
@@ -995,11 +1054,31 @@ static int sierra_resume(struct usb_serial *serial)
995 1054
996 return ec ? -EIO : 0; 1055 return ec ? -EIO : 0;
997} 1056}
1057
1058static int sierra_reset_resume(struct usb_interface *intf)
1059{
1060 struct usb_serial *serial = usb_get_intfdata(intf);
1061 dev_err(&serial->dev->dev, "%s\n", __func__);
1062 return usb_serial_resume(intf);
1063}
998#else 1064#else
999#define sierra_suspend NULL 1065#define sierra_suspend NULL
1000#define sierra_resume NULL 1066#define sierra_resume NULL
1067#define sierra_reset_resume NULL
1001#endif 1068#endif
1002 1069
1070static struct usb_driver sierra_driver = {
1071 .name = "sierra",
1072 .probe = usb_serial_probe,
1073 .disconnect = usb_serial_disconnect,
1074 .suspend = usb_serial_suspend,
1075 .resume = usb_serial_resume,
1076 .reset_resume = sierra_reset_resume,
1077 .id_table = id_table,
1078 .no_dynamic_id = 1,
1079 .supports_autosuspend = 1,
1080};
1081
1003static struct usb_serial_driver sierra_device = { 1082static struct usb_serial_driver sierra_device = {
1004 .driver = { 1083 .driver = {
1005 .owner = THIS_MODULE, 1084 .owner = THIS_MODULE,
diff --git a/drivers/usb/serial/spcp8x5.c b/drivers/usb/serial/spcp8x5.c
index 1e58220403d1..5d39191e7244 100644
--- a/drivers/usb/serial/spcp8x5.c
+++ b/drivers/usb/serial/spcp8x5.c
@@ -45,7 +45,7 @@ static int debug;
45#define SPCP8x5_835_VID 0x04fc 45#define SPCP8x5_835_VID 0x04fc
46#define SPCP8x5_835_PID 0x0231 46#define SPCP8x5_835_PID 0x0231
47 47
48static struct usb_device_id id_table [] = { 48static const struct usb_device_id id_table[] = {
49 { USB_DEVICE(SPCP8x5_PHILIPS_VID , SPCP8x5_PHILIPS_PID)}, 49 { USB_DEVICE(SPCP8x5_PHILIPS_VID , SPCP8x5_PHILIPS_PID)},
50 { USB_DEVICE(SPCP8x5_INTERMATIC_VID, SPCP8x5_INTERMATIC_PID)}, 50 { USB_DEVICE(SPCP8x5_INTERMATIC_VID, SPCP8x5_INTERMATIC_PID)},
51 { USB_DEVICE(SPCP8x5_835_VID, SPCP8x5_835_PID)}, 51 { USB_DEVICE(SPCP8x5_835_VID, SPCP8x5_835_PID)},
@@ -609,7 +609,7 @@ static void spcp8x5_set_termios(struct tty_struct *tty,
609 if (i < 0) 609 if (i < 0)
610 dev_err(&port->dev, "Set UART format %#x failed (error = %d)\n", 610 dev_err(&port->dev, "Set UART format %#x failed (error = %d)\n",
611 uartdata, i); 611 uartdata, i);
612 dbg("0x21:0x40:0:0 %d\n", i); 612 dbg("0x21:0x40:0:0 %d", i);
613 613
614 if (cflag & CRTSCTS) { 614 if (cflag & CRTSCTS) {
615 /* enable hardware flow control */ 615 /* enable hardware flow control */
@@ -677,7 +677,6 @@ static void spcp8x5_read_bulk_callback(struct urb *urb)
677 struct tty_struct *tty; 677 struct tty_struct *tty;
678 unsigned char *data = urb->transfer_buffer; 678 unsigned char *data = urb->transfer_buffer;
679 unsigned long flags; 679 unsigned long flags;
680 int i;
681 int result = urb->status; 680 int result = urb->status;
682 u8 status; 681 u8 status;
683 char tty_flag; 682 char tty_flag;
@@ -687,8 +686,6 @@ static void spcp8x5_read_bulk_callback(struct urb *urb)
687 686
688 /* check the urb status */ 687 /* check the urb status */
689 if (result) { 688 if (result) {
690 if (!port->port.count)
691 return;
692 if (result == -EPROTO) { 689 if (result == -EPROTO) {
693 /* spcp8x5 mysteriously fails with -EPROTO */ 690 /* spcp8x5 mysteriously fails with -EPROTO */
694 /* reschedule the read */ 691 /* reschedule the read */
@@ -726,26 +723,20 @@ static void spcp8x5_read_bulk_callback(struct urb *urb)
726 723
727 tty = tty_port_tty_get(&port->port); 724 tty = tty_port_tty_get(&port->port);
728 if (tty && urb->actual_length) { 725 if (tty && urb->actual_length) {
729 tty_buffer_request_room(tty, urb->actual_length + 1);
730 /* overrun is special, not associated with a char */ 726 /* overrun is special, not associated with a char */
731 if (status & UART_OVERRUN_ERROR) 727 if (status & UART_OVERRUN_ERROR)
732 tty_insert_flip_char(tty, 0, TTY_OVERRUN); 728 tty_insert_flip_char(tty, 0, TTY_OVERRUN);
733 for (i = 0; i < urb->actual_length; ++i) 729 tty_insert_flip_string_fixed_flag(tty, data,
734 tty_insert_flip_char(tty, data[i], tty_flag); 730 urb->actual_length, tty_flag);
735 tty_flip_buffer_push(tty); 731 tty_flip_buffer_push(tty);
736 } 732 }
737 tty_kref_put(tty); 733 tty_kref_put(tty);
738 734
739 /* Schedule the next read _if_ we are still open */ 735 /* Schedule the next read */
740 if (port->port.count) { 736 urb->dev = port->serial->dev;
741 urb->dev = port->serial->dev; 737 result = usb_submit_urb(urb , GFP_ATOMIC);
742 result = usb_submit_urb(urb , GFP_ATOMIC); 738 if (result)
743 if (result) 739 dev_dbg(&port->dev, "failed submitting read urb %d\n", result);
744 dev_dbg(&port->dev, "failed submitting read urb %d\n",
745 result);
746 }
747
748 return;
749} 740}
750 741
751/* get data from ring buffer and then write to usb bus */ 742/* get data from ring buffer and then write to usb bus */
diff --git a/drivers/usb/serial/symbolserial.c b/drivers/usb/serial/symbolserial.c
index b282c0f2d8e5..d9457bd4fe10 100644
--- a/drivers/usb/serial/symbolserial.c
+++ b/drivers/usb/serial/symbolserial.c
@@ -12,6 +12,7 @@
12#include <linux/kernel.h> 12#include <linux/kernel.h>
13#include <linux/init.h> 13#include <linux/init.h>
14#include <linux/tty.h> 14#include <linux/tty.h>
15#include <linux/slab.h>
15#include <linux/tty_driver.h> 16#include <linux/tty_driver.h>
16#include <linux/tty_flip.h> 17#include <linux/tty_flip.h>
17#include <linux/module.h> 18#include <linux/module.h>
@@ -21,7 +22,7 @@
21 22
22static int debug; 23static int debug;
23 24
24static struct usb_device_id id_table[] = { 25static const struct usb_device_id id_table[] = {
25 { USB_DEVICE(0x05e0, 0x0600) }, 26 { USB_DEVICE(0x05e0, 0x0600) },
26 { }, 27 { },
27}; 28};
@@ -51,7 +52,6 @@ static void symbol_int_callback(struct urb *urb)
51 int status = urb->status; 52 int status = urb->status;
52 struct tty_struct *tty; 53 struct tty_struct *tty;
53 int result; 54 int result;
54 int available_room = 0;
55 int data_length; 55 int data_length;
56 56
57 dbg("%s - port %d", __func__, port->number); 57 dbg("%s - port %d", __func__, port->number);
@@ -89,18 +89,13 @@ static void symbol_int_callback(struct urb *urb)
89 */ 89 */
90 tty = tty_port_tty_get(&port->port); 90 tty = tty_port_tty_get(&port->port);
91 if (tty) { 91 if (tty) {
92 available_room = tty_buffer_request_room(tty, 92 tty_insert_flip_string(tty, &data[1], data_length);
93 data_length); 93 tty_flip_buffer_push(tty);
94 if (available_room) {
95 tty_insert_flip_string(tty, &data[1],
96 available_room);
97 tty_flip_buffer_push(tty);
98 }
99 tty_kref_put(tty); 94 tty_kref_put(tty);
100 } 95 }
101 } else { 96 } else {
102 dev_dbg(&priv->udev->dev, 97 dev_dbg(&priv->udev->dev,
103 "Improper ammount of data received from the device, " 98 "Improper amount of data received from the device, "
104 "%d bytes", urb->actual_length); 99 "%d bytes", urb->actual_length);
105 } 100 }
106 101
diff --git a/drivers/usb/serial/ti_usb_3410_5052.c b/drivers/usb/serial/ti_usb_3410_5052.c
index 1e9dc8821698..e1bfda33f5b9 100644
--- a/drivers/usb/serial/ti_usb_3410_5052.c
+++ b/drivers/usb/serial/ti_usb_3410_5052.c
@@ -172,7 +172,7 @@ static unsigned int product_5052_count;
172/* the array dimension is the number of default entries plus */ 172/* the array dimension is the number of default entries plus */
173/* TI_EXTRA_VID_PID_COUNT user defined entries plus 1 terminating */ 173/* TI_EXTRA_VID_PID_COUNT user defined entries plus 1 terminating */
174/* null entry */ 174/* null entry */
175static struct usb_device_id ti_id_table_3410[10+TI_EXTRA_VID_PID_COUNT+1] = { 175static struct usb_device_id ti_id_table_3410[13+TI_EXTRA_VID_PID_COUNT+1] = {
176 { USB_DEVICE(TI_VENDOR_ID, TI_3410_PRODUCT_ID) }, 176 { USB_DEVICE(TI_VENDOR_ID, TI_3410_PRODUCT_ID) },
177 { USB_DEVICE(TI_VENDOR_ID, TI_3410_EZ430_ID) }, 177 { USB_DEVICE(TI_VENDOR_ID, TI_3410_EZ430_ID) },
178 { USB_DEVICE(MTS_VENDOR_ID, MTS_GSM_NO_FW_PRODUCT_ID) }, 178 { USB_DEVICE(MTS_VENDOR_ID, MTS_GSM_NO_FW_PRODUCT_ID) },
@@ -180,6 +180,9 @@ static struct usb_device_id ti_id_table_3410[10+TI_EXTRA_VID_PID_COUNT+1] = {
180 { USB_DEVICE(MTS_VENDOR_ID, MTS_CDMA_PRODUCT_ID) }, 180 { USB_DEVICE(MTS_VENDOR_ID, MTS_CDMA_PRODUCT_ID) },
181 { USB_DEVICE(MTS_VENDOR_ID, MTS_GSM_PRODUCT_ID) }, 181 { USB_DEVICE(MTS_VENDOR_ID, MTS_GSM_PRODUCT_ID) },
182 { USB_DEVICE(MTS_VENDOR_ID, MTS_EDGE_PRODUCT_ID) }, 182 { USB_DEVICE(MTS_VENDOR_ID, MTS_EDGE_PRODUCT_ID) },
183 { USB_DEVICE(MTS_VENDOR_ID, MTS_MT9234MU_PRODUCT_ID) },
184 { USB_DEVICE(MTS_VENDOR_ID, MTS_MT9234ZBA_PRODUCT_ID) },
185 { USB_DEVICE(MTS_VENDOR_ID, MTS_MT9234ZBAOLD_PRODUCT_ID) },
183 { USB_DEVICE(IBM_VENDOR_ID, IBM_4543_PRODUCT_ID) }, 186 { USB_DEVICE(IBM_VENDOR_ID, IBM_4543_PRODUCT_ID) },
184 { USB_DEVICE(IBM_VENDOR_ID, IBM_454B_PRODUCT_ID) }, 187 { USB_DEVICE(IBM_VENDOR_ID, IBM_454B_PRODUCT_ID) },
185 { USB_DEVICE(IBM_VENDOR_ID, IBM_454C_PRODUCT_ID) }, 188 { USB_DEVICE(IBM_VENDOR_ID, IBM_454C_PRODUCT_ID) },
@@ -192,7 +195,7 @@ static struct usb_device_id ti_id_table_5052[5+TI_EXTRA_VID_PID_COUNT+1] = {
192 { USB_DEVICE(TI_VENDOR_ID, TI_5052_FIRMWARE_PRODUCT_ID) }, 195 { USB_DEVICE(TI_VENDOR_ID, TI_5052_FIRMWARE_PRODUCT_ID) },
193}; 196};
194 197
195static struct usb_device_id ti_id_table_combined[14+2*TI_EXTRA_VID_PID_COUNT+1] = { 198static struct usb_device_id ti_id_table_combined[17+2*TI_EXTRA_VID_PID_COUNT+1] = {
196 { USB_DEVICE(TI_VENDOR_ID, TI_3410_PRODUCT_ID) }, 199 { USB_DEVICE(TI_VENDOR_ID, TI_3410_PRODUCT_ID) },
197 { USB_DEVICE(TI_VENDOR_ID, TI_3410_EZ430_ID) }, 200 { USB_DEVICE(TI_VENDOR_ID, TI_3410_EZ430_ID) },
198 { USB_DEVICE(MTS_VENDOR_ID, MTS_GSM_NO_FW_PRODUCT_ID) }, 201 { USB_DEVICE(MTS_VENDOR_ID, MTS_GSM_NO_FW_PRODUCT_ID) },
@@ -200,6 +203,9 @@ static struct usb_device_id ti_id_table_combined[14+2*TI_EXTRA_VID_PID_COUNT+1]
200 { USB_DEVICE(MTS_VENDOR_ID, MTS_CDMA_PRODUCT_ID) }, 203 { USB_DEVICE(MTS_VENDOR_ID, MTS_CDMA_PRODUCT_ID) },
201 { USB_DEVICE(MTS_VENDOR_ID, MTS_GSM_PRODUCT_ID) }, 204 { USB_DEVICE(MTS_VENDOR_ID, MTS_GSM_PRODUCT_ID) },
202 { USB_DEVICE(MTS_VENDOR_ID, MTS_EDGE_PRODUCT_ID) }, 205 { USB_DEVICE(MTS_VENDOR_ID, MTS_EDGE_PRODUCT_ID) },
206 { USB_DEVICE(MTS_VENDOR_ID, MTS_MT9234MU_PRODUCT_ID) },
207 { USB_DEVICE(MTS_VENDOR_ID, MTS_MT9234ZBA_PRODUCT_ID) },
208 { USB_DEVICE(MTS_VENDOR_ID, MTS_MT9234ZBAOLD_PRODUCT_ID) },
203 { USB_DEVICE(TI_VENDOR_ID, TI_5052_BOOT_PRODUCT_ID) }, 209 { USB_DEVICE(TI_VENDOR_ID, TI_5052_BOOT_PRODUCT_ID) },
204 { USB_DEVICE(TI_VENDOR_ID, TI_5152_BOOT_PRODUCT_ID) }, 210 { USB_DEVICE(TI_VENDOR_ID, TI_5152_BOOT_PRODUCT_ID) },
205 { USB_DEVICE(TI_VENDOR_ID, TI_5052_EEPROM_PRODUCT_ID) }, 211 { USB_DEVICE(TI_VENDOR_ID, TI_5052_EEPROM_PRODUCT_ID) },
@@ -287,6 +293,8 @@ MODULE_FIRMWARE("ti_5052.fw");
287MODULE_FIRMWARE("mts_cdma.fw"); 293MODULE_FIRMWARE("mts_cdma.fw");
288MODULE_FIRMWARE("mts_gsm.fw"); 294MODULE_FIRMWARE("mts_gsm.fw");
289MODULE_FIRMWARE("mts_edge.fw"); 295MODULE_FIRMWARE("mts_edge.fw");
296MODULE_FIRMWARE("mts_mt9234mu.fw");
297MODULE_FIRMWARE("mts_mt9234zba.fw");
290 298
291module_param(debug, bool, S_IRUGO | S_IWUSR); 299module_param(debug, bool, S_IRUGO | S_IWUSR);
292MODULE_PARM_DESC(debug, "Enable debugging, 0=no, 1=yes"); 300MODULE_PARM_DESC(debug, "Enable debugging, 0=no, 1=yes");
@@ -1271,14 +1279,13 @@ static void ti_recv(struct device *dev, struct tty_struct *tty,
1271 int cnt; 1279 int cnt;
1272 1280
1273 do { 1281 do {
1274 cnt = tty_buffer_request_room(tty, length); 1282 cnt = tty_insert_flip_string(tty, data, length);
1275 if (cnt < length) { 1283 if (cnt < length) {
1276 dev_err(dev, "%s - dropping data, %d bytes lost\n", 1284 dev_err(dev, "%s - dropping data, %d bytes lost\n",
1277 __func__, length - cnt); 1285 __func__, length - cnt);
1278 if (cnt == 0) 1286 if (cnt == 0)
1279 break; 1287 break;
1280 } 1288 }
1281 tty_insert_flip_string(tty, data, cnt);
1282 tty_flip_buffer_push(tty); 1289 tty_flip_buffer_push(tty);
1283 data += cnt; 1290 data += cnt;
1284 length -= cnt; 1291 length -= cnt;
@@ -1688,6 +1695,7 @@ static int ti_download_firmware(struct ti_device *tdev)
1688 const struct firmware *fw_p; 1695 const struct firmware *fw_p;
1689 char buf[32]; 1696 char buf[32];
1690 1697
1698 dbg("%s\n", __func__);
1691 /* try ID specific firmware first, then try generic firmware */ 1699 /* try ID specific firmware first, then try generic firmware */
1692 sprintf(buf, "ti_usb-v%04x-p%04x.fw", dev->descriptor.idVendor, 1700 sprintf(buf, "ti_usb-v%04x-p%04x.fw", dev->descriptor.idVendor,
1693 dev->descriptor.idProduct); 1701 dev->descriptor.idProduct);
@@ -1704,7 +1712,15 @@ static int ti_download_firmware(struct ti_device *tdev)
1704 case MTS_EDGE_PRODUCT_ID: 1712 case MTS_EDGE_PRODUCT_ID:
1705 strcpy(buf, "mts_edge.fw"); 1713 strcpy(buf, "mts_edge.fw");
1706 break; 1714 break;
1707 } 1715 case MTS_MT9234MU_PRODUCT_ID:
1716 strcpy(buf, "mts_mt9234mu.fw");
1717 break;
1718 case MTS_MT9234ZBA_PRODUCT_ID:
1719 strcpy(buf, "mts_mt9234zba.fw");
1720 break;
1721 case MTS_MT9234ZBAOLD_PRODUCT_ID:
1722 strcpy(buf, "mts_mt9234zba.fw");
1723 break; }
1708 } 1724 }
1709 if (buf[0] == '\0') { 1725 if (buf[0] == '\0') {
1710 if (tdev->td_is_3410) 1726 if (tdev->td_is_3410)
@@ -1719,7 +1735,7 @@ static int ti_download_firmware(struct ti_device *tdev)
1719 return -ENOENT; 1735 return -ENOENT;
1720 } 1736 }
1721 if (fw_p->size > TI_FIRMWARE_BUF_SIZE) { 1737 if (fw_p->size > TI_FIRMWARE_BUF_SIZE) {
1722 dev_err(&dev->dev, "%s - firmware too large\n", __func__); 1738 dev_err(&dev->dev, "%s - firmware too large %zu\n", __func__, fw_p->size);
1723 return -ENOENT; 1739 return -ENOENT;
1724 } 1740 }
1725 1741
@@ -1731,6 +1747,7 @@ static int ti_download_firmware(struct ti_device *tdev)
1731 status = ti_do_download(dev, pipe, buffer, fw_p->size); 1747 status = ti_do_download(dev, pipe, buffer, fw_p->size);
1732 kfree(buffer); 1748 kfree(buffer);
1733 } else { 1749 } else {
1750 dbg("%s ENOMEM\n", __func__);
1734 status = -ENOMEM; 1751 status = -ENOMEM;
1735 } 1752 }
1736 release_firmware(fw_p); 1753 release_firmware(fw_p);
diff --git a/drivers/usb/serial/ti_usb_3410_5052.h b/drivers/usb/serial/ti_usb_3410_5052.h
index f323c6025858..2aac1953993b 100644
--- a/drivers/usb/serial/ti_usb_3410_5052.h
+++ b/drivers/usb/serial/ti_usb_3410_5052.h
@@ -45,6 +45,9 @@
45#define MTS_CDMA_PRODUCT_ID 0xF110 45#define MTS_CDMA_PRODUCT_ID 0xF110
46#define MTS_GSM_PRODUCT_ID 0xF111 46#define MTS_GSM_PRODUCT_ID 0xF111
47#define MTS_EDGE_PRODUCT_ID 0xF112 47#define MTS_EDGE_PRODUCT_ID 0xF112
48#define MTS_MT9234MU_PRODUCT_ID 0xF114
49#define MTS_MT9234ZBA_PRODUCT_ID 0xF115
50#define MTS_MT9234ZBAOLD_PRODUCT_ID 0x0319
48 51
49/* Commands */ 52/* Commands */
50#define TI_GET_VERSION 0x01 53#define TI_GET_VERSION 0x01
diff --git a/drivers/usb/serial/usb-serial.c b/drivers/usb/serial/usb-serial.c
index bd3fa7ff15b1..3873660d8217 100644
--- a/drivers/usb/serial/usb-serial.c
+++ b/drivers/usb/serial/usb-serial.c
@@ -247,96 +247,66 @@ static int serial_install(struct tty_driver *driver, struct tty_struct *tty)
247 return retval; 247 return retval;
248} 248}
249 249
250static int serial_open(struct tty_struct *tty, struct file *filp) 250static int serial_activate(struct tty_port *tport, struct tty_struct *tty)
251{ 251{
252 struct usb_serial_port *port = tty->driver_data; 252 struct usb_serial_port *port =
253 container_of(tport, struct usb_serial_port, port);
253 struct usb_serial *serial = port->serial; 254 struct usb_serial *serial = port->serial;
254 int retval; 255 int retval;
255 256
256 dbg("%s - port %d", __func__, port->number); 257 mutex_lock(&serial->disc_mutex);
257 258 if (serial->disconnected)
258 spin_lock_irq(&port->port.lock); 259 retval = -ENODEV;
259 if (!tty_hung_up_p(filp)) 260 else
260 ++port->port.count; 261 retval = port->serial->type->open(tty, port);
261 spin_unlock_irq(&port->port.lock); 262 mutex_unlock(&serial->disc_mutex);
262 tty_port_tty_set(&port->port, tty); 263 return retval;
264}
263 265
264 /* Do the device-specific open only if the hardware isn't 266static int serial_open(struct tty_struct *tty, struct file *filp)
265 * already initialized. 267{
266 */ 268 struct usb_serial_port *port = tty->driver_data;
267 if (!test_bit(ASYNCB_INITIALIZED, &port->port.flags)) {
268 if (mutex_lock_interruptible(&port->mutex))
269 return -ERESTARTSYS;
270 mutex_lock(&serial->disc_mutex);
271 if (serial->disconnected)
272 retval = -ENODEV;
273 else
274 retval = port->serial->type->open(tty, port);
275 mutex_unlock(&serial->disc_mutex);
276 mutex_unlock(&port->mutex);
277 if (retval)
278 return retval;
279 set_bit(ASYNCB_INITIALIZED, &port->port.flags);
280 }
281 269
282 /* Now do the correct tty layer semantics */ 270 dbg("%s - port %d", __func__, port->number);
283 retval = tty_port_block_til_ready(&port->port, tty, filp); 271 return tty_port_open(&port->port, tty, filp);
284 return retval;
285} 272}
286 273
287/** 274/**
288 * serial_down - shut down hardware 275 * serial_down - shut down hardware
289 * @port: port to shut down 276 * @tport: tty port to shut down
290 * 277 *
291 * Shut down a USB serial port unless it is the console. We never 278 * Shut down a USB serial port unless it is the console. We never
292 * shut down the console hardware as it will always be in use. 279 * shut down the console hardware as it will always be in use. Serialized
280 * against activate by the tport mutex and kept to matching open/close pairs
281 * of calls by the ASYNCB_INITIALIZED flag.
293 */ 282 */
294static void serial_down(struct usb_serial_port *port) 283static void serial_down(struct tty_port *tport)
295{ 284{
285 struct usb_serial_port *port =
286 container_of(tport, struct usb_serial_port, port);
296 struct usb_serial_driver *drv = port->serial->type; 287 struct usb_serial_driver *drv = port->serial->type;
297
298 /* 288 /*
299 * The console is magical. Do not hang up the console hardware 289 * The console is magical. Do not hang up the console hardware
300 * or there will be tears. 290 * or there will be tears.
301 */ 291 */
302 if (port->console) 292 if (port->console)
303 return; 293 return;
304
305 /* Don't call the close method if the hardware hasn't been
306 * initialized.
307 */
308 if (!test_and_clear_bit(ASYNCB_INITIALIZED, &port->port.flags))
309 return;
310
311 mutex_lock(&port->mutex);
312 if (drv->close) 294 if (drv->close)
313 drv->close(port); 295 drv->close(port);
314 mutex_unlock(&port->mutex);
315} 296}
316 297
317static void serial_hangup(struct tty_struct *tty) 298static void serial_hangup(struct tty_struct *tty)
318{ 299{
319 struct usb_serial_port *port = tty->driver_data; 300 struct usb_serial_port *port = tty->driver_data;
320
321 dbg("%s - port %d", __func__, port->number); 301 dbg("%s - port %d", __func__, port->number);
322
323 serial_down(port);
324 tty_port_hangup(&port->port); 302 tty_port_hangup(&port->port);
325} 303}
326 304
327static void serial_close(struct tty_struct *tty, struct file *filp) 305static void serial_close(struct tty_struct *tty, struct file *filp)
328{ 306{
329 struct usb_serial_port *port = tty->driver_data; 307 struct usb_serial_port *port = tty->driver_data;
330
331 dbg("%s - port %d", __func__, port->number); 308 dbg("%s - port %d", __func__, port->number);
332 309 tty_port_close(&port->port, tty, filp);
333 if (tty_hung_up_p(filp))
334 return;
335 if (tty_port_close_start(&port->port, tty, filp) == 0)
336 return;
337 serial_down(port);
338 tty_port_close_end(&port->port, tty);
339 tty_port_tty_set(&port->port, NULL);
340} 310}
341 311
342/** 312/**
@@ -388,10 +358,6 @@ static int serial_write(struct tty_struct *tty, const unsigned char *buf,
388 358
389 dbg("%s - port %d, %d byte(s)", __func__, port->number, count); 359 dbg("%s - port %d, %d byte(s)", __func__, port->number, count);
390 360
391 /* count is managed under the mutex lock for the tty so cannot
392 drop to zero until after the last close completes */
393 WARN_ON(!port->port.count);
394
395 /* pass on to the driver specific version of this function */ 361 /* pass on to the driver specific version of this function */
396 retval = port->serial->type->write(tty, port, buf, count); 362 retval = port->serial->type->write(tty, port, buf, count);
397 363
@@ -403,7 +369,6 @@ static int serial_write_room(struct tty_struct *tty)
403{ 369{
404 struct usb_serial_port *port = tty->driver_data; 370 struct usb_serial_port *port = tty->driver_data;
405 dbg("%s - port %d", __func__, port->number); 371 dbg("%s - port %d", __func__, port->number);
406 WARN_ON(!port->port.count);
407 /* pass on to the driver specific version of this function */ 372 /* pass on to the driver specific version of this function */
408 return port->serial->type->write_room(tty); 373 return port->serial->type->write_room(tty);
409} 374}
@@ -411,7 +376,7 @@ static int serial_write_room(struct tty_struct *tty)
411static int serial_chars_in_buffer(struct tty_struct *tty) 376static int serial_chars_in_buffer(struct tty_struct *tty)
412{ 377{
413 struct usb_serial_port *port = tty->driver_data; 378 struct usb_serial_port *port = tty->driver_data;
414 dbg("%s = port %d", __func__, port->number); 379 dbg("%s - port %d", __func__, port->number);
415 380
416 /* if the device was unplugged then any remaining characters 381 /* if the device was unplugged then any remaining characters
417 fell out of the connector ;) */ 382 fell out of the connector ;) */
@@ -426,7 +391,6 @@ static void serial_throttle(struct tty_struct *tty)
426 struct usb_serial_port *port = tty->driver_data; 391 struct usb_serial_port *port = tty->driver_data;
427 dbg("%s - port %d", __func__, port->number); 392 dbg("%s - port %d", __func__, port->number);
428 393
429 WARN_ON(!port->port.count);
430 /* pass on to the driver specific version of this function */ 394 /* pass on to the driver specific version of this function */
431 if (port->serial->type->throttle) 395 if (port->serial->type->throttle)
432 port->serial->type->throttle(tty); 396 port->serial->type->throttle(tty);
@@ -437,7 +401,6 @@ static void serial_unthrottle(struct tty_struct *tty)
437 struct usb_serial_port *port = tty->driver_data; 401 struct usb_serial_port *port = tty->driver_data;
438 dbg("%s - port %d", __func__, port->number); 402 dbg("%s - port %d", __func__, port->number);
439 403
440 WARN_ON(!port->port.count);
441 /* pass on to the driver specific version of this function */ 404 /* pass on to the driver specific version of this function */
442 if (port->serial->type->unthrottle) 405 if (port->serial->type->unthrottle)
443 port->serial->type->unthrottle(tty); 406 port->serial->type->unthrottle(tty);
@@ -451,8 +414,6 @@ static int serial_ioctl(struct tty_struct *tty, struct file *file,
451 414
452 dbg("%s - port %d, cmd 0x%.4x", __func__, port->number, cmd); 415 dbg("%s - port %d, cmd 0x%.4x", __func__, port->number, cmd);
453 416
454 WARN_ON(!port->port.count);
455
456 /* pass on to the driver specific version of this function 417 /* pass on to the driver specific version of this function
457 if it is available */ 418 if it is available */
458 if (port->serial->type->ioctl) { 419 if (port->serial->type->ioctl) {
@@ -467,7 +428,6 @@ static void serial_set_termios(struct tty_struct *tty, struct ktermios *old)
467 struct usb_serial_port *port = tty->driver_data; 428 struct usb_serial_port *port = tty->driver_data;
468 dbg("%s - port %d", __func__, port->number); 429 dbg("%s - port %d", __func__, port->number);
469 430
470 WARN_ON(!port->port.count);
471 /* pass on to the driver specific version of this function 431 /* pass on to the driver specific version of this function
472 if it is available */ 432 if it is available */
473 if (port->serial->type->set_termios) 433 if (port->serial->type->set_termios)
@@ -482,7 +442,6 @@ static int serial_break(struct tty_struct *tty, int break_state)
482 442
483 dbg("%s - port %d", __func__, port->number); 443 dbg("%s - port %d", __func__, port->number);
484 444
485 WARN_ON(!port->port.count);
486 /* pass on to the driver specific version of this function 445 /* pass on to the driver specific version of this function
487 if it is available */ 446 if it is available */
488 if (port->serial->type->break_ctl) 447 if (port->serial->type->break_ctl)
@@ -543,7 +502,6 @@ static int serial_tiocmget(struct tty_struct *tty, struct file *file)
543 502
544 dbg("%s - port %d", __func__, port->number); 503 dbg("%s - port %d", __func__, port->number);
545 504
546 WARN_ON(!port->port.count);
547 if (port->serial->type->tiocmget) 505 if (port->serial->type->tiocmget)
548 return port->serial->type->tiocmget(tty, file); 506 return port->serial->type->tiocmget(tty, file);
549 return -EINVAL; 507 return -EINVAL;
@@ -556,7 +514,6 @@ static int serial_tiocmset(struct tty_struct *tty, struct file *file,
556 514
557 dbg("%s - port %d", __func__, port->number); 515 dbg("%s - port %d", __func__, port->number);
558 516
559 WARN_ON(!port->port.count);
560 if (port->serial->type->tiocmset) 517 if (port->serial->type->tiocmset)
561 return port->serial->type->tiocmset(tty, file, set, clear); 518 return port->serial->type->tiocmset(tty, file, set, clear);
562 return -EINVAL; 519 return -EINVAL;
@@ -625,8 +582,7 @@ static void port_release(struct device *dev)
625 usb_free_urb(port->write_urb); 582 usb_free_urb(port->write_urb);
626 usb_free_urb(port->interrupt_in_urb); 583 usb_free_urb(port->interrupt_in_urb);
627 usb_free_urb(port->interrupt_out_urb); 584 usb_free_urb(port->interrupt_out_urb);
628 if (!IS_ERR(port->write_fifo) && port->write_fifo) 585 kfifo_free(&port->write_fifo);
629 kfifo_free(port->write_fifo);
630 kfree(port->bulk_in_buffer); 586 kfree(port->bulk_in_buffer);
631 kfree(port->bulk_out_buffer); 587 kfree(port->bulk_out_buffer);
632 kfree(port->interrupt_in_buffer); 588 kfree(port->interrupt_in_buffer);
@@ -725,6 +681,8 @@ static void serial_dtr_rts(struct tty_port *port, int on)
725static const struct tty_port_operations serial_port_ops = { 681static const struct tty_port_operations serial_port_ops = {
726 .carrier_raised = serial_carrier_raised, 682 .carrier_raised = serial_carrier_raised,
727 .dtr_rts = serial_dtr_rts, 683 .dtr_rts = serial_dtr_rts,
684 .activate = serial_activate,
685 .shutdown = serial_down,
728}; 686};
729 687
730int usb_serial_probe(struct usb_interface *interface, 688int usb_serial_probe(struct usb_interface *interface,
@@ -923,7 +881,8 @@ int usb_serial_probe(struct usb_interface *interface,
923 port->port.ops = &serial_port_ops; 881 port->port.ops = &serial_port_ops;
924 port->serial = serial; 882 port->serial = serial;
925 spin_lock_init(&port->lock); 883 spin_lock_init(&port->lock);
926 mutex_init(&port->mutex); 884 /* Keep this for private driver use for the moment but
885 should probably go away */
927 INIT_WORK(&port->work, usb_serial_port_work); 886 INIT_WORK(&port->work, usb_serial_port_work);
928 serial->port[i] = port; 887 serial->port[i] = port;
929 port->dev.parent = &interface->dev; 888 port->dev.parent = &interface->dev;
@@ -966,9 +925,7 @@ int usb_serial_probe(struct usb_interface *interface,
966 dev_err(&interface->dev, "No free urbs available\n"); 925 dev_err(&interface->dev, "No free urbs available\n");
967 goto probe_error; 926 goto probe_error;
968 } 927 }
969 port->write_fifo = kfifo_alloc(PAGE_SIZE, GFP_KERNEL, 928 if (kfifo_alloc(&port->write_fifo, PAGE_SIZE, GFP_KERNEL))
970 &port->lock);
971 if (IS_ERR(port->write_fifo))
972 goto probe_error; 929 goto probe_error;
973 buffer_size = le16_to_cpu(endpoint->wMaxPacketSize); 930 buffer_size = le16_to_cpu(endpoint->wMaxPacketSize);
974 port->bulk_out_size = buffer_size; 931 port->bulk_out_size = buffer_size;
diff --git a/drivers/usb/serial/usb_debug.c b/drivers/usb/serial/usb_debug.c
index 7b5bfc4edd3d..28026b47344a 100644
--- a/drivers/usb/serial/usb_debug.c
+++ b/drivers/usb/serial/usb_debug.c
@@ -8,6 +8,7 @@
8 * 2 as published by the Free Software Foundation. 8 * 2 as published by the Free Software Foundation.
9 */ 9 */
10 10
11#include <linux/gfp.h>
11#include <linux/kernel.h> 12#include <linux/kernel.h>
12#include <linux/init.h> 13#include <linux/init.h>
13#include <linux/tty.h> 14#include <linux/tty.h>
@@ -29,7 +30,7 @@ static char USB_DEBUG_BRK[USB_DEBUG_BRK_SIZE] = {
29 0xff, 30 0xff,
30}; 31};
31 32
32static struct usb_device_id id_table [] = { 33static const struct usb_device_id id_table[] = {
33 { USB_DEVICE(0x0525, 0x127a) }, 34 { USB_DEVICE(0x0525, 0x127a) },
34 { }, 35 { },
35}; 36};
diff --git a/drivers/usb/serial/visor.c b/drivers/usb/serial/visor.c
index ad1f9232292d..094942707c7d 100644
--- a/drivers/usb/serial/visor.c
+++ b/drivers/usb/serial/visor.c
@@ -368,7 +368,7 @@ static int visor_write(struct tty_struct *tty, struct usb_serial_port *port,
368 spin_lock_irqsave(&priv->lock, flags); 368 spin_lock_irqsave(&priv->lock, flags);
369 if (priv->outstanding_urbs > URB_UPPER_LIMIT) { 369 if (priv->outstanding_urbs > URB_UPPER_LIMIT) {
370 spin_unlock_irqrestore(&priv->lock, flags); 370 spin_unlock_irqrestore(&priv->lock, flags);
371 dbg("%s - write limit hit\n", __func__); 371 dbg("%s - write limit hit", __func__);
372 return 0; 372 return 0;
373 } 373 }
374 priv->outstanding_urbs++; 374 priv->outstanding_urbs++;
@@ -446,7 +446,7 @@ static int visor_write_room(struct tty_struct *tty)
446 spin_lock_irqsave(&priv->lock, flags); 446 spin_lock_irqsave(&priv->lock, flags);
447 if (priv->outstanding_urbs > URB_UPPER_LIMIT * 2 / 3) { 447 if (priv->outstanding_urbs > URB_UPPER_LIMIT * 2 / 3) {
448 spin_unlock_irqrestore(&priv->lock, flags); 448 spin_unlock_irqrestore(&priv->lock, flags);
449 dbg("%s - write limit hit\n", __func__); 449 dbg("%s - write limit hit", __func__);
450 return 0; 450 return 0;
451 } 451 }
452 spin_unlock_irqrestore(&priv->lock, flags); 452 spin_unlock_irqrestore(&priv->lock, flags);
@@ -503,13 +503,9 @@ static void visor_read_bulk_callback(struct urb *urb)
503 if (urb->actual_length) { 503 if (urb->actual_length) {
504 tty = tty_port_tty_get(&port->port); 504 tty = tty_port_tty_get(&port->port);
505 if (tty) { 505 if (tty) {
506 available_room = tty_buffer_request_room(tty, 506 tty_insert_flip_string(tty, data,
507 urb->actual_length); 507 urb->actual_length);
508 if (available_room) { 508 tty_flip_buffer_push(tty);
509 tty_insert_flip_string(tty, data,
510 available_room);
511 tty_flip_buffer_push(tty);
512 }
513 tty_kref_put(tty); 509 tty_kref_put(tty);
514 } 510 }
515 spin_lock(&priv->lock); 511 spin_lock(&priv->lock);
@@ -807,10 +803,14 @@ static int clie_3_5_startup(struct usb_serial *serial)
807{ 803{
808 struct device *dev = &serial->dev->dev; 804 struct device *dev = &serial->dev->dev;
809 int result; 805 int result;
810 u8 data; 806 u8 *data;
811 807
812 dbg("%s", __func__); 808 dbg("%s", __func__);
813 809
810 data = kmalloc(1, GFP_KERNEL);
811 if (!data)
812 return -ENOMEM;
813
814 /* 814 /*
815 * Note that PEG-300 series devices expect the following two calls. 815 * Note that PEG-300 series devices expect the following two calls.
816 */ 816 */
@@ -818,36 +818,42 @@ static int clie_3_5_startup(struct usb_serial *serial)
818 /* get the config number */ 818 /* get the config number */
819 result = usb_control_msg(serial->dev, usb_rcvctrlpipe(serial->dev, 0), 819 result = usb_control_msg(serial->dev, usb_rcvctrlpipe(serial->dev, 0),
820 USB_REQ_GET_CONFIGURATION, USB_DIR_IN, 820 USB_REQ_GET_CONFIGURATION, USB_DIR_IN,
821 0, 0, &data, 1, 3000); 821 0, 0, data, 1, 3000);
822 if (result < 0) { 822 if (result < 0) {
823 dev_err(dev, "%s: get config number failed: %d\n", 823 dev_err(dev, "%s: get config number failed: %d\n",
824 __func__, result); 824 __func__, result);
825 return result; 825 goto out;
826 } 826 }
827 if (result != 1) { 827 if (result != 1) {
828 dev_err(dev, "%s: get config number bad return length: %d\n", 828 dev_err(dev, "%s: get config number bad return length: %d\n",
829 __func__, result); 829 __func__, result);
830 return -EIO; 830 result = -EIO;
831 goto out;
831 } 832 }
832 833
833 /* get the interface number */ 834 /* get the interface number */
834 result = usb_control_msg(serial->dev, usb_rcvctrlpipe(serial->dev, 0), 835 result = usb_control_msg(serial->dev, usb_rcvctrlpipe(serial->dev, 0),
835 USB_REQ_GET_INTERFACE, 836 USB_REQ_GET_INTERFACE,
836 USB_DIR_IN | USB_RECIP_INTERFACE, 837 USB_DIR_IN | USB_RECIP_INTERFACE,
837 0, 0, &data, 1, 3000); 838 0, 0, data, 1, 3000);
838 if (result < 0) { 839 if (result < 0) {
839 dev_err(dev, "%s: get interface number failed: %d\n", 840 dev_err(dev, "%s: get interface number failed: %d\n",
840 __func__, result); 841 __func__, result);
841 return result; 842 goto out;
842 } 843 }
843 if (result != 1) { 844 if (result != 1) {
844 dev_err(dev, 845 dev_err(dev,
845 "%s: get interface number bad return length: %d\n", 846 "%s: get interface number bad return length: %d\n",
846 __func__, result); 847 __func__, result);
847 return -EIO; 848 result = -EIO;
849 goto out;
848 } 850 }
849 851
850 return generic_startup(serial); 852 result = generic_startup(serial);
853out:
854 kfree(data);
855
856 return result;
851} 857}
852 858
853static int treo_attach(struct usb_serial *serial) 859static int treo_attach(struct usb_serial *serial)
diff --git a/drivers/usb/serial/vivopay-serial.c b/drivers/usb/serial/vivopay-serial.c
new file mode 100644
index 000000000000..f719d00972fc
--- /dev/null
+++ b/drivers/usb/serial/vivopay-serial.c
@@ -0,0 +1,76 @@
1/*
2 * Copyright (C) 2001-2005 Greg Kroah-Hartman (greg@kroah.com)
3 * Copyright (C) 2009 Outpost Embedded, LLC
4 */
5
6#include <linux/kernel.h>
7#include <linux/init.h>
8#include <linux/tty.h>
9#include <linux/module.h>
10#include <linux/usb.h>
11#include <linux/usb/serial.h>
12
13
14#define DRIVER_VERSION "v1.0"
15#define DRIVER_DESC "ViVOpay USB Serial Driver"
16
17#define VIVOPAY_VENDOR_ID 0x1d5f
18
19
20static struct usb_device_id id_table [] = {
21 /* ViVOpay 8800 */
22 { USB_DEVICE(VIVOPAY_VENDOR_ID, 0x1004) },
23 { },
24};
25
26MODULE_DEVICE_TABLE(usb, id_table);
27
28static struct usb_driver vivopay_serial_driver = {
29 .name = "vivopay-serial",
30 .probe = usb_serial_probe,
31 .disconnect = usb_serial_disconnect,
32 .id_table = id_table,
33 .no_dynamic_id = 1,
34};
35
36static struct usb_serial_driver vivopay_serial_device = {
37 .driver = {
38 .owner = THIS_MODULE,
39 .name = "vivopay-serial",
40 },
41 .id_table = id_table,
42 .usb_driver = &vivopay_serial_driver,
43 .num_ports = 1,
44};
45
46static int __init vivopay_serial_init(void)
47{
48 int retval;
49 retval = usb_serial_register(&vivopay_serial_device);
50 if (retval)
51 goto failed_usb_serial_register;
52 retval = usb_register(&vivopay_serial_driver);
53 if (retval)
54 goto failed_usb_register;
55 printk(KERN_INFO KBUILD_MODNAME ": " DRIVER_VERSION ":"
56 DRIVER_DESC "\n");
57 return 0;
58failed_usb_register:
59 usb_serial_deregister(&vivopay_serial_device);
60failed_usb_serial_register:
61 return retval;
62}
63
64static void __exit vivopay_serial_exit(void)
65{
66 usb_deregister(&vivopay_serial_driver);
67 usb_serial_deregister(&vivopay_serial_device);
68}
69
70module_init(vivopay_serial_init);
71module_exit(vivopay_serial_exit);
72
73MODULE_AUTHOR("Forest Bond <forest.bond@outpostembedded.com>");
74MODULE_DESCRIPTION(DRIVER_DESC);
75MODULE_VERSION(DRIVER_VERSION);
76MODULE_LICENSE("GPL");
diff --git a/drivers/usb/serial/whiteheat.c b/drivers/usb/serial/whiteheat.c
index 1093d2eb046a..12ed8209ca72 100644
--- a/drivers/usb/serial/whiteheat.c
+++ b/drivers/usb/serial/whiteheat.c
@@ -111,17 +111,17 @@ static int debug;
111 separate ID tables, and then a third table that combines them 111 separate ID tables, and then a third table that combines them
112 just for the purpose of exporting the autoloading information. 112 just for the purpose of exporting the autoloading information.
113*/ 113*/
114static struct usb_device_id id_table_std [] = { 114static const struct usb_device_id id_table_std[] = {
115 { USB_DEVICE(CONNECT_TECH_VENDOR_ID, CONNECT_TECH_WHITE_HEAT_ID) }, 115 { USB_DEVICE(CONNECT_TECH_VENDOR_ID, CONNECT_TECH_WHITE_HEAT_ID) },
116 { } /* Terminating entry */ 116 { } /* Terminating entry */
117}; 117};
118 118
119static struct usb_device_id id_table_prerenumeration [] = { 119static const struct usb_device_id id_table_prerenumeration[] = {
120 { USB_DEVICE(CONNECT_TECH_VENDOR_ID, CONNECT_TECH_FAKE_WHITE_HEAT_ID) }, 120 { USB_DEVICE(CONNECT_TECH_VENDOR_ID, CONNECT_TECH_FAKE_WHITE_HEAT_ID) },
121 { } /* Terminating entry */ 121 { } /* Terminating entry */
122}; 122};
123 123
124static struct usb_device_id id_table_combined [] = { 124static const struct usb_device_id id_table_combined[] = {
125 { USB_DEVICE(CONNECT_TECH_VENDOR_ID, CONNECT_TECH_WHITE_HEAT_ID) }, 125 { USB_DEVICE(CONNECT_TECH_VENDOR_ID, CONNECT_TECH_WHITE_HEAT_ID) },
126 { USB_DEVICE(CONNECT_TECH_VENDOR_ID, CONNECT_TECH_FAKE_WHITE_HEAT_ID) }, 126 { USB_DEVICE(CONNECT_TECH_VENDOR_ID, CONNECT_TECH_FAKE_WHITE_HEAT_ID) },
127 { } /* Terminating entry */ 127 { } /* Terminating entry */
@@ -1492,21 +1492,9 @@ static void rx_data_softint(struct work_struct *work)
1492 wrap = list_entry(tmp, struct whiteheat_urb_wrap, list); 1492 wrap = list_entry(tmp, struct whiteheat_urb_wrap, list);
1493 urb = wrap->urb; 1493 urb = wrap->urb;
1494 1494
1495 if (tty && urb->actual_length) { 1495 if (tty && urb->actual_length)
1496 int len = tty_buffer_request_room(tty, 1496 sent += tty_insert_flip_string(tty,
1497 urb->actual_length); 1497 urb->transfer_buffer, urb->actual_length);
1498 /* This stuff can go away now I suspect */
1499 if (unlikely(len < urb->actual_length)) {
1500 spin_lock_irqsave(&info->lock, flags);
1501 list_add(tmp, &info->rx_urb_q);
1502 spin_unlock_irqrestore(&info->lock, flags);
1503 tty_flip_buffer_push(tty);
1504 schedule_work(&info->rx_work);
1505 goto out;
1506 }
1507 tty_insert_flip_string(tty, urb->transfer_buffer, len);
1508 sent += len;
1509 }
1510 1498
1511 urb->dev = port->serial->dev; 1499 urb->dev = port->serial->dev;
1512 result = usb_submit_urb(urb, GFP_ATOMIC); 1500 result = usb_submit_urb(urb, GFP_ATOMIC);