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.c4
-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.c198
-rw-r--r--drivers/usb/serial/ftdi_sio.h6
-rw-r--r--drivers/usb/serial/ftdi_sio_ids.h46
-rw-r--r--drivers/usb/serial/funsoft.c2
-rw-r--r--drivers/usb/serial/garmin_gps.c3
-rw-r--r--drivers/usb/serial/generic.c56
-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.c27
-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.c20
-rw-r--r--drivers/usb/serial/option.c125
-rw-r--r--drivers/usb/serial/oti6858.c36
-rw-r--r--drivers/usb/serial/pl2303.c38
-rw-r--r--drivers/usb/serial/qcaux.c96
-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.c60
-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.c3
-rw-r--r--drivers/usb/serial/usb-serial.c15
-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
56 files changed, 1152 insertions, 686 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 a9c2dec8e3fb..9b66bf19f751 100644
--- a/drivers/usb/serial/ark3116.c
+++ b/drivers/usb/serial/ark3116.c
@@ -26,6 +26,7 @@
26#include <linux/init.h> 26#include <linux/init.h>
27#include <linux/ioctl.h> 27#include <linux/ioctl.h>
28#include <linux/tty.h> 28#include <linux/tty.h>
29#include <linux/slab.h>
29#include <linux/tty_flip.h> 30#include <linux/tty_flip.h>
30#include <linux/module.h> 31#include <linux/module.h>
31#include <linux/usb.h> 32#include <linux/usb.h>
@@ -50,7 +51,7 @@ static int debug;
50/* usb timeout of 1 second */ 51/* usb timeout of 1 second */
51#define ARK_TIMEOUT (1*HZ) 52#define ARK_TIMEOUT (1*HZ)
52 53
53static struct usb_device_id id_table [] = { 54static const struct usb_device_id id_table[] = {
54 { USB_DEVICE(0x6547, 0x0232) }, 55 { USB_DEVICE(0x6547, 0x0232) },
55 { USB_DEVICE(0x18ec, 0x3118) }, /* USB to IrDA adapter */ 56 { USB_DEVICE(0x18ec, 0x3118) }, /* USB to IrDA adapter */
56 { }, 57 { },
@@ -733,7 +734,6 @@ static void ark3116_read_bulk_callback(struct urb *urb)
733 734
734 tty = tty_port_tty_get(&port->port); 735 tty = tty_port_tty_get(&port->port);
735 if (tty) { 736 if (tty) {
736 tty_buffer_request_room(tty, urb->actual_length + 1);
737 /* overrun is special, not associated with a char */ 737 /* overrun is special, not associated with a char */
738 if (unlikely(lsr & UART_LSR_OE)) 738 if (unlikely(lsr & UART_LSR_OE))
739 tty_insert_flip_char(tty, 0, TTY_OVERRUN); 739 tty_insert_flip_char(tty, 0, TTY_OVERRUN);
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 7638828e7317..1d7c4fac02e8 100644
--- a/drivers/usb/serial/ftdi_sio.c
+++ b/drivers/usb/serial/ftdi_sio.c
@@ -33,12 +33,12 @@
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>
@@ -88,10 +88,10 @@ struct ftdi_private {
88 88
89 unsigned int latency; /* latency setting in use */ 89 unsigned int latency; /* latency setting in use */
90 spinlock_t tx_lock; /* spinlock for transmit state */ 90 spinlock_t tx_lock; /* spinlock for transmit state */
91 unsigned long tx_bytes;
92 unsigned long tx_outstanding_bytes; 91 unsigned long tx_outstanding_bytes;
93 unsigned long tx_outstanding_urbs; 92 unsigned long tx_outstanding_urbs;
94 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() */
95}; 95};
96 96
97/* struct ftdi_sio_quirk is used by devices requiring special attention. */ 97/* struct ftdi_sio_quirk is used by devices requiring special attention. */
@@ -614,6 +614,7 @@ static struct usb_device_id id_table_combined [] = {
614 { USB_DEVICE(FTDI_VID, FTDI_OCEANIC_PID) }, 614 { USB_DEVICE(FTDI_VID, FTDI_OCEANIC_PID) },
615 { USB_DEVICE(TTI_VID, TTI_QL355P_PID) }, 615 { USB_DEVICE(TTI_VID, TTI_QL355P_PID) },
616 { 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) },
617 { USB_DEVICE(BANDB_VID, BANDB_USOTL4_PID) }, 618 { USB_DEVICE(BANDB_VID, BANDB_USOTL4_PID) },
618 { USB_DEVICE(BANDB_VID, BANDB_USTL4_PID) }, 619 { USB_DEVICE(BANDB_VID, BANDB_USTL4_PID) },
619 { USB_DEVICE(BANDB_VID, BANDB_USO9ML2_PID) }, 620 { USB_DEVICE(BANDB_VID, BANDB_USO9ML2_PID) },
@@ -657,6 +658,7 @@ static struct usb_device_id id_table_combined [] = {
657 { USB_DEVICE(EVOLUTION_VID, EVOLUTION_ER1_PID) }, 658 { USB_DEVICE(EVOLUTION_VID, EVOLUTION_ER1_PID) },
658 { USB_DEVICE(EVOLUTION_VID, EVO_HYBRID_PID) }, 659 { USB_DEVICE(EVOLUTION_VID, EVO_HYBRID_PID) },
659 { USB_DEVICE(EVOLUTION_VID, EVO_RCM4_PID) }, 660 { USB_DEVICE(EVOLUTION_VID, EVO_RCM4_PID) },
661 { USB_DEVICE(CONTEC_VID, CONTEC_COM1USBH_PID) },
660 { USB_DEVICE(FTDI_VID, FTDI_ARTEMIS_PID) }, 662 { USB_DEVICE(FTDI_VID, FTDI_ARTEMIS_PID) },
661 { USB_DEVICE(FTDI_VID, FTDI_ATIK_ATK16_PID) }, 663 { USB_DEVICE(FTDI_VID, FTDI_ATIK_ATK16_PID) },
662 { USB_DEVICE(FTDI_VID, FTDI_ATIK_ATK16C_PID) }, 664 { USB_DEVICE(FTDI_VID, FTDI_ATIK_ATK16C_PID) },
@@ -737,6 +739,10 @@ static struct usb_device_id id_table_combined [] = {
737 .driver_info = (kernel_ulong_t)&ftdi_jtag_quirk }, 739 .driver_info = (kernel_ulong_t)&ftdi_jtag_quirk },
738 { USB_DEVICE(FTDI_VID, HAMEG_HO820_PID) }, 740 { USB_DEVICE(FTDI_VID, HAMEG_HO820_PID) },
739 { 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) },
740 { }, /* Optional parameter entry */ 746 { }, /* Optional parameter entry */
741 { } /* Terminating entry */ 747 { } /* Terminating entry */
742}; 748};
@@ -812,7 +818,7 @@ static struct usb_serial_driver ftdi_sio_device = {
812 .name = "ftdi_sio", 818 .name = "ftdi_sio",
813 }, 819 },
814 .description = "FTDI USB Serial Device", 820 .description = "FTDI USB Serial Device",
815 .usb_driver = &ftdi_driver , 821 .usb_driver = &ftdi_driver,
816 .id_table = id_table_combined, 822 .id_table = id_table_combined,
817 .num_ports = 1, 823 .num_ports = 1,
818 .probe = ftdi_sio_probe, 824 .probe = ftdi_sio_probe,
@@ -828,8 +834,8 @@ static struct usb_serial_driver ftdi_sio_device = {
828 .chars_in_buffer = ftdi_chars_in_buffer, 834 .chars_in_buffer = ftdi_chars_in_buffer,
829 .read_bulk_callback = ftdi_read_bulk_callback, 835 .read_bulk_callback = ftdi_read_bulk_callback,
830 .write_bulk_callback = ftdi_write_bulk_callback, 836 .write_bulk_callback = ftdi_write_bulk_callback,
831 .tiocmget = ftdi_tiocmget, 837 .tiocmget = ftdi_tiocmget,
832 .tiocmset = ftdi_tiocmset, 838 .tiocmset = ftdi_tiocmset,
833 .ioctl = ftdi_ioctl, 839 .ioctl = ftdi_ioctl,
834 .set_termios = ftdi_set_termios, 840 .set_termios = ftdi_set_termios,
835 .break_ctl = ftdi_break_ctl, 841 .break_ctl = ftdi_break_ctl,
@@ -935,7 +941,6 @@ static int update_mctrl(struct usb_serial_port *port, unsigned int set,
935 unsigned int clear) 941 unsigned int clear)
936{ 942{
937 struct ftdi_private *priv = usb_get_serial_port_data(port); 943 struct ftdi_private *priv = usb_get_serial_port_data(port);
938 char *buf;
939 unsigned urb_value; 944 unsigned urb_value;
940 int rv; 945 int rv;
941 946
@@ -944,10 +949,6 @@ static int update_mctrl(struct usb_serial_port *port, unsigned int set,
944 return 0; /* no change */ 949 return 0; /* no change */
945 } 950 }
946 951
947 buf = kmalloc(1, GFP_NOIO);
948 if (!buf)
949 return -ENOMEM;
950
951 clear &= ~set; /* 'set' takes precedence over 'clear' */ 952 clear &= ~set; /* 'set' takes precedence over 'clear' */
952 urb_value = 0; 953 urb_value = 0;
953 if (clear & TIOCM_DTR) 954 if (clear & TIOCM_DTR)
@@ -963,9 +964,7 @@ static int update_mctrl(struct usb_serial_port *port, unsigned int set,
963 FTDI_SIO_SET_MODEM_CTRL_REQUEST, 964 FTDI_SIO_SET_MODEM_CTRL_REQUEST,
964 FTDI_SIO_SET_MODEM_CTRL_REQUEST_TYPE, 965 FTDI_SIO_SET_MODEM_CTRL_REQUEST_TYPE,
965 urb_value, priv->interface, 966 urb_value, priv->interface,
966 buf, 0, WDR_TIMEOUT); 967 NULL, 0, WDR_TIMEOUT);
967
968 kfree(buf);
969 if (rv < 0) { 968 if (rv < 0) {
970 dbg("%s Error from MODEM_CTRL urb: DTR %s, RTS %s", 969 dbg("%s Error from MODEM_CTRL urb: DTR %s, RTS %s",
971 __func__, 970 __func__,
@@ -1124,16 +1123,11 @@ static __u32 get_ftdi_divisor(struct tty_struct *tty,
1124static 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)
1125{ 1124{
1126 struct ftdi_private *priv = usb_get_serial_port_data(port); 1125 struct ftdi_private *priv = usb_get_serial_port_data(port);
1127 char *buf;
1128 __u16 urb_value; 1126 __u16 urb_value;
1129 __u16 urb_index; 1127 __u16 urb_index;
1130 __u32 urb_index_value; 1128 __u32 urb_index_value;
1131 int rv; 1129 int rv;
1132 1130
1133 buf = kmalloc(1, GFP_NOIO);
1134 if (!buf)
1135 return -ENOMEM;
1136
1137 urb_index_value = get_ftdi_divisor(tty, port); 1131 urb_index_value = get_ftdi_divisor(tty, port);
1138 urb_value = (__u16)urb_index_value; 1132 urb_value = (__u16)urb_index_value;
1139 urb_index = (__u16)(urb_index_value >> 16); 1133 urb_index = (__u16)(urb_index_value >> 16);
@@ -1146,9 +1140,7 @@ static int change_speed(struct tty_struct *tty, struct usb_serial_port *port)
1146 FTDI_SIO_SET_BAUDRATE_REQUEST, 1140 FTDI_SIO_SET_BAUDRATE_REQUEST,
1147 FTDI_SIO_SET_BAUDRATE_REQUEST_TYPE, 1141 FTDI_SIO_SET_BAUDRATE_REQUEST_TYPE,
1148 urb_value, urb_index, 1142 urb_value, urb_index,
1149 buf, 0, WDR_SHORT_TIMEOUT); 1143 NULL, 0, WDR_SHORT_TIMEOUT);
1150
1151 kfree(buf);
1152 return rv; 1144 return rv;
1153} 1145}
1154 1146
@@ -1156,8 +1148,7 @@ static int write_latency_timer(struct usb_serial_port *port)
1156{ 1148{
1157 struct ftdi_private *priv = usb_get_serial_port_data(port); 1149 struct ftdi_private *priv = usb_get_serial_port_data(port);
1158 struct usb_device *udev = port->serial->dev; 1150 struct usb_device *udev = port->serial->dev;
1159 char buf[1]; 1151 int rv;
1160 int rv = 0;
1161 int l = priv->latency; 1152 int l = priv->latency;
1162 1153
1163 if (priv->flags & ASYNC_LOW_LATENCY) 1154 if (priv->flags & ASYNC_LOW_LATENCY)
@@ -1170,8 +1161,7 @@ static int write_latency_timer(struct usb_serial_port *port)
1170 FTDI_SIO_SET_LATENCY_TIMER_REQUEST, 1161 FTDI_SIO_SET_LATENCY_TIMER_REQUEST,
1171 FTDI_SIO_SET_LATENCY_TIMER_REQUEST_TYPE, 1162 FTDI_SIO_SET_LATENCY_TIMER_REQUEST_TYPE,
1172 l, priv->interface, 1163 l, priv->interface,
1173 buf, 0, WDR_TIMEOUT); 1164 NULL, 0, WDR_TIMEOUT);
1174
1175 if (rv < 0) 1165 if (rv < 0)
1176 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);
1177 return rv; 1167 return rv;
@@ -1181,24 +1171,29 @@ static int read_latency_timer(struct usb_serial_port *port)
1181{ 1171{
1182 struct ftdi_private *priv = usb_get_serial_port_data(port); 1172 struct ftdi_private *priv = usb_get_serial_port_data(port);
1183 struct usb_device *udev = port->serial->dev; 1173 struct usb_device *udev = port->serial->dev;
1184 unsigned short latency = 0; 1174 unsigned char *buf;
1185 int rv = 0; 1175 int rv;
1186
1187 1176
1188 dbg("%s", __func__); 1177 dbg("%s", __func__);
1189 1178
1179 buf = kmalloc(1, GFP_KERNEL);
1180 if (!buf)
1181 return -ENOMEM;
1182
1190 rv = usb_control_msg(udev, 1183 rv = usb_control_msg(udev,
1191 usb_rcvctrlpipe(udev, 0), 1184 usb_rcvctrlpipe(udev, 0),
1192 FTDI_SIO_GET_LATENCY_TIMER_REQUEST, 1185 FTDI_SIO_GET_LATENCY_TIMER_REQUEST,
1193 FTDI_SIO_GET_LATENCY_TIMER_REQUEST_TYPE, 1186 FTDI_SIO_GET_LATENCY_TIMER_REQUEST_TYPE,
1194 0, priv->interface, 1187 0, priv->interface,
1195 (char *) &latency, 1, WDR_TIMEOUT); 1188 buf, 1, WDR_TIMEOUT);
1196 1189 if (rv < 0)
1197 if (rv < 0) {
1198 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);
1199 return -EIO; 1191 else
1200 } 1192 priv->latency = buf[0];
1201 return latency; 1193
1194 kfree(buf);
1195
1196 return rv;
1202} 1197}
1203 1198
1204static int get_serial_info(struct usb_serial_port *port, 1199static int get_serial_info(struct usb_serial_port *port,
@@ -1229,7 +1224,7 @@ static int set_serial_info(struct tty_struct *tty,
1229 if (copy_from_user(&new_serial, newinfo, sizeof(new_serial))) 1224 if (copy_from_user(&new_serial, newinfo, sizeof(new_serial)))
1230 return -EFAULT; 1225 return -EFAULT;
1231 1226
1232 lock_kernel(); 1227 mutex_lock(&priv->cfg_lock);
1233 old_priv = *priv; 1228 old_priv = *priv;
1234 1229
1235 /* Do error checking and permission checking */ 1230 /* Do error checking and permission checking */
@@ -1237,7 +1232,7 @@ static int set_serial_info(struct tty_struct *tty,
1237 if (!capable(CAP_SYS_ADMIN)) { 1232 if (!capable(CAP_SYS_ADMIN)) {
1238 if (((new_serial.flags & ~ASYNC_USR_MASK) != 1233 if (((new_serial.flags & ~ASYNC_USR_MASK) !=
1239 (priv->flags & ~ASYNC_USR_MASK))) { 1234 (priv->flags & ~ASYNC_USR_MASK))) {
1240 unlock_kernel(); 1235 mutex_unlock(&priv->cfg_lock);
1241 return -EPERM; 1236 return -EPERM;
1242 } 1237 }
1243 priv->flags = ((priv->flags & ~ASYNC_USR_MASK) | 1238 priv->flags = ((priv->flags & ~ASYNC_USR_MASK) |
@@ -1248,7 +1243,7 @@ static int set_serial_info(struct tty_struct *tty,
1248 1243
1249 if ((new_serial.baud_base != priv->baud_base) && 1244 if ((new_serial.baud_base != priv->baud_base) &&
1250 (new_serial.baud_base < 9600)) { 1245 (new_serial.baud_base < 9600)) {
1251 unlock_kernel(); 1246 mutex_unlock(&priv->cfg_lock);
1252 return -EINVAL; 1247 return -EINVAL;
1253 } 1248 }
1254 1249
@@ -1278,11 +1273,11 @@ check_and_exit:
1278 (priv->flags & ASYNC_SPD_MASK)) || 1273 (priv->flags & ASYNC_SPD_MASK)) ||
1279 (((priv->flags & ASYNC_SPD_MASK) == ASYNC_SPD_CUST) && 1274 (((priv->flags & ASYNC_SPD_MASK) == ASYNC_SPD_CUST) &&
1280 (old_priv.custom_divisor != priv->custom_divisor))) { 1275 (old_priv.custom_divisor != priv->custom_divisor))) {
1281 unlock_kernel();
1282 change_speed(tty, port); 1276 change_speed(tty, port);
1277 mutex_unlock(&priv->cfg_lock);
1283 } 1278 }
1284 else 1279 else
1285 unlock_kernel(); 1280 mutex_unlock(&priv->cfg_lock);
1286 return 0; 1281 return 0;
1287 1282
1288} /* set_serial_info */ 1283} /* set_serial_info */
@@ -1338,20 +1333,20 @@ static void ftdi_determine_type(struct usb_serial_port *port)
1338 __func__); 1333 __func__);
1339 } 1334 }
1340 } else if (version < 0x200) { 1335 } else if (version < 0x200) {
1341 /* Old device. Assume its the original SIO. */ 1336 /* Old device. Assume it's the original SIO. */
1342 priv->chip_type = SIO; 1337 priv->chip_type = SIO;
1343 priv->baud_base = 12000000 / 16; 1338 priv->baud_base = 12000000 / 16;
1344 priv->write_offset = 1; 1339 priv->write_offset = 1;
1345 } else if (version < 0x400) { 1340 } else if (version < 0x400) {
1346 /* Assume its an FT8U232AM (or FT8U245AM) */ 1341 /* Assume it's an FT8U232AM (or FT8U245AM) */
1347 /* (It might be a BM because of the iSerialNumber bug, 1342 /* (It might be a BM because of the iSerialNumber bug,
1348 * but it will still work as an AM device.) */ 1343 * but it will still work as an AM device.) */
1349 priv->chip_type = FT8U232AM; 1344 priv->chip_type = FT8U232AM;
1350 } else if (version < 0x600) { 1345 } else if (version < 0x600) {
1351 /* Assume its an FT232BM (or FT245BM) */ 1346 /* Assume it's an FT232BM (or FT245BM) */
1352 priv->chip_type = FT232BM; 1347 priv->chip_type = FT232BM;
1353 } else { 1348 } else {
1354 /* Assume its an FT232R */ 1349 /* Assume it's an FT232R */
1355 priv->chip_type = FT232RL; 1350 priv->chip_type = FT232RL;
1356 } 1351 }
1357 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]);
@@ -1371,7 +1366,7 @@ static void ftdi_set_max_packet_size(struct usb_serial_port *port)
1371 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;
1372 1367
1373 unsigned num_endpoints; 1368 unsigned num_endpoints;
1374 int i = 0; 1369 int i;
1375 1370
1376 num_endpoints = interface->cur_altsetting->desc.bNumEndpoints; 1371 num_endpoints = interface->cur_altsetting->desc.bNumEndpoints;
1377 dev_info(&udev->dev, "Number of endpoints %d\n", num_endpoints); 1372 dev_info(&udev->dev, "Number of endpoints %d\n", num_endpoints);
@@ -1423,7 +1418,7 @@ static ssize_t store_latency_timer(struct device *dev,
1423 struct usb_serial_port *port = to_usb_serial_port(dev); 1418 struct usb_serial_port *port = to_usb_serial_port(dev);
1424 struct ftdi_private *priv = usb_get_serial_port_data(port); 1419 struct ftdi_private *priv = usb_get_serial_port_data(port);
1425 int v = simple_strtoul(valbuf, NULL, 10); 1420 int v = simple_strtoul(valbuf, NULL, 10);
1426 int rv = 0; 1421 int rv;
1427 1422
1428 priv->latency = v; 1423 priv->latency = v;
1429 rv = write_latency_timer(port); 1424 rv = write_latency_timer(port);
@@ -1440,9 +1435,8 @@ static ssize_t store_event_char(struct device *dev,
1440 struct usb_serial_port *port = to_usb_serial_port(dev); 1435 struct usb_serial_port *port = to_usb_serial_port(dev);
1441 struct ftdi_private *priv = usb_get_serial_port_data(port); 1436 struct ftdi_private *priv = usb_get_serial_port_data(port);
1442 struct usb_device *udev = port->serial->dev; 1437 struct usb_device *udev = port->serial->dev;
1443 char buf[1];
1444 int v = simple_strtoul(valbuf, NULL, 10); 1438 int v = simple_strtoul(valbuf, NULL, 10);
1445 int rv = 0; 1439 int rv;
1446 1440
1447 dbg("%s: setting event char = %i", __func__, v); 1441 dbg("%s: setting event char = %i", __func__, v);
1448 1442
@@ -1451,8 +1445,7 @@ static ssize_t store_event_char(struct device *dev,
1451 FTDI_SIO_SET_EVENT_CHAR_REQUEST, 1445 FTDI_SIO_SET_EVENT_CHAR_REQUEST,
1452 FTDI_SIO_SET_EVENT_CHAR_REQUEST_TYPE, 1446 FTDI_SIO_SET_EVENT_CHAR_REQUEST_TYPE,
1453 v, priv->interface, 1447 v, priv->interface,
1454 buf, 0, WDR_TIMEOUT); 1448 NULL, 0, WDR_TIMEOUT);
1455
1456 if (rv < 0) { 1449 if (rv < 0) {
1457 dbg("Unable to write event character: %i", rv); 1450 dbg("Unable to write event character: %i", rv);
1458 return -EIO; 1451 return -EIO;
@@ -1551,9 +1544,9 @@ static int ftdi_sio_port_probe(struct usb_serial_port *port)
1551 1544
1552 kref_init(&priv->kref); 1545 kref_init(&priv->kref);
1553 spin_lock_init(&priv->tx_lock); 1546 spin_lock_init(&priv->tx_lock);
1547 mutex_init(&priv->cfg_lock);
1554 init_waitqueue_head(&priv->delta_msr_wait); 1548 init_waitqueue_head(&priv->delta_msr_wait);
1555 /* This will push the characters through immediately rather 1549
1556 than queue a task to deliver them */
1557 priv->flags = ASYNC_LOW_LATENCY; 1550 priv->flags = ASYNC_LOW_LATENCY;
1558 1551
1559 if (quirk && quirk->port_probe) 1552 if (quirk && quirk->port_probe)
@@ -1585,7 +1578,8 @@ static int ftdi_sio_port_probe(struct usb_serial_port *port)
1585 1578
1586 ftdi_determine_type(port); 1579 ftdi_determine_type(port);
1587 ftdi_set_max_packet_size(port); 1580 ftdi_set_max_packet_size(port);
1588 read_latency_timer(port); 1581 if (read_latency_timer(port) < 0)
1582 priv->latency = 16;
1589 create_sysfs_attrs(port); 1583 create_sysfs_attrs(port);
1590 return 0; 1584 return 0;
1591} 1585}
@@ -1630,8 +1624,6 @@ static int ftdi_NDI_device_setup(struct usb_serial *serial)
1630{ 1624{
1631 struct usb_device *udev = serial->dev; 1625 struct usb_device *udev = serial->dev;
1632 int latency = ndi_latency_timer; 1626 int latency = ndi_latency_timer;
1633 int rv = 0;
1634 char buf[1];
1635 1627
1636 if (latency == 0) 1628 if (latency == 0)
1637 latency = 1; 1629 latency = 1;
@@ -1641,10 +1633,11 @@ static int ftdi_NDI_device_setup(struct usb_serial *serial)
1641 dbg("%s setting NDI device latency to %d", __func__, latency); 1633 dbg("%s setting NDI device latency to %d", __func__, latency);
1642 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);
1643 1635
1644 rv = usb_control_msg(udev, usb_sndctrlpipe(udev, 0), 1636 /* FIXME: errors are not returned */
1637 usb_control_msg(udev, usb_sndctrlpipe(udev, 0),
1645 FTDI_SIO_SET_LATENCY_TIMER_REQUEST, 1638 FTDI_SIO_SET_LATENCY_TIMER_REQUEST,
1646 FTDI_SIO_SET_LATENCY_TIMER_REQUEST_TYPE, 1639 FTDI_SIO_SET_LATENCY_TIMER_REQUEST_TYPE,
1647 latency, 0, buf, 0, WDR_TIMEOUT); 1640 latency, 0, NULL, 0, WDR_TIMEOUT);
1648 return 0; 1641 return 0;
1649} 1642}
1650 1643
@@ -1720,7 +1713,7 @@ static int ftdi_submit_read_urb(struct usb_serial_port *port, gfp_t mem_flags)
1720 urb->transfer_buffer_length, 1713 urb->transfer_buffer_length,
1721 ftdi_read_bulk_callback, port); 1714 ftdi_read_bulk_callback, port);
1722 result = usb_submit_urb(urb, mem_flags); 1715 result = usb_submit_urb(urb, mem_flags);
1723 if (result) 1716 if (result && result != -EPERM)
1724 dev_err(&port->dev, 1717 dev_err(&port->dev,
1725 "%s - failed submitting read urb, error %d\n", 1718 "%s - failed submitting read urb, error %d\n",
1726 __func__, result); 1719 __func__, result);
@@ -1732,16 +1725,10 @@ static int ftdi_open(struct tty_struct *tty, struct usb_serial_port *port)
1732 struct usb_device *dev = port->serial->dev; 1725 struct usb_device *dev = port->serial->dev;
1733 struct ftdi_private *priv = usb_get_serial_port_data(port); 1726 struct ftdi_private *priv = usb_get_serial_port_data(port);
1734 unsigned long flags; 1727 unsigned long flags;
1735 1728 int result;
1736 int result = 0;
1737 char buf[1]; /* Needed for the usb_control_msg I think */
1738 1729
1739 dbg("%s", __func__); 1730 dbg("%s", __func__);
1740 1731
1741 spin_lock_irqsave(&priv->tx_lock, flags);
1742 priv->tx_bytes = 0;
1743 spin_unlock_irqrestore(&priv->tx_lock, flags);
1744
1745 write_latency_timer(port); 1732 write_latency_timer(port);
1746 1733
1747 /* No error checking for this (will get errors later anyway) */ 1734 /* No error checking for this (will get errors later anyway) */
@@ -1749,7 +1736,7 @@ static int ftdi_open(struct tty_struct *tty, struct usb_serial_port *port)
1749 usb_control_msg(dev, usb_sndctrlpipe(dev, 0), 1736 usb_control_msg(dev, usb_sndctrlpipe(dev, 0),
1750 FTDI_SIO_RESET_REQUEST, FTDI_SIO_RESET_REQUEST_TYPE, 1737 FTDI_SIO_RESET_REQUEST, FTDI_SIO_RESET_REQUEST_TYPE,
1751 FTDI_SIO_RESET_SIO, 1738 FTDI_SIO_RESET_SIO,
1752 priv->interface, buf, 0, WDR_TIMEOUT); 1739 priv->interface, NULL, 0, WDR_TIMEOUT);
1753 1740
1754 /* 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
1755 port->tty->termios - this would lose speed settings, etc. 1742 port->tty->termios - this would lose speed settings, etc.
@@ -1777,7 +1764,6 @@ static int ftdi_open(struct tty_struct *tty, struct usb_serial_port *port)
1777static void ftdi_dtr_rts(struct usb_serial_port *port, int on) 1764static void ftdi_dtr_rts(struct usb_serial_port *port, int on)
1778{ 1765{
1779 struct ftdi_private *priv = usb_get_serial_port_data(port); 1766 struct ftdi_private *priv = usb_get_serial_port_data(port);
1780 char buf[1];
1781 1767
1782 mutex_lock(&port->serial->disc_mutex); 1768 mutex_lock(&port->serial->disc_mutex);
1783 if (!port->serial->disconnected) { 1769 if (!port->serial->disconnected) {
@@ -1786,7 +1772,7 @@ static void ftdi_dtr_rts(struct usb_serial_port *port, int on)
1786 usb_sndctrlpipe(port->serial->dev, 0), 1772 usb_sndctrlpipe(port->serial->dev, 0),
1787 FTDI_SIO_SET_FLOW_CTRL_REQUEST, 1773 FTDI_SIO_SET_FLOW_CTRL_REQUEST,
1788 FTDI_SIO_SET_FLOW_CTRL_REQUEST_TYPE, 1774 FTDI_SIO_SET_FLOW_CTRL_REQUEST_TYPE,
1789 0, priv->interface, buf, 0, 1775 0, priv->interface, NULL, 0,
1790 WDR_TIMEOUT) < 0) { 1776 WDR_TIMEOUT) < 0) {
1791 dev_err(&port->dev, "error from flowcontrol urb\n"); 1777 dev_err(&port->dev, "error from flowcontrol urb\n");
1792 } 1778 }
@@ -1847,7 +1833,7 @@ static int ftdi_write(struct tty_struct *tty, struct usb_serial_port *port,
1847 spin_lock_irqsave(&priv->tx_lock, flags); 1833 spin_lock_irqsave(&priv->tx_lock, flags);
1848 if (priv->tx_outstanding_urbs > URB_UPPER_LIMIT) { 1834 if (priv->tx_outstanding_urbs > URB_UPPER_LIMIT) {
1849 spin_unlock_irqrestore(&priv->tx_lock, flags); 1835 spin_unlock_irqrestore(&priv->tx_lock, flags);
1850 dbg("%s - write limit hit\n", __func__); 1836 dbg("%s - write limit hit", __func__);
1851 return 0; 1837 return 0;
1852 } 1838 }
1853 priv->tx_outstanding_urbs++; 1839 priv->tx_outstanding_urbs++;
@@ -1927,7 +1913,6 @@ static int ftdi_write(struct tty_struct *tty, struct usb_serial_port *port,
1927 } else { 1913 } else {
1928 spin_lock_irqsave(&priv->tx_lock, flags); 1914 spin_lock_irqsave(&priv->tx_lock, flags);
1929 priv->tx_outstanding_bytes += count; 1915 priv->tx_outstanding_bytes += count;
1930 priv->tx_bytes += count;
1931 spin_unlock_irqrestore(&priv->tx_lock, flags); 1916 spin_unlock_irqrestore(&priv->tx_lock, flags);
1932 } 1917 }
1933 1918
@@ -2154,8 +2139,7 @@ static void ftdi_break_ctl(struct tty_struct *tty, int break_state)
2154{ 2139{
2155 struct usb_serial_port *port = tty->driver_data; 2140 struct usb_serial_port *port = tty->driver_data;
2156 struct ftdi_private *priv = usb_get_serial_port_data(port); 2141 struct ftdi_private *priv = usb_get_serial_port_data(port);
2157 __u16 urb_value = 0; 2142 __u16 urb_value;
2158 char buf[1];
2159 2143
2160 /* 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 */
2161 /* see drivers/char/tty_io.c to see it used */ 2145 /* see drivers/char/tty_io.c to see it used */
@@ -2171,7 +2155,7 @@ static void ftdi_break_ctl(struct tty_struct *tty, int break_state)
2171 FTDI_SIO_SET_DATA_REQUEST, 2155 FTDI_SIO_SET_DATA_REQUEST,
2172 FTDI_SIO_SET_DATA_REQUEST_TYPE, 2156 FTDI_SIO_SET_DATA_REQUEST_TYPE,
2173 urb_value , priv->interface, 2157 urb_value , priv->interface,
2174 buf, 0, WDR_TIMEOUT) < 0) { 2158 NULL, 0, WDR_TIMEOUT) < 0) {
2175 dev_err(&port->dev, "%s FAILED to enable/disable break state " 2159 dev_err(&port->dev, "%s FAILED to enable/disable break state "
2176 "(state was %d)\n", __func__, break_state); 2160 "(state was %d)\n", __func__, break_state);
2177 } 2161 }
@@ -2195,7 +2179,6 @@ static void ftdi_set_termios(struct tty_struct *tty,
2195 struct ktermios *termios = tty->termios; 2179 struct ktermios *termios = tty->termios;
2196 unsigned int cflag = termios->c_cflag; 2180 unsigned int cflag = termios->c_cflag;
2197 __u16 urb_value; /* will hold the new flags */ 2181 __u16 urb_value; /* will hold the new flags */
2198 char buf[1]; /* Perhaps I should dynamically alloc this? */
2199 2182
2200 /* Added for xon/xoff support */ 2183 /* Added for xon/xoff support */
2201 unsigned int iflag = termios->c_iflag; 2184 unsigned int iflag = termios->c_iflag;
@@ -2246,12 +2229,10 @@ static void ftdi_set_termios(struct tty_struct *tty,
2246 } 2229 }
2247 if (cflag & CSIZE) { 2230 if (cflag & CSIZE) {
2248 switch (cflag & CSIZE) { 2231 switch (cflag & CSIZE) {
2249 case CS5: urb_value |= 5; dbg("Setting CS5"); break;
2250 case CS6: urb_value |= 6; dbg("Setting CS6"); break;
2251 case CS7: urb_value |= 7; dbg("Setting CS7"); break; 2232 case CS7: urb_value |= 7; dbg("Setting CS7"); break;
2252 case CS8: urb_value |= 8; dbg("Setting CS8"); break; 2233 case CS8: urb_value |= 8; dbg("Setting CS8"); break;
2253 default: 2234 default:
2254 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");
2255 } 2236 }
2256 } 2237 }
2257 2238
@@ -2263,7 +2244,7 @@ static void ftdi_set_termios(struct tty_struct *tty,
2263 FTDI_SIO_SET_DATA_REQUEST, 2244 FTDI_SIO_SET_DATA_REQUEST,
2264 FTDI_SIO_SET_DATA_REQUEST_TYPE, 2245 FTDI_SIO_SET_DATA_REQUEST_TYPE,
2265 urb_value , priv->interface, 2246 urb_value , priv->interface,
2266 buf, 0, WDR_SHORT_TIMEOUT) < 0) { 2247 NULL, 0, WDR_SHORT_TIMEOUT) < 0) {
2267 dev_err(&port->dev, "%s FAILED to set " 2248 dev_err(&port->dev, "%s FAILED to set "
2268 "databits/stopbits/parity\n", __func__); 2249 "databits/stopbits/parity\n", __func__);
2269 } 2250 }
@@ -2275,7 +2256,7 @@ static void ftdi_set_termios(struct tty_struct *tty,
2275 FTDI_SIO_SET_FLOW_CTRL_REQUEST, 2256 FTDI_SIO_SET_FLOW_CTRL_REQUEST,
2276 FTDI_SIO_SET_FLOW_CTRL_REQUEST_TYPE, 2257 FTDI_SIO_SET_FLOW_CTRL_REQUEST_TYPE,
2277 0, priv->interface, 2258 0, priv->interface,
2278 buf, 0, WDR_TIMEOUT) < 0) { 2259 NULL, 0, WDR_TIMEOUT) < 0) {
2279 dev_err(&port->dev, 2260 dev_err(&port->dev,
2280 "%s error from disable flowcontrol urb\n", 2261 "%s error from disable flowcontrol urb\n",
2281 __func__); 2262 __func__);
@@ -2284,9 +2265,11 @@ static void ftdi_set_termios(struct tty_struct *tty,
2284 clear_mctrl(port, TIOCM_DTR | TIOCM_RTS); 2265 clear_mctrl(port, TIOCM_DTR | TIOCM_RTS);
2285 } else { 2266 } else {
2286 /* set the baudrate determined before */ 2267 /* set the baudrate determined before */
2268 mutex_lock(&priv->cfg_lock);
2287 if (change_speed(tty, port)) 2269 if (change_speed(tty, port))
2288 dev_err(&port->dev, "%s urb failed to set baudrate\n", 2270 dev_err(&port->dev, "%s urb failed to set baudrate\n",
2289 __func__); 2271 __func__);
2272 mutex_unlock(&priv->cfg_lock);
2290 /* Ensure RTS and DTR are raised when baudrate changed from 0 */ 2273 /* Ensure RTS and DTR are raised when baudrate changed from 0 */
2291 if (!old_termios || (old_termios->c_cflag & CBAUD) == B0) 2274 if (!old_termios || (old_termios->c_cflag & CBAUD) == B0)
2292 set_mctrl(port, TIOCM_DTR | TIOCM_RTS); 2275 set_mctrl(port, TIOCM_DTR | TIOCM_RTS);
@@ -2301,7 +2284,7 @@ static void ftdi_set_termios(struct tty_struct *tty,
2301 FTDI_SIO_SET_FLOW_CTRL_REQUEST, 2284 FTDI_SIO_SET_FLOW_CTRL_REQUEST,
2302 FTDI_SIO_SET_FLOW_CTRL_REQUEST_TYPE, 2285 FTDI_SIO_SET_FLOW_CTRL_REQUEST_TYPE,
2303 0 , (FTDI_SIO_RTS_CTS_HS | priv->interface), 2286 0 , (FTDI_SIO_RTS_CTS_HS | priv->interface),
2304 buf, 0, WDR_TIMEOUT) < 0) { 2287 NULL, 0, WDR_TIMEOUT) < 0) {
2305 dev_err(&port->dev, 2288 dev_err(&port->dev,
2306 "urb failed to set to rts/cts flow control\n"); 2289 "urb failed to set to rts/cts flow control\n");
2307 } 2290 }
@@ -2333,7 +2316,7 @@ static void ftdi_set_termios(struct tty_struct *tty,
2333 FTDI_SIO_SET_FLOW_CTRL_REQUEST_TYPE, 2316 FTDI_SIO_SET_FLOW_CTRL_REQUEST_TYPE,
2334 urb_value , (FTDI_SIO_XON_XOFF_HS 2317 urb_value , (FTDI_SIO_XON_XOFF_HS
2335 | priv->interface), 2318 | priv->interface),
2336 buf, 0, WDR_TIMEOUT) < 0) { 2319 NULL, 0, WDR_TIMEOUT) < 0) {
2337 dev_err(&port->dev, "urb failed to set to " 2320 dev_err(&port->dev, "urb failed to set to "
2338 "xon/xoff flow control\n"); 2321 "xon/xoff flow control\n");
2339 } 2322 }
@@ -2347,7 +2330,7 @@ static void ftdi_set_termios(struct tty_struct *tty,
2347 FTDI_SIO_SET_FLOW_CTRL_REQUEST, 2330 FTDI_SIO_SET_FLOW_CTRL_REQUEST,
2348 FTDI_SIO_SET_FLOW_CTRL_REQUEST_TYPE, 2331 FTDI_SIO_SET_FLOW_CTRL_REQUEST_TYPE,
2349 0, priv->interface, 2332 0, priv->interface,
2350 buf, 0, WDR_TIMEOUT) < 0) { 2333 NULL, 0, WDR_TIMEOUT) < 0) {
2351 dev_err(&port->dev, 2334 dev_err(&port->dev,
2352 "urb failed to clear flow control\n"); 2335 "urb failed to clear flow control\n");
2353 } 2336 }
@@ -2361,21 +2344,22 @@ static int ftdi_tiocmget(struct tty_struct *tty, struct file *file)
2361{ 2344{
2362 struct usb_serial_port *port = tty->driver_data; 2345 struct usb_serial_port *port = tty->driver_data;
2363 struct ftdi_private *priv = usb_get_serial_port_data(port); 2346 struct ftdi_private *priv = usb_get_serial_port_data(port);
2364 unsigned char buf[2]; 2347 unsigned char *buf;
2348 int len;
2365 int ret; 2349 int ret;
2366 2350
2367 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 */
2368 switch (priv->chip_type) { 2360 switch (priv->chip_type) {
2369 case SIO: 2361 case SIO:
2370 /* Request the status from the device */ 2362 len = 1;
2371 ret = usb_control_msg(port->serial->dev,
2372 usb_rcvctrlpipe(port->serial->dev, 0),
2373 FTDI_SIO_GET_MODEM_STATUS_REQUEST,
2374 FTDI_SIO_GET_MODEM_STATUS_REQUEST_TYPE,
2375 0, 0,
2376 buf, 1, WDR_TIMEOUT);
2377 if (ret < 0)
2378 return ret;
2379 break; 2363 break;
2380 case FT8U232AM: 2364 case FT8U232AM:
2381 case FT232BM: 2365 case FT232BM:
@@ -2383,27 +2367,30 @@ static int ftdi_tiocmget(struct tty_struct *tty, struct file *file)
2383 case FT232RL: 2367 case FT232RL:
2384 case FT2232H: 2368 case FT2232H:
2385 case FT4232H: 2369 case FT4232H:
2386 /* the 8U232AM returns a two byte value (the sio is a 1 byte 2370 len = 2;
2387 value) - in the same format as the data returned from the in
2388 point */
2389 ret = usb_control_msg(port->serial->dev,
2390 usb_rcvctrlpipe(port->serial->dev, 0),
2391 FTDI_SIO_GET_MODEM_STATUS_REQUEST,
2392 FTDI_SIO_GET_MODEM_STATUS_REQUEST_TYPE,
2393 0, priv->interface,
2394 buf, 2, WDR_TIMEOUT);
2395 if (ret < 0)
2396 return ret;
2397 break; 2371 break;
2398 default: 2372 default:
2399 return -EFAULT; 2373 ret = -EFAULT;
2374 goto out;
2400 } 2375 }
2401 2376
2402 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) |
2403 (buf[0] & FTDI_SIO_CTS_MASK ? TIOCM_CTS : 0) | 2387 (buf[0] & FTDI_SIO_CTS_MASK ? TIOCM_CTS : 0) |
2404 (buf[0] & FTDI_SIO_RI_MASK ? TIOCM_RI : 0) | 2388 (buf[0] & FTDI_SIO_RI_MASK ? TIOCM_RI : 0) |
2405 (buf[0] & FTDI_SIO_RLSD_MASK ? TIOCM_CD : 0) | 2389 (buf[0] & FTDI_SIO_RLSD_MASK ? TIOCM_CD : 0) |
2406 priv->last_dtr_rts; 2390 priv->last_dtr_rts;
2391out:
2392 kfree(buf);
2393 return ret;
2407} 2394}
2408 2395
2409static int ftdi_tiocmset(struct tty_struct *tty, struct file *file, 2396static int ftdi_tiocmset(struct tty_struct *tty, struct file *file,
@@ -2508,8 +2495,7 @@ void ftdi_unthrottle(struct tty_struct *tty)
2508 port->throttled = port->throttle_req = 0; 2495 port->throttled = port->throttle_req = 0;
2509 spin_unlock_irqrestore(&port->lock, flags); 2496 spin_unlock_irqrestore(&port->lock, flags);
2510 2497
2511 /* Resubmit urb if throttled and open. */ 2498 if (was_throttled)
2512 if (was_throttled && test_bit(ASYNCB_INITIALIZED, &port->port.flags))
2513 ftdi_submit_read_urb(port, GFP_KERNEL); 2499 ftdi_submit_read_urb(port, GFP_KERNEL);
2514} 2500}
2515 2501
diff --git a/drivers/usb/serial/ftdi_sio.h b/drivers/usb/serial/ftdi_sio.h
index b0e0d64f822e..ff9bf80327a3 100644
--- a/drivers/usb/serial/ftdi_sio.h
+++ b/drivers/usb/serial/ftdi_sio.h
@@ -28,13 +28,13 @@
28#define FTDI_SIO_SET_FLOW_CTRL 2 /* Set flow control register */ 28#define FTDI_SIO_SET_FLOW_CTRL 2 /* Set flow control register */
29#define FTDI_SIO_SET_BAUD_RATE 3 /* Set baud rate */ 29#define FTDI_SIO_SET_BAUD_RATE 3 /* Set baud rate */
30#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 */
31#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 */
32#define FTDI_SIO_SET_EVENT_CHAR 6 /* Set the event character */ 32#define FTDI_SIO_SET_EVENT_CHAR 6 /* Set the event character */
33#define FTDI_SIO_SET_ERROR_CHAR 7 /* Set the error character */ 33#define FTDI_SIO_SET_ERROR_CHAR 7 /* Set the error character */
34#define FTDI_SIO_SET_LATENCY_TIMER 9 /* Set the latency timer */ 34#define FTDI_SIO_SET_LATENCY_TIMER 9 /* Set the latency timer */
35#define FTDI_SIO_GET_LATENCY_TIMER 10 /* Get the latency timer */ 35#define FTDI_SIO_GET_LATENCY_TIMER 10 /* Get the latency timer */
36 36
37/* Interface indicies for FT2232, FT2232H and FT4232H devices*/ 37/* Interface indices for FT2232, FT2232H and FT4232H devices */
38#define INTERFACE_A 1 38#define INTERFACE_A 1
39#define INTERFACE_B 2 39#define INTERFACE_B 2
40#define INTERFACE_C 3 40#define INTERFACE_C 3
@@ -270,7 +270,7 @@ typedef enum {
270 * BmRequestType: 0100 0000b 270 * BmRequestType: 0100 0000b
271 * bRequest: FTDI_SIO_SET_FLOW_CTRL 271 * bRequest: FTDI_SIO_SET_FLOW_CTRL
272 * wValue: Xoff/Xon 272 * wValue: Xoff/Xon
273 * wIndex: Protocol/Port - hIndex is protocl / lIndex is port 273 * wIndex: Protocol/Port - hIndex is protocol / lIndex is port
274 * wLength: 0 274 * wLength: 0
275 * Data: None 275 * Data: None
276 * 276 *
diff --git a/drivers/usb/serial/ftdi_sio_ids.h b/drivers/usb/serial/ftdi_sio_ids.h
index c8951aeed983..75482cbc3998 100644
--- a/drivers/usb/serial/ftdi_sio_ids.h
+++ b/drivers/usb/serial/ftdi_sio_ids.h
@@ -22,7 +22,7 @@
22#define FTDI_8U232AM_ALT_PID 0x6006 /* FTDI's alternate PID for above */ 22#define FTDI_8U232AM_ALT_PID 0x6006 /* FTDI's alternate PID for above */
23#define FTDI_8U2232C_PID 0x6010 /* Dual channel device */ 23#define FTDI_8U2232C_PID 0x6010 /* Dual channel device */
24#define FTDI_4232H_PID 0x6011 /* Quad channel hi-speed device */ 24#define FTDI_4232H_PID 0x6011 /* Quad channel hi-speed device */
25#define FTDI_SIO_PID 0x8372 /* Product Id SIO application of 8U100AX */ 25#define FTDI_SIO_PID 0x8372 /* Product Id SIO application of 8U100AX */
26#define FTDI_232RL_PID 0xFBFA /* Product ID for FT232RL */ 26#define FTDI_232RL_PID 0xFBFA /* Product ID for FT232RL */
27 27
28 28
@@ -49,7 +49,7 @@
49#define LMI_LM3S_DEVEL_BOARD_PID 0xbcd8 49#define LMI_LM3S_DEVEL_BOARD_PID 0xbcd8
50#define LMI_LM3S_EVAL_BOARD_PID 0xbcd9 50#define LMI_LM3S_EVAL_BOARD_PID 0xbcd9
51 51
52#define FTDI_TURTELIZER_PID 0xBDC8 /* JTAG/RS-232 adapter by egnite GmBH */ 52#define FTDI_TURTELIZER_PID 0xBDC8 /* JTAG/RS-232 adapter by egnite GmbH */
53 53
54/* OpenDCC (www.opendcc.de) product id */ 54/* OpenDCC (www.opendcc.de) product id */
55#define FTDI_OPENDCC_PID 0xBFD8 55#define FTDI_OPENDCC_PID 0xBFD8
@@ -185,7 +185,7 @@
185#define FTDI_ELV_TFD128_PID 0xE0EC /* ELV Temperatur-Feuchte-Datenlogger TFD 128 */ 185#define FTDI_ELV_TFD128_PID 0xE0EC /* ELV Temperatur-Feuchte-Datenlogger TFD 128 */
186#define FTDI_ELV_FM3RX_PID 0xE0ED /* ELV Messwertuebertragung FM3 RX */ 186#define FTDI_ELV_FM3RX_PID 0xE0ED /* ELV Messwertuebertragung FM3 RX */
187#define FTDI_ELV_WS777_PID 0xE0EE /* Conrad WS 777 */ 187#define FTDI_ELV_WS777_PID 0xE0EE /* Conrad WS 777 */
188#define FTDI_ELV_EM1010PC_PID 0xE0EF /* Engery monitor EM 1010 PC */ 188#define FTDI_ELV_EM1010PC_PID 0xE0EF /* Energy monitor EM 1010 PC */
189#define FTDI_ELV_CSI8_PID 0xE0F0 /* Computer-Schalt-Interface (CSI 8) */ 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) */ 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) */ 191#define FTDI_ELV_PCK100_PID 0xE0F2 /* PC-Kabeltester (PCK 100) */
@@ -212,8 +212,8 @@
212 * drivers, or possibly the Comedi drivers in some cases. */ 212 * drivers, or possibly the Comedi drivers in some cases. */
213#define FTDI_ELV_CLI7000_PID 0xFB59 /* Computer-Light-Interface (CLI 7000) */ 213#define FTDI_ELV_CLI7000_PID 0xFB59 /* Computer-Light-Interface (CLI 7000) */
214#define FTDI_ELV_PPS7330_PID 0xFB5C /* Processor-Power-Supply (PPS 7330) */ 214#define FTDI_ELV_PPS7330_PID 0xFB5C /* Processor-Power-Supply (PPS 7330) */
215#define FTDI_ELV_TFM100_PID 0xFB5D /* Temperartur-Feuchte Messgeraet (TFM 100) */ 215#define FTDI_ELV_TFM100_PID 0xFB5D /* Temperatur-Feuchte-Messgeraet (TFM 100) */
216#define FTDI_ELV_UDF77_PID 0xFB5E /* USB DCF Funkurh (UDF 77) */ 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) */ 217#define FTDI_ELV_UIO88_PID 0xFB5F /* USB-I/O Interface (UIO 88) */
218 218
219/* 219/*
@@ -320,7 +320,7 @@
320 320
321/* 321/*
322 * 4N-GALAXY.DE PIDs for CAN-USB, USB-RS232, USB-RS422, USB-RS485, 322 * 4N-GALAXY.DE PIDs for CAN-USB, USB-RS232, USB-RS422, USB-RS485,
323 * USB-TTY activ, USB-TTY passiv. Some PIDs are used by several devices 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. 324 * and I'm not entirely sure which are used by which.
325 */ 325 */
326#define FTDI_4N_GALAXY_DE_1_PID 0xF3C0 326#define FTDI_4N_GALAXY_DE_1_PID 0xF3C0
@@ -330,10 +330,10 @@
330 * Linx Technologies product ids 330 * Linx Technologies product ids
331 */ 331 */
332#define LINX_SDMUSBQSS_PID 0xF448 /* Linx SDM-USB-QS-S */ 332#define LINX_SDMUSBQSS_PID 0xF448 /* Linx SDM-USB-QS-S */
333#define LINX_MASTERDEVEL2_PID 0xF449 /* Linx Master Development 2.0 */ 333#define LINX_MASTERDEVEL2_PID 0xF449 /* Linx Master Development 2.0 */
334#define LINX_FUTURE_0_PID 0xF44A /* Linx future device */ 334#define LINX_FUTURE_0_PID 0xF44A /* Linx future device */
335#define LINX_FUTURE_1_PID 0xF44B /* Linx future device */ 335#define LINX_FUTURE_1_PID 0xF44B /* Linx future device */
336#define LINX_FUTURE_2_PID 0xF44C /* Linx future device */ 336#define LINX_FUTURE_2_PID 0xF44C /* Linx future device */
337 337
338/* 338/*
339 * Oceanic product ids 339 * Oceanic product ids
@@ -494,6 +494,20 @@
494#define RATOC_PRODUCT_ID_USB60F 0xb020 494#define RATOC_PRODUCT_ID_USB60F 0xb020
495 495
496/* 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/*
497 * Definitions for B&B Electronics products. 511 * Definitions for B&B Electronics products.
498 */ 512 */
499#define BANDB_VID 0x0856 /* B&B Electronics Vendor ID */ 513#define BANDB_VID 0x0856 /* B&B Electronics Vendor ID */
@@ -642,7 +656,7 @@
642#define FALCOM_TWIST_PID 0x0001 /* Falcom Twist USB GPRS modem */ 656#define FALCOM_TWIST_PID 0x0001 /* Falcom Twist USB GPRS modem */
643#define FALCOM_SAMBA_PID 0x0005 /* Falcom Samba USB GPRS modem */ 657#define FALCOM_SAMBA_PID 0x0005 /* Falcom Samba USB GPRS modem */
644 658
645/* Larsen and Brusgaard AltiTrack/USBtrack */ 659/* Larsen and Brusgaard AltiTrack/USBtrack */
646#define LARSENBRUSGAARD_VID 0x0FD8 660#define LARSENBRUSGAARD_VID 0x0FD8
647#define LB_ALTITRACK_PID 0x0001 661#define LB_ALTITRACK_PID 0x0001
648 662
@@ -971,7 +985,7 @@
971#define ALTI2_N3_PID 0x6001 /* Neptune 3 */ 985#define ALTI2_N3_PID 0x6001 /* Neptune 3 */
972 986
973/* 987/*
974 * Dresden Elektronic Sensor Terminal Board 988 * Dresden Elektronik Sensor Terminal Board
975 */ 989 */
976#define DE_VID 0x1cf1 /* Vendor ID */ 990#define DE_VID 0x1cf1 /* Vendor ID */
977#define STB_PID 0x0001 /* Sensor Terminal Board */ 991#define STB_PID 0x0001 /* Sensor Terminal Board */
@@ -1002,3 +1016,11 @@
1002#define EVO_8U232AM_PID 0x02FF /* Evolution robotics RCM2 (FT232AM)*/ 1016#define EVO_8U232AM_PID 0x02FF /* Evolution robotics RCM2 (FT232AM)*/
1003#define EVO_HYBRID_PID 0x0302 /* Evolution robotics RCM4 PID (FT232BM)*/ 1017#define EVO_HYBRID_PID 0x0302 /* Evolution robotics RCM4 PID (FT232BM)*/
1004#define EVO_RCM4_PID 0x0303 /* Evolution robotics RCM4 PID */ 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 83443d6306d6..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;
@@ -332,15 +333,15 @@ 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);
@@ -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 = kfifo_avail(&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,15 +387,18 @@ 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
395 if (!port->bulk_out_size)
396 return 0;
397
389 spin_lock_irqsave(&port->lock, flags); 398 spin_lock_irqsave(&port->lock, flags);
390 if (serial->type->max_in_flight_urbs) 399 if (serial->type->max_in_flight_urbs)
391 chars = port->tx_bytes_flight; 400 chars = port->tx_bytes_flight;
392 else if (serial->num_bulk_out) 401 else
393 chars = kfifo_len(&port->write_fifo); 402 chars = kfifo_len(&port->write_fifo);
394 spin_unlock_irqrestore(&port->lock, flags); 403 spin_unlock_irqrestore(&port->lock, flags);
395 404
@@ -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
@@ -497,23 +508,18 @@ void usb_serial_generic_write_bulk_callback(struct urb *urb)
497 if (port->urbs_in_flight < 0) 508 if (port->urbs_in_flight < 0)
498 port->urbs_in_flight = 0; 509 port->urbs_in_flight = 0;
499 spin_unlock_irqrestore(&port->lock, flags); 510 spin_unlock_irqrestore(&port->lock, flags);
500
501 if (status) {
502 dbg("%s - nonzero multi-urb write bulk status "
503 "received: %d", __func__, status);
504 return;
505 }
506 } else { 511 } else {
507 port->write_urb_busy = 0; 512 port->write_urb_busy = 0;
508 513
509 if (status) { 514 if (status)
510 dbg("%s - nonzero multi-urb write bulk status "
511 "received: %d", __func__, status);
512 kfifo_reset_out(&port->write_fifo); 515 kfifo_reset_out(&port->write_fifo);
513 } else 516 else
514 usb_serial_generic_write_start(port); 517 usb_serial_generic_write_start(port);
515 } 518 }
516 519
520 if (status)
521 dbg("%s - non-zero urb status: %d", __func__, status);
522
517 usb_serial_port_softint(port); 523 usb_serial_port_softint(port);
518} 524}
519EXPORT_SYMBOL_GPL(usb_serial_generic_write_bulk_callback); 525EXPORT_SYMBOL_GPL(usb_serial_generic_write_bulk_callback);
@@ -585,7 +591,7 @@ int usb_serial_generic_resume(struct usb_serial *serial)
585 591
586 for (i = 0; i < serial->num_ports; i++) { 592 for (i = 0; i < serial->num_ports; i++) {
587 port = serial->port[i]; 593 port = serial->port[i];
588 if (!port->port.count) 594 if (!test_bit(ASYNCB_INITIALIZED, &port->port.flags))
589 continue; 595 continue;
590 596
591 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 2cfe2451ed97..2fda1c0182b7 100644
--- a/drivers/usb/serial/mos7840.c
+++ b/drivers/usb/serial/mos7840.c
@@ -181,7 +181,7 @@
181#define URB_TRANSFER_BUFFER_SIZE 32 /* URB Size */ 181#define URB_TRANSFER_BUFFER_SIZE 32 /* URB Size */
182 182
183 183
184static struct usb_device_id moschip_port_id_table[] = { 184static const struct usb_device_id moschip_port_id_table[] = {
185 {USB_DEVICE(USB_VENDOR_ID_MOSCHIP, MOSCHIP_DEVICE_ID_7840)}, 185 {USB_DEVICE(USB_VENDOR_ID_MOSCHIP, MOSCHIP_DEVICE_ID_7840)},
186 {USB_DEVICE(USB_VENDOR_ID_MOSCHIP, MOSCHIP_DEVICE_ID_7820)}, 186 {USB_DEVICE(USB_VENDOR_ID_MOSCHIP, MOSCHIP_DEVICE_ID_7820)},
187 {USB_DEVICE(USB_VENDOR_ID_BANDB, BANDB_DEVICE_ID_USO9ML2_2)}, 187 {USB_DEVICE(USB_VENDOR_ID_BANDB, BANDB_DEVICE_ID_USO9ML2_2)},
@@ -198,7 +198,7 @@ static struct usb_device_id moschip_port_id_table[] = {
198 {} /* terminating entry */ 198 {} /* terminating entry */
199}; 199};
200 200
201static __devinitdata struct usb_device_id moschip_id_table_combined[] = { 201static const struct usb_device_id moschip_id_table_combined[] __devinitconst = {
202 {USB_DEVICE(USB_VENDOR_ID_MOSCHIP, MOSCHIP_DEVICE_ID_7840)}, 202 {USB_DEVICE(USB_VENDOR_ID_MOSCHIP, MOSCHIP_DEVICE_ID_7840)},
203 {USB_DEVICE(USB_VENDOR_ID_MOSCHIP, MOSCHIP_DEVICE_ID_7820)}, 203 {USB_DEVICE(USB_VENDOR_ID_MOSCHIP, MOSCHIP_DEVICE_ID_7820)},
204 {USB_DEVICE(USB_VENDOR_ID_BANDB, BANDB_DEVICE_ID_USO9ML2_2)}, 204 {USB_DEVICE(USB_VENDOR_ID_BANDB, BANDB_DEVICE_ID_USO9ML2_2)},
@@ -283,12 +283,19 @@ static int mos7840_get_reg_sync(struct usb_serial_port *port, __u16 reg,
283{ 283{
284 struct usb_device *dev = port->serial->dev; 284 struct usb_device *dev = port->serial->dev;
285 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;
286 291
287 ret = usb_control_msg(dev, usb_rcvctrlpipe(dev, 0), MCS_RDREQ, 292 ret = usb_control_msg(dev, usb_rcvctrlpipe(dev, 0), MCS_RDREQ,
288 MCS_RD_RTYPE, 0, reg, val, VENDOR_READ_LENGTH, 293 MCS_RD_RTYPE, 0, reg, buf, VENDOR_READ_LENGTH,
289 MOS_WDR_TIMEOUT); 294 MOS_WDR_TIMEOUT);
295 *val = buf[0];
290 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);
291 *val = (*val) & 0x00ff; 297
298 kfree(buf);
292 return ret; 299 return ret;
293} 300}
294 301
@@ -341,6 +348,11 @@ static int mos7840_get_uart_reg(struct usb_serial_port *port, __u16 reg,
341 struct usb_device *dev = port->serial->dev; 348 struct usb_device *dev = port->serial->dev;
342 int ret = 0; 349 int ret = 0;
343 __u16 Wval; 350 __u16 Wval;
351 u8 *buf;
352
353 buf = kmalloc(VENDOR_READ_LENGTH, GFP_KERNEL);
354 if (!buf)
355 return -ENOMEM;
344 356
345 /* dbg("application number is %4x", 357 /* dbg("application number is %4x",
346 (((__u16)port->number - (__u16)(port->serial->minor))+1)<<8); */ 358 (((__u16)port->number - (__u16)(port->serial->minor))+1)<<8); */
@@ -364,9 +376,11 @@ static int mos7840_get_uart_reg(struct usb_serial_port *port, __u16 reg,
364 } 376 }
365 } 377 }
366 ret = usb_control_msg(dev, usb_rcvctrlpipe(dev, 0), MCS_RDREQ, 378 ret = usb_control_msg(dev, usb_rcvctrlpipe(dev, 0), MCS_RDREQ,
367 MCS_RD_RTYPE, Wval, reg, val, VENDOR_READ_LENGTH, 379 MCS_RD_RTYPE, Wval, reg, buf, VENDOR_READ_LENGTH,
368 MOS_WDR_TIMEOUT); 380 MOS_WDR_TIMEOUT);
369 *val = (*val) & 0x00ff; 381 *val = buf[0];
382
383 kfree(buf);
370 return ret; 384 return ret;
371} 385}
372 386
@@ -750,7 +764,6 @@ static void mos7840_bulk_in_callback(struct urb *urb)
750 if (urb->actual_length) { 764 if (urb->actual_length) {
751 tty = tty_port_tty_get(&mos7840_port->port->port); 765 tty = tty_port_tty_get(&mos7840_port->port->port);
752 if (tty) { 766 if (tty) {
753 tty_buffer_request_room(tty, urb->actual_length);
754 tty_insert_flip_string(tty, data, urb->actual_length); 767 tty_insert_flip_string(tty, data, urb->actual_length);
755 dbg(" %s ", data); 768 dbg(" %s ", data);
756 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 4cdb975caa89..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);
diff --git a/drivers/usb/serial/option.c b/drivers/usb/serial/option.c
index 6e94a6711f08..ca9d866672aa 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
@@ -309,6 +312,7 @@ static int option_resume(struct usb_serial *serial);
309#define DLINK_VENDOR_ID 0x1186 312#define DLINK_VENDOR_ID 0x1186
310#define DLINK_PRODUCT_DWM_652 0x3e04 313#define DLINK_PRODUCT_DWM_652 0x3e04
311#define DLINK_PRODUCT_DWM_652_U5 0xce16 314#define DLINK_PRODUCT_DWM_652_U5 0xce16
315#define DLINK_PRODUCT_DWM_652_U5A 0xce1e
312 316
313#define QISDA_VENDOR_ID 0x1da5 317#define QISDA_VENDOR_ID 0x1da5
314#define QISDA_PRODUCT_H21_4512 0x4512 318#define QISDA_PRODUCT_H21_4512 0x4512
@@ -332,19 +336,64 @@ static int option_resume(struct usb_serial *serial);
332#define ALCATEL_VENDOR_ID 0x1bbb 336#define ALCATEL_VENDOR_ID 0x1bbb
333#define ALCATEL_PRODUCT_X060S 0x0000 337#define ALCATEL_PRODUCT_X060S 0x0000
334 338
339#define PIRELLI_VENDOR_ID 0x1266
340#define PIRELLI_PRODUCT_C100_1 0x1002
341#define PIRELLI_PRODUCT_C100_2 0x1003
342#define PIRELLI_PRODUCT_1004 0x1004
343#define PIRELLI_PRODUCT_1005 0x1005
344#define PIRELLI_PRODUCT_1006 0x1006
345#define PIRELLI_PRODUCT_1007 0x1007
346#define PIRELLI_PRODUCT_1008 0x1008
347#define PIRELLI_PRODUCT_1009 0x1009
348#define PIRELLI_PRODUCT_100A 0x100a
349#define PIRELLI_PRODUCT_100B 0x100b
350#define PIRELLI_PRODUCT_100C 0x100c
351#define PIRELLI_PRODUCT_100D 0x100d
352#define PIRELLI_PRODUCT_100E 0x100e
353#define PIRELLI_PRODUCT_100F 0x100f
354#define PIRELLI_PRODUCT_1011 0x1011
355#define PIRELLI_PRODUCT_1012 0x1012
356
335/* Airplus products */ 357/* Airplus products */
336#define AIRPLUS_VENDOR_ID 0x1011 358#define AIRPLUS_VENDOR_ID 0x1011
337#define AIRPLUS_PRODUCT_MCD650 0x3198 359#define AIRPLUS_PRODUCT_MCD650 0x3198
338 360
361/* Longcheer/Longsung vendor ID; makes whitelabel devices that
362 * many other vendors like 4G Systems, Alcatel, ChinaBird,
363 * Mobidata, etc sell under their own brand names.
364 */
365#define LONGCHEER_VENDOR_ID 0x1c9e
366
339/* 4G Systems products */ 367/* 4G Systems products */
340#define FOUR_G_SYSTEMS_VENDOR_ID 0x1c9e 368/* This is the 4G XS Stick W14 a.k.a. Mobilcom Debitel Surf-Stick *
369 * It seems to contain a Qualcomm QSC6240/6290 chipset */
341#define FOUR_G_SYSTEMS_PRODUCT_W14 0x9603 370#define FOUR_G_SYSTEMS_PRODUCT_W14 0x9603
342 371
343/* Haier products */ 372/* Haier products */
344#define HAIER_VENDOR_ID 0x201e 373#define HAIER_VENDOR_ID 0x201e
345#define HAIER_PRODUCT_CE100 0x2009 374#define HAIER_PRODUCT_CE100 0x2009
346 375
347static struct usb_device_id option_ids[] = { 376/* some devices interfaces need special handling due to a number of reasons */
377enum option_blacklist_reason {
378 OPTION_BLACKLIST_NONE = 0,
379 OPTION_BLACKLIST_SENDSETUP = 1,
380 OPTION_BLACKLIST_RESERVED_IF = 2
381};
382
383struct option_blacklist_info {
384 const u32 infolen; /* number of interface numbers on blacklist */
385 const u8 *ifaceinfo; /* pointer to the array holding the numbers */
386 enum option_blacklist_reason reason;
387};
388
389static const u8 four_g_w14_no_sendsetup[] = { 0, 1 };
390static const struct option_blacklist_info four_g_w14_blacklist = {
391 .infolen = ARRAY_SIZE(four_g_w14_no_sendsetup),
392 .ifaceinfo = four_g_w14_no_sendsetup,
393 .reason = OPTION_BLACKLIST_SENDSETUP
394};
395
396static const struct usb_device_id option_ids[] = {
348 { USB_DEVICE(OPTION_VENDOR_ID, OPTION_PRODUCT_COLT) }, 397 { USB_DEVICE(OPTION_VENDOR_ID, OPTION_PRODUCT_COLT) },
349 { USB_DEVICE(OPTION_VENDOR_ID, OPTION_PRODUCT_RICOLA) }, 398 { USB_DEVICE(OPTION_VENDOR_ID, OPTION_PRODUCT_RICOLA) },
350 { USB_DEVICE(OPTION_VENDOR_ID, OPTION_PRODUCT_RICOLA_LIGHT) }, 399 { USB_DEVICE(OPTION_VENDOR_ID, OPTION_PRODUCT_RICOLA_LIGHT) },
@@ -520,7 +569,8 @@ static struct usb_device_id option_ids[] = {
520 { USB_DEVICE(KYOCERA_VENDOR_ID, KYOCERA_PRODUCT_KPC680) }, 569 { USB_DEVICE(KYOCERA_VENDOR_ID, KYOCERA_PRODUCT_KPC680) },
521 { USB_DEVICE(QUALCOMM_VENDOR_ID, 0x6000)}, /* ZTE AC8700 */ 570 { USB_DEVICE(QUALCOMM_VENDOR_ID, 0x6000)}, /* ZTE AC8700 */
522 { USB_DEVICE(QUALCOMM_VENDOR_ID, 0x6613)}, /* Onda H600/ZTE MF330 */ 571 { USB_DEVICE(QUALCOMM_VENDOR_ID, 0x6613)}, /* Onda H600/ZTE MF330 */
523 { USB_DEVICE(MAXON_VENDOR_ID, 0x6280) }, /* BP3-USB & BP3-EXT HSDPA */ 572 { USB_DEVICE(CMOTECH_VENDOR_ID, CMOTECH_PRODUCT_6280) }, /* BP3-USB & BP3-EXT HSDPA */
573 { USB_DEVICE(CMOTECH_VENDOR_ID, CMOTECH_PRODUCT_6008) },
524 { USB_DEVICE(TELIT_VENDOR_ID, TELIT_PRODUCT_UC864E) }, 574 { USB_DEVICE(TELIT_VENDOR_ID, TELIT_PRODUCT_UC864E) },
525 { USB_DEVICE(TELIT_VENDOR_ID, TELIT_PRODUCT_UC864G) }, 575 { USB_DEVICE(TELIT_VENDOR_ID, TELIT_PRODUCT_UC864G) },
526 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, ZTE_PRODUCT_MF622, 0xff, 0xff, 0xff) }, /* ZTE WCDMA products */ 576 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, ZTE_PRODUCT_MF622, 0xff, 0xff, 0xff) }, /* ZTE WCDMA products */
@@ -632,6 +682,7 @@ static struct usb_device_id option_ids[] = {
632 { USB_DEVICE(BENQ_VENDOR_ID, BENQ_PRODUCT_H10) }, 682 { USB_DEVICE(BENQ_VENDOR_ID, BENQ_PRODUCT_H10) },
633 { USB_DEVICE(DLINK_VENDOR_ID, DLINK_PRODUCT_DWM_652) }, 683 { USB_DEVICE(DLINK_VENDOR_ID, DLINK_PRODUCT_DWM_652) },
634 { USB_DEVICE(ALINK_VENDOR_ID, DLINK_PRODUCT_DWM_652_U5) }, /* Yes, ALINK_VENDOR_ID */ 684 { USB_DEVICE(ALINK_VENDOR_ID, DLINK_PRODUCT_DWM_652_U5) }, /* Yes, ALINK_VENDOR_ID */
685 { USB_DEVICE(ALINK_VENDOR_ID, DLINK_PRODUCT_DWM_652_U5A) },
635 { USB_DEVICE(QISDA_VENDOR_ID, QISDA_PRODUCT_H21_4512) }, 686 { USB_DEVICE(QISDA_VENDOR_ID, QISDA_PRODUCT_H21_4512) },
636 { USB_DEVICE(QISDA_VENDOR_ID, QISDA_PRODUCT_H21_4523) }, 687 { USB_DEVICE(QISDA_VENDOR_ID, QISDA_PRODUCT_H21_4523) },
637 { USB_DEVICE(QISDA_VENDOR_ID, QISDA_PRODUCT_H20_4515) }, 688 { USB_DEVICE(QISDA_VENDOR_ID, QISDA_PRODUCT_H20_4515) },
@@ -639,13 +690,32 @@ static struct usb_device_id option_ids[] = {
639 { USB_DEVICE(TOSHIBA_VENDOR_ID, TOSHIBA_PRODUCT_G450) }, 690 { USB_DEVICE(TOSHIBA_VENDOR_ID, TOSHIBA_PRODUCT_G450) },
640 { USB_DEVICE(TOSHIBA_VENDOR_ID, TOSHIBA_PRODUCT_HSDPA_MINICARD ) }, /* Toshiba 3G HSDPA == Novatel Expedite EU870D MiniCard */ 691 { USB_DEVICE(TOSHIBA_VENDOR_ID, TOSHIBA_PRODUCT_HSDPA_MINICARD ) }, /* Toshiba 3G HSDPA == Novatel Expedite EU870D MiniCard */
641 { USB_DEVICE(ALINK_VENDOR_ID, 0x9000) }, 692 { USB_DEVICE(ALINK_VENDOR_ID, 0x9000) },
642 { USB_DEVICE(ALINK_VENDOR_ID, 0xce16) },
643 { USB_DEVICE_AND_INTERFACE_INFO(ALINK_VENDOR_ID, ALINK_PRODUCT_3GU, 0xff, 0xff, 0xff) }, 693 { USB_DEVICE_AND_INTERFACE_INFO(ALINK_VENDOR_ID, ALINK_PRODUCT_3GU, 0xff, 0xff, 0xff) },
644 { USB_DEVICE(ALCATEL_VENDOR_ID, ALCATEL_PRODUCT_X060S) }, 694 { USB_DEVICE(ALCATEL_VENDOR_ID, ALCATEL_PRODUCT_X060S) },
645 { USB_DEVICE(AIRPLUS_VENDOR_ID, AIRPLUS_PRODUCT_MCD650) }, 695 { USB_DEVICE(AIRPLUS_VENDOR_ID, AIRPLUS_PRODUCT_MCD650) },
646 { USB_DEVICE(TLAYTECH_VENDOR_ID, TLAYTECH_PRODUCT_TEU800) }, 696 { USB_DEVICE(TLAYTECH_VENDOR_ID, TLAYTECH_PRODUCT_TEU800) },
647 { USB_DEVICE(FOUR_G_SYSTEMS_VENDOR_ID, FOUR_G_SYSTEMS_PRODUCT_W14) }, 697 { USB_DEVICE(LONGCHEER_VENDOR_ID, FOUR_G_SYSTEMS_PRODUCT_W14),
698 .driver_info = (kernel_ulong_t)&four_g_w14_blacklist
699 },
648 { USB_DEVICE(HAIER_VENDOR_ID, HAIER_PRODUCT_CE100) }, 700 { USB_DEVICE(HAIER_VENDOR_ID, HAIER_PRODUCT_CE100) },
701 /* Pirelli */
702 { USB_DEVICE(PIRELLI_VENDOR_ID, PIRELLI_PRODUCT_C100_1)},
703 { USB_DEVICE(PIRELLI_VENDOR_ID, PIRELLI_PRODUCT_C100_2)},
704 { USB_DEVICE(PIRELLI_VENDOR_ID, PIRELLI_PRODUCT_1004)},
705 { USB_DEVICE(PIRELLI_VENDOR_ID, PIRELLI_PRODUCT_1005)},
706 { USB_DEVICE(PIRELLI_VENDOR_ID, PIRELLI_PRODUCT_1006)},
707 { USB_DEVICE(PIRELLI_VENDOR_ID, PIRELLI_PRODUCT_1007)},
708 { USB_DEVICE(PIRELLI_VENDOR_ID, PIRELLI_PRODUCT_1008)},
709 { USB_DEVICE(PIRELLI_VENDOR_ID, PIRELLI_PRODUCT_1009)},
710 { USB_DEVICE(PIRELLI_VENDOR_ID, PIRELLI_PRODUCT_100A)},
711 { USB_DEVICE(PIRELLI_VENDOR_ID, PIRELLI_PRODUCT_100B) },
712 { USB_DEVICE(PIRELLI_VENDOR_ID, PIRELLI_PRODUCT_100C) },
713 { USB_DEVICE(PIRELLI_VENDOR_ID, PIRELLI_PRODUCT_100D) },
714 { USB_DEVICE(PIRELLI_VENDOR_ID, PIRELLI_PRODUCT_100E) },
715 { USB_DEVICE(PIRELLI_VENDOR_ID, PIRELLI_PRODUCT_100F) },
716 { USB_DEVICE(PIRELLI_VENDOR_ID, PIRELLI_PRODUCT_1011)},
717 { USB_DEVICE(PIRELLI_VENDOR_ID, PIRELLI_PRODUCT_1012)},
718
649 { } /* Terminating entry */ 719 { } /* Terminating entry */
650}; 720};
651MODULE_DEVICE_TABLE(usb, option_ids); 721MODULE_DEVICE_TABLE(usb, option_ids);
@@ -709,6 +779,7 @@ struct option_intf_private {
709 spinlock_t susp_lock; 779 spinlock_t susp_lock;
710 unsigned int suspended:1; 780 unsigned int suspended:1;
711 int in_flight; 781 int in_flight;
782 struct option_blacklist_info *blacklist_info;
712}; 783};
713 784
714struct option_port_private { 785struct option_port_private {
@@ -768,19 +839,44 @@ static int option_probe(struct usb_serial *serial,
768 const struct usb_device_id *id) 839 const struct usb_device_id *id)
769{ 840{
770 struct option_intf_private *data; 841 struct option_intf_private *data;
842
771 /* D-Link DWM 652 still exposes CD-Rom emulation interface in modem mode */ 843 /* D-Link DWM 652 still exposes CD-Rom emulation interface in modem mode */
772 if (serial->dev->descriptor.idVendor == DLINK_VENDOR_ID && 844 if (serial->dev->descriptor.idVendor == DLINK_VENDOR_ID &&
773 serial->dev->descriptor.idProduct == DLINK_PRODUCT_DWM_652 && 845 serial->dev->descriptor.idProduct == DLINK_PRODUCT_DWM_652 &&
774 serial->interface->cur_altsetting->desc.bInterfaceClass == 0x8) 846 serial->interface->cur_altsetting->desc.bInterfaceClass == 0x8)
775 return -ENODEV; 847 return -ENODEV;
776 848
849 /* Bandrich modem and AT command interface is 0xff */
850 if ((serial->dev->descriptor.idVendor == BANDRICH_VENDOR_ID ||
851 serial->dev->descriptor.idVendor == PIRELLI_VENDOR_ID) &&
852 serial->interface->cur_altsetting->desc.bInterfaceClass != 0xff)
853 return -ENODEV;
854
777 data = serial->private = kzalloc(sizeof(struct option_intf_private), GFP_KERNEL); 855 data = serial->private = kzalloc(sizeof(struct option_intf_private), GFP_KERNEL);
778 if (!data) 856 if (!data)
779 return -ENOMEM; 857 return -ENOMEM;
780 spin_lock_init(&data->susp_lock); 858 spin_lock_init(&data->susp_lock);
859 data->blacklist_info = (struct option_blacklist_info*) id->driver_info;
781 return 0; 860 return 0;
782} 861}
783 862
863static enum option_blacklist_reason is_blacklisted(const u8 ifnum,
864 const struct option_blacklist_info *blacklist)
865{
866 const u8 *info;
867 int i;
868
869 if (blacklist) {
870 info = blacklist->ifaceinfo;
871
872 for (i = 0; i < blacklist->infolen; i++) {
873 if (info[i] == ifnum)
874 return blacklist->reason;
875 }
876 }
877 return OPTION_BLACKLIST_NONE;
878}
879
784static void option_set_termios(struct tty_struct *tty, 880static void option_set_termios(struct tty_struct *tty,
785 struct usb_serial_port *port, struct ktermios *old_termios) 881 struct usb_serial_port *port, struct ktermios *old_termios)
786{ 882{
@@ -921,7 +1017,6 @@ static void option_indat_callback(struct urb *urb)
921 } else { 1017 } else {
922 tty = tty_port_tty_get(&port->port); 1018 tty = tty_port_tty_get(&port->port);
923 if (urb->actual_length) { 1019 if (urb->actual_length) {
924 tty_buffer_request_room(tty, urb->actual_length);
925 tty_insert_flip_string(tty, data, urb->actual_length); 1020 tty_insert_flip_string(tty, data, urb->actual_length);
926 tty_flip_buffer_push(tty); 1021 tty_flip_buffer_push(tty);
927 } else 1022 } else
@@ -929,9 +1024,9 @@ static void option_indat_callback(struct urb *urb)
929 tty_kref_put(tty); 1024 tty_kref_put(tty);
930 1025
931 /* Resubmit urb so we continue receiving */ 1026 /* Resubmit urb so we continue receiving */
932 if (port->port.count && status != -ESHUTDOWN) { 1027 if (status != -ESHUTDOWN) {
933 err = usb_submit_urb(urb, GFP_ATOMIC); 1028 err = usb_submit_urb(urb, GFP_ATOMIC);
934 if (err) 1029 if (err && err != -EPERM)
935 printk(KERN_ERR "%s: resubmit read urb failed. " 1030 printk(KERN_ERR "%s: resubmit read urb failed. "
936 "(%d)", __func__, err); 1031 "(%d)", __func__, err);
937 else 1032 else
@@ -985,7 +1080,7 @@ static void option_instat_callback(struct urb *urb)
985 (struct usb_ctrlrequest *)urb->transfer_buffer; 1080 (struct usb_ctrlrequest *)urb->transfer_buffer;
986 1081
987 if (!req_pkt) { 1082 if (!req_pkt) {
988 dbg("%s: NULL req_pkt\n", __func__); 1083 dbg("%s: NULL req_pkt", __func__);
989 return; 1084 return;
990 } 1085 }
991 if ((req_pkt->bRequestType == 0xA1) && 1086 if ((req_pkt->bRequestType == 0xA1) &&
@@ -1211,11 +1306,19 @@ static void option_setup_urbs(struct usb_serial *serial)
1211static int option_send_setup(struct usb_serial_port *port) 1306static int option_send_setup(struct usb_serial_port *port)
1212{ 1307{
1213 struct usb_serial *serial = port->serial; 1308 struct usb_serial *serial = port->serial;
1309 struct option_intf_private *intfdata =
1310 (struct option_intf_private *) serial->private;
1214 struct option_port_private *portdata; 1311 struct option_port_private *portdata;
1215 int ifNum = serial->interface->cur_altsetting->desc.bInterfaceNumber; 1312 int ifNum = serial->interface->cur_altsetting->desc.bInterfaceNumber;
1216 int val = 0; 1313 int val = 0;
1217 dbg("%s", __func__); 1314 dbg("%s", __func__);
1218 1315
1316 if (is_blacklisted(ifNum, intfdata->blacklist_info) ==
1317 OPTION_BLACKLIST_SENDSETUP) {
1318 dbg("No send_setup on blacklisted interface #%d\n", ifNum);
1319 return -EIO;
1320 }
1321
1219 portdata = usb_get_serial_port_data(port); 1322 portdata = usb_get_serial_port_data(port);
1220 1323
1221 if (portdata->dtr_state) 1324 if (portdata->dtr_state)
@@ -1401,7 +1504,7 @@ static int option_resume(struct usb_serial *serial)
1401 for (i = 0; i < serial->num_ports; i++) { 1504 for (i = 0; i < serial->num_ports; i++) {
1402 port = serial->port[i]; 1505 port = serial->port[i];
1403 if (!port->interrupt_in_urb) { 1506 if (!port->interrupt_in_urb) {
1404 dbg("%s: No interrupt URB for port %d\n", __func__, i); 1507 dbg("%s: No interrupt URB for port %d", __func__, i);
1405 continue; 1508 continue;
1406 } 1509 }
1407 err = usb_submit_urb(port->interrupt_in_urb, GFP_NOIO); 1510 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..73d5f346d3e0 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) },
@@ -451,7 +451,6 @@ static void pl2303_send(struct usb_serial_port *port)
451 port->write_urb->transfer_buffer); 451 port->write_urb->transfer_buffer);
452 452
453 port->write_urb->transfer_buffer_length = count; 453 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); 454 result = usb_submit_urb(port->write_urb, GFP_ATOMIC);
456 if (result) { 455 if (result) {
457 dev_err(&port->dev, "%s - failed submitting write urb," 456 dev_err(&port->dev, "%s - failed submitting write urb,"
@@ -769,7 +768,6 @@ static int pl2303_open(struct tty_struct *tty, struct usb_serial_port *port)
769 pl2303_set_termios(tty, port, &tmp_termios); 768 pl2303_set_termios(tty, port, &tmp_termios);
770 769
771 dbg("%s - submitting read urb", __func__); 770 dbg("%s - submitting read urb", __func__);
772 port->read_urb->dev = serial->dev;
773 result = usb_submit_urb(port->read_urb, GFP_KERNEL); 771 result = usb_submit_urb(port->read_urb, GFP_KERNEL);
774 if (result) { 772 if (result) {
775 dev_err(&port->dev, "%s - failed submitting read urb," 773 dev_err(&port->dev, "%s - failed submitting read urb,"
@@ -779,7 +777,6 @@ static int pl2303_open(struct tty_struct *tty, struct usb_serial_port *port)
779 } 777 }
780 778
781 dbg("%s - submitting interrupt urb", __func__); 779 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); 780 result = usb_submit_urb(port->interrupt_in_urb, GFP_KERNEL);
784 if (result) { 781 if (result) {
785 dev_err(&port->dev, "%s - failed submitting interrupt urb," 782 dev_err(&port->dev, "%s - failed submitting interrupt urb,"
@@ -895,10 +892,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, 892static int pl2303_ioctl(struct tty_struct *tty, struct file *file,
896 unsigned int cmd, unsigned long arg) 893 unsigned int cmd, unsigned long arg)
897{ 894{
895 struct serial_struct ser;
898 struct usb_serial_port *port = tty->driver_data; 896 struct usb_serial_port *port = tty->driver_data;
899 dbg("%s (%d) cmd = 0x%04x", __func__, port->number, cmd); 897 dbg("%s (%d) cmd = 0x%04x", __func__, port->number, cmd);
900 898
901 switch (cmd) { 899 switch (cmd) {
900 case TIOCGSERIAL:
901 memset(&ser, 0, sizeof ser);
902 ser.type = PORT_16654;
903 ser.line = port->serial->minor;
904 ser.port = port->number;
905 ser.baud_base = 460800;
906
907 if (copy_to_user((void __user *)arg, &ser, sizeof ser))
908 return -EFAULT;
909
910 return 0;
911
902 case TIOCMIWAIT: 912 case TIOCMIWAIT:
903 dbg("%s (%d) TIOCMIWAIT", __func__, port->number); 913 dbg("%s (%d) TIOCMIWAIT", __func__, port->number);
904 return wait_modem_info(port, arg); 914 return wait_modem_info(port, arg);
@@ -1042,7 +1052,6 @@ static void pl2303_push_data(struct tty_struct *tty,
1042 tty_flag = TTY_FRAME; 1052 tty_flag = TTY_FRAME;
1043 dbg("%s - tty_flag = %d", __func__, tty_flag); 1053 dbg("%s - tty_flag = %d", __func__, tty_flag);
1044 1054
1045 tty_buffer_request_room(tty, urb->actual_length + 1);
1046 /* overrun is special, not associated with a char */ 1055 /* overrun is special, not associated with a char */
1047 if (line_status & UART_OVERRUN_ERROR) 1056 if (line_status & UART_OVERRUN_ERROR)
1048 tty_insert_flip_char(tty, 0, TTY_OVERRUN); 1057 tty_insert_flip_char(tty, 0, TTY_OVERRUN);
@@ -1072,16 +1081,11 @@ static void pl2303_read_bulk_callback(struct urb *urb)
1072 1081
1073 if (status) { 1082 if (status) {
1074 dbg("%s - urb status = %d", __func__, status); 1083 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) { 1084 if (status == -EPROTO) {
1080 /* PL2303 mysteriously fails with -EPROTO reschedule 1085 /* PL2303 mysteriously fails with -EPROTO reschedule
1081 * the read */ 1086 * the read */
1082 dbg("%s - caught -EPROTO, resubmitting the urb", 1087 dbg("%s - caught -EPROTO, resubmitting the urb",
1083 __func__); 1088 __func__);
1084 urb->dev = port->serial->dev;
1085 result = usb_submit_urb(urb, GFP_ATOMIC); 1089 result = usb_submit_urb(urb, GFP_ATOMIC);
1086 if (result) 1090 if (result)
1087 dev_err(&urb->dev->dev, "%s - failed" 1091 dev_err(&urb->dev->dev, "%s - failed"
@@ -1108,15 +1112,10 @@ static void pl2303_read_bulk_callback(struct urb *urb)
1108 } 1112 }
1109 tty_kref_put(tty); 1113 tty_kref_put(tty);
1110 /* Schedule the next read _if_ we are still open */ 1114 /* Schedule the next read _if_ we are still open */
1111 if (port->port.count) { 1115 result = usb_submit_urb(urb, GFP_ATOMIC);
1112 urb->dev = port->serial->dev; 1116 if (result && result != -EPERM)
1113 result = usb_submit_urb(urb, GFP_ATOMIC); 1117 dev_err(&urb->dev->dev, "%s - failed resubmitting"
1114 if (result) 1118 " 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} 1119}
1121 1120
1122static void pl2303_write_bulk_callback(struct urb *urb) 1121static void pl2303_write_bulk_callback(struct urb *urb)
@@ -1146,7 +1145,6 @@ static void pl2303_write_bulk_callback(struct urb *urb)
1146 dbg("%s - nonzero write bulk status received: %d", __func__, 1145 dbg("%s - nonzero write bulk status received: %d", __func__,
1147 status); 1146 status);
1148 port->write_urb->transfer_buffer_length = 1; 1147 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); 1148 result = usb_submit_urb(port->write_urb, GFP_ATOMIC);
1151 if (result) 1149 if (result)
1152 dev_err(&urb->dev->dev, "%s - failed resubmitting write" 1150 dev_err(&urb->dev->dev, "%s - failed resubmitting write"
diff --git a/drivers/usb/serial/qcaux.c b/drivers/usb/serial/qcaux.c
new file mode 100644
index 000000000000..0b9362061713
--- /dev/null
+++ b/drivers/usb/serial/qcaux.c
@@ -0,0 +1,96 @@
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
45static struct usb_device_id id_table[] = {
46 { USB_DEVICE_AND_INTERFACE_INFO(UTSTARCOM_VENDOR_ID, UTSTARCOM_PRODUCT_PC5740, 0xff, 0x00, 0x00) },
47 { USB_DEVICE_AND_INTERFACE_INFO(UTSTARCOM_VENDOR_ID, UTSTARCOM_PRODUCT_PC5750, 0xff, 0x00, 0x00) },
48 { USB_DEVICE_AND_INTERFACE_INFO(UTSTARCOM_VENDOR_ID, UTSTARCOM_PRODUCT_UM150, 0xff, 0x00, 0x00) },
49 { USB_DEVICE_AND_INTERFACE_INFO(UTSTARCOM_VENDOR_ID, UTSTARCOM_PRODUCT_UM175_V1, 0xff, 0x00, 0x00) },
50 { USB_DEVICE_AND_INTERFACE_INFO(UTSTARCOM_VENDOR_ID, UTSTARCOM_PRODUCT_UM175_V2, 0xff, 0x00, 0x00) },
51 { USB_DEVICE_AND_INTERFACE_INFO(UTSTARCOM_VENDOR_ID, UTSTARCOM_PRODUCT_UM175_ALLTEL, 0xff, 0x00, 0x00) },
52 { USB_DEVICE_AND_INTERFACE_INFO(CMOTECH_VENDOR_ID, CMOTECH_PRODUCT_CDU550, 0xff, 0xff, 0x00) },
53 { USB_DEVICE_AND_INTERFACE_INFO(CMOTECH_VENDOR_ID, CMOTECH_PRODUCT_CDX650, 0xff, 0xff, 0x00) },
54 { },
55};
56MODULE_DEVICE_TABLE(usb, id_table);
57
58static struct usb_driver qcaux_driver = {
59 .name = "qcaux",
60 .probe = usb_serial_probe,
61 .disconnect = usb_serial_disconnect,
62 .id_table = id_table,
63 .no_dynamic_id = 1,
64};
65
66static struct usb_serial_driver qcaux_device = {
67 .driver = {
68 .owner = THIS_MODULE,
69 .name = "qcaux",
70 },
71 .id_table = id_table,
72 .num_ports = 1,
73};
74
75static int __init qcaux_init(void)
76{
77 int retval;
78
79 retval = usb_serial_register(&qcaux_device);
80 if (retval)
81 return retval;
82 retval = usb_register(&qcaux_driver);
83 if (retval)
84 usb_serial_deregister(&qcaux_device);
85 return retval;
86}
87
88static void __exit qcaux_exit(void)
89{
90 usb_deregister(&qcaux_driver);
91 usb_serial_deregister(&qcaux_device);
92}
93
94module_init(qcaux_init);
95module_exit(qcaux_exit);
96MODULE_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 3eb6143bb646..9202f94505e6 100644
--- a/drivers/usb/serial/sierra.c
+++ b/drivers/usb/serial/sierra.c
@@ -26,6 +26,7 @@
26#include <linux/jiffies.h> 26#include <linux/jiffies.h>
27#include <linux/errno.h> 27#include <linux/errno.h>
28#include <linux/tty.h> 28#include <linux/tty.h>
29#include <linux/slab.h>
29#include <linux/tty_flip.h> 30#include <linux/tty_flip.h>
30#include <linux/module.h> 31#include <linux/module.h>
31#include <linux/usb.h> 32#include <linux/usb.h>
@@ -226,7 +227,7 @@ static const struct sierra_iface_info direct_ip_interface_blacklist = {
226 .ifaceinfo = direct_ip_non_serial_ifaces, 227 .ifaceinfo = direct_ip_non_serial_ifaces,
227}; 228};
228 229
229static struct usb_device_id id_table [] = { 230static const struct usb_device_id id_table[] = {
230 { USB_DEVICE(0x0F3D, 0x0112) }, /* Airprime/Sierra PC 5220 */ 231 { USB_DEVICE(0x0F3D, 0x0112) }, /* Airprime/Sierra PC 5220 */
231 { USB_DEVICE(0x03F0, 0x1B1D) }, /* HP ev2200 a.k.a MC5720 */ 232 { USB_DEVICE(0x03F0, 0x1B1D) }, /* HP ev2200 a.k.a MC5720 */
232 { USB_DEVICE(0x03F0, 0x1E1D) }, /* HP hs2300 a.k.a MC8775 */ 233 { USB_DEVICE(0x03F0, 0x1E1D) }, /* HP hs2300 a.k.a MC8775 */
@@ -304,16 +305,6 @@ static struct usb_device_id id_table [] = {
304}; 305};
305MODULE_DEVICE_TABLE(usb, id_table); 306MODULE_DEVICE_TABLE(usb, id_table);
306 307
307static struct usb_driver sierra_driver = {
308 .name = "sierra",
309 .probe = usb_serial_probe,
310 .disconnect = usb_serial_disconnect,
311 .suspend = usb_serial_suspend,
312 .resume = usb_serial_resume,
313 .id_table = id_table,
314 .no_dynamic_id = 1,
315 .supports_autosuspend = 1,
316};
317 308
318struct sierra_port_private { 309struct sierra_port_private {
319 spinlock_t lock; /* lock the structure */ 310 spinlock_t lock; /* lock the structure */
@@ -477,7 +468,7 @@ static void sierra_outdat_callback(struct urb *urb)
477static int sierra_write(struct tty_struct *tty, struct usb_serial_port *port, 468static int sierra_write(struct tty_struct *tty, struct usb_serial_port *port,
478 const unsigned char *buf, int count) 469 const unsigned char *buf, int count)
479{ 470{
480 struct sierra_port_private *portdata = usb_get_serial_port_data(port); 471 struct sierra_port_private *portdata;
481 struct sierra_intf_private *intfdata; 472 struct sierra_intf_private *intfdata;
482 struct usb_serial *serial = port->serial; 473 struct usb_serial *serial = port->serial;
483 unsigned long flags; 474 unsigned long flags;
@@ -604,14 +595,15 @@ static void sierra_indat_callback(struct urb *urb)
604 } else { 595 } else {
605 if (urb->actual_length) { 596 if (urb->actual_length) {
606 tty = tty_port_tty_get(&port->port); 597 tty = tty_port_tty_get(&port->port);
607 598 if (tty) {
608 tty_buffer_request_room(tty, urb->actual_length); 599 tty_insert_flip_string(tty, data,
609 tty_insert_flip_string(tty, data, urb->actual_length); 600 urb->actual_length);
610 tty_flip_buffer_push(tty); 601 tty_flip_buffer_push(tty);
611 602
612 tty_kref_put(tty); 603 tty_kref_put(tty);
613 usb_serial_debug_data(debug, &port->dev, __func__, 604 usb_serial_debug_data(debug, &port->dev,
614 urb->actual_length, data); 605 __func__, urb->actual_length, data);
606 }
615 } else { 607 } else {
616 dev_dbg(&port->dev, "%s: empty read urb" 608 dev_dbg(&port->dev, "%s: empty read urb"
617 " received\n", __func__); 609 " received\n", __func__);
@@ -619,10 +611,10 @@ static void sierra_indat_callback(struct urb *urb)
619 } 611 }
620 612
621 /* Resubmit urb so we continue receiving */ 613 /* Resubmit urb so we continue receiving */
622 if (port->port.count && status != -ESHUTDOWN && status != -EPERM) { 614 if (status != -ESHUTDOWN && status != -EPERM) {
623 usb_mark_last_busy(port->serial->dev); 615 usb_mark_last_busy(port->serial->dev);
624 err = usb_submit_urb(urb, GFP_ATOMIC); 616 err = usb_submit_urb(urb, GFP_ATOMIC);
625 if (err) 617 if (err && err != -EPERM)
626 dev_err(&port->dev, "resubmit read urb failed." 618 dev_err(&port->dev, "resubmit read urb failed."
627 "(%d)\n", err); 619 "(%d)\n", err);
628 } 620 }
@@ -681,11 +673,11 @@ static void sierra_instat_callback(struct urb *urb)
681 dev_dbg(&port->dev, "%s: error %d\n", __func__, status); 673 dev_dbg(&port->dev, "%s: error %d\n", __func__, status);
682 674
683 /* Resubmit urb so we continue receiving IRQ data */ 675 /* Resubmit urb so we continue receiving IRQ data */
684 if (port->port.count && status != -ESHUTDOWN && status != -ENOENT) { 676 if (status != -ESHUTDOWN && status != -ENOENT) {
685 usb_mark_last_busy(serial->dev); 677 usb_mark_last_busy(serial->dev);
686 urb->dev = serial->dev; 678 urb->dev = serial->dev;
687 err = usb_submit_urb(urb, GFP_ATOMIC); 679 err = usb_submit_urb(urb, GFP_ATOMIC);
688 if (err) 680 if (err && err != -EPERM)
689 dev_err(&port->dev, "%s: resubmit intr urb " 681 dev_err(&port->dev, "%s: resubmit intr urb "
690 "failed. (%d)\n", __func__, err); 682 "failed. (%d)\n", __func__, err);
691 } 683 }
@@ -1061,11 +1053,31 @@ static int sierra_resume(struct usb_serial *serial)
1061 1053
1062 return ec ? -EIO : 0; 1054 return ec ? -EIO : 0;
1063} 1055}
1056
1057static int sierra_reset_resume(struct usb_interface *intf)
1058{
1059 struct usb_serial *serial = usb_get_intfdata(intf);
1060 dev_err(&serial->dev->dev, "%s\n", __func__);
1061 return usb_serial_resume(intf);
1062}
1064#else 1063#else
1065#define sierra_suspend NULL 1064#define sierra_suspend NULL
1066#define sierra_resume NULL 1065#define sierra_resume NULL
1066#define sierra_reset_resume NULL
1067#endif 1067#endif
1068 1068
1069static struct usb_driver sierra_driver = {
1070 .name = "sierra",
1071 .probe = usb_serial_probe,
1072 .disconnect = usb_serial_disconnect,
1073 .suspend = usb_serial_suspend,
1074 .resume = usb_serial_resume,
1075 .reset_resume = sierra_reset_resume,
1076 .id_table = id_table,
1077 .no_dynamic_id = 1,
1078 .supports_autosuspend = 1,
1079};
1080
1069static struct usb_serial_driver sierra_device = { 1081static struct usb_serial_driver sierra_device = {
1070 .driver = { 1082 .driver = {
1071 .owner = THIS_MODULE, 1083 .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..0afe5c71c17e 100644
--- a/drivers/usb/serial/ti_usb_3410_5052.c
+++ b/drivers/usb/serial/ti_usb_3410_5052.c
@@ -1271,14 +1271,13 @@ static void ti_recv(struct device *dev, struct tty_struct *tty,
1271 int cnt; 1271 int cnt;
1272 1272
1273 do { 1273 do {
1274 cnt = tty_buffer_request_room(tty, length); 1274 cnt = tty_insert_flip_string(tty, data, length);
1275 if (cnt < length) { 1275 if (cnt < length) {
1276 dev_err(dev, "%s - dropping data, %d bytes lost\n", 1276 dev_err(dev, "%s - dropping data, %d bytes lost\n",
1277 __func__, length - cnt); 1277 __func__, length - cnt);
1278 if (cnt == 0) 1278 if (cnt == 0)
1279 break; 1279 break;
1280 } 1280 }
1281 tty_insert_flip_string(tty, data, cnt);
1282 tty_flip_buffer_push(tty); 1281 tty_flip_buffer_push(tty);
1283 data += cnt; 1282 data += cnt;
1284 length -= cnt; 1283 length -= cnt;
diff --git a/drivers/usb/serial/usb-serial.c b/drivers/usb/serial/usb-serial.c
index 33c85f7084f8..3873660d8217 100644
--- a/drivers/usb/serial/usb-serial.c
+++ b/drivers/usb/serial/usb-serial.c
@@ -358,10 +358,6 @@ static int serial_write(struct tty_struct *tty, const unsigned char *buf,
358 358
359 dbg("%s - port %d, %d byte(s)", __func__, port->number, count); 359 dbg("%s - port %d, %d byte(s)", __func__, port->number, count);
360 360
361 /* count is managed under the mutex lock for the tty so cannot
362 drop to zero until after the last close completes */
363 WARN_ON(!port->port.count);
364
365 /* pass on to the driver specific version of this function */ 361 /* pass on to the driver specific version of this function */
366 retval = port->serial->type->write(tty, port, buf, count); 362 retval = port->serial->type->write(tty, port, buf, count);
367 363
@@ -373,7 +369,6 @@ static int serial_write_room(struct tty_struct *tty)
373{ 369{
374 struct usb_serial_port *port = tty->driver_data; 370 struct usb_serial_port *port = tty->driver_data;
375 dbg("%s - port %d", __func__, port->number); 371 dbg("%s - port %d", __func__, port->number);
376 WARN_ON(!port->port.count);
377 /* pass on to the driver specific version of this function */ 372 /* pass on to the driver specific version of this function */
378 return port->serial->type->write_room(tty); 373 return port->serial->type->write_room(tty);
379} 374}
@@ -381,7 +376,7 @@ static int serial_write_room(struct tty_struct *tty)
381static int serial_chars_in_buffer(struct tty_struct *tty) 376static int serial_chars_in_buffer(struct tty_struct *tty)
382{ 377{
383 struct usb_serial_port *port = tty->driver_data; 378 struct usb_serial_port *port = tty->driver_data;
384 dbg("%s = port %d", __func__, port->number); 379 dbg("%s - port %d", __func__, port->number);
385 380
386 /* if the device was unplugged then any remaining characters 381 /* if the device was unplugged then any remaining characters
387 fell out of the connector ;) */ 382 fell out of the connector ;) */
@@ -396,7 +391,6 @@ static void serial_throttle(struct tty_struct *tty)
396 struct usb_serial_port *port = tty->driver_data; 391 struct usb_serial_port *port = tty->driver_data;
397 dbg("%s - port %d", __func__, port->number); 392 dbg("%s - port %d", __func__, port->number);
398 393
399 WARN_ON(!port->port.count);
400 /* pass on to the driver specific version of this function */ 394 /* pass on to the driver specific version of this function */
401 if (port->serial->type->throttle) 395 if (port->serial->type->throttle)
402 port->serial->type->throttle(tty); 396 port->serial->type->throttle(tty);
@@ -407,7 +401,6 @@ static void serial_unthrottle(struct tty_struct *tty)
407 struct usb_serial_port *port = tty->driver_data; 401 struct usb_serial_port *port = tty->driver_data;
408 dbg("%s - port %d", __func__, port->number); 402 dbg("%s - port %d", __func__, port->number);
409 403
410 WARN_ON(!port->port.count);
411 /* pass on to the driver specific version of this function */ 404 /* pass on to the driver specific version of this function */
412 if (port->serial->type->unthrottle) 405 if (port->serial->type->unthrottle)
413 port->serial->type->unthrottle(tty); 406 port->serial->type->unthrottle(tty);
@@ -421,8 +414,6 @@ static int serial_ioctl(struct tty_struct *tty, struct file *file,
421 414
422 dbg("%s - port %d, cmd 0x%.4x", __func__, port->number, cmd); 415 dbg("%s - port %d, cmd 0x%.4x", __func__, port->number, cmd);
423 416
424 WARN_ON(!port->port.count);
425
426 /* pass on to the driver specific version of this function 417 /* pass on to the driver specific version of this function
427 if it is available */ 418 if it is available */
428 if (port->serial->type->ioctl) { 419 if (port->serial->type->ioctl) {
@@ -437,7 +428,6 @@ static void serial_set_termios(struct tty_struct *tty, struct ktermios *old)
437 struct usb_serial_port *port = tty->driver_data; 428 struct usb_serial_port *port = tty->driver_data;
438 dbg("%s - port %d", __func__, port->number); 429 dbg("%s - port %d", __func__, port->number);
439 430
440 WARN_ON(!port->port.count);
441 /* pass on to the driver specific version of this function 431 /* pass on to the driver specific version of this function
442 if it is available */ 432 if it is available */
443 if (port->serial->type->set_termios) 433 if (port->serial->type->set_termios)
@@ -452,7 +442,6 @@ static int serial_break(struct tty_struct *tty, int break_state)
452 442
453 dbg("%s - port %d", __func__, port->number); 443 dbg("%s - port %d", __func__, port->number);
454 444
455 WARN_ON(!port->port.count);
456 /* pass on to the driver specific version of this function 445 /* pass on to the driver specific version of this function
457 if it is available */ 446 if it is available */
458 if (port->serial->type->break_ctl) 447 if (port->serial->type->break_ctl)
@@ -513,7 +502,6 @@ static int serial_tiocmget(struct tty_struct *tty, struct file *file)
513 502
514 dbg("%s - port %d", __func__, port->number); 503 dbg("%s - port %d", __func__, port->number);
515 504
516 WARN_ON(!port->port.count);
517 if (port->serial->type->tiocmget) 505 if (port->serial->type->tiocmget)
518 return port->serial->type->tiocmget(tty, file); 506 return port->serial->type->tiocmget(tty, file);
519 return -EINVAL; 507 return -EINVAL;
@@ -526,7 +514,6 @@ static int serial_tiocmset(struct tty_struct *tty, struct file *file,
526 514
527 dbg("%s - port %d", __func__, port->number); 515 dbg("%s - port %d", __func__, port->number);
528 516
529 WARN_ON(!port->port.count);
530 if (port->serial->type->tiocmset) 517 if (port->serial->type->tiocmset)
531 return port->serial->type->tiocmset(tty, file, set, clear); 518 return port->serial->type->tiocmset(tty, file, set, clear);
532 return -EINVAL; 519 return -EINVAL;
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);