aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/usb/serial
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/usb/serial')
-rw-r--r--drivers/usb/serial/Kconfig11
-rw-r--r--drivers/usb/serial/Makefile1
-rw-r--r--drivers/usb/serial/airprime.c2
-rw-r--r--drivers/usb/serial/anydata.c4
-rw-r--r--drivers/usb/serial/ark3116.c2
-rw-r--r--drivers/usb/serial/belkin_sa.c2
-rw-r--r--drivers/usb/serial/bus.c2
-rw-r--r--drivers/usb/serial/console.c3
-rw-r--r--drivers/usb/serial/cp2101.c2
-rw-r--r--drivers/usb/serial/cyberjack.c2
-rw-r--r--drivers/usb/serial/cypress_m8.c2
-rw-r--r--drivers/usb/serial/digi_acceleport.c2
-rw-r--r--drivers/usb/serial/empeg.c2
-rw-r--r--drivers/usb/serial/ezusb.c2
-rw-r--r--drivers/usb/serial/ftdi_sio.c108
-rw-r--r--drivers/usb/serial/ftdi_sio.h15
-rw-r--r--drivers/usb/serial/funsoft.c2
-rw-r--r--drivers/usb/serial/garmin_gps.c3
-rw-r--r--drivers/usb/serial/generic.c3
-rw-r--r--drivers/usb/serial/hp4x.c2
-rw-r--r--drivers/usb/serial/io_edgeport.c2
-rw-r--r--drivers/usb/serial/io_ti.c2
-rw-r--r--drivers/usb/serial/ipaq.c25
-rw-r--r--drivers/usb/serial/ipw.c4
-rw-r--r--drivers/usb/serial/ir-usb.c2
-rw-r--r--drivers/usb/serial/keyspan.c2
-rw-r--r--drivers/usb/serial/keyspan_pda.c3
-rw-r--r--drivers/usb/serial/kl5kusb105.c2
-rw-r--r--drivers/usb/serial/kobil_sct.c2
-rw-r--r--drivers/usb/serial/mct_u232.c2
-rw-r--r--drivers/usb/serial/navman.c2
-rw-r--r--drivers/usb/serial/omninet.c2
-rw-r--r--drivers/usb/serial/option.c8
-rw-r--r--drivers/usb/serial/pl2303.c4
-rw-r--r--drivers/usb/serial/pl2303.h5
-rw-r--r--drivers/usb/serial/safe_serial.c2
-rw-r--r--drivers/usb/serial/sierra.c75
-rw-r--r--drivers/usb/serial/ti_usb_3410_5052.c2
-rw-r--r--drivers/usb/serial/usb-serial.c25
-rw-r--r--drivers/usb/serial/usb-serial.h300
-rw-r--r--drivers/usb/serial/visor.c39
-rw-r--r--drivers/usb/serial/whiteheat.c2
42 files changed, 306 insertions, 378 deletions
diff --git a/drivers/usb/serial/Kconfig b/drivers/usb/serial/Kconfig
index 8bd44fda5eaf..ac33bd47cfce 100644
--- a/drivers/usb/serial/Kconfig
+++ b/drivers/usb/serial/Kconfig
@@ -456,6 +456,17 @@ config USB_SERIAL_SAFE_PADDED
456 bool "USB Secure Encapsulated Driver - Padded" 456 bool "USB Secure Encapsulated Driver - Padded"
457 depends on USB_SERIAL_SAFE 457 depends on USB_SERIAL_SAFE
458 458
459config USB_SERIAL_SIERRAWIRELESS
460 tristate "USB Sierra Wireless Driver"
461 depends on USB_SERIAL
462 help
463 Say M here if you want to use a Sierra Wireless device (if
464 using an PC 5220 or AC580 please use the Airprime driver
465 instead).
466
467 To compile this driver as a module, choose M here: the
468 module will be called sierra.
469
459config USB_SERIAL_TI 470config USB_SERIAL_TI
460 tristate "USB TI 3410/5052 Serial Driver" 471 tristate "USB TI 3410/5052 Serial Driver"
461 depends on USB_SERIAL 472 depends on USB_SERIAL
diff --git a/drivers/usb/serial/Makefile b/drivers/usb/serial/Makefile
index 5a0960fc9d3e..35d4acc7f1d3 100644
--- a/drivers/usb/serial/Makefile
+++ b/drivers/usb/serial/Makefile
@@ -39,6 +39,7 @@ obj-$(CONFIG_USB_SERIAL_OMNINET) += omninet.o
39obj-$(CONFIG_USB_SERIAL_OPTION) += option.o 39obj-$(CONFIG_USB_SERIAL_OPTION) += option.o
40obj-$(CONFIG_USB_SERIAL_PL2303) += pl2303.o 40obj-$(CONFIG_USB_SERIAL_PL2303) += pl2303.o
41obj-$(CONFIG_USB_SERIAL_SAFE) += safe_serial.o 41obj-$(CONFIG_USB_SERIAL_SAFE) += safe_serial.o
42obj-$(CONFIG_USB_SERIAL_SIERRAWIRELESS) += sierra.o
42obj-$(CONFIG_USB_SERIAL_TI) += ti_usb_3410_5052.o 43obj-$(CONFIG_USB_SERIAL_TI) += ti_usb_3410_5052.o
43obj-$(CONFIG_USB_SERIAL_VISOR) += visor.o 44obj-$(CONFIG_USB_SERIAL_VISOR) += visor.o
44obj-$(CONFIG_USB_SERIAL_WHITEHEAT) += whiteheat.o 45obj-$(CONFIG_USB_SERIAL_WHITEHEAT) += whiteheat.o
diff --git a/drivers/usb/serial/airprime.c b/drivers/usb/serial/airprime.c
index 94b9ba0ff875..62082532a8b3 100644
--- a/drivers/usb/serial/airprime.c
+++ b/drivers/usb/serial/airprime.c
@@ -13,7 +13,7 @@
13#include <linux/tty.h> 13#include <linux/tty.h>
14#include <linux/module.h> 14#include <linux/module.h>
15#include <linux/usb.h> 15#include <linux/usb.h>
16#include "usb-serial.h" 16#include <linux/usb/serial.h>
17 17
18static struct usb_device_id id_table [] = { 18static struct usb_device_id id_table [] = {
19 { USB_DEVICE(0x0c88, 0x17da) }, /* Kyocera Wireless KPC650/Passport */ 19 { USB_DEVICE(0x0c88, 0x17da) }, /* Kyocera Wireless KPC650/Passport */
diff --git a/drivers/usb/serial/anydata.c b/drivers/usb/serial/anydata.c
index 343f6f228220..01843ef8c11e 100644
--- a/drivers/usb/serial/anydata.c
+++ b/drivers/usb/serial/anydata.c
@@ -13,7 +13,7 @@
13#include <linux/tty.h> 13#include <linux/tty.h>
14#include <linux/module.h> 14#include <linux/module.h>
15#include <linux/usb.h> 15#include <linux/usb.h>
16#include "usb-serial.h" 16#include <linux/usb/serial.h>
17 17
18static struct usb_device_id id_table [] = { 18static struct usb_device_id id_table [] = {
19 { USB_DEVICE(0x16d5, 0x6501) }, /* AirData CDMA device */ 19 { USB_DEVICE(0x16d5, 0x6501) }, /* AirData CDMA device */
@@ -71,7 +71,7 @@ static int anydata_open(struct usb_serial_port *port, struct file *filp)
71 port->bulk_in_endpointAddress), 71 port->bulk_in_endpointAddress),
72 port->read_urb->transfer_buffer, 72 port->read_urb->transfer_buffer,
73 port->read_urb->transfer_buffer_length, 73 port->read_urb->transfer_buffer_length,
74 usb_serial_generic_write_bulk_callback, port); 74 usb_serial_generic_read_bulk_callback, port);
75 result = usb_submit_urb(port->read_urb, GFP_KERNEL); 75 result = usb_submit_urb(port->read_urb, GFP_KERNEL);
76 if (result) 76 if (result)
77 dev_err(&port->dev, 77 dev_err(&port->dev,
diff --git a/drivers/usb/serial/ark3116.c b/drivers/usb/serial/ark3116.c
index 8dec796222a0..970d9ef0a7a5 100644
--- a/drivers/usb/serial/ark3116.c
+++ b/drivers/usb/serial/ark3116.c
@@ -21,7 +21,7 @@
21#include <linux/tty.h> 21#include <linux/tty.h>
22#include <linux/module.h> 22#include <linux/module.h>
23#include <linux/usb.h> 23#include <linux/usb.h>
24#include "usb-serial.h" 24#include <linux/usb/serial.h>
25 25
26 26
27static int debug; 27static int debug;
diff --git a/drivers/usb/serial/belkin_sa.c b/drivers/usb/serial/belkin_sa.c
index 3faa7aa0111a..70ece9e01ce4 100644
--- a/drivers/usb/serial/belkin_sa.c
+++ b/drivers/usb/serial/belkin_sa.c
@@ -74,7 +74,7 @@
74#include <linux/spinlock.h> 74#include <linux/spinlock.h>
75#include <asm/uaccess.h> 75#include <asm/uaccess.h>
76#include <linux/usb.h> 76#include <linux/usb.h>
77#include "usb-serial.h" 77#include <linux/usb/serial.h>
78#include "belkin_sa.h" 78#include "belkin_sa.h"
79 79
80static int debug; 80static int debug;
diff --git a/drivers/usb/serial/bus.c b/drivers/usb/serial/bus.c
index f2d993b70c18..6542f220468f 100644
--- a/drivers/usb/serial/bus.c
+++ b/drivers/usb/serial/bus.c
@@ -13,7 +13,7 @@
13#include <linux/tty.h> 13#include <linux/tty.h>
14#include <linux/module.h> 14#include <linux/module.h>
15#include <linux/usb.h> 15#include <linux/usb.h>
16#include "usb-serial.h" 16#include <linux/usb/serial.h>
17 17
18static int usb_serial_device_match (struct device *dev, struct device_driver *drv) 18static int usb_serial_device_match (struct device *dev, struct device_driver *drv)
19{ 19{
diff --git a/drivers/usb/serial/console.c b/drivers/usb/serial/console.c
index 3d456b32c316..3a9073dbfe6a 100644
--- a/drivers/usb/serial/console.c
+++ b/drivers/usb/serial/console.c
@@ -17,11 +17,10 @@
17#include <linux/tty.h> 17#include <linux/tty.h>
18#include <linux/console.h> 18#include <linux/console.h>
19#include <linux/usb.h> 19#include <linux/usb.h>
20#include <linux/usb/serial.h>
20 21
21static int debug; 22static int debug;
22 23
23#include "usb-serial.h"
24
25struct usbcons_info { 24struct usbcons_info {
26 int magic; 25 int magic;
27 int break_flag; 26 int break_flag;
diff --git a/drivers/usb/serial/cp2101.c b/drivers/usb/serial/cp2101.c
index df0a4f98b4ae..486c7411b9a7 100644
--- a/drivers/usb/serial/cp2101.c
+++ b/drivers/usb/serial/cp2101.c
@@ -26,7 +26,7 @@
26#include <linux/moduleparam.h> 26#include <linux/moduleparam.h>
27#include <linux/usb.h> 27#include <linux/usb.h>
28#include <asm/uaccess.h> 28#include <asm/uaccess.h>
29#include "usb-serial.h" 29#include <linux/usb/serial.h>
30 30
31/* 31/*
32 * Version Information 32 * Version Information
diff --git a/drivers/usb/serial/cyberjack.c b/drivers/usb/serial/cyberjack.c
index 49b51ab0d4cb..6286aba86fae 100644
--- a/drivers/usb/serial/cyberjack.c
+++ b/drivers/usb/serial/cyberjack.c
@@ -39,7 +39,7 @@
39#include <linux/spinlock.h> 39#include <linux/spinlock.h>
40#include <asm/uaccess.h> 40#include <asm/uaccess.h>
41#include <linux/usb.h> 41#include <linux/usb.h>
42#include "usb-serial.h" 42#include <linux/usb/serial.h>
43 43
44#define CYBERJACK_LOCAL_BUF_SIZE 32 44#define CYBERJACK_LOCAL_BUF_SIZE 32
45 45
diff --git a/drivers/usb/serial/cypress_m8.c b/drivers/usb/serial/cypress_m8.c
index 4ff2dfb299bd..ee70fddcab60 100644
--- a/drivers/usb/serial/cypress_m8.c
+++ b/drivers/usb/serial/cypress_m8.c
@@ -59,11 +59,11 @@
59#include <linux/moduleparam.h> 59#include <linux/moduleparam.h>
60#include <linux/spinlock.h> 60#include <linux/spinlock.h>
61#include <linux/usb.h> 61#include <linux/usb.h>
62#include <linux/usb/serial.h>
62#include <linux/serial.h> 63#include <linux/serial.h>
63#include <linux/delay.h> 64#include <linux/delay.h>
64#include <asm/uaccess.h> 65#include <asm/uaccess.h>
65 66
66#include "usb-serial.h"
67#include "cypress_m8.h" 67#include "cypress_m8.h"
68 68
69 69
diff --git a/drivers/usb/serial/digi_acceleport.c b/drivers/usb/serial/digi_acceleport.c
index 6953d3ef5738..9b225183fc7a 100644
--- a/drivers/usb/serial/digi_acceleport.c
+++ b/drivers/usb/serial/digi_acceleport.c
@@ -246,7 +246,7 @@
246#include <asm/uaccess.h> 246#include <asm/uaccess.h>
247#include <linux/usb.h> 247#include <linux/usb.h>
248#include <linux/wait.h> 248#include <linux/wait.h>
249#include "usb-serial.h" 249#include <linux/usb/serial.h>
250 250
251/* Defines */ 251/* Defines */
252 252
diff --git a/drivers/usb/serial/empeg.c b/drivers/usb/serial/empeg.c
index 1e2b31eeb497..daafe405d86d 100644
--- a/drivers/usb/serial/empeg.c
+++ b/drivers/usb/serial/empeg.c
@@ -62,7 +62,7 @@
62#include <linux/spinlock.h> 62#include <linux/spinlock.h>
63#include <asm/uaccess.h> 63#include <asm/uaccess.h>
64#include <linux/usb.h> 64#include <linux/usb.h>
65#include "usb-serial.h" 65#include <linux/usb/serial.h>
66 66
67static int debug; 67static int debug;
68 68
diff --git a/drivers/usb/serial/ezusb.c b/drivers/usb/serial/ezusb.c
index debc3b0f9662..5169c2d154ab 100644
--- a/drivers/usb/serial/ezusb.c
+++ b/drivers/usb/serial/ezusb.c
@@ -15,7 +15,7 @@
15#include <linux/tty.h> 15#include <linux/tty.h>
16#include <linux/module.h> 16#include <linux/module.h>
17#include <linux/usb.h> 17#include <linux/usb.h>
18#include "usb-serial.h" 18#include <linux/usb/serial.h>
19 19
20/* EZ-USB Control and Status Register. Bit 0 controls 8051 reset */ 20/* EZ-USB Control and Status Register. Bit 0 controls 8051 reset */
21#define CPUCS_REG 0x7F92 21#define CPUCS_REG 0x7F92
diff --git a/drivers/usb/serial/ftdi_sio.c b/drivers/usb/serial/ftdi_sio.c
index 8a74b19f1283..b458aedc5fb6 100644
--- a/drivers/usb/serial/ftdi_sio.c
+++ b/drivers/usb/serial/ftdi_sio.c
@@ -257,7 +257,7 @@
257#include <asm/uaccess.h> 257#include <asm/uaccess.h>
258#include <linux/usb.h> 258#include <linux/usb.h>
259#include <linux/serial.h> 259#include <linux/serial.h>
260#include "usb-serial.h" 260#include <linux/usb/serial.h>
261#include "ftdi_sio.h" 261#include "ftdi_sio.h"
262 262
263/* 263/*
@@ -313,6 +313,7 @@ static struct usb_device_id id_table_combined [] = {
313 { USB_DEVICE(FTDI_VID, FTDI_8U232AM_PID) }, 313 { USB_DEVICE(FTDI_VID, FTDI_8U232AM_PID) },
314 { USB_DEVICE(FTDI_VID, FTDI_8U232AM_ALT_PID) }, 314 { USB_DEVICE(FTDI_VID, FTDI_8U232AM_ALT_PID) },
315 { USB_DEVICE(FTDI_VID, FTDI_8U2232C_PID) }, 315 { USB_DEVICE(FTDI_VID, FTDI_8U2232C_PID) },
316 { USB_DEVICE(FTDI_VID, FTDI_MICRO_CHAMELEON_PID) },
316 { USB_DEVICE(FTDI_VID, FTDI_RELAIS_PID) }, 317 { USB_DEVICE(FTDI_VID, FTDI_RELAIS_PID) },
317 { USB_DEVICE(INTERBIOMETRICS_VID, INTERBIOMETRICS_IOBOARD_PID) }, 318 { USB_DEVICE(INTERBIOMETRICS_VID, INTERBIOMETRICS_IOBOARD_PID) },
318 { USB_DEVICE(INTERBIOMETRICS_VID, INTERBIOMETRICS_MINI_IOBOARD_PID) }, 319 { USB_DEVICE(INTERBIOMETRICS_VID, INTERBIOMETRICS_MINI_IOBOARD_PID) },
@@ -500,6 +501,8 @@ static struct usb_device_id id_table_combined [] = {
500 { USB_DEVICE(PAPOUCH_VID, PAPOUCH_TMU_PID) }, 501 { USB_DEVICE(PAPOUCH_VID, PAPOUCH_TMU_PID) },
501 { USB_DEVICE(FTDI_VID, FTDI_ACG_HFDUAL_PID) }, 502 { USB_DEVICE(FTDI_VID, FTDI_ACG_HFDUAL_PID) },
502 { USB_DEVICE(FTDI_VID, FTDI_YEI_SERVOCENTER31_PID) }, 503 { USB_DEVICE(FTDI_VID, FTDI_YEI_SERVOCENTER31_PID) },
504 { USB_DEVICE(FTDI_VID, FTDI_THORLABS_PID) },
505 { USB_DEVICE(TESTO_VID, TESTO_USB_INTERFACE_PID) },
503 { }, /* Optional parameter entry */ 506 { }, /* Optional parameter entry */
504 { } /* Terminating entry */ 507 { } /* Terminating entry */
505}; 508};
@@ -548,11 +551,17 @@ struct ftdi_private {
548 spinlock_t rx_lock; /* spinlock for receive state */ 551 spinlock_t rx_lock; /* spinlock for receive state */
549 struct work_struct rx_work; 552 struct work_struct rx_work;
550 int rx_processed; 553 int rx_processed;
554 unsigned long rx_bytes;
551 555
552 __u16 interface; /* FT2232C port interface (0 for FT232/245) */ 556 __u16 interface; /* FT2232C port interface (0 for FT232/245) */
553 557
554 int force_baud; /* if non-zero, force the baud rate to this value */ 558 int force_baud; /* if non-zero, force the baud rate to this value */
555 int force_rtscts; /* if non-zero, force RTS-CTS to always be enabled */ 559 int force_rtscts; /* if non-zero, force RTS-CTS to always be enabled */
560
561 spinlock_t tx_lock; /* spinlock for transmit state */
562 unsigned long tx_bytes;
563 unsigned long tx_outstanding_bytes;
564 unsigned long tx_outstanding_urbs;
556}; 565};
557 566
558/* Used for TIOCMIWAIT */ 567/* Used for TIOCMIWAIT */
@@ -626,6 +635,9 @@ static struct usb_serial_driver ftdi_sio_device = {
626#define HIGH 1 635#define HIGH 1
627#define LOW 0 636#define LOW 0
628 637
638/* number of outstanding urbs to prevent userspace DoS from happening */
639#define URB_UPPER_LIMIT 42
640
629/* 641/*
630 * *************************************************************************** 642 * ***************************************************************************
631 * Utlity functions 643 * Utlity functions
@@ -1156,6 +1168,7 @@ static int ftdi_sio_attach (struct usb_serial *serial)
1156 } 1168 }
1157 1169
1158 spin_lock_init(&priv->rx_lock); 1170 spin_lock_init(&priv->rx_lock);
1171 spin_lock_init(&priv->tx_lock);
1159 init_waitqueue_head(&priv->delta_msr_wait); 1172 init_waitqueue_head(&priv->delta_msr_wait);
1160 /* This will push the characters through immediately rather 1173 /* This will push the characters through immediately rather
1161 than queue a task to deliver them */ 1174 than queue a task to deliver them */
@@ -1270,6 +1283,13 @@ static int ftdi_open (struct usb_serial_port *port, struct file *filp)
1270 1283
1271 dbg("%s", __FUNCTION__); 1284 dbg("%s", __FUNCTION__);
1272 1285
1286 spin_lock_irqsave(&priv->tx_lock, flags);
1287 priv->tx_bytes = 0;
1288 spin_unlock_irqrestore(&priv->tx_lock, flags);
1289 spin_lock_irqsave(&priv->rx_lock, flags);
1290 priv->rx_bytes = 0;
1291 spin_unlock_irqrestore(&priv->rx_lock, flags);
1292
1273 if (port->tty) 1293 if (port->tty)
1274 port->tty->low_latency = (priv->flags & ASYNC_LOW_LATENCY) ? 1 : 0; 1294 port->tty->low_latency = (priv->flags & ASYNC_LOW_LATENCY) ? 1 : 0;
1275 1295
@@ -1372,6 +1392,7 @@ static int ftdi_write (struct usb_serial_port *port,
1372 int data_offset ; /* will be 1 for the SIO and 0 otherwise */ 1392 int data_offset ; /* will be 1 for the SIO and 0 otherwise */
1373 int status; 1393 int status;
1374 int transfer_size; 1394 int transfer_size;
1395 unsigned long flags;
1375 1396
1376 dbg("%s port %d, %d bytes", __FUNCTION__, port->number, count); 1397 dbg("%s port %d, %d bytes", __FUNCTION__, port->number, count);
1377 1398
@@ -1379,6 +1400,13 @@ static int ftdi_write (struct usb_serial_port *port,
1379 dbg("write request of 0 bytes"); 1400 dbg("write request of 0 bytes");
1380 return 0; 1401 return 0;
1381 } 1402 }
1403 spin_lock_irqsave(&priv->tx_lock, flags);
1404 if (priv->tx_outstanding_urbs > URB_UPPER_LIMIT) {
1405 spin_unlock_irqrestore(&priv->tx_lock, flags);
1406 dbg("%s - write limit hit\n", __FUNCTION__);
1407 return 0;
1408 }
1409 spin_unlock_irqrestore(&priv->tx_lock, flags);
1382 1410
1383 data_offset = priv->write_offset; 1411 data_offset = priv->write_offset;
1384 dbg("data_offset set to %d",data_offset); 1412 dbg("data_offset set to %d",data_offset);
@@ -1445,6 +1473,12 @@ static int ftdi_write (struct usb_serial_port *port,
1445 err("%s - failed submitting write urb, error %d", __FUNCTION__, status); 1473 err("%s - failed submitting write urb, error %d", __FUNCTION__, status);
1446 count = status; 1474 count = status;
1447 kfree (buffer); 1475 kfree (buffer);
1476 } else {
1477 spin_lock_irqsave(&priv->tx_lock, flags);
1478 ++priv->tx_outstanding_urbs;
1479 priv->tx_outstanding_bytes += count;
1480 priv->tx_bytes += count;
1481 spin_unlock_irqrestore(&priv->tx_lock, flags);
1448 } 1482 }
1449 1483
1450 /* we are done with this urb, so let the host driver 1484 /* we are done with this urb, so let the host driver
@@ -1460,7 +1494,11 @@ static int ftdi_write (struct usb_serial_port *port,
1460 1494
1461static void ftdi_write_bulk_callback (struct urb *urb, struct pt_regs *regs) 1495static void ftdi_write_bulk_callback (struct urb *urb, struct pt_regs *regs)
1462{ 1496{
1497 unsigned long flags;
1463 struct usb_serial_port *port = (struct usb_serial_port *)urb->context; 1498 struct usb_serial_port *port = (struct usb_serial_port *)urb->context;
1499 struct ftdi_private *priv;
1500 int data_offset; /* will be 1 for the SIO and 0 otherwise */
1501 unsigned long countback;
1464 1502
1465 /* free up the transfer buffer, as usb_free_urb() does not do this */ 1503 /* free up the transfer buffer, as usb_free_urb() does not do this */
1466 kfree (urb->transfer_buffer); 1504 kfree (urb->transfer_buffer);
@@ -1472,34 +1510,67 @@ static void ftdi_write_bulk_callback (struct urb *urb, struct pt_regs *regs)
1472 return; 1510 return;
1473 } 1511 }
1474 1512
1513 priv = usb_get_serial_port_data(port);
1514 if (!priv) {
1515 dbg("%s - bad port private data pointer - exiting", __FUNCTION__);
1516 return;
1517 }
1518 /* account for transferred data */
1519 countback = urb->actual_length;
1520 data_offset = priv->write_offset;
1521 if (data_offset > 0) {
1522 /* Subtract the control bytes */
1523 countback -= (data_offset * ((countback + (PKTSZ - 1)) / PKTSZ));
1524 }
1525 spin_lock_irqsave(&priv->tx_lock, flags);
1526 --priv->tx_outstanding_urbs;
1527 priv->tx_outstanding_bytes -= countback;
1528 spin_unlock_irqrestore(&priv->tx_lock, flags);
1529
1475 usb_serial_port_softint(port); 1530 usb_serial_port_softint(port);
1476} /* ftdi_write_bulk_callback */ 1531} /* ftdi_write_bulk_callback */
1477 1532
1478 1533
1479static int ftdi_write_room( struct usb_serial_port *port ) 1534static int ftdi_write_room( struct usb_serial_port *port )
1480{ 1535{
1536 struct ftdi_private *priv = usb_get_serial_port_data(port);
1537 int room;
1538 unsigned long flags;
1539
1481 dbg("%s - port %d", __FUNCTION__, port->number); 1540 dbg("%s - port %d", __FUNCTION__, port->number);
1482 1541
1483 /* 1542 spin_lock_irqsave(&priv->tx_lock, flags);
1484 * We really can take anything the user throws at us 1543 if (priv->tx_outstanding_urbs < URB_UPPER_LIMIT) {
1485 * but let's pick a nice big number to tell the tty 1544 /*
1486 * layer that we have lots of free space 1545 * We really can take anything the user throws at us
1487 */ 1546 * but let's pick a nice big number to tell the tty
1488 return 2048; 1547 * layer that we have lots of free space
1548 */
1549 room = 2048;
1550 } else {
1551 room = 0;
1552 }
1553 spin_unlock_irqrestore(&priv->tx_lock, flags);
1554 return room;
1489} /* ftdi_write_room */ 1555} /* ftdi_write_room */
1490 1556
1491 1557
1492static int ftdi_chars_in_buffer (struct usb_serial_port *port) 1558static int ftdi_chars_in_buffer (struct usb_serial_port *port)
1493{ /* ftdi_chars_in_buffer */ 1559{ /* ftdi_chars_in_buffer */
1560 struct ftdi_private *priv = usb_get_serial_port_data(port);
1561 int buffered;
1562 unsigned long flags;
1563
1494 dbg("%s - port %d", __FUNCTION__, port->number); 1564 dbg("%s - port %d", __FUNCTION__, port->number);
1495 1565
1496 /* 1566 spin_lock_irqsave(&priv->tx_lock, flags);
1497 * We can't really account for how much data we 1567 buffered = (int)priv->tx_outstanding_bytes;
1498 * have sent out, but hasn't made it through to the 1568 spin_unlock_irqrestore(&priv->tx_lock, flags);
1499 * device, so just tell the tty layer that everything 1569 if (buffered < 0) {
1500 * is flushed. 1570 err("%s outstanding tx bytes is negative!", __FUNCTION__);
1501 */ 1571 buffered = 0;
1502 return 0; 1572 }
1573 return buffered;
1503} /* ftdi_chars_in_buffer */ 1574} /* ftdi_chars_in_buffer */
1504 1575
1505 1576
@@ -1509,6 +1580,8 @@ static void ftdi_read_bulk_callback (struct urb *urb, struct pt_regs *regs)
1509 struct usb_serial_port *port = (struct usb_serial_port *)urb->context; 1580 struct usb_serial_port *port = (struct usb_serial_port *)urb->context;
1510 struct tty_struct *tty; 1581 struct tty_struct *tty;
1511 struct ftdi_private *priv; 1582 struct ftdi_private *priv;
1583 unsigned long countread;
1584 unsigned long flags;
1512 1585
1513 if (urb->number_of_packets > 0) { 1586 if (urb->number_of_packets > 0) {
1514 err("%s transfer_buffer_length %d actual_length %d number of packets %d",__FUNCTION__, 1587 err("%s transfer_buffer_length %d actual_length %d number of packets %d",__FUNCTION__,
@@ -1543,6 +1616,13 @@ static void ftdi_read_bulk_callback (struct urb *urb, struct pt_regs *regs)
1543 return; 1616 return;
1544 } 1617 }
1545 1618
1619 /* count data bytes, but not status bytes */
1620 countread = urb->actual_length;
1621 countread -= 2 * ((countread + (PKTSZ - 1)) / PKTSZ);
1622 spin_lock_irqsave(&priv->rx_lock, flags);
1623 priv->rx_bytes += countread;
1624 spin_unlock_irqrestore(&priv->rx_lock, flags);
1625
1546 ftdi_process_read(port); 1626 ftdi_process_read(port);
1547 1627
1548} /* ftdi_read_bulk_callback */ 1628} /* ftdi_read_bulk_callback */
diff --git a/drivers/usb/serial/ftdi_sio.h b/drivers/usb/serial/ftdi_sio.h
index 6ab2ac845bd7..04ef90fcb876 100644
--- a/drivers/usb/serial/ftdi_sio.h
+++ b/drivers/usb/serial/ftdi_sio.h
@@ -36,6 +36,9 @@
36#define FTDI_ACTZWAVE_PID 0xF2D0 36#define FTDI_ACTZWAVE_PID 0xF2D0
37 37
38 38
39/* www.starting-point-systems.com µChameleon device */
40#define FTDI_MICRO_CHAMELEON_PID 0xCAA0 /* Product Id */
41
39/* www.irtrans.de device */ 42/* www.irtrans.de device */
40#define FTDI_IRTRANS_PID 0xFC60 /* Product Id */ 43#define FTDI_IRTRANS_PID 0xFC60 /* Product Id */
41 44
@@ -442,6 +445,18 @@
442 */ 445 */
443#define FTDI_YEI_SERVOCENTER31_PID 0xE050 /* YEI ServoCenter3.1 USB */ 446#define FTDI_YEI_SERVOCENTER31_PID 0xE050 /* YEI ServoCenter3.1 USB */
444 447
448/*
449 * ThorLabs USB motor drivers
450 */
451#define FTDI_THORLABS_PID 0xfaf0 /* ThorLabs USB motor drivers */
452
453/*
454 * Testo products (http://www.testo.com/)
455 * Submitted by Colin Leroy
456 */
457#define TESTO_VID 0x128D
458#define TESTO_USB_INTERFACE_PID 0x0001
459
445/* Commands */ 460/* Commands */
446#define FTDI_SIO_RESET 0 /* Reset the port */ 461#define FTDI_SIO_RESET 0 /* Reset the port */
447#define FTDI_SIO_MODEM_CTRL 1 /* Set the modem control register */ 462#define FTDI_SIO_MODEM_CTRL 1 /* Set the modem control register */
diff --git a/drivers/usb/serial/funsoft.c b/drivers/usb/serial/funsoft.c
index 803721b97e2e..77b977206a8c 100644
--- a/drivers/usb/serial/funsoft.c
+++ b/drivers/usb/serial/funsoft.c
@@ -13,7 +13,7 @@
13#include <linux/tty.h> 13#include <linux/tty.h>
14#include <linux/module.h> 14#include <linux/module.h>
15#include <linux/usb.h> 15#include <linux/usb.h>
16#include "usb-serial.h" 16#include <linux/usb/serial.h>
17 17
18static struct usb_device_id id_table [] = { 18static struct usb_device_id id_table [] = {
19 { USB_DEVICE(0x1404, 0xcddc) }, 19 { USB_DEVICE(0x1404, 0xcddc) },
diff --git a/drivers/usb/serial/garmin_gps.c b/drivers/usb/serial/garmin_gps.c
index 1f5d1620baa1..727852634be9 100644
--- a/drivers/usb/serial/garmin_gps.c
+++ b/drivers/usb/serial/garmin_gps.c
@@ -35,6 +35,7 @@
35#include <linux/spinlock.h> 35#include <linux/spinlock.h>
36#include <asm/uaccess.h> 36#include <asm/uaccess.h>
37#include <linux/usb.h> 37#include <linux/usb.h>
38#include <linux/usb/serial.h>
38 39
39/* the mode to be set when the port ist opened */ 40/* the mode to be set when the port ist opened */
40static int initial_mode = 1; 41static int initial_mode = 1;
@@ -42,8 +43,6 @@ static int initial_mode = 1;
42/* debug flag */ 43/* debug flag */
43static int debug = 0; 44static int debug = 0;
44 45
45#include "usb-serial.h"
46
47#define GARMIN_VENDOR_ID 0x091E 46#define GARMIN_VENDOR_ID 0x091E
48 47
49/* 48/*
diff --git a/drivers/usb/serial/generic.c b/drivers/usb/serial/generic.c
index 945b8bb38c92..172713556393 100644
--- a/drivers/usb/serial/generic.c
+++ b/drivers/usb/serial/generic.c
@@ -17,8 +17,8 @@
17#include <linux/module.h> 17#include <linux/module.h>
18#include <linux/moduleparam.h> 18#include <linux/moduleparam.h>
19#include <linux/usb.h> 19#include <linux/usb.h>
20#include <linux/usb/serial.h>
20#include <asm/uaccess.h> 21#include <asm/uaccess.h>
21#include "usb-serial.h"
22 22
23static int debug; 23static int debug;
24 24
@@ -285,6 +285,7 @@ void usb_serial_generic_read_bulk_callback (struct urb *urb, struct pt_regs *reg
285 if (result) 285 if (result)
286 dev_err(&port->dev, "%s - failed resubmitting read urb, error %d\n", __FUNCTION__, result); 286 dev_err(&port->dev, "%s - failed resubmitting read urb, error %d\n", __FUNCTION__, result);
287} 287}
288EXPORT_SYMBOL_GPL(usb_serial_generic_read_bulk_callback);
288 289
289void usb_serial_generic_write_bulk_callback (struct urb *urb, struct pt_regs *regs) 290void usb_serial_generic_write_bulk_callback (struct urb *urb, struct pt_regs *regs)
290{ 291{
diff --git a/drivers/usb/serial/hp4x.c b/drivers/usb/serial/hp4x.c
index 7e06358b0310..ebcac701b069 100644
--- a/drivers/usb/serial/hp4x.c
+++ b/drivers/usb/serial/hp4x.c
@@ -17,7 +17,7 @@
17#include <linux/tty.h> 17#include <linux/tty.h>
18#include <linux/module.h> 18#include <linux/module.h>
19#include <linux/usb.h> 19#include <linux/usb.h>
20#include "usb-serial.h" 20#include <linux/usb/serial.h>
21 21
22/* 22/*
23 * Version Information 23 * Version Information
diff --git a/drivers/usb/serial/io_edgeport.c b/drivers/usb/serial/io_edgeport.c
index bd2c05dac2a9..c49976c3ad52 100644
--- a/drivers/usb/serial/io_edgeport.c
+++ b/drivers/usb/serial/io_edgeport.c
@@ -44,7 +44,7 @@
44#include <linux/wait.h> 44#include <linux/wait.h>
45#include <asm/uaccess.h> 45#include <asm/uaccess.h>
46#include <linux/usb.h> 46#include <linux/usb.h>
47#include "usb-serial.h" 47#include <linux/usb/serial.h>
48#include "io_edgeport.h" 48#include "io_edgeport.h"
49#include "io_ionsp.h" /* info for the iosp messages */ 49#include "io_ionsp.h" /* info for the iosp messages */
50#include "io_16654.h" /* 16654 UART defines */ 50#include "io_16654.h" /* 16654 UART defines */
diff --git a/drivers/usb/serial/io_ti.c b/drivers/usb/serial/io_ti.c
index 723a12ae87b5..17c5b1d2311a 100644
--- a/drivers/usb/serial/io_ti.c
+++ b/drivers/usb/serial/io_ti.c
@@ -39,8 +39,8 @@
39#include <asm/uaccess.h> 39#include <asm/uaccess.h>
40#include <asm/semaphore.h> 40#include <asm/semaphore.h>
41#include <linux/usb.h> 41#include <linux/usb.h>
42#include <linux/usb/serial.h>
42 43
43#include "usb-serial.h"
44#include "io_16654.h" 44#include "io_16654.h"
45#include "io_usbvend.h" 45#include "io_usbvend.h"
46#include "io_ti.h" 46#include "io_ti.h"
diff --git a/drivers/usb/serial/ipaq.c b/drivers/usb/serial/ipaq.c
index dbcfe172a5cc..59c5d999009a 100644
--- a/drivers/usb/serial/ipaq.c
+++ b/drivers/usb/serial/ipaq.c
@@ -55,7 +55,7 @@
55#include <linux/spinlock.h> 55#include <linux/spinlock.h>
56#include <asm/uaccess.h> 56#include <asm/uaccess.h>
57#include <linux/usb.h> 57#include <linux/usb.h>
58#include "usb-serial.h" 58#include <linux/usb/serial.h>
59#include "ipaq.h" 59#include "ipaq.h"
60 60
61#define KP_RETRIES 100 61#define KP_RETRIES 100
@@ -70,6 +70,8 @@
70 70
71static __u16 product, vendor; 71static __u16 product, vendor;
72static int debug; 72static int debug;
73static int connect_retries = KP_RETRIES;
74static int initial_wait;
73 75
74/* Function prototypes for an ipaq */ 76/* Function prototypes for an ipaq */
75static int ipaq_open (struct usb_serial_port *port, struct file *filp); 77static int ipaq_open (struct usb_serial_port *port, struct file *filp);
@@ -582,7 +584,7 @@ static int ipaq_open(struct usb_serial_port *port, struct file *filp)
582 struct ipaq_private *priv; 584 struct ipaq_private *priv;
583 struct ipaq_packet *pkt; 585 struct ipaq_packet *pkt;
584 int i, result = 0; 586 int i, result = 0;
585 int retries = KP_RETRIES; 587 int retries = connect_retries;
586 588
587 dbg("%s - port %d", __FUNCTION__, port->number); 589 dbg("%s - port %d", __FUNCTION__, port->number);
588 590
@@ -646,16 +648,12 @@ static int ipaq_open(struct usb_serial_port *port, struct file *filp)
646 port->read_urb->transfer_buffer_length = URBDATA_SIZE; 648 port->read_urb->transfer_buffer_length = URBDATA_SIZE;
647 port->bulk_out_size = port->write_urb->transfer_buffer_length = URBDATA_SIZE; 649 port->bulk_out_size = port->write_urb->transfer_buffer_length = URBDATA_SIZE;
648 650
651 msleep(1000*initial_wait);
649 /* Start reading from the device */ 652 /* Start reading from the device */
650 usb_fill_bulk_urb(port->read_urb, serial->dev, 653 usb_fill_bulk_urb(port->read_urb, serial->dev,
651 usb_rcvbulkpipe(serial->dev, port->bulk_in_endpointAddress), 654 usb_rcvbulkpipe(serial->dev, port->bulk_in_endpointAddress),
652 port->read_urb->transfer_buffer, port->read_urb->transfer_buffer_length, 655 port->read_urb->transfer_buffer, port->read_urb->transfer_buffer_length,
653 ipaq_read_bulk_callback, port); 656 ipaq_read_bulk_callback, port);
654 result = usb_submit_urb(port->read_urb, GFP_KERNEL);
655 if (result) {
656 err("%s - failed submitting read urb, error %d", __FUNCTION__, result);
657 goto error;
658 }
659 657
660 /* 658 /*
661 * Send out control message observed in win98 sniffs. Not sure what 659 * Send out control message observed in win98 sniffs. Not sure what
@@ -670,8 +668,14 @@ static int ipaq_open(struct usb_serial_port *port, struct file *filp)
670 usb_sndctrlpipe(serial->dev, 0), 0x22, 0x21, 668 usb_sndctrlpipe(serial->dev, 0), 0x22, 0x21,
671 0x1, 0, NULL, 0, 100); 669 0x1, 0, NULL, 0, 100);
672 if (result == 0) { 670 if (result == 0) {
671 result = usb_submit_urb(port->read_urb, GFP_KERNEL);
672 if (result) {
673 err("%s - failed submitting read urb, error %d", __FUNCTION__, result);
674 goto error;
675 }
673 return 0; 676 return 0;
674 } 677 }
678 msleep(1000);
675 } 679 }
676 err("%s - failed doing control urb, error %d", __FUNCTION__, result); 680 err("%s - failed doing control urb, error %d", __FUNCTION__, result);
677 goto error; 681 goto error;
@@ -854,6 +858,7 @@ static void ipaq_write_bulk_callback(struct urb *urb, struct pt_regs *regs)
854 858
855 if (urb->status) { 859 if (urb->status) {
856 dbg("%s - nonzero write bulk status received: %d", __FUNCTION__, urb->status); 860 dbg("%s - nonzero write bulk status received: %d", __FUNCTION__, urb->status);
861 return;
857 } 862 }
858 863
859 spin_lock_irqsave(&write_list_lock, flags); 864 spin_lock_irqsave(&write_list_lock, flags);
@@ -966,3 +971,9 @@ MODULE_PARM_DESC(vendor, "User specified USB idVendor");
966 971
967module_param(product, ushort, 0); 972module_param(product, ushort, 0);
968MODULE_PARM_DESC(product, "User specified USB idProduct"); 973MODULE_PARM_DESC(product, "User specified USB idProduct");
974
975module_param(connect_retries, int, S_IRUGO|S_IWUSR);
976MODULE_PARM_DESC(connect_retries, "Maximum number of connect retries (one second each)");
977
978module_param(initial_wait, int, S_IRUGO|S_IWUSR);
979MODULE_PARM_DESC(initial_wait, "Time to wait before attempting a connection (in seconds)");
diff --git a/drivers/usb/serial/ipw.c b/drivers/usb/serial/ipw.c
index a4a0bfeaab00..87306cb6f9f5 100644
--- a/drivers/usb/serial/ipw.c
+++ b/drivers/usb/serial/ipw.c
@@ -46,8 +46,8 @@
46#include <linux/module.h> 46#include <linux/module.h>
47#include <linux/spinlock.h> 47#include <linux/spinlock.h>
48#include <linux/usb.h> 48#include <linux/usb.h>
49#include <linux/usb/serial.h>
49#include <asm/uaccess.h> 50#include <asm/uaccess.h>
50#include "usb-serial.h"
51 51
52/* 52/*
53 * Version Information 53 * Version Information
@@ -373,6 +373,8 @@ static void ipw_write_bulk_callback(struct urb *urb, struct pt_regs *regs)
373 373
374 dbg("%s", __FUNCTION__); 374 dbg("%s", __FUNCTION__);
375 375
376 port->write_urb_busy = 0;
377
376 if (urb->status) 378 if (urb->status)
377 dbg("%s - nonzero write bulk status received: %d", __FUNCTION__, urb->status); 379 dbg("%s - nonzero write bulk status received: %d", __FUNCTION__, urb->status);
378 380
diff --git a/drivers/usb/serial/ir-usb.c b/drivers/usb/serial/ir-usb.c
index 2cf1fed3de43..1738b0b6a376 100644
--- a/drivers/usb/serial/ir-usb.c
+++ b/drivers/usb/serial/ir-usb.c
@@ -57,7 +57,7 @@
57#include <linux/spinlock.h> 57#include <linux/spinlock.h>
58#include <asm/uaccess.h> 58#include <asm/uaccess.h>
59#include <linux/usb.h> 59#include <linux/usb.h>
60#include "usb-serial.h" 60#include <linux/usb/serial.h>
61 61
62/* 62/*
63 * Version Information 63 * Version Information
diff --git a/drivers/usb/serial/keyspan.c b/drivers/usb/serial/keyspan.c
index d7c58f1bc960..015ad6cc1bbb 100644
--- a/drivers/usb/serial/keyspan.c
+++ b/drivers/usb/serial/keyspan.c
@@ -107,7 +107,7 @@
107#include <linux/spinlock.h> 107#include <linux/spinlock.h>
108#include <asm/uaccess.h> 108#include <asm/uaccess.h>
109#include <linux/usb.h> 109#include <linux/usb.h>
110#include "usb-serial.h" 110#include <linux/usb/serial.h>
111#include "keyspan.h" 111#include "keyspan.h"
112 112
113static int debug; 113static int debug;
diff --git a/drivers/usb/serial/keyspan_pda.c b/drivers/usb/serial/keyspan_pda.c
index 03ab3c0f3cce..49b8dc039d1f 100644
--- a/drivers/usb/serial/keyspan_pda.c
+++ b/drivers/usb/serial/keyspan_pda.c
@@ -78,6 +78,7 @@
78#include <linux/workqueue.h> 78#include <linux/workqueue.h>
79#include <asm/uaccess.h> 79#include <asm/uaccess.h>
80#include <linux/usb.h> 80#include <linux/usb.h>
81#include <linux/usb/serial.h>
81 82
82static int debug; 83static int debug;
83 84
@@ -107,8 +108,6 @@ struct ezusb_hex_record {
107#include "xircom_pgs_fw.h" 108#include "xircom_pgs_fw.h"
108#endif 109#endif
109 110
110#include "usb-serial.h"
111
112/* 111/*
113 * Version Information 112 * Version Information
114 */ 113 */
diff --git a/drivers/usb/serial/kl5kusb105.c b/drivers/usb/serial/kl5kusb105.c
index b45ff3e7ab40..2a2f3e2da055 100644
--- a/drivers/usb/serial/kl5kusb105.c
+++ b/drivers/usb/serial/kl5kusb105.c
@@ -55,7 +55,7 @@
55#include <linux/module.h> 55#include <linux/module.h>
56#include <asm/uaccess.h> 56#include <asm/uaccess.h>
57#include <linux/usb.h> 57#include <linux/usb.h>
58#include "usb-serial.h" 58#include <linux/usb/serial.h>
59#include "kl5kusb105.h" 59#include "kl5kusb105.h"
60 60
61static int debug; 61static int debug;
diff --git a/drivers/usb/serial/kobil_sct.c b/drivers/usb/serial/kobil_sct.c
index 457733374772..d50dce034958 100644
--- a/drivers/usb/serial/kobil_sct.c
+++ b/drivers/usb/serial/kobil_sct.c
@@ -46,8 +46,8 @@
46#include <linux/spinlock.h> 46#include <linux/spinlock.h>
47#include <asm/uaccess.h> 47#include <asm/uaccess.h>
48#include <linux/usb.h> 48#include <linux/usb.h>
49#include <linux/usb/serial.h>
49#include <linux/ioctl.h> 50#include <linux/ioctl.h>
50#include "usb-serial.h"
51#include "kobil_sct.h" 51#include "kobil_sct.h"
52 52
53static int debug; 53static int debug;
diff --git a/drivers/usb/serial/mct_u232.c b/drivers/usb/serial/mct_u232.c
index ca05d3275f3e..f4d4305c2c02 100644
--- a/drivers/usb/serial/mct_u232.c
+++ b/drivers/usb/serial/mct_u232.c
@@ -75,7 +75,7 @@
75#include <linux/spinlock.h> 75#include <linux/spinlock.h>
76#include <asm/uaccess.h> 76#include <asm/uaccess.h>
77#include <linux/usb.h> 77#include <linux/usb.h>
78#include "usb-serial.h" 78#include <linux/usb/serial.h>
79#include "mct_u232.h" 79#include "mct_u232.h"
80 80
81/* 81/*
diff --git a/drivers/usb/serial/navman.c b/drivers/usb/serial/navman.c
index 7f544081032e..ac3f8b5d2c49 100644
--- a/drivers/usb/serial/navman.c
+++ b/drivers/usb/serial/navman.c
@@ -14,7 +14,7 @@
14#include <linux/tty_flip.h> 14#include <linux/tty_flip.h>
15#include <linux/module.h> 15#include <linux/module.h>
16#include <linux/usb.h> 16#include <linux/usb.h>
17#include "usb-serial.h" 17#include <linux/usb/serial.h>
18 18
19static int debug; 19static int debug;
20 20
diff --git a/drivers/usb/serial/omninet.c b/drivers/usb/serial/omninet.c
index cfb711a21a45..e49f40913c27 100644
--- a/drivers/usb/serial/omninet.c
+++ b/drivers/usb/serial/omninet.c
@@ -46,7 +46,7 @@
46#include <linux/spinlock.h> 46#include <linux/spinlock.h>
47#include <asm/uaccess.h> 47#include <asm/uaccess.h>
48#include <linux/usb.h> 48#include <linux/usb.h>
49#include "usb-serial.h" 49#include <linux/usb/serial.h>
50 50
51static int debug; 51static int debug;
52 52
diff --git a/drivers/usb/serial/option.c b/drivers/usb/serial/option.c
index 78ad4b3126a6..f0530c1d7b7a 100644
--- a/drivers/usb/serial/option.c
+++ b/drivers/usb/serial/option.c
@@ -35,6 +35,7 @@
35 2006-06-01 v0.6.2 add backwards-compatibility stuff 35 2006-06-01 v0.6.2 add backwards-compatibility stuff
36 2006-06-01 v0.6.3 add Novatel Wireless 36 2006-06-01 v0.6.3 add Novatel Wireless
37 2006-06-01 v0.7 Option => GSM 37 2006-06-01 v0.7 Option => GSM
38 2006-06-01 v0.7.1 add COBRA2
38 39
39 Work sponsored by: Sigos GmbH, Germany <info@sigos.de> 40 Work sponsored by: Sigos GmbH, Germany <info@sigos.de>
40 41
@@ -53,7 +54,7 @@
53 device features. 54 device features.
54*/ 55*/
55 56
56#define DRIVER_VERSION "v0.7.0" 57#define DRIVER_VERSION "v0.7.1"
57#define DRIVER_AUTHOR "Matthias Urlichs <smurf@smurf.noris.de>" 58#define DRIVER_AUTHOR "Matthias Urlichs <smurf@smurf.noris.de>"
58#define DRIVER_DESC "USB Driver for GSM modems" 59#define DRIVER_DESC "USB Driver for GSM modems"
59 60
@@ -64,7 +65,7 @@
64#include <linux/tty_flip.h> 65#include <linux/tty_flip.h>
65#include <linux/module.h> 66#include <linux/module.h>
66#include <linux/usb.h> 67#include <linux/usb.h>
67#include "usb-serial.h" 68#include <linux/usb/serial.h>
68 69
69/* Function prototypes */ 70/* Function prototypes */
70static int option_open(struct usb_serial_port *port, struct file *filp); 71static int option_open(struct usb_serial_port *port, struct file *filp);
@@ -102,6 +103,7 @@ static int option_send_setup(struct usb_serial_port *port);
102#define OPTION_PRODUCT_FUSION 0x6000 103#define OPTION_PRODUCT_FUSION 0x6000
103#define OPTION_PRODUCT_FUSION2 0x6300 104#define OPTION_PRODUCT_FUSION2 0x6300
104#define OPTION_PRODUCT_COBRA 0x6500 105#define OPTION_PRODUCT_COBRA 0x6500
106#define OPTION_PRODUCT_COBRA2 0x6600
105#define HUAWEI_PRODUCT_E600 0x1001 107#define HUAWEI_PRODUCT_E600 0x1001
106#define AUDIOVOX_PRODUCT_AIRCARD 0x0112 108#define AUDIOVOX_PRODUCT_AIRCARD 0x0112
107#define SIERRAWIRELESS_PRODUCT_MC8755 0x6802 109#define SIERRAWIRELESS_PRODUCT_MC8755 0x6802
@@ -112,6 +114,7 @@ static struct usb_device_id option_ids[] = {
112 { USB_DEVICE(OPTION_VENDOR_ID, OPTION_PRODUCT_FUSION) }, 114 { USB_DEVICE(OPTION_VENDOR_ID, OPTION_PRODUCT_FUSION) },
113 { USB_DEVICE(OPTION_VENDOR_ID, OPTION_PRODUCT_FUSION2) }, 115 { USB_DEVICE(OPTION_VENDOR_ID, OPTION_PRODUCT_FUSION2) },
114 { USB_DEVICE(OPTION_VENDOR_ID, OPTION_PRODUCT_COBRA) }, 116 { USB_DEVICE(OPTION_VENDOR_ID, OPTION_PRODUCT_COBRA) },
117 { USB_DEVICE(OPTION_VENDOR_ID, OPTION_PRODUCT_COBRA2) },
115 { USB_DEVICE(HUAWEI_VENDOR_ID, HUAWEI_PRODUCT_E600) }, 118 { USB_DEVICE(HUAWEI_VENDOR_ID, HUAWEI_PRODUCT_E600) },
116 { USB_DEVICE(AUDIOVOX_VENDOR_ID, AUDIOVOX_PRODUCT_AIRCARD) }, 119 { USB_DEVICE(AUDIOVOX_VENDOR_ID, AUDIOVOX_PRODUCT_AIRCARD) },
117 { USB_DEVICE(SIERRAWIRELESS_VENDOR_ID, SIERRAWIRELESS_PRODUCT_MC8755) }, 120 { USB_DEVICE(SIERRAWIRELESS_VENDOR_ID, SIERRAWIRELESS_PRODUCT_MC8755) },
@@ -124,6 +127,7 @@ static struct usb_device_id option_ids1[] = {
124 { USB_DEVICE(OPTION_VENDOR_ID, OPTION_PRODUCT_FUSION) }, 127 { USB_DEVICE(OPTION_VENDOR_ID, OPTION_PRODUCT_FUSION) },
125 { USB_DEVICE(OPTION_VENDOR_ID, OPTION_PRODUCT_FUSION2) }, 128 { USB_DEVICE(OPTION_VENDOR_ID, OPTION_PRODUCT_FUSION2) },
126 { USB_DEVICE(OPTION_VENDOR_ID, OPTION_PRODUCT_COBRA) }, 129 { USB_DEVICE(OPTION_VENDOR_ID, OPTION_PRODUCT_COBRA) },
130 { USB_DEVICE(OPTION_VENDOR_ID, OPTION_PRODUCT_COBRA2) },
127 { USB_DEVICE(HUAWEI_VENDOR_ID, HUAWEI_PRODUCT_E600) }, 131 { USB_DEVICE(HUAWEI_VENDOR_ID, HUAWEI_PRODUCT_E600) },
128 { USB_DEVICE(AUDIOVOX_VENDOR_ID, AUDIOVOX_PRODUCT_AIRCARD) }, 132 { USB_DEVICE(AUDIOVOX_VENDOR_ID, AUDIOVOX_PRODUCT_AIRCARD) },
129 { USB_DEVICE(NOVATELWIRELESS_VENDOR_ID,NOVATELWIRELESS_PRODUCT_U740) }, 133 { USB_DEVICE(NOVATELWIRELESS_VENDOR_ID,NOVATELWIRELESS_PRODUCT_U740) },
diff --git a/drivers/usb/serial/pl2303.c b/drivers/usb/serial/pl2303.c
index de93a2b909e7..259db31b65c1 100644
--- a/drivers/usb/serial/pl2303.c
+++ b/drivers/usb/serial/pl2303.c
@@ -27,7 +27,7 @@
27#include <linux/spinlock.h> 27#include <linux/spinlock.h>
28#include <asm/uaccess.h> 28#include <asm/uaccess.h>
29#include <linux/usb.h> 29#include <linux/usb.h>
30#include "usb-serial.h" 30#include <linux/usb/serial.h>
31#include "pl2303.h" 31#include "pl2303.h"
32 32
33/* 33/*
@@ -52,6 +52,7 @@ struct pl2303_buf {
52static struct usb_device_id id_table [] = { 52static struct usb_device_id id_table [] = {
53 { USB_DEVICE(PL2303_VENDOR_ID, PL2303_PRODUCT_ID) }, 53 { USB_DEVICE(PL2303_VENDOR_ID, PL2303_PRODUCT_ID) },
54 { USB_DEVICE(PL2303_VENDOR_ID, PL2303_PRODUCT_ID_RSAQ2) }, 54 { USB_DEVICE(PL2303_VENDOR_ID, PL2303_PRODUCT_ID_RSAQ2) },
55 { USB_DEVICE(PL2303_VENDOR_ID, PL2303_PRODUCT_ID_DCU11) },
55 { USB_DEVICE(PL2303_VENDOR_ID, PL2303_PRODUCT_ID_RSAQ3) }, 56 { USB_DEVICE(PL2303_VENDOR_ID, PL2303_PRODUCT_ID_RSAQ3) },
56 { USB_DEVICE(PL2303_VENDOR_ID, PL2303_PRODUCT_ID_PHAROS) }, 57 { USB_DEVICE(PL2303_VENDOR_ID, PL2303_PRODUCT_ID_PHAROS) },
57 { USB_DEVICE(IODATA_VENDOR_ID, IODATA_PRODUCT_ID) }, 58 { USB_DEVICE(IODATA_VENDOR_ID, IODATA_PRODUCT_ID) },
@@ -79,6 +80,7 @@ static struct usb_device_id id_table [] = {
79 { USB_DEVICE(LEADTEK_VENDOR_ID, LEADTEK_9531_PRODUCT_ID) }, 80 { USB_DEVICE(LEADTEK_VENDOR_ID, LEADTEK_9531_PRODUCT_ID) },
80 { USB_DEVICE(SPEEDDRAGON_VENDOR_ID, SPEEDDRAGON_PRODUCT_ID) }, 81 { USB_DEVICE(SPEEDDRAGON_VENDOR_ID, SPEEDDRAGON_PRODUCT_ID) },
81 { USB_DEVICE(OTI_VENDOR_ID, OTI_PRODUCT_ID) }, 82 { USB_DEVICE(OTI_VENDOR_ID, OTI_PRODUCT_ID) },
83 { USB_DEVICE(DATAPILOT_U2_VENDOR_ID, DATAPILOT_U2_PRODUCT_ID) },
82 { } /* Terminating entry */ 84 { } /* Terminating entry */
83}; 85};
84 86
diff --git a/drivers/usb/serial/pl2303.h b/drivers/usb/serial/pl2303.h
index 7f29e81d3e35..d9c1e6e0b4b3 100644
--- a/drivers/usb/serial/pl2303.h
+++ b/drivers/usb/serial/pl2303.h
@@ -10,6 +10,7 @@
10#define PL2303_VENDOR_ID 0x067b 10#define PL2303_VENDOR_ID 0x067b
11#define PL2303_PRODUCT_ID 0x2303 11#define PL2303_PRODUCT_ID 0x2303
12#define PL2303_PRODUCT_ID_RSAQ2 0x04bb 12#define PL2303_PRODUCT_ID_RSAQ2 0x04bb
13#define PL2303_PRODUCT_ID_DCU11 0x1234
13#define PL2303_PRODUCT_ID_PHAROS 0xaaa0 14#define PL2303_PRODUCT_ID_PHAROS 0xaaa0
14#define PL2303_PRODUCT_ID_RSAQ3 0xaaa2 15#define PL2303_PRODUCT_ID_RSAQ3 0xaaa2
15 16
@@ -84,3 +85,7 @@
84/* Ours Technology Inc DKU-5 clone, chipset: Prolific Technology Inc */ 85/* Ours Technology Inc DKU-5 clone, chipset: Prolific Technology Inc */
85#define OTI_VENDOR_ID 0x0ea0 86#define OTI_VENDOR_ID 0x0ea0
86#define OTI_PRODUCT_ID 0x6858 87#define OTI_PRODUCT_ID 0x6858
88
89/* DATAPILOT Universal-2 Phone Cable */
90#define DATAPILOT_U2_VENDOR_ID 0x0731
91#define DATAPILOT_U2_PRODUCT_ID 0x2003
diff --git a/drivers/usb/serial/safe_serial.c b/drivers/usb/serial/safe_serial.c
index 897d8447252b..789771ecdb11 100644
--- a/drivers/usb/serial/safe_serial.c
+++ b/drivers/usb/serial/safe_serial.c
@@ -71,7 +71,7 @@
71#include <linux/spinlock.h> 71#include <linux/spinlock.h>
72#include <asm/uaccess.h> 72#include <asm/uaccess.h>
73#include <linux/usb.h> 73#include <linux/usb.h>
74#include "usb-serial.h" 74#include <linux/usb/serial.h>
75 75
76 76
77#ifndef CONFIG_USB_SAFE_PADDED 77#ifndef CONFIG_USB_SAFE_PADDED
diff --git a/drivers/usb/serial/sierra.c b/drivers/usb/serial/sierra.c
new file mode 100644
index 000000000000..d29638daa987
--- /dev/null
+++ b/drivers/usb/serial/sierra.c
@@ -0,0 +1,75 @@
1/*
2 * Sierra Wireless CDMA Wireless Serial USB driver
3 *
4 * Current Copy modified by: Kevin Lloyd <linux@sierrawireless.com>
5 * Original Copyright (C) 2005-2006 Greg Kroah-Hartman <gregkh@suse.de>
6 *
7 * This program is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU General Public License version
9 * 2 as published by the Free Software Foundation.
10 */
11
12#include <linux/kernel.h>
13#include <linux/init.h>
14#include <linux/tty.h>
15#include <linux/module.h>
16#include <linux/usb.h>
17#include <linux/usb/serial.h>
18
19static struct usb_device_id id_table [] = {
20 { USB_DEVICE(0x1199, 0x0018) }, /* Sierra Wireless MC5720 */
21 { USB_DEVICE(0x1199, 0x0020) }, /* Sierra Wireless MC5725 */
22 { USB_DEVICE(0x1199, 0x0017) }, /* Sierra Wireless EM5625 */
23 { USB_DEVICE(0x1199, 0x0019) }, /* Sierra Wireless AirCard 595 */
24 { USB_DEVICE(0x1199, 0x6802) }, /* Sierra Wireless MC8755 */
25 { USB_DEVICE(0x1199, 0x6803) }, /* Sierra Wireless MC8765 */
26 { USB_DEVICE(0x1199, 0x6812) }, /* Sierra Wireless MC8775 */
27 { USB_DEVICE(0x1199, 0x6820) }, /* Sierra Wireless AirCard 875 */
28 /* Following devices are supported in the airprime.c driver */
29 /* { USB_DEVICE(0x1199, 0x0112) }, */ /* Sierra Wireless AirCard 580 */
30 /* { USB_DEVICE(0x0F3D, 0x0112) }, */ /* AirPrime/Sierra PC 5220 */
31 { }
32};
33MODULE_DEVICE_TABLE(usb, id_table);
34
35static struct usb_driver sierra_driver = {
36 .name = "sierra_wireless",
37 .probe = usb_serial_probe,
38 .disconnect = usb_serial_disconnect,
39 .id_table = id_table,
40};
41
42static struct usb_serial_driver sierra_device = {
43 .driver = {
44 .owner = THIS_MODULE,
45 .name = "Sierra_Wireless",
46 },
47 .id_table = id_table,
48 .num_interrupt_in = NUM_DONT_CARE,
49 .num_bulk_in = NUM_DONT_CARE,
50 .num_bulk_out = NUM_DONT_CARE,
51 .num_ports = 3,
52};
53
54static int __init sierra_init(void)
55{
56 int retval;
57
58 retval = usb_serial_register(&sierra_device);
59 if (retval)
60 return retval;
61 retval = usb_register(&sierra_driver);
62 if (retval)
63 usb_serial_deregister(&sierra_device);
64 return retval;
65}
66
67static void __exit sierra_exit(void)
68{
69 usb_deregister(&sierra_driver);
70 usb_serial_deregister(&sierra_device);
71}
72
73module_init(sierra_init);
74module_exit(sierra_exit);
75MODULE_LICENSE("GPL");
diff --git a/drivers/usb/serial/ti_usb_3410_5052.c b/drivers/usb/serial/ti_usb_3410_5052.c
index a9afff31a921..ac9b8ee52d44 100644
--- a/drivers/usb/serial/ti_usb_3410_5052.c
+++ b/drivers/usb/serial/ti_usb_3410_5052.c
@@ -83,8 +83,8 @@
83#include <asm/uaccess.h> 83#include <asm/uaccess.h>
84#include <asm/semaphore.h> 84#include <asm/semaphore.h>
85#include <linux/usb.h> 85#include <linux/usb.h>
86#include <linux/usb/serial.h>
86 87
87#include "usb-serial.h"
88#include "ti_usb_3410_5052.h" 88#include "ti_usb_3410_5052.h"
89#include "ti_fw_3410.h" /* firmware image for 3410 */ 89#include "ti_fw_3410.h" /* firmware image for 3410 */
90#include "ti_fw_5052.h" /* firmware image for 5052 */ 90#include "ti_fw_5052.h" /* firmware image for 5052 */
diff --git a/drivers/usb/serial/usb-serial.c b/drivers/usb/serial/usb-serial.c
index b59a0536ea5c..12c1694d322e 100644
--- a/drivers/usb/serial/usb-serial.c
+++ b/drivers/usb/serial/usb-serial.c
@@ -31,7 +31,7 @@
31#include <linux/smp_lock.h> 31#include <linux/smp_lock.h>
32#include <asm/uaccess.h> 32#include <asm/uaccess.h>
33#include <linux/usb.h> 33#include <linux/usb.h>
34#include "usb-serial.h" 34#include <linux/usb/serial.h>
35#include "pl2303.h" 35#include "pl2303.h"
36 36
37/* 37/*
@@ -40,6 +40,8 @@
40#define DRIVER_AUTHOR "Greg Kroah-Hartman, greg@kroah.com, http://www.kroah.com/linux/" 40#define DRIVER_AUTHOR "Greg Kroah-Hartman, greg@kroah.com, http://www.kroah.com/linux/"
41#define DRIVER_DESC "USB Serial Driver core" 41#define DRIVER_DESC "USB Serial Driver core"
42 42
43static void port_free(struct usb_serial_port *port);
44
43/* Driver structure we register with the USB core */ 45/* Driver structure we register with the USB core */
44static struct usb_driver usb_serial_driver = { 46static struct usb_driver usb_serial_driver = {
45 .name = "usbserial", 47 .name = "usbserial",
@@ -146,23 +148,10 @@ static void destroy_serial(struct kref *kref)
146 port = serial->port[i]; 148 port = serial->port[i];
147 if (!port) 149 if (!port)
148 continue; 150 continue;
149 usb_kill_urb(port->read_urb); 151 port_free(port);
150 usb_free_urb(port->read_urb);
151 usb_kill_urb(port->write_urb);
152 usb_free_urb(port->write_urb);
153 usb_kill_urb(port->interrupt_in_urb);
154 usb_free_urb(port->interrupt_in_urb);
155 usb_kill_urb(port->interrupt_out_urb);
156 usb_free_urb(port->interrupt_out_urb);
157 kfree(port->bulk_in_buffer);
158 kfree(port->bulk_out_buffer);
159 kfree(port->interrupt_in_buffer);
160 kfree(port->interrupt_out_buffer);
161 } 152 }
162 } 153 }
163 154
164 flush_scheduled_work(); /* port->work */
165
166 usb_put_dev(serial->dev); 155 usb_put_dev(serial->dev);
167 156
168 /* free up any memory that we allocated */ 157 /* free up any memory that we allocated */
@@ -564,6 +553,11 @@ static void port_release(struct device *dev)
564 struct usb_serial_port *port = to_usb_serial_port(dev); 553 struct usb_serial_port *port = to_usb_serial_port(dev);
565 554
566 dbg ("%s - %s", __FUNCTION__, dev->bus_id); 555 dbg ("%s - %s", __FUNCTION__, dev->bus_id);
556 port_free(port);
557}
558
559static void port_free(struct usb_serial_port *port)
560{
567 usb_kill_urb(port->read_urb); 561 usb_kill_urb(port->read_urb);
568 usb_free_urb(port->read_urb); 562 usb_free_urb(port->read_urb);
569 usb_kill_urb(port->write_urb); 563 usb_kill_urb(port->write_urb);
@@ -576,6 +570,7 @@ static void port_release(struct device *dev)
576 kfree(port->bulk_out_buffer); 570 kfree(port->bulk_out_buffer);
577 kfree(port->interrupt_in_buffer); 571 kfree(port->interrupt_in_buffer);
578 kfree(port->interrupt_out_buffer); 572 kfree(port->interrupt_out_buffer);
573 flush_scheduled_work(); /* port->work */
579 kfree(port); 574 kfree(port);
580} 575}
581 576
diff --git a/drivers/usb/serial/usb-serial.h b/drivers/usb/serial/usb-serial.h
deleted file mode 100644
index 0f2802a60194..000000000000
--- a/drivers/usb/serial/usb-serial.h
+++ /dev/null
@@ -1,300 +0,0 @@
1/*
2 * USB Serial Converter driver
3 *
4 * Copyright (C) 1999 - 2005
5 * Greg Kroah-Hartman (greg@kroah.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 as published by
9 * the Free Software Foundation; either version 2 of the License.
10 *
11 */
12
13
14#ifndef __LINUX_USB_SERIAL_H
15#define __LINUX_USB_SERIAL_H
16
17#include <linux/kref.h>
18#include <linux/mutex.h>
19
20#define SERIAL_TTY_MAJOR 188 /* Nice legal number now */
21#define SERIAL_TTY_MINORS 255 /* loads of devices :) */
22
23#define MAX_NUM_PORTS 8 /* The maximum number of ports one device can grab at once */
24
25/* parity check flag */
26#define RELEVANT_IFLAG(iflag) (iflag & (IGNBRK|BRKINT|IGNPAR|PARMRK|INPCK))
27
28/**
29 * usb_serial_port: structure for the specific ports of a device.
30 * @serial: pointer back to the struct usb_serial owner of this port.
31 * @tty: pointer to the corresponding tty for this port.
32 * @lock: spinlock to grab when updating portions of this structure.
33 * @mutex: mutex used to synchronize serial_open() and serial_close()
34 * access for this port.
35 * @number: the number of the port (the minor number).
36 * @interrupt_in_buffer: pointer to the interrupt in buffer for this port.
37 * @interrupt_in_urb: pointer to the interrupt in struct urb for this port.
38 * @interrupt_in_endpointAddress: endpoint address for the interrupt in pipe
39 * for this port.
40 * @interrupt_out_buffer: pointer to the interrupt out buffer for this port.
41 * @interrupt_out_size: the size of the interrupt_out_buffer, in bytes.
42 * @interrupt_out_urb: pointer to the interrupt out struct urb for this port.
43 * @interrupt_out_endpointAddress: endpoint address for the interrupt out pipe
44 * for this port.
45 * @bulk_in_buffer: pointer to the bulk in buffer for this port.
46 * @read_urb: pointer to the bulk in struct urb for this port.
47 * @bulk_in_endpointAddress: endpoint address for the bulk in pipe for this
48 * port.
49 * @bulk_out_buffer: pointer to the bulk out buffer for this port.
50 * @bulk_out_size: the size of the bulk_out_buffer, in bytes.
51 * @write_urb: pointer to the bulk out struct urb for this port.
52 * @bulk_out_endpointAddress: endpoint address for the bulk out pipe for this
53 * port.
54 * @write_wait: a wait_queue_head_t used by the port.
55 * @work: work queue entry for the line discipline waking up.
56 * @open_count: number of times this port has been opened.
57 *
58 * This structure is used by the usb-serial core and drivers for the specific
59 * ports of a device.
60 */
61struct usb_serial_port {
62 struct usb_serial * serial;
63 struct tty_struct * tty;
64 spinlock_t lock;
65 struct mutex mutex;
66 unsigned char number;
67
68 unsigned char * interrupt_in_buffer;
69 struct urb * interrupt_in_urb;
70 __u8 interrupt_in_endpointAddress;
71
72 unsigned char * interrupt_out_buffer;
73 int interrupt_out_size;
74 struct urb * interrupt_out_urb;
75 __u8 interrupt_out_endpointAddress;
76
77 unsigned char * bulk_in_buffer;
78 int bulk_in_size;
79 struct urb * read_urb;
80 __u8 bulk_in_endpointAddress;
81
82 unsigned char * bulk_out_buffer;
83 int bulk_out_size;
84 struct urb * write_urb;
85 int write_urb_busy;
86 __u8 bulk_out_endpointAddress;
87
88 wait_queue_head_t write_wait;
89 struct work_struct work;
90 int open_count;
91 struct device dev;
92};
93#define to_usb_serial_port(d) container_of(d, struct usb_serial_port, dev)
94
95/* get and set the port private data pointer helper functions */
96static inline void *usb_get_serial_port_data (struct usb_serial_port *port)
97{
98 return dev_get_drvdata(&port->dev);
99}
100
101static inline void usb_set_serial_port_data (struct usb_serial_port *port, void *data)
102{
103 dev_set_drvdata(&port->dev, data);
104}
105
106/**
107 * usb_serial - structure used by the usb-serial core for a device
108 * @dev: pointer to the struct usb_device for this device
109 * @type: pointer to the struct usb_serial_driver for this device
110 * @interface: pointer to the struct usb_interface for this device
111 * @minor: the starting minor number for this device
112 * @num_ports: the number of ports this device has
113 * @num_interrupt_in: number of interrupt in endpoints we have
114 * @num_interrupt_out: number of interrupt out endpoints we have
115 * @num_bulk_in: number of bulk in endpoints we have
116 * @num_bulk_out: number of bulk out endpoints we have
117 * @port: array of struct usb_serial_port structures for the different ports.
118 * @private: place to put any driver specific information that is needed. The
119 * usb-serial driver is required to manage this data, the usb-serial core
120 * will not touch this. Use usb_get_serial_data() and
121 * usb_set_serial_data() to access this.
122 */
123struct usb_serial {
124 struct usb_device * dev;
125 struct usb_serial_driver * type;
126 struct usb_interface * interface;
127 unsigned char minor;
128 unsigned char num_ports;
129 unsigned char num_port_pointers;
130 char num_interrupt_in;
131 char num_interrupt_out;
132 char num_bulk_in;
133 char num_bulk_out;
134 struct usb_serial_port * port[MAX_NUM_PORTS];
135 struct kref kref;
136 void * private;
137};
138#define to_usb_serial(d) container_of(d, struct usb_serial, kref)
139
140#define NUM_DONT_CARE (-1)
141
142/* get and set the serial private data pointer helper functions */
143static inline void *usb_get_serial_data (struct usb_serial *serial)
144{
145 return serial->private;
146}
147
148static inline void usb_set_serial_data (struct usb_serial *serial, void *data)
149{
150 serial->private = data;
151}
152
153/**
154 * usb_serial_driver - describes a usb serial driver
155 * @description: pointer to a string that describes this driver. This string used
156 * in the syslog messages when a device is inserted or removed.
157 * @id_table: pointer to a list of usb_device_id structures that define all
158 * of the devices this structure can support.
159 * @num_interrupt_in: the number of interrupt in endpoints this device will
160 * have.
161 * @num_interrupt_out: the number of interrupt out endpoints this device will
162 * have.
163 * @num_bulk_in: the number of bulk in endpoints this device will have.
164 * @num_bulk_out: the number of bulk out endpoints this device will have.
165 * @num_ports: the number of different ports this device will have.
166 * @calc_num_ports: pointer to a function to determine how many ports this
167 * device has dynamically. It will be called after the probe()
168 * callback is called, but before attach()
169 * @probe: pointer to the driver's probe function.
170 * This will be called when the device is inserted into the system,
171 * but before the device has been fully initialized by the usb_serial
172 * subsystem. Use this function to download any firmware to the device,
173 * or any other early initialization that might be needed.
174 * Return 0 to continue on with the initialization sequence. Anything
175 * else will abort it.
176 * @attach: pointer to the driver's attach function.
177 * This will be called when the struct usb_serial structure is fully set
178 * set up. Do any local initialization of the device, or any private
179 * memory structure allocation at this point in time.
180 * @shutdown: pointer to the driver's shutdown function. This will be
181 * called when the device is removed from the system.
182 *
183 * This structure is defines a USB Serial driver. It provides all of
184 * the information that the USB serial core code needs. If the function
185 * pointers are defined, then the USB serial core code will call them when
186 * the corresponding tty port functions are called. If they are not
187 * called, the generic serial function will be used instead.
188 *
189 * The driver.owner field should be set to the module owner of this driver.
190 * The driver.name field should be set to the name of this driver (remember
191 * it will show up in sysfs, so it needs to be short and to the point.
192 * Useing the module name is a good idea.)
193 */
194struct usb_serial_driver {
195 const char *description;
196 const struct usb_device_id *id_table;
197 char num_interrupt_in;
198 char num_interrupt_out;
199 char num_bulk_in;
200 char num_bulk_out;
201 char num_ports;
202
203 struct list_head driver_list;
204 struct device_driver driver;
205
206 int (*probe) (struct usb_serial *serial, const struct usb_device_id *id);
207 int (*attach) (struct usb_serial *serial);
208 int (*calc_num_ports) (struct usb_serial *serial);
209
210 void (*shutdown) (struct usb_serial *serial);
211
212 int (*port_probe) (struct usb_serial_port *port);
213 int (*port_remove) (struct usb_serial_port *port);
214
215 /* serial function calls */
216 int (*open) (struct usb_serial_port *port, struct file * filp);
217 void (*close) (struct usb_serial_port *port, struct file * filp);
218 int (*write) (struct usb_serial_port *port, const unsigned char *buf, int count);
219 int (*write_room) (struct usb_serial_port *port);
220 int (*ioctl) (struct usb_serial_port *port, struct file * file, unsigned int cmd, unsigned long arg);
221 void (*set_termios) (struct usb_serial_port *port, struct termios * old);
222 void (*break_ctl) (struct usb_serial_port *port, int break_state);
223 int (*chars_in_buffer) (struct usb_serial_port *port);
224 void (*throttle) (struct usb_serial_port *port);
225 void (*unthrottle) (struct usb_serial_port *port);
226 int (*tiocmget) (struct usb_serial_port *port, struct file *file);
227 int (*tiocmset) (struct usb_serial_port *port, struct file *file, unsigned int set, unsigned int clear);
228
229 void (*read_int_callback)(struct urb *urb, struct pt_regs *regs);
230 void (*write_int_callback)(struct urb *urb, struct pt_regs *regs);
231 void (*read_bulk_callback)(struct urb *urb, struct pt_regs *regs);
232 void (*write_bulk_callback)(struct urb *urb, struct pt_regs *regs);
233};
234#define to_usb_serial_driver(d) container_of(d, struct usb_serial_driver, driver)
235
236extern int usb_serial_register(struct usb_serial_driver *driver);
237extern void usb_serial_deregister(struct usb_serial_driver *driver);
238extern void usb_serial_port_softint(struct usb_serial_port *port);
239
240extern int usb_serial_probe(struct usb_interface *iface, const struct usb_device_id *id);
241extern void usb_serial_disconnect(struct usb_interface *iface);
242
243extern int ezusb_writememory (struct usb_serial *serial, int address, unsigned char *data, int length, __u8 bRequest);
244extern int ezusb_set_reset (struct usb_serial *serial, unsigned char reset_bit);
245
246/* USB Serial console functions */
247#ifdef CONFIG_USB_SERIAL_CONSOLE
248extern void usb_serial_console_init (int debug, int minor);
249extern void usb_serial_console_exit (void);
250extern void usb_serial_console_disconnect(struct usb_serial *serial);
251#else
252static inline void usb_serial_console_init (int debug, int minor) { }
253static inline void usb_serial_console_exit (void) { }
254static inline void usb_serial_console_disconnect(struct usb_serial *serial) {}
255#endif
256
257/* Functions needed by other parts of the usbserial core */
258extern struct usb_serial *usb_serial_get_by_index (unsigned int minor);
259extern void usb_serial_put(struct usb_serial *serial);
260extern int usb_serial_generic_open (struct usb_serial_port *port, struct file *filp);
261extern int usb_serial_generic_write (struct usb_serial_port *port, const unsigned char *buf, int count);
262extern void usb_serial_generic_close (struct usb_serial_port *port, struct file *filp);
263extern int usb_serial_generic_write_room (struct usb_serial_port *port);
264extern int usb_serial_generic_chars_in_buffer (struct usb_serial_port *port);
265extern void usb_serial_generic_read_bulk_callback (struct urb *urb, struct pt_regs *regs);
266extern void usb_serial_generic_write_bulk_callback (struct urb *urb, struct pt_regs *regs);
267extern void usb_serial_generic_shutdown (struct usb_serial *serial);
268extern int usb_serial_generic_register (int debug);
269extern void usb_serial_generic_deregister (void);
270
271extern int usb_serial_bus_register (struct usb_serial_driver *device);
272extern void usb_serial_bus_deregister (struct usb_serial_driver *device);
273
274extern struct usb_serial_driver usb_serial_generic_device;
275extern struct bus_type usb_serial_bus_type;
276extern struct tty_driver *usb_serial_tty_driver;
277
278static inline void usb_serial_debug_data(int debug,
279 struct device *dev,
280 const char *function, int size,
281 const unsigned char *data)
282{
283 int i;
284
285 if (debug) {
286 dev_printk(KERN_DEBUG, dev, "%s - length = %d, data = ", function, size);
287 for (i = 0; i < size; ++i)
288 printk ("%.2x ", data[i]);
289 printk ("\n");
290 }
291}
292
293/* Use our own dbg macro */
294#undef dbg
295#define dbg(format, arg...) do { if (debug) printk(KERN_DEBUG "%s: " format "\n" , __FILE__ , ## arg); } while (0)
296
297
298
299#endif /* ifdef __LINUX_USB_SERIAL_H */
300
diff --git a/drivers/usb/serial/visor.c b/drivers/usb/serial/visor.c
index 95a2936e902e..88949f7884ca 100644
--- a/drivers/usb/serial/visor.c
+++ b/drivers/usb/serial/visor.c
@@ -25,7 +25,7 @@
25#include <linux/spinlock.h> 25#include <linux/spinlock.h>
26#include <asm/uaccess.h> 26#include <asm/uaccess.h>
27#include <linux/usb.h> 27#include <linux/usb.h>
28#include "usb-serial.h" 28#include <linux/usb/serial.h>
29#include "visor.h" 29#include "visor.h"
30 30
31/* 31/*
@@ -302,7 +302,6 @@ static int visor_open (struct usb_serial_port *port, struct file *filp)
302 spin_lock_irqsave(&priv->lock, flags); 302 spin_lock_irqsave(&priv->lock, flags);
303 priv->bytes_in = 0; 303 priv->bytes_in = 0;
304 priv->bytes_out = 0; 304 priv->bytes_out = 0;
305 priv->outstanding_urbs = 0;
306 priv->throttled = 0; 305 priv->throttled = 0;
307 spin_unlock_irqrestore(&priv->lock, flags); 306 spin_unlock_irqrestore(&priv->lock, flags);
308 307
@@ -435,13 +434,25 @@ static int visor_write (struct usb_serial_port *port, const unsigned char *buf,
435 434
436static int visor_write_room (struct usb_serial_port *port) 435static int visor_write_room (struct usb_serial_port *port)
437{ 436{
437 struct visor_private *priv = usb_get_serial_port_data(port);
438 unsigned long flags;
439
438 dbg("%s - port %d", __FUNCTION__, port->number); 440 dbg("%s - port %d", __FUNCTION__, port->number);
439 441
440 /* 442 /*
441 * We really can take anything the user throws at us 443 * We really can take anything the user throws at us
442 * but let's pick a nice big number to tell the tty 444 * but let's pick a nice big number to tell the tty
443 * layer that we have lots of free space 445 * layer that we have lots of free space, unless we don't.
444 */ 446 */
447
448 spin_lock_irqsave(&priv->lock, flags);
449 if (priv->outstanding_urbs > URB_UPPER_LIMIT * 2 / 3) {
450 spin_unlock_irqrestore(&priv->lock, flags);
451 dbg("%s - write limit hit\n", __FUNCTION__);
452 return 0;
453 }
454 spin_unlock_irqrestore(&priv->lock, flags);
455
445 return 2048; 456 return 2048;
446} 457}
447 458
@@ -758,15 +769,22 @@ static int visor_calc_num_ports (struct usb_serial *serial)
758 769
759static int generic_startup(struct usb_serial *serial) 770static int generic_startup(struct usb_serial *serial)
760{ 771{
772 struct usb_serial_port **ports = serial->port;
761 struct visor_private *priv; 773 struct visor_private *priv;
762 int i; 774 int i;
763 775
764 for (i = 0; i < serial->num_ports; ++i) { 776 for (i = 0; i < serial->num_ports; ++i) {
765 priv = kzalloc (sizeof(*priv), GFP_KERNEL); 777 priv = kzalloc (sizeof(*priv), GFP_KERNEL);
766 if (!priv) 778 if (!priv) {
779 while (i-- != 0) {
780 priv = usb_get_serial_port_data(ports[i]);
781 usb_set_serial_port_data(ports[i], NULL);
782 kfree(priv);
783 }
767 return -ENOMEM; 784 return -ENOMEM;
785 }
768 spin_lock_init(&priv->lock); 786 spin_lock_init(&priv->lock);
769 usb_set_serial_port_data(serial->port[i], priv); 787 usb_set_serial_port_data(ports[i], priv);
770 } 788 }
771 return 0; 789 return 0;
772} 790}
@@ -876,7 +894,18 @@ static int clie_5_attach (struct usb_serial *serial)
876 894
877static void visor_shutdown (struct usb_serial *serial) 895static void visor_shutdown (struct usb_serial *serial)
878{ 896{
897 struct visor_private *priv;
898 int i;
899
879 dbg("%s", __FUNCTION__); 900 dbg("%s", __FUNCTION__);
901
902 for (i = 0; i < serial->num_ports; i++) {
903 priv = usb_get_serial_port_data(serial->port[i]);
904 if (priv) {
905 usb_set_serial_port_data(serial->port[i], NULL);
906 kfree(priv);
907 }
908 }
880} 909}
881 910
882static int visor_ioctl (struct usb_serial_port *port, struct file * file, unsigned int cmd, unsigned long arg) 911static int visor_ioctl (struct usb_serial_port *port, struct file * file, unsigned int cmd, unsigned long arg)
diff --git a/drivers/usb/serial/whiteheat.c b/drivers/usb/serial/whiteheat.c
index 540438c3f381..6e6c7934be32 100644
--- a/drivers/usb/serial/whiteheat.c
+++ b/drivers/usb/serial/whiteheat.c
@@ -79,7 +79,7 @@
79#include <linux/usb.h> 79#include <linux/usb.h>
80#include <linux/serial_reg.h> 80#include <linux/serial_reg.h>
81#include <linux/serial.h> 81#include <linux/serial.h>
82#include "usb-serial.h" 82#include <linux/usb/serial.h>
83#include "whiteheat_fw.h" /* firmware for the ConnectTech WhiteHEAT device */ 83#include "whiteheat_fw.h" /* firmware for the ConnectTech WhiteHEAT device */
84#include "whiteheat.h" /* WhiteHEAT specific commands */ 84#include "whiteheat.h" /* WhiteHEAT specific commands */
85 85