aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/usb/serial
diff options
context:
space:
mode:
authorPaul Mackerras <paulus@samba.org>2007-04-29 22:38:01 -0400
committerPaul Mackerras <paulus@samba.org>2007-04-29 22:38:01 -0400
commit49e1900d4cc2e7bcecb681fe60f0990bec2dcce8 (patch)
tree253801ebf57e0a23856a2c7be129c2c178f62fdf /drivers/usb/serial
parent34f6d749c0a328817d5e36274e53121c1db734dc (diff)
parentb9099ff63c75216d6ca10bce5a1abcd9293c27e6 (diff)
Merge branch 'linux-2.6' into for-2.6.22
Diffstat (limited to 'drivers/usb/serial')
-rw-r--r--drivers/usb/serial/Kconfig6
-rw-r--r--drivers/usb/serial/aircable.c7
-rw-r--r--drivers/usb/serial/ark3116.c3
-rw-r--r--drivers/usb/serial/cp2101.c2
-rw-r--r--drivers/usb/serial/ftdi_sio.c23
-rw-r--r--drivers/usb/serial/ftdi_sio.h1
-rw-r--r--drivers/usb/serial/io_edgeport.c139
-rw-r--r--drivers/usb/serial/io_edgeport.h6
-rw-r--r--drivers/usb/serial/ipaq.c1
-rw-r--r--drivers/usb/serial/kl5kusb105.c28
-rw-r--r--drivers/usb/serial/mct_u232.c12
-rw-r--r--drivers/usb/serial/mos7720.c34
-rw-r--r--drivers/usb/serial/mos7840.c233
-rw-r--r--drivers/usb/serial/omninet.c40
-rw-r--r--drivers/usb/serial/option.c23
-rw-r--r--drivers/usb/serial/sierra.c25
-rw-r--r--drivers/usb/serial/visor.c22
-rw-r--r--drivers/usb/serial/whiteheat.c8
-rw-r--r--drivers/usb/serial/whiteheat.h4
19 files changed, 365 insertions, 252 deletions
diff --git a/drivers/usb/serial/Kconfig b/drivers/usb/serial/Kconfig
index 2f4d303ee36f..ba5d1dc03036 100644
--- a/drivers/usb/serial/Kconfig
+++ b/drivers/usb/serial/Kconfig
@@ -423,11 +423,11 @@ config USB_SERIAL_MCT_U232
423 module will be called mct_u232. 423 module will be called mct_u232.
424 424
425config USB_SERIAL_MOS7720 425config USB_SERIAL_MOS7720
426 tristate "USB Moschip 7720 Single Port Serial Driver" 426 tristate "USB Moschip 7720 Serial Driver"
427 depends on USB_SERIAL 427 depends on USB_SERIAL
428 ---help--- 428 ---help---
429 Say Y here if you want to use a USB Serial single port adapter from 429 Say Y here if you want to use USB Serial single and double
430 Moschip Semiconductor Tech. 430 port adapters from Moschip Semiconductor Tech.
431 431
432 To compile this driver as a module, choose M here: the 432 To compile this driver as a module, choose M here: the
433 module will be called mos7720. 433 module will be called mos7720.
diff --git a/drivers/usb/serial/aircable.c b/drivers/usb/serial/aircable.c
index 11dad42c3c60..b675735bfbee 100644
--- a/drivers/usb/serial/aircable.c
+++ b/drivers/usb/serial/aircable.c
@@ -209,6 +209,7 @@ static void aircable_send(struct usb_serial_port *port)
209 int count, result; 209 int count, result;
210 struct aircable_private *priv = usb_get_serial_port_data(port); 210 struct aircable_private *priv = usb_get_serial_port_data(port);
211 unsigned char* buf; 211 unsigned char* buf;
212 u16 *dbuf;
212 dbg("%s - port %d", __FUNCTION__, port->number); 213 dbg("%s - port %d", __FUNCTION__, port->number);
213 if (port->write_urb_busy) 214 if (port->write_urb_busy)
214 return; 215 return;
@@ -226,8 +227,8 @@ static void aircable_send(struct usb_serial_port *port)
226 227
227 buf[0] = TX_HEADER_0; 228 buf[0] = TX_HEADER_0;
228 buf[1] = TX_HEADER_1; 229 buf[1] = TX_HEADER_1;
229 buf[2] = (unsigned char)count; 230 dbuf = (u16 *)&buf[2];
230 buf[3] = (unsigned char)(count >> 8); 231 *dbuf = cpu_to_le16((u16)count);
231 serial_buf_get(priv->tx_buf,buf + HCI_HEADER_LENGTH, MAX_HCI_FRAMESIZE); 232 serial_buf_get(priv->tx_buf,buf + HCI_HEADER_LENGTH, MAX_HCI_FRAMESIZE);
232 233
233 memcpy(port->write_urb->transfer_buffer, buf, 234 memcpy(port->write_urb->transfer_buffer, buf,
@@ -434,7 +435,7 @@ static void aircable_write_bulk_callback(struct urb *urb)
434 __FUNCTION__, urb->status); 435 __FUNCTION__, urb->status);
435 port->write_urb->transfer_buffer_length = 1; 436 port->write_urb->transfer_buffer_length = 1;
436 port->write_urb->dev = port->serial->dev; 437 port->write_urb->dev = port->serial->dev;
437 result = usb_submit_urb(port->write_urb, GFP_KERNEL); 438 result = usb_submit_urb(port->write_urb, GFP_ATOMIC);
438 if (result) 439 if (result)
439 dev_err(&urb->dev->dev, 440 dev_err(&urb->dev->dev,
440 "%s - failed resubmitting write urb, error %d\n", 441 "%s - failed resubmitting write urb, error %d\n",
diff --git a/drivers/usb/serial/ark3116.c b/drivers/usb/serial/ark3116.c
index edd685791a6b..ea2175bb2274 100644
--- a/drivers/usb/serial/ark3116.c
+++ b/drivers/usb/serial/ark3116.c
@@ -341,7 +341,7 @@ static int ark3116_open(struct usb_serial_port *port, struct file *filp)
341 341
342 result = usb_serial_generic_open(port, filp); 342 result = usb_serial_generic_open(port, filp);
343 if (result) 343 if (result)
344 return result; 344 goto err_out;
345 345
346 /* open */ 346 /* open */
347 ARK3116_RCV(serial, 111, 0xFE, 0xC0, 0x0000, 0x0003, 0x02, buf); 347 ARK3116_RCV(serial, 111, 0xFE, 0xC0, 0x0000, 0x0003, 0x02, buf);
@@ -372,6 +372,7 @@ static int ark3116_open(struct usb_serial_port *port, struct file *filp)
372 if (port->tty) 372 if (port->tty)
373 ark3116_set_termios(port, &tmp_termios); 373 ark3116_set_termios(port, &tmp_termios);
374 374
375err_out:
375 kfree(buf); 376 kfree(buf);
376 377
377 return result; 378 return result;
diff --git a/drivers/usb/serial/cp2101.c b/drivers/usb/serial/cp2101.c
index d7d0ba986a80..e831cb7f64fd 100644
--- a/drivers/usb/serial/cp2101.c
+++ b/drivers/usb/serial/cp2101.c
@@ -58,9 +58,11 @@ static struct usb_device_id id_table [] = {
58 { USB_DEVICE(0x10AB, 0x10C5) }, /* Siemens MC60 Cable */ 58 { USB_DEVICE(0x10AB, 0x10C5) }, /* Siemens MC60 Cable */
59 { USB_DEVICE(0x10B5, 0xAC70) }, /* Nokia CA-42 USB */ 59 { USB_DEVICE(0x10B5, 0xAC70) }, /* Nokia CA-42 USB */
60 { USB_DEVICE(0x10C4, 0x803B) }, /* Pololu USB-serial converter */ 60 { USB_DEVICE(0x10C4, 0x803B) }, /* Pololu USB-serial converter */
61 { USB_DEVICE(0x10C4, 0x8053) }, /* Enfora EDG1228 */
61 { USB_DEVICE(0x10C4, 0x8066) }, /* Argussoft In-System Programmer */ 62 { USB_DEVICE(0x10C4, 0x8066) }, /* Argussoft In-System Programmer */
62 { USB_DEVICE(0x10C4, 0x807A) }, /* Crumb128 board */ 63 { USB_DEVICE(0x10C4, 0x807A) }, /* Crumb128 board */
63 { USB_DEVICE(0x10C4, 0x80CA) }, /* Degree Controls Inc */ 64 { USB_DEVICE(0x10C4, 0x80CA) }, /* Degree Controls Inc */
65 { USB_DEVICE(0x10C4, 0x80DD) }, /* Tracient RFID */
64 { USB_DEVICE(0x10C4, 0x80F6) }, /* Suunto sports instrument */ 66 { USB_DEVICE(0x10C4, 0x80F6) }, /* Suunto sports instrument */
65 { USB_DEVICE(0x10C4, 0x813D) }, /* Burnside Telecom Deskmobile */ 67 { USB_DEVICE(0x10C4, 0x813D) }, /* Burnside Telecom Deskmobile */
66 { USB_DEVICE(0x10C4, 0x814A) }, /* West Mountain Radio RIGblaster P&P */ 68 { USB_DEVICE(0x10C4, 0x814A) }, /* West Mountain Radio RIGblaster P&P */
diff --git a/drivers/usb/serial/ftdi_sio.c b/drivers/usb/serial/ftdi_sio.c
index 8ff9d54b21e6..95a1805b064f 100644
--- a/drivers/usb/serial/ftdi_sio.c
+++ b/drivers/usb/serial/ftdi_sio.c
@@ -342,6 +342,7 @@ static struct usb_device_id id_table_combined [] = {
342 { USB_DEVICE(FTDI_VID, FTDI_PERLE_ULTRAPORT_PID) }, 342 { USB_DEVICE(FTDI_VID, FTDI_PERLE_ULTRAPORT_PID) },
343 { USB_DEVICE(FTDI_VID, FTDI_PIEGROUP_PID) }, 343 { USB_DEVICE(FTDI_VID, FTDI_PIEGROUP_PID) },
344 { USB_DEVICE(FTDI_VID, FTDI_TNC_X_PID) }, 344 { USB_DEVICE(FTDI_VID, FTDI_TNC_X_PID) },
345 { USB_DEVICE(FTDI_VID, FTDI_USBX_707_PID) },
345 { USB_DEVICE(SEALEVEL_VID, SEALEVEL_2101_PID) }, 346 { USB_DEVICE(SEALEVEL_VID, SEALEVEL_2101_PID) },
346 { USB_DEVICE(SEALEVEL_VID, SEALEVEL_2102_PID) }, 347 { USB_DEVICE(SEALEVEL_VID, SEALEVEL_2102_PID) },
347 { USB_DEVICE(SEALEVEL_VID, SEALEVEL_2103_PID) }, 348 { USB_DEVICE(SEALEVEL_VID, SEALEVEL_2103_PID) },
@@ -1433,6 +1434,7 @@ static int ftdi_write (struct usb_serial_port *port,
1433 dbg("%s - write limit hit\n", __FUNCTION__); 1434 dbg("%s - write limit hit\n", __FUNCTION__);
1434 return 0; 1435 return 0;
1435 } 1436 }
1437 priv->tx_outstanding_urbs++;
1436 spin_unlock_irqrestore(&priv->tx_lock, flags); 1438 spin_unlock_irqrestore(&priv->tx_lock, flags);
1437 1439
1438 data_offset = priv->write_offset; 1440 data_offset = priv->write_offset;
@@ -1450,14 +1452,15 @@ static int ftdi_write (struct usb_serial_port *port,
1450 buffer = kmalloc (transfer_size, GFP_ATOMIC); 1452 buffer = kmalloc (transfer_size, GFP_ATOMIC);
1451 if (!buffer) { 1453 if (!buffer) {
1452 err("%s ran out of kernel memory for urb ...", __FUNCTION__); 1454 err("%s ran out of kernel memory for urb ...", __FUNCTION__);
1453 return -ENOMEM; 1455 count = -ENOMEM;
1456 goto error_no_buffer;
1454 } 1457 }
1455 1458
1456 urb = usb_alloc_urb(0, GFP_ATOMIC); 1459 urb = usb_alloc_urb(0, GFP_ATOMIC);
1457 if (!urb) { 1460 if (!urb) {
1458 err("%s - no more free urbs", __FUNCTION__); 1461 err("%s - no more free urbs", __FUNCTION__);
1459 kfree (buffer); 1462 count = -ENOMEM;
1460 return -ENOMEM; 1463 goto error_no_urb;
1461 } 1464 }
1462 1465
1463 /* Copy data */ 1466 /* Copy data */
@@ -1499,10 +1502,9 @@ static int ftdi_write (struct usb_serial_port *port,
1499 if (status) { 1502 if (status) {
1500 err("%s - failed submitting write urb, error %d", __FUNCTION__, status); 1503 err("%s - failed submitting write urb, error %d", __FUNCTION__, status);
1501 count = status; 1504 count = status;
1502 kfree (buffer); 1505 goto error;
1503 } else { 1506 } else {
1504 spin_lock_irqsave(&priv->tx_lock, flags); 1507 spin_lock_irqsave(&priv->tx_lock, flags);
1505 ++priv->tx_outstanding_urbs;
1506 priv->tx_outstanding_bytes += count; 1508 priv->tx_outstanding_bytes += count;
1507 priv->tx_bytes += count; 1509 priv->tx_bytes += count;
1508 spin_unlock_irqrestore(&priv->tx_lock, flags); 1510 spin_unlock_irqrestore(&priv->tx_lock, flags);
@@ -1510,10 +1512,19 @@ static int ftdi_write (struct usb_serial_port *port,
1510 1512
1511 /* we are done with this urb, so let the host driver 1513 /* we are done with this urb, so let the host driver
1512 * really free it when it is finished with it */ 1514 * really free it when it is finished with it */
1513 usb_free_urb (urb); 1515 usb_free_urb(urb);
1514 1516
1515 dbg("%s write returning: %d", __FUNCTION__, count); 1517 dbg("%s write returning: %d", __FUNCTION__, count);
1516 return count; 1518 return count;
1519error:
1520 usb_free_urb(urb);
1521error_no_urb:
1522 kfree (buffer);
1523error_no_buffer:
1524 spin_lock_irqsave(&priv->tx_lock, flags);
1525 priv->tx_outstanding_urbs--;
1526 spin_unlock_irqrestore(&priv->tx_lock, flags);
1527 return count;
1517} /* ftdi_write */ 1528} /* ftdi_write */
1518 1529
1519 1530
diff --git a/drivers/usb/serial/ftdi_sio.h b/drivers/usb/serial/ftdi_sio.h
index 513cfe1b768b..77ad0a09b384 100644
--- a/drivers/usb/serial/ftdi_sio.h
+++ b/drivers/usb/serial/ftdi_sio.h
@@ -31,6 +31,7 @@
31#define FTDI_RELAIS_PID 0xFA10 /* Relais device from Rudolf Gugler */ 31#define FTDI_RELAIS_PID 0xFA10 /* Relais device from Rudolf Gugler */
32#define FTDI_NF_RIC_VID 0x0DCD /* Vendor Id */ 32#define FTDI_NF_RIC_VID 0x0DCD /* Vendor Id */
33#define FTDI_NF_RIC_PID 0x0001 /* Product Id */ 33#define FTDI_NF_RIC_PID 0x0001 /* Product Id */
34#define FTDI_USBX_707_PID 0xF857 /* ADSTech IR Blaster USBX-707 */
34 35
35 36
36/* www.canusb.com Lawicel CANUSB device */ 37/* www.canusb.com Lawicel CANUSB device */
diff --git a/drivers/usb/serial/io_edgeport.c b/drivers/usb/serial/io_edgeport.c
index 6a26a2e683a6..18f74ac76565 100644
--- a/drivers/usb/serial/io_edgeport.c
+++ b/drivers/usb/serial/io_edgeport.c
@@ -111,7 +111,7 @@ struct edgeport_port {
111 111
112 struct TxFifo txfifo; /* transmit fifo -- size will be maxTxCredits */ 112 struct TxFifo txfifo; /* transmit fifo -- size will be maxTxCredits */
113 struct urb *write_urb; /* write URB for this port */ 113 struct urb *write_urb; /* write URB for this port */
114 char write_in_progress; /* TRUE while a write URB is outstanding */ 114 bool write_in_progress; /* 'true' while a write URB is outstanding */
115 spinlock_t ep_lock; 115 spinlock_t ep_lock;
116 116
117 __u8 shadowLCR; /* last LCR value received */ 117 __u8 shadowLCR; /* last LCR value received */
@@ -123,11 +123,11 @@ struct edgeport_port {
123 __u8 validDataMask; 123 __u8 validDataMask;
124 __u32 baudRate; 124 __u32 baudRate;
125 125
126 char open; 126 bool open;
127 char openPending; 127 bool openPending;
128 char commandPending; 128 bool commandPending;
129 char closePending; 129 bool closePending;
130 char chaseResponsePending; 130 bool chaseResponsePending;
131 131
132 wait_queue_head_t wait_chase; /* for handling sleeping while waiting for chase to finish */ 132 wait_queue_head_t wait_chase; /* for handling sleeping while waiting for chase to finish */
133 wait_queue_head_t wait_open; /* for handling sleeping while waiting for open to finish */ 133 wait_queue_head_t wait_open; /* for handling sleeping while waiting for open to finish */
@@ -156,7 +156,7 @@ struct edgeport_serial {
156 __u8 bulk_in_endpoint; /* the bulk in endpoint handle */ 156 __u8 bulk_in_endpoint; /* the bulk in endpoint handle */
157 unsigned char * bulk_in_buffer; /* the buffer we use for the bulk in endpoint */ 157 unsigned char * bulk_in_buffer; /* the buffer we use for the bulk in endpoint */
158 struct urb * read_urb; /* our bulk read urb */ 158 struct urb * read_urb; /* our bulk read urb */
159 int read_in_progress; 159 bool read_in_progress;
160 spinlock_t es_lock; 160 spinlock_t es_lock;
161 161
162 __u8 bulk_out_endpoint; /* the bulk out endpoint handle */ 162 __u8 bulk_out_endpoint; /* the bulk out endpoint handle */
@@ -212,7 +212,7 @@ static int debug;
212 212
213static int low_latency = 1; /* tty low latency flag, on by default */ 213static int low_latency = 1; /* tty low latency flag, on by default */
214 214
215static int CmdUrbs = 0; /* Number of outstanding Command Write Urbs */ 215static atomic_t CmdUrbs; /* Number of outstanding Command Write Urbs */
216 216
217 217
218/* local function prototypes */ 218/* local function prototypes */
@@ -631,14 +631,14 @@ static void edge_interrupt_callback (struct urb *urb)
631 if (edge_serial->rxBytesAvail > 0 && 631 if (edge_serial->rxBytesAvail > 0 &&
632 !edge_serial->read_in_progress) { 632 !edge_serial->read_in_progress) {
633 dbg("%s - posting a read", __FUNCTION__); 633 dbg("%s - posting a read", __FUNCTION__);
634 edge_serial->read_in_progress = TRUE; 634 edge_serial->read_in_progress = true;
635 635
636 /* we have pending bytes on the bulk in pipe, send a request */ 636 /* we have pending bytes on the bulk in pipe, send a request */
637 edge_serial->read_urb->dev = edge_serial->serial->dev; 637 edge_serial->read_urb->dev = edge_serial->serial->dev;
638 result = usb_submit_urb(edge_serial->read_urb, GFP_ATOMIC); 638 result = usb_submit_urb(edge_serial->read_urb, GFP_ATOMIC);
639 if (result) { 639 if (result) {
640 dev_err(&edge_serial->serial->dev->dev, "%s - usb_submit_urb(read bulk) failed with result = %d\n", __FUNCTION__, result); 640 dev_err(&edge_serial->serial->dev->dev, "%s - usb_submit_urb(read bulk) failed with result = %d\n", __FUNCTION__, result);
641 edge_serial->read_in_progress = FALSE; 641 edge_serial->read_in_progress = false;
642 } 642 }
643 } 643 }
644 spin_unlock(&edge_serial->es_lock); 644 spin_unlock(&edge_serial->es_lock);
@@ -695,13 +695,13 @@ static void edge_bulk_in_callback (struct urb *urb)
695 695
696 if (urb->status) { 696 if (urb->status) {
697 dbg("%s - nonzero read bulk status received: %d", __FUNCTION__, urb->status); 697 dbg("%s - nonzero read bulk status received: %d", __FUNCTION__, urb->status);
698 edge_serial->read_in_progress = FALSE; 698 edge_serial->read_in_progress = false;
699 return; 699 return;
700 } 700 }
701 701
702 if (urb->actual_length == 0) { 702 if (urb->actual_length == 0) {
703 dbg("%s - read bulk callback with no data", __FUNCTION__); 703 dbg("%s - read bulk callback with no data", __FUNCTION__);
704 edge_serial->read_in_progress = FALSE; 704 edge_serial->read_in_progress = false;
705 return; 705 return;
706 } 706 }
707 707
@@ -725,10 +725,10 @@ static void edge_bulk_in_callback (struct urb *urb)
725 status = usb_submit_urb(edge_serial->read_urb, GFP_ATOMIC); 725 status = usb_submit_urb(edge_serial->read_urb, GFP_ATOMIC);
726 if (status) { 726 if (status) {
727 dev_err(&urb->dev->dev, "%s - usb_submit_urb(read bulk) failed, status = %d\n", __FUNCTION__, status); 727 dev_err(&urb->dev->dev, "%s - usb_submit_urb(read bulk) failed, status = %d\n", __FUNCTION__, status);
728 edge_serial->read_in_progress = FALSE; 728 edge_serial->read_in_progress = false;
729 } 729 }
730 } else { 730 } else {
731 edge_serial->read_in_progress = FALSE; 731 edge_serial->read_in_progress = false;
732 } 732 }
733 733
734 spin_unlock(&edge_serial->es_lock); 734 spin_unlock(&edge_serial->es_lock);
@@ -759,7 +759,7 @@ static void edge_bulk_out_data_callback (struct urb *urb)
759 } 759 }
760 760
761 // Release the Write URB 761 // Release the Write URB
762 edge_port->write_in_progress = FALSE; 762 edge_port->write_in_progress = false;
763 763
764 // Check if more data needs to be sent 764 // Check if more data needs to be sent
765 send_more_port_data((struct edgeport_serial *)(usb_get_serial_data(edge_port->port->serial)), edge_port); 765 send_more_port_data((struct edgeport_serial *)(usb_get_serial_data(edge_port->port->serial)), edge_port);
@@ -779,8 +779,8 @@ static void edge_bulk_out_cmd_callback (struct urb *urb)
779 779
780 dbg("%s", __FUNCTION__); 780 dbg("%s", __FUNCTION__);
781 781
782 CmdUrbs--; 782 atomic_dec(&CmdUrbs);
783 dbg("%s - FREE URB %p (outstanding %d)", __FUNCTION__, urb, CmdUrbs); 783 dbg("%s - FREE URB %p (outstanding %d)", __FUNCTION__, urb, atomic_read(&CmdUrbs));
784 784
785 785
786 /* clean up the transfer buffer */ 786 /* clean up the transfer buffer */
@@ -802,7 +802,7 @@ static void edge_bulk_out_cmd_callback (struct urb *urb)
802 tty_wakeup(tty); 802 tty_wakeup(tty);
803 803
804 /* we have completed the command */ 804 /* we have completed the command */
805 edge_port->commandPending = FALSE; 805 edge_port->commandPending = false;
806 wake_up(&edge_port->wait_command); 806 wake_up(&edge_port->wait_command);
807} 807}
808 808
@@ -868,7 +868,7 @@ static int edge_open (struct usb_serial_port *port, struct file * filp)
868 port0->bulk_in_buffer, 868 port0->bulk_in_buffer,
869 edge_serial->read_urb->transfer_buffer_length, 869 edge_serial->read_urb->transfer_buffer_length,
870 edge_bulk_in_callback, edge_serial); 870 edge_bulk_in_callback, edge_serial);
871 edge_serial->read_in_progress = FALSE; 871 edge_serial->read_in_progress = false;
872 872
873 /* start interrupt read for this edgeport 873 /* start interrupt read for this edgeport
874 * this interrupt will continue as long as the edgeport is connected */ 874 * this interrupt will continue as long as the edgeport is connected */
@@ -890,26 +890,26 @@ static int edge_open (struct usb_serial_port *port, struct file * filp)
890 /* initialize our port settings */ 890 /* initialize our port settings */
891 edge_port->txCredits = 0; /* Can't send any data yet */ 891 edge_port->txCredits = 0; /* Can't send any data yet */
892 edge_port->shadowMCR = MCR_MASTER_IE; /* Must always set this bit to enable ints! */ 892 edge_port->shadowMCR = MCR_MASTER_IE; /* Must always set this bit to enable ints! */
893 edge_port->chaseResponsePending = FALSE; 893 edge_port->chaseResponsePending = false;
894 894
895 /* send a open port command */ 895 /* send a open port command */
896 edge_port->openPending = TRUE; 896 edge_port->openPending = true;
897 edge_port->open = FALSE; 897 edge_port->open = false;
898 response = send_iosp_ext_cmd (edge_port, IOSP_CMD_OPEN_PORT, 0); 898 response = send_iosp_ext_cmd (edge_port, IOSP_CMD_OPEN_PORT, 0);
899 899
900 if (response < 0) { 900 if (response < 0) {
901 dev_err(&port->dev, "%s - error sending open port command\n", __FUNCTION__); 901 dev_err(&port->dev, "%s - error sending open port command\n", __FUNCTION__);
902 edge_port->openPending = FALSE; 902 edge_port->openPending = false;
903 return -ENODEV; 903 return -ENODEV;
904 } 904 }
905 905
906 /* now wait for the port to be completely opened */ 906 /* now wait for the port to be completely opened */
907 wait_event_timeout(edge_port->wait_open, (edge_port->openPending != TRUE), OPEN_TIMEOUT); 907 wait_event_timeout(edge_port->wait_open, !edge_port->openPending, OPEN_TIMEOUT);
908 908
909 if (edge_port->open == FALSE) { 909 if (!edge_port->open) {
910 /* open timed out */ 910 /* open timed out */
911 dbg("%s - open timedout", __FUNCTION__); 911 dbg("%s - open timedout", __FUNCTION__);
912 edge_port->openPending = FALSE; 912 edge_port->openPending = false;
913 return -ENODEV; 913 return -ENODEV;
914 } 914 }
915 915
@@ -928,7 +928,7 @@ static int edge_open (struct usb_serial_port *port, struct file * filp)
928 928
929 /* Allocate a URB for the write */ 929 /* Allocate a URB for the write */
930 edge_port->write_urb = usb_alloc_urb (0, GFP_KERNEL); 930 edge_port->write_urb = usb_alloc_urb (0, GFP_KERNEL);
931 edge_port->write_in_progress = FALSE; 931 edge_port->write_in_progress = false;
932 932
933 if (!edge_port->write_urb) { 933 if (!edge_port->write_urb) {
934 dbg("%s - no memory", __FUNCTION__); 934 dbg("%s - no memory", __FUNCTION__);
@@ -966,7 +966,7 @@ static void block_until_chase_response(struct edgeport_port *edge_port)
966 lastCredits = edge_port->txCredits; 966 lastCredits = edge_port->txCredits;
967 967
968 // Did we get our Chase response 968 // Did we get our Chase response
969 if (edge_port->chaseResponsePending == FALSE) { 969 if (!edge_port->chaseResponsePending) {
970 dbg("%s - Got Chase Response", __FUNCTION__); 970 dbg("%s - Got Chase Response", __FUNCTION__);
971 971
972 // did we get all of our credit back? 972 // did we get all of our credit back?
@@ -985,7 +985,7 @@ static void block_until_chase_response(struct edgeport_port *edge_port)
985 // No activity.. count down. 985 // No activity.. count down.
986 loop--; 986 loop--;
987 if (loop == 0) { 987 if (loop == 0) {
988 edge_port->chaseResponsePending = FALSE; 988 edge_port->chaseResponsePending = false;
989 dbg("%s - Chase TIMEOUT", __FUNCTION__); 989 dbg("%s - Chase TIMEOUT", __FUNCTION__);
990 return; 990 return;
991 } 991 }
@@ -1068,13 +1068,13 @@ static void edge_close (struct usb_serial_port *port, struct file * filp)
1068 // block until tx is empty 1068 // block until tx is empty
1069 block_until_tx_empty(edge_port); 1069 block_until_tx_empty(edge_port);
1070 1070
1071 edge_port->closePending = TRUE; 1071 edge_port->closePending = true;
1072 1072
1073 if ((!edge_serial->is_epic) || 1073 if ((!edge_serial->is_epic) ||
1074 ((edge_serial->is_epic) && 1074 ((edge_serial->is_epic) &&
1075 (edge_serial->epic_descriptor.Supports.IOSPChase))) { 1075 (edge_serial->epic_descriptor.Supports.IOSPChase))) {
1076 /* flush and chase */ 1076 /* flush and chase */
1077 edge_port->chaseResponsePending = TRUE; 1077 edge_port->chaseResponsePending = true;
1078 1078
1079 dbg("%s - Sending IOSP_CMD_CHASE_PORT", __FUNCTION__); 1079 dbg("%s - Sending IOSP_CMD_CHASE_PORT", __FUNCTION__);
1080 status = send_iosp_ext_cmd (edge_port, IOSP_CMD_CHASE_PORT, 0); 1080 status = send_iosp_ext_cmd (edge_port, IOSP_CMD_CHASE_PORT, 0);
@@ -1082,7 +1082,7 @@ static void edge_close (struct usb_serial_port *port, struct file * filp)
1082 // block until chase finished 1082 // block until chase finished
1083 block_until_chase_response(edge_port); 1083 block_until_chase_response(edge_port);
1084 } else { 1084 } else {
1085 edge_port->chaseResponsePending = FALSE; 1085 edge_port->chaseResponsePending = false;
1086 } 1086 }
1087 } 1087 }
1088 1088
@@ -1094,10 +1094,10 @@ static void edge_close (struct usb_serial_port *port, struct file * filp)
1094 send_iosp_ext_cmd (edge_port, IOSP_CMD_CLOSE_PORT, 0); 1094 send_iosp_ext_cmd (edge_port, IOSP_CMD_CLOSE_PORT, 0);
1095 } 1095 }
1096 1096
1097 //port->close = TRUE; 1097 //port->close = true;
1098 edge_port->closePending = FALSE; 1098 edge_port->closePending = false;
1099 edge_port->open = FALSE; 1099 edge_port->open = false;
1100 edge_port->openPending = FALSE; 1100 edge_port->openPending = false;
1101 1101
1102 usb_kill_urb(edge_port->write_urb); 1102 usb_kill_urb(edge_port->write_urb);
1103 1103
@@ -1247,7 +1247,7 @@ static void send_more_port_data(struct edgeport_serial *edge_serial, struct edge
1247 } 1247 }
1248 1248
1249 // lock this write 1249 // lock this write
1250 edge_port->write_in_progress = TRUE; 1250 edge_port->write_in_progress = true;
1251 1251
1252 // get a pointer to the write_urb 1252 // get a pointer to the write_urb
1253 urb = edge_port->write_urb; 1253 urb = edge_port->write_urb;
@@ -1261,7 +1261,7 @@ static void send_more_port_data(struct edgeport_serial *edge_serial, struct edge
1261 buffer = kmalloc (count+2, GFP_ATOMIC); 1261 buffer = kmalloc (count+2, GFP_ATOMIC);
1262 if (buffer == NULL) { 1262 if (buffer == NULL) {
1263 dev_err(&edge_port->port->dev, "%s - no more kernel memory...\n", __FUNCTION__); 1263 dev_err(&edge_port->port->dev, "%s - no more kernel memory...\n", __FUNCTION__);
1264 edge_port->write_in_progress = FALSE; 1264 edge_port->write_in_progress = false;
1265 goto exit_send; 1265 goto exit_send;
1266 } 1266 }
1267 buffer[0] = IOSP_BUILD_DATA_HDR1 (edge_port->port->number - edge_port->port->serial->minor, count); 1267 buffer[0] = IOSP_BUILD_DATA_HDR1 (edge_port->port->number - edge_port->port->serial->minor, count);
@@ -1301,7 +1301,7 @@ static void send_more_port_data(struct edgeport_serial *edge_serial, struct edge
1301 if (status) { 1301 if (status) {
1302 /* something went wrong */ 1302 /* something went wrong */
1303 dev_err(&edge_port->port->dev, "%s - usb_submit_urb(write bulk) failed, status = %d, data lost\n", __FUNCTION__, status); 1303 dev_err(&edge_port->port->dev, "%s - usb_submit_urb(write bulk) failed, status = %d, data lost\n", __FUNCTION__, status);
1304 edge_port->write_in_progress = FALSE; 1304 edge_port->write_in_progress = false;
1305 1305
1306 /* revert the credits as something bad happened. */ 1306 /* revert the credits as something bad happened. */
1307 edge_port->txCredits += count; 1307 edge_port->txCredits += count;
@@ -1332,7 +1332,7 @@ static int edge_write_room (struct usb_serial_port *port)
1332 1332
1333 if (edge_port == NULL) 1333 if (edge_port == NULL)
1334 return -ENODEV; 1334 return -ENODEV;
1335 if (edge_port->closePending == TRUE) 1335 if (edge_port->closePending)
1336 return -ENODEV; 1336 return -ENODEV;
1337 1337
1338 dbg("%s - port %d", __FUNCTION__, port->number); 1338 dbg("%s - port %d", __FUNCTION__, port->number);
@@ -1371,7 +1371,7 @@ static int edge_chars_in_buffer (struct usb_serial_port *port)
1371 1371
1372 if (edge_port == NULL) 1372 if (edge_port == NULL)
1373 return -ENODEV; 1373 return -ENODEV;
1374 if (edge_port->closePending == TRUE) 1374 if (edge_port->closePending)
1375 return -ENODEV; 1375 return -ENODEV;
1376 1376
1377 if (!edge_port->open) { 1377 if (!edge_port->open) {
@@ -1762,7 +1762,7 @@ static void edge_break (struct usb_serial_port *port, int break_state)
1762 ((edge_serial->is_epic) && 1762 ((edge_serial->is_epic) &&
1763 (edge_serial->epic_descriptor.Supports.IOSPChase))) { 1763 (edge_serial->epic_descriptor.Supports.IOSPChase))) {
1764 /* flush and chase */ 1764 /* flush and chase */
1765 edge_port->chaseResponsePending = TRUE; 1765 edge_port->chaseResponsePending = true;
1766 1766
1767 dbg("%s - Sending IOSP_CMD_CHASE_PORT", __FUNCTION__); 1767 dbg("%s - Sending IOSP_CMD_CHASE_PORT", __FUNCTION__);
1768 status = send_iosp_ext_cmd (edge_port, IOSP_CMD_CHASE_PORT, 0); 1768 status = send_iosp_ext_cmd (edge_port, IOSP_CMD_CHASE_PORT, 0);
@@ -1770,7 +1770,7 @@ static void edge_break (struct usb_serial_port *port, int break_state)
1770 // block until chase finished 1770 // block until chase finished
1771 block_until_chase_response(edge_port); 1771 block_until_chase_response(edge_port);
1772 } else { 1772 } else {
1773 edge_port->chaseResponsePending = FALSE; 1773 edge_port->chaseResponsePending = false;
1774 } 1774 }
1775 } 1775 }
1776 1776
@@ -1952,13 +1952,13 @@ static void process_rcvd_status (struct edgeport_serial *edge_serial, __u8 byte2
1952 // Also, we currently clear flag and close the port regardless of content of above's Byte3. 1952 // Also, we currently clear flag and close the port regardless of content of above's Byte3.
1953 // We could choose to do something else when Byte3 says Timeout on Chase from Edgeport, 1953 // We could choose to do something else when Byte3 says Timeout on Chase from Edgeport,
1954 // like wait longer in block_until_chase_response, but for now we don't. 1954 // like wait longer in block_until_chase_response, but for now we don't.
1955 edge_port->chaseResponsePending = FALSE; 1955 edge_port->chaseResponsePending = false;
1956 wake_up (&edge_port->wait_chase); 1956 wake_up (&edge_port->wait_chase);
1957 return; 1957 return;
1958 1958
1959 case IOSP_EXT_STATUS_RX_CHECK_RSP: 1959 case IOSP_EXT_STATUS_RX_CHECK_RSP:
1960 dbg("%s ========== Port %u CHECK_RSP Sequence = %02x =============\n", __FUNCTION__, edge_serial->rxPort, byte3 ); 1960 dbg("%s ========== Port %u CHECK_RSP Sequence = %02x =============\n", __FUNCTION__, edge_serial->rxPort, byte3 );
1961 //Port->RxCheckRsp = TRUE; 1961 //Port->RxCheckRsp = true;
1962 return; 1962 return;
1963 } 1963 }
1964 } 1964 }
@@ -1974,8 +1974,8 @@ static void process_rcvd_status (struct edgeport_serial *edge_serial, __u8 byte2
1974 change_port_settings (edge_port, edge_port->port->tty->termios); 1974 change_port_settings (edge_port, edge_port->port->tty->termios);
1975 1975
1976 /* we have completed the open */ 1976 /* we have completed the open */
1977 edge_port->openPending = FALSE; 1977 edge_port->openPending = false;
1978 edge_port->open = TRUE; 1978 edge_port->open = true;
1979 wake_up(&edge_port->wait_open); 1979 wake_up(&edge_port->wait_open);
1980 return; 1980 return;
1981 } 1981 }
@@ -1983,7 +1983,7 @@ static void process_rcvd_status (struct edgeport_serial *edge_serial, __u8 byte2
1983 // If port is closed, silently discard all rcvd status. We can 1983 // If port is closed, silently discard all rcvd status. We can
1984 // have cases where buffered status is received AFTER the close 1984 // have cases where buffered status is received AFTER the close
1985 // port command is sent to the Edgeport. 1985 // port command is sent to the Edgeport.
1986 if ((!edge_port->open ) || (edge_port->closePending)) { 1986 if (!edge_port->open || edge_port->closePending) {
1987 return; 1987 return;
1988 } 1988 }
1989 1989
@@ -1991,14 +1991,14 @@ static void process_rcvd_status (struct edgeport_serial *edge_serial, __u8 byte2
1991 // Not currently sent by Edgeport 1991 // Not currently sent by Edgeport
1992 case IOSP_STATUS_LSR: 1992 case IOSP_STATUS_LSR:
1993 dbg("%s - Port %u LSR Status = %02x", __FUNCTION__, edge_serial->rxPort, byte2); 1993 dbg("%s - Port %u LSR Status = %02x", __FUNCTION__, edge_serial->rxPort, byte2);
1994 handle_new_lsr (edge_port, FALSE, byte2, 0); 1994 handle_new_lsr(edge_port, false, byte2, 0);
1995 break; 1995 break;
1996 1996
1997 case IOSP_STATUS_LSR_DATA: 1997 case IOSP_STATUS_LSR_DATA:
1998 dbg("%s - Port %u LSR Status = %02x, Data = %02x", __FUNCTION__, edge_serial->rxPort, byte2, byte3); 1998 dbg("%s - Port %u LSR Status = %02x, Data = %02x", __FUNCTION__, edge_serial->rxPort, byte2, byte3);
1999 // byte2 is LSR Register 1999 // byte2 is LSR Register
2000 // byte3 is broken data byte 2000 // byte3 is broken data byte
2001 handle_new_lsr (edge_port, TRUE, byte2, byte3); 2001 handle_new_lsr(edge_port, true, byte2, byte3);
2002 break; 2002 break;
2003 // 2003 //
2004 // case IOSP_EXT_4_STATUS: 2004 // case IOSP_EXT_4_STATUS:
@@ -2317,14 +2317,14 @@ static int write_cmd_usb (struct edgeport_port *edge_port, unsigned char *buffer
2317 if (!urb) 2317 if (!urb)
2318 return -ENOMEM; 2318 return -ENOMEM;
2319 2319
2320 CmdUrbs++; 2320 atomic_inc(&CmdUrbs);
2321 dbg("%s - ALLOCATE URB %p (outstanding %d)", __FUNCTION__, urb, CmdUrbs); 2321 dbg("%s - ALLOCATE URB %p (outstanding %d)", __FUNCTION__, urb, atomic_read(&CmdUrbs));
2322 2322
2323 usb_fill_bulk_urb (urb, edge_serial->serial->dev, 2323 usb_fill_bulk_urb (urb, edge_serial->serial->dev,
2324 usb_sndbulkpipe(edge_serial->serial->dev, edge_serial->bulk_out_endpoint), 2324 usb_sndbulkpipe(edge_serial->serial->dev, edge_serial->bulk_out_endpoint),
2325 buffer, length, edge_bulk_out_cmd_callback, edge_port); 2325 buffer, length, edge_bulk_out_cmd_callback, edge_port);
2326 2326
2327 edge_port->commandPending = TRUE; 2327 edge_port->commandPending = true;
2328 status = usb_submit_urb(urb, GFP_ATOMIC); 2328 status = usb_submit_urb(urb, GFP_ATOMIC);
2329 2329
2330 if (status) { 2330 if (status) {
@@ -2332,16 +2332,16 @@ static int write_cmd_usb (struct edgeport_port *edge_port, unsigned char *buffer
2332 dev_err(&edge_port->port->dev, "%s - usb_submit_urb(write command) failed, status = %d\n", __FUNCTION__, status); 2332 dev_err(&edge_port->port->dev, "%s - usb_submit_urb(write command) failed, status = %d\n", __FUNCTION__, status);
2333 usb_kill_urb(urb); 2333 usb_kill_urb(urb);
2334 usb_free_urb(urb); 2334 usb_free_urb(urb);
2335 CmdUrbs--; 2335 atomic_dec(&CmdUrbs);
2336 return status; 2336 return status;
2337 } 2337 }
2338 2338
2339 // wait for command to finish 2339 // wait for command to finish
2340 timeout = COMMAND_TIMEOUT; 2340 timeout = COMMAND_TIMEOUT;
2341#if 0 2341#if 0
2342 wait_event (&edge_port->wait_command, (edge_port->commandPending == FALSE)); 2342 wait_event (&edge_port->wait_command, !edge_port->commandPending);
2343 2343
2344 if (edge_port->commandPending == TRUE) { 2344 if (edge_port->commandPending) {
2345 /* command timed out */ 2345 /* command timed out */
2346 dbg("%s - command timed out", __FUNCTION__); 2346 dbg("%s - command timed out", __FUNCTION__);
2347 status = -EINVAL; 2347 status = -EINVAL;
@@ -2524,8 +2524,8 @@ static void change_port_settings (struct edgeport_port *edge_port, struct ktermi
2524 2524
2525 dbg("%s - port %d", __FUNCTION__, edge_port->port->number); 2525 dbg("%s - port %d", __FUNCTION__, edge_port->port->number);
2526 2526
2527 if ((!edge_port->open) && 2527 if (!edge_port->open &&
2528 (!edge_port->openPending)) { 2528 !edge_port->openPending) {
2529 dbg("%s - port not opened", __FUNCTION__); 2529 dbg("%s - port not opened", __FUNCTION__);
2530 return; 2530 return;
2531 } 2531 }
@@ -2836,9 +2836,9 @@ static int edge_startup (struct usb_serial *serial)
2836 struct usb_device *dev; 2836 struct usb_device *dev;
2837 int i, j; 2837 int i, j;
2838 int response; 2838 int response;
2839 int interrupt_in_found; 2839 bool interrupt_in_found;
2840 int bulk_in_found; 2840 bool bulk_in_found;
2841 int bulk_out_found; 2841 bool bulk_out_found;
2842 static __u32 descriptor[3] = { EDGE_COMPATIBILITY_MASK0, 2842 static __u32 descriptor[3] = { EDGE_COMPATIBILITY_MASK0,
2843 EDGE_COMPATIBILITY_MASK1, 2843 EDGE_COMPATIBILITY_MASK1,
2844 EDGE_COMPATIBILITY_MASK2 }; 2844 EDGE_COMPATIBILITY_MASK2 };
@@ -2936,14 +2936,14 @@ static int edge_startup (struct usb_serial *serial)
2936 if (edge_serial->is_epic) { 2936 if (edge_serial->is_epic) {
2937 /* EPIC thing, set up our interrupt polling now and our read urb, so 2937 /* EPIC thing, set up our interrupt polling now and our read urb, so
2938 * that the device knows it really is connected. */ 2938 * that the device knows it really is connected. */
2939 interrupt_in_found = bulk_in_found = bulk_out_found = FALSE; 2939 interrupt_in_found = bulk_in_found = bulk_out_found = false;
2940 for (i = 0; i < serial->interface->altsetting[0].desc.bNumEndpoints; ++i) { 2940 for (i = 0; i < serial->interface->altsetting[0].desc.bNumEndpoints; ++i) {
2941 struct usb_endpoint_descriptor *endpoint; 2941 struct usb_endpoint_descriptor *endpoint;
2942 int buffer_size; 2942 int buffer_size;
2943 2943
2944 endpoint = &serial->interface->altsetting[0].endpoint[i].desc; 2944 endpoint = &serial->interface->altsetting[0].endpoint[i].desc;
2945 buffer_size = le16_to_cpu(endpoint->wMaxPacketSize); 2945 buffer_size = le16_to_cpu(endpoint->wMaxPacketSize);
2946 if ((!interrupt_in_found) && 2946 if (!interrupt_in_found &&
2947 (usb_endpoint_is_int_in(endpoint))) { 2947 (usb_endpoint_is_int_in(endpoint))) {
2948 /* we found a interrupt in endpoint */ 2948 /* we found a interrupt in endpoint */
2949 dbg("found interrupt in"); 2949 dbg("found interrupt in");
@@ -2972,10 +2972,10 @@ static int edge_startup (struct usb_serial *serial)
2972 edge_serial, 2972 edge_serial,
2973 endpoint->bInterval); 2973 endpoint->bInterval);
2974 2974
2975 interrupt_in_found = TRUE; 2975 interrupt_in_found = true;
2976 } 2976 }
2977 2977
2978 if ((!bulk_in_found) && 2978 if (!bulk_in_found &&
2979 (usb_endpoint_is_bulk_in(endpoint))) { 2979 (usb_endpoint_is_bulk_in(endpoint))) {
2980 /* we found a bulk in endpoint */ 2980 /* we found a bulk in endpoint */
2981 dbg("found bulk in"); 2981 dbg("found bulk in");
@@ -3001,19 +3001,19 @@ static int edge_startup (struct usb_serial *serial)
3001 endpoint->wMaxPacketSize, 3001 endpoint->wMaxPacketSize,
3002 edge_bulk_in_callback, 3002 edge_bulk_in_callback,
3003 edge_serial); 3003 edge_serial);
3004 bulk_in_found = TRUE; 3004 bulk_in_found = true;
3005 } 3005 }
3006 3006
3007 if ((!bulk_out_found) && 3007 if (!bulk_out_found &&
3008 (usb_endpoint_is_bulk_out(endpoint))) { 3008 (usb_endpoint_is_bulk_out(endpoint))) {
3009 /* we found a bulk out endpoint */ 3009 /* we found a bulk out endpoint */
3010 dbg("found bulk out"); 3010 dbg("found bulk out");
3011 edge_serial->bulk_out_endpoint = endpoint->bEndpointAddress; 3011 edge_serial->bulk_out_endpoint = endpoint->bEndpointAddress;
3012 bulk_out_found = TRUE; 3012 bulk_out_found = true;
3013 } 3013 }
3014 } 3014 }
3015 3015
3016 if ((!interrupt_in_found) || (!bulk_in_found) || (!bulk_out_found)) { 3016 if (!interrupt_in_found || !bulk_in_found || !bulk_out_found) {
3017 err ("Error - the proper endpoints were not found!"); 3017 err ("Error - the proper endpoints were not found!");
3018 return -ENODEV; 3018 return -ENODEV;
3019 } 3019 }
@@ -3083,6 +3083,7 @@ static int __init edgeport_init(void)
3083 retval = usb_register(&io_driver); 3083 retval = usb_register(&io_driver);
3084 if (retval) 3084 if (retval)
3085 goto failed_usb_register; 3085 goto failed_usb_register;
3086 atomic_set(&CmdUrbs, 0);
3086 info(DRIVER_DESC " " DRIVER_VERSION); 3087 info(DRIVER_DESC " " DRIVER_VERSION);
3087 return 0; 3088 return 0;
3088 3089
diff --git a/drivers/usb/serial/io_edgeport.h b/drivers/usb/serial/io_edgeport.h
index 29a913a6daca..cb201c1f67f9 100644
--- a/drivers/usb/serial/io_edgeport.h
+++ b/drivers/usb/serial/io_edgeport.h
@@ -19,12 +19,6 @@
19#define MAX_RS232_PORTS 8 /* Max # of RS-232 ports per device */ 19#define MAX_RS232_PORTS 8 /* Max # of RS-232 ports per device */
20 20
21/* typedefs that the insideout headers need */ 21/* typedefs that the insideout headers need */
22#ifndef TRUE
23 #define TRUE (1)
24#endif
25#ifndef FALSE
26 #define FALSE (0)
27#endif
28#ifndef LOW8 22#ifndef LOW8
29 #define LOW8(a) ((unsigned char)(a & 0xff)) 23 #define LOW8(a) ((unsigned char)(a & 0xff))
30#endif 24#endif
diff --git a/drivers/usb/serial/ipaq.c b/drivers/usb/serial/ipaq.c
index d16e2e1764ad..4df0ec74e0b1 100644
--- a/drivers/usb/serial/ipaq.c
+++ b/drivers/usb/serial/ipaq.c
@@ -255,6 +255,7 @@ static struct usb_device_id ipaq_id_table [] = {
255 { USB_DEVICE(0x04DD, 0x9102) }, /* SHARP WS003SH USB Modem */ 255 { USB_DEVICE(0x04DD, 0x9102) }, /* SHARP WS003SH USB Modem */
256 { USB_DEVICE(0x04DD, 0x9121) }, /* SHARP WS004SH USB Modem */ 256 { USB_DEVICE(0x04DD, 0x9121) }, /* SHARP WS004SH USB Modem */
257 { USB_DEVICE(0x04DD, 0x9123) }, /* SHARP WS007SH USB Modem */ 257 { USB_DEVICE(0x04DD, 0x9123) }, /* SHARP WS007SH USB Modem */
258 { USB_DEVICE(0x04DD, 0x9151) }, /* SHARP S01SH USB Modem */
258 { USB_DEVICE(0x04E8, 0x5F00) }, /* Samsung NEXiO USB Sync */ 259 { USB_DEVICE(0x04E8, 0x5F00) }, /* Samsung NEXiO USB Sync */
259 { USB_DEVICE(0x04E8, 0x5F01) }, /* Samsung NEXiO USB Sync */ 260 { USB_DEVICE(0x04E8, 0x5F01) }, /* Samsung NEXiO USB Sync */
260 { USB_DEVICE(0x04E8, 0x5F02) }, /* Samsung NEXiO USB Sync */ 261 { USB_DEVICE(0x04E8, 0x5F02) }, /* Samsung NEXiO USB Sync */
diff --git a/drivers/usb/serial/kl5kusb105.c b/drivers/usb/serial/kl5kusb105.c
index b2097c45a235..7b085f334ceb 100644
--- a/drivers/usb/serial/kl5kusb105.c
+++ b/drivers/usb/serial/kl5kusb105.c
@@ -238,7 +238,7 @@ static int klsi_105_get_line_state(struct usb_serial_port *port,
238 if (rc < 0) 238 if (rc < 0)
239 err("Reading line status failed (error = %d)", rc); 239 err("Reading line status failed (error = %d)", rc);
240 else { 240 else {
241 status = status_buf[0] + (status_buf[1]<<8); 241 status = le16_to_cpu(*(u16 *)status_buf);
242 242
243 info("%s - read status %x %x", __FUNCTION__, 243 info("%s - read status %x %x", __FUNCTION__,
244 status_buf[0], status_buf[1]); 244 status_buf[0], status_buf[1]);
@@ -257,7 +257,7 @@ static int klsi_105_get_line_state(struct usb_serial_port *port,
257static int klsi_105_startup (struct usb_serial *serial) 257static int klsi_105_startup (struct usb_serial *serial)
258{ 258{
259 struct klsi_105_private *priv; 259 struct klsi_105_private *priv;
260 int i; 260 int i, j;
261 261
262 /* check if we support the product id (see keyspan.c) 262 /* check if we support the product id (see keyspan.c)
263 * FIXME 263 * FIXME
@@ -265,12 +265,12 @@ static int klsi_105_startup (struct usb_serial *serial)
265 265
266 /* allocate the private data structure */ 266 /* allocate the private data structure */
267 for (i=0; i<serial->num_ports; i++) { 267 for (i=0; i<serial->num_ports; i++) {
268 int j;
269 priv = kmalloc(sizeof(struct klsi_105_private), 268 priv = kmalloc(sizeof(struct klsi_105_private),
270 GFP_KERNEL); 269 GFP_KERNEL);
271 if (!priv) { 270 if (!priv) {
272 dbg("%skmalloc for klsi_105_private failed.", __FUNCTION__); 271 dbg("%skmalloc for klsi_105_private failed.", __FUNCTION__);
273 return -ENOMEM; 272 i--;
273 goto err_cleanup;
274 } 274 }
275 /* set initial values for control structures */ 275 /* set initial values for control structures */
276 priv->cfg.pktlen = 5; 276 priv->cfg.pktlen = 5;
@@ -292,15 +292,14 @@ static int klsi_105_startup (struct usb_serial *serial)
292 priv->write_urb_pool[j] = urb; 292 priv->write_urb_pool[j] = urb;
293 if (urb == NULL) { 293 if (urb == NULL) {
294 err("No more urbs???"); 294 err("No more urbs???");
295 continue; 295 goto err_cleanup;
296 } 296 }
297 297
298 urb->transfer_buffer = NULL;
299 urb->transfer_buffer = kmalloc (URB_TRANSFER_BUFFER_SIZE, 298 urb->transfer_buffer = kmalloc (URB_TRANSFER_BUFFER_SIZE,
300 GFP_KERNEL); 299 GFP_KERNEL);
301 if (!urb->transfer_buffer) { 300 if (!urb->transfer_buffer) {
302 err("%s - out of memory for urb buffers.", __FUNCTION__); 301 err("%s - out of memory for urb buffers.", __FUNCTION__);
303 continue; 302 goto err_cleanup;
304 } 303 }
305 } 304 }
306 305
@@ -308,7 +307,20 @@ static int klsi_105_startup (struct usb_serial *serial)
308 init_waitqueue_head(&serial->port[i]->write_wait); 307 init_waitqueue_head(&serial->port[i]->write_wait);
309 } 308 }
310 309
311 return (0); 310 return 0;
311
312err_cleanup:
313 for (; i >= 0; i--) {
314 priv = usb_get_serial_port_data(serial->port[i]);
315 for (j=0; j < NUM_URBS; j++) {
316 if (priv->write_urb_pool[j]) {
317 kfree(priv->write_urb_pool[j]->transfer_buffer);
318 usb_free_urb(priv->write_urb_pool[j]);
319 }
320 }
321 usb_set_serial_port_data(serial->port[i], NULL);
322 }
323 return -ENOMEM;
312} /* klsi_105_startup */ 324} /* klsi_105_startup */
313 325
314 326
diff --git a/drivers/usb/serial/mct_u232.c b/drivers/usb/serial/mct_u232.c
index 4cd839b1407f..3db1adc25f84 100644
--- a/drivers/usb/serial/mct_u232.c
+++ b/drivers/usb/serial/mct_u232.c
@@ -438,17 +438,21 @@ static int mct_u232_open (struct usb_serial_port *port, struct file *filp)
438 if (retval) { 438 if (retval) {
439 err("usb_submit_urb(read bulk) failed pipe 0x%x err %d", 439 err("usb_submit_urb(read bulk) failed pipe 0x%x err %d",
440 port->read_urb->pipe, retval); 440 port->read_urb->pipe, retval);
441 goto exit; 441 goto error;
442 } 442 }
443 443
444 port->interrupt_in_urb->dev = port->serial->dev; 444 port->interrupt_in_urb->dev = port->serial->dev;
445 retval = usb_submit_urb(port->interrupt_in_urb, GFP_KERNEL); 445 retval = usb_submit_urb(port->interrupt_in_urb, GFP_KERNEL);
446 if (retval) 446 if (retval) {
447 usb_kill_urb(port->read_urb);
447 err(" usb_submit_urb(read int) failed pipe 0x%x err %d", 448 err(" usb_submit_urb(read int) failed pipe 0x%x err %d",
448 port->interrupt_in_urb->pipe, retval); 449 port->interrupt_in_urb->pipe, retval);
449 450 goto error;
450exit: 451 }
451 return 0; 452 return 0;
453
454error:
455 return retval;
452} /* mct_u232_open */ 456} /* mct_u232_open */
453 457
454 458
diff --git a/drivers/usb/serial/mos7720.c b/drivers/usb/serial/mos7720.c
index 19bf403f9db2..b563e2ad8728 100644
--- a/drivers/usb/serial/mos7720.c
+++ b/drivers/usb/serial/mos7720.c
@@ -103,11 +103,9 @@ static void mos7720_interrupt_callback(struct urb *urb)
103{ 103{
104 int result; 104 int result;
105 int length; 105 int length;
106 __u32 *data; 106 __u8 *data;
107 unsigned int status;
108 __u8 sp1; 107 __u8 sp1;
109 __u8 sp2; 108 __u8 sp2;
110 __u8 st;
111 109
112 dbg("%s"," : Entering\n"); 110 dbg("%s"," : Entering\n");
113 111
@@ -141,18 +139,19 @@ static void mos7720_interrupt_callback(struct urb *urb)
141 * Byte 2 IIR Port 2 (port.number is 1) 139 * Byte 2 IIR Port 2 (port.number is 1)
142 * Byte 3 -------------- 140 * Byte 3 --------------
143 * Byte 4 FIFO status for both */ 141 * Byte 4 FIFO status for both */
144 if (length && length > 4) { 142
143 /* the above description is inverted
144 * oneukum 2007-03-14 */
145
146 if (unlikely(length != 4)) {
145 dbg("Wrong data !!!"); 147 dbg("Wrong data !!!");
146 return; 148 return;
147 } 149 }
148 150
149 status = *data; 151 sp1 = data[3];
150 152 sp2 = data[2];
151 sp1 = (status & 0xff000000)>>24;
152 sp2 = (status & 0x00ff0000)>>16;
153 st = status & 0x000000ff;
154 153
155 if ((sp1 & 0x01) || (sp2 & 0x01)) { 154 if ((sp1 | sp2) & 0x01) {
156 /* No Interrupt Pending in both the ports */ 155 /* No Interrupt Pending in both the ports */
157 dbg("No Interrupt !!!"); 156 dbg("No Interrupt !!!");
158 } else { 157 } else {
@@ -333,6 +332,7 @@ static int mos7720_open(struct usb_serial_port *port, struct file * filp)
333 int response; 332 int response;
334 int port_number; 333 int port_number;
335 char data; 334 char data;
335 int allocated_urbs = 0;
336 int j; 336 int j;
337 337
338 serial = port->serial; 338 serial = port->serial;
@@ -353,7 +353,7 @@ static int mos7720_open(struct usb_serial_port *port, struct file * filp)
353 353
354 /* Initialising the write urb pool */ 354 /* Initialising the write urb pool */
355 for (j = 0; j < NUM_URBS; ++j) { 355 for (j = 0; j < NUM_URBS; ++j) {
356 urb = usb_alloc_urb(0,GFP_ATOMIC); 356 urb = usb_alloc_urb(0,GFP_KERNEL);
357 mos7720_port->write_urb_pool[j] = urb; 357 mos7720_port->write_urb_pool[j] = urb;
358 358
359 if (urb == NULL) { 359 if (urb == NULL) {
@@ -365,10 +365,16 @@ static int mos7720_open(struct usb_serial_port *port, struct file * filp)
365 GFP_KERNEL); 365 GFP_KERNEL);
366 if (!urb->transfer_buffer) { 366 if (!urb->transfer_buffer) {
367 err("%s-out of memory for urb buffers.", __FUNCTION__); 367 err("%s-out of memory for urb buffers.", __FUNCTION__);
368 usb_free_urb(mos7720_port->write_urb_pool[j]);
369 mos7720_port->write_urb_pool[j] = NULL;
368 continue; 370 continue;
369 } 371 }
372 allocated_urbs++;
370 } 373 }
371 374
375 if (!allocated_urbs)
376 return -ENOMEM;
377
372 /* Initialize MCS7720 -- Write Init values to corresponding Registers 378 /* Initialize MCS7720 -- Write Init values to corresponding Registers
373 * 379 *
374 * Register Index 380 * Register Index
@@ -526,7 +532,7 @@ static int mos7720_chars_in_buffer(struct usb_serial_port *port)
526 } 532 }
527 533
528 for (i = 0; i < NUM_URBS; ++i) { 534 for (i = 0; i < NUM_URBS; ++i) {
529 if (mos7720_port->write_urb_pool[i]->status == -EINPROGRESS) 535 if (mos7720_port->write_urb_pool[i] && mos7720_port->write_urb_pool[i]->status == -EINPROGRESS)
530 chars += URB_TRANSFER_BUFFER_SIZE; 536 chars += URB_TRANSFER_BUFFER_SIZE;
531 } 537 }
532 dbg("%s - returns %d", __FUNCTION__, chars); 538 dbg("%s - returns %d", __FUNCTION__, chars);
@@ -629,7 +635,7 @@ static int mos7720_write_room(struct usb_serial_port *port)
629 } 635 }
630 636
631 for (i = 0; i < NUM_URBS; ++i) { 637 for (i = 0; i < NUM_URBS; ++i) {
632 if (mos7720_port->write_urb_pool[i]->status != -EINPROGRESS) 638 if (mos7720_port->write_urb_pool[i] && mos7720_port->write_urb_pool[i]->status != -EINPROGRESS)
633 room += URB_TRANSFER_BUFFER_SIZE; 639 room += URB_TRANSFER_BUFFER_SIZE;
634 } 640 }
635 641
@@ -664,7 +670,7 @@ static int mos7720_write(struct usb_serial_port *port,
664 urb = NULL; 670 urb = NULL;
665 671
666 for (i = 0; i < NUM_URBS; ++i) { 672 for (i = 0; i < NUM_URBS; ++i) {
667 if (mos7720_port->write_urb_pool[i]->status != -EINPROGRESS) { 673 if (mos7720_port->write_urb_pool[i] && mos7720_port->write_urb_pool[i]->status != -EINPROGRESS) {
668 urb = mos7720_port->write_urb_pool[i]; 674 urb = mos7720_port->write_urb_pool[i];
669 dbg("URB:%d",i); 675 dbg("URB:%d",i);
670 break; 676 break;
diff --git a/drivers/usb/serial/mos7840.c b/drivers/usb/serial/mos7840.c
index c6cca859af45..2366e7b63ece 100644
--- a/drivers/usb/serial/mos7840.c
+++ b/drivers/usb/serial/mos7840.c
@@ -176,9 +176,12 @@ struct moschip_port {
176 int port_num; /*Actual port number in the device(1,2,etc) */ 176 int port_num; /*Actual port number in the device(1,2,etc) */
177 struct urb *write_urb; /* write URB for this port */ 177 struct urb *write_urb; /* write URB for this port */
178 struct urb *read_urb; /* read URB for this port */ 178 struct urb *read_urb; /* read URB for this port */
179 struct urb *int_urb;
179 __u8 shadowLCR; /* last LCR value received */ 180 __u8 shadowLCR; /* last LCR value received */
180 __u8 shadowMCR; /* last MCR value received */ 181 __u8 shadowMCR; /* last MCR value received */
181 char open; 182 char open;
183 char open_ports;
184 char zombie;
182 wait_queue_head_t wait_chase; /* for handling sleeping while waiting for chase to finish */ 185 wait_queue_head_t wait_chase; /* for handling sleeping while waiting for chase to finish */
183 wait_queue_head_t delta_msr_wait; /* for handling sleeping while waiting for msr change to happen */ 186 wait_queue_head_t delta_msr_wait; /* for handling sleeping while waiting for msr change to happen */
184 int delta_msr_cond; 187 int delta_msr_cond;
@@ -191,17 +194,17 @@ struct moschip_port {
191 __u8 DcrRegOffset; 194 __u8 DcrRegOffset;
192 //for processing control URBS in interrupt context 195 //for processing control URBS in interrupt context
193 struct urb *control_urb; 196 struct urb *control_urb;
197 struct usb_ctrlrequest *dr;
194 char *ctrl_buf; 198 char *ctrl_buf;
195 int MsrLsr; 199 int MsrLsr;
196 200
201 spinlock_t pool_lock;
197 struct urb *write_urb_pool[NUM_URBS]; 202 struct urb *write_urb_pool[NUM_URBS];
203 char busy[NUM_URBS];
198}; 204};
199 205
200 206
201static int debug; 207static int debug;
202static int mos7840_num_ports; //this says the number of ports in the device
203static int mos7840_num_open_ports;
204
205 208
206/* 209/*
207 * mos7840_set_reg_sync 210 * mos7840_set_reg_sync
@@ -254,7 +257,7 @@ static int mos7840_set_uart_reg(struct usb_serial_port *port, __u16 reg,
254 struct usb_device *dev = port->serial->dev; 257 struct usb_device *dev = port->serial->dev;
255 val = val & 0x00ff; 258 val = val & 0x00ff;
256 // For the UART control registers, the application number need to be Or'ed 259 // For the UART control registers, the application number need to be Or'ed
257 if (mos7840_num_ports == 4) { 260 if (port->serial->num_ports == 4) {
258 val |= 261 val |=
259 (((__u16) port->number - (__u16) (port->serial->minor)) + 262 (((__u16) port->number - (__u16) (port->serial->minor)) +
260 1) << 8; 263 1) << 8;
@@ -294,7 +297,7 @@ static int mos7840_get_uart_reg(struct usb_serial_port *port, __u16 reg,
294 297
295 //dbg("application number is %4x \n",(((__u16)port->number - (__u16)(port->serial->minor))+1)<<8); 298 //dbg("application number is %4x \n",(((__u16)port->number - (__u16)(port->serial->minor))+1)<<8);
296 /*Wval is same as application number */ 299 /*Wval is same as application number */
297 if (mos7840_num_ports == 4) { 300 if (port->serial->num_ports == 4) {
298 Wval = 301 Wval =
299 (((__u16) port->number - (__u16) (port->serial->minor)) + 302 (((__u16) port->number - (__u16) (port->serial->minor)) +
300 1) << 8; 303 1) << 8;
@@ -352,7 +355,7 @@ static inline struct moschip_port *mos7840_get_port_private(struct
352 return (struct moschip_port *)usb_get_serial_port_data(port); 355 return (struct moschip_port *)usb_get_serial_port_data(port);
353} 356}
354 357
355static int mos7840_handle_new_msr(struct moschip_port *port, __u8 new_msr) 358static void mos7840_handle_new_msr(struct moschip_port *port, __u8 new_msr)
356{ 359{
357 struct moschip_port *mos7840_port; 360 struct moschip_port *mos7840_port;
358 struct async_icount *icount; 361 struct async_icount *icount;
@@ -366,22 +369,24 @@ static int mos7840_handle_new_msr(struct moschip_port *port, __u8 new_msr)
366 /* update input line counters */ 369 /* update input line counters */
367 if (new_msr & MOS_MSR_DELTA_CTS) { 370 if (new_msr & MOS_MSR_DELTA_CTS) {
368 icount->cts++; 371 icount->cts++;
372 smp_wmb();
369 } 373 }
370 if (new_msr & MOS_MSR_DELTA_DSR) { 374 if (new_msr & MOS_MSR_DELTA_DSR) {
371 icount->dsr++; 375 icount->dsr++;
376 smp_wmb();
372 } 377 }
373 if (new_msr & MOS_MSR_DELTA_CD) { 378 if (new_msr & MOS_MSR_DELTA_CD) {
374 icount->dcd++; 379 icount->dcd++;
380 smp_wmb();
375 } 381 }
376 if (new_msr & MOS_MSR_DELTA_RI) { 382 if (new_msr & MOS_MSR_DELTA_RI) {
377 icount->rng++; 383 icount->rng++;
384 smp_wmb();
378 } 385 }
379 } 386 }
380
381 return 0;
382} 387}
383 388
384static int mos7840_handle_new_lsr(struct moschip_port *port, __u8 new_lsr) 389static void mos7840_handle_new_lsr(struct moschip_port *port, __u8 new_lsr)
385{ 390{
386 struct async_icount *icount; 391 struct async_icount *icount;
387 392
@@ -400,18 +405,20 @@ static int mos7840_handle_new_lsr(struct moschip_port *port, __u8 new_lsr)
400 icount = &port->icount; 405 icount = &port->icount;
401 if (new_lsr & SERIAL_LSR_BI) { 406 if (new_lsr & SERIAL_LSR_BI) {
402 icount->brk++; 407 icount->brk++;
408 smp_wmb();
403 } 409 }
404 if (new_lsr & SERIAL_LSR_OE) { 410 if (new_lsr & SERIAL_LSR_OE) {
405 icount->overrun++; 411 icount->overrun++;
412 smp_wmb();
406 } 413 }
407 if (new_lsr & SERIAL_LSR_PE) { 414 if (new_lsr & SERIAL_LSR_PE) {
408 icount->parity++; 415 icount->parity++;
416 smp_wmb();
409 } 417 }
410 if (new_lsr & SERIAL_LSR_FE) { 418 if (new_lsr & SERIAL_LSR_FE) {
411 icount->frame++; 419 icount->frame++;
420 smp_wmb();
412 } 421 }
413
414 return 0;
415} 422}
416 423
417/************************************************************************/ 424/************************************************************************/
@@ -426,12 +433,15 @@ static void mos7840_control_callback(struct urb *urb)
426 unsigned char *data; 433 unsigned char *data;
427 struct moschip_port *mos7840_port; 434 struct moschip_port *mos7840_port;
428 __u8 regval = 0x0; 435 __u8 regval = 0x0;
436 int result = 0;
429 437
430 if (!urb) { 438 if (!urb) {
431 dbg("%s", "Invalid Pointer !!!!:\n"); 439 dbg("%s", "Invalid Pointer !!!!:\n");
432 return; 440 return;
433 } 441 }
434 442
443 mos7840_port = (struct moschip_port *)urb->context;
444
435 switch (urb->status) { 445 switch (urb->status) {
436 case 0: 446 case 0:
437 /* success */ 447 /* success */
@@ -449,8 +459,6 @@ static void mos7840_control_callback(struct urb *urb)
449 goto exit; 459 goto exit;
450 } 460 }
451 461
452 mos7840_port = (struct moschip_port *)urb->context;
453
454 dbg("%s urb buffer size is %d\n", __FUNCTION__, urb->actual_length); 462 dbg("%s urb buffer size is %d\n", __FUNCTION__, urb->actual_length);
455 dbg("%s mos7840_port->MsrLsr is %d port %d\n", __FUNCTION__, 463 dbg("%s mos7840_port->MsrLsr is %d port %d\n", __FUNCTION__,
456 mos7840_port->MsrLsr, mos7840_port->port_num); 464 mos7840_port->MsrLsr, mos7840_port->port_num);
@@ -462,21 +470,26 @@ static void mos7840_control_callback(struct urb *urb)
462 else if (mos7840_port->MsrLsr == 1) 470 else if (mos7840_port->MsrLsr == 1)
463 mos7840_handle_new_lsr(mos7840_port, regval); 471 mos7840_handle_new_lsr(mos7840_port, regval);
464 472
465 exit: 473exit:
466 return; 474 spin_lock(&mos7840_port->pool_lock);
475 if (!mos7840_port->zombie)
476 result = usb_submit_urb(mos7840_port->int_urb, GFP_ATOMIC);
477 spin_unlock(&mos7840_port->pool_lock);
478 if (result) {
479 dev_err(&urb->dev->dev,
480 "%s - Error %d submitting interrupt urb\n",
481 __FUNCTION__, result);
482 }
467} 483}
468 484
469static int mos7840_get_reg(struct moschip_port *mcs, __u16 Wval, __u16 reg, 485static int mos7840_get_reg(struct moschip_port *mcs, __u16 Wval, __u16 reg,
470 __u16 * val) 486 __u16 * val)
471{ 487{
472 struct usb_device *dev = mcs->port->serial->dev; 488 struct usb_device *dev = mcs->port->serial->dev;
473 struct usb_ctrlrequest *dr = NULL; 489 struct usb_ctrlrequest *dr = mcs->dr;
474 unsigned char *buffer = NULL; 490 unsigned char *buffer = mcs->ctrl_buf;
475 int ret = 0; 491 int ret;
476 buffer = (__u8 *) mcs->ctrl_buf;
477 492
478// dr=(struct usb_ctrlrequest *)(buffer);
479 dr = (void *)(buffer + 2);
480 dr->bRequestType = MCS_RD_RTYPE; 493 dr->bRequestType = MCS_RD_RTYPE;
481 dr->bRequest = MCS_RDREQ; 494 dr->bRequest = MCS_RDREQ;
482 dr->wValue = cpu_to_le16(Wval); //0; 495 dr->wValue = cpu_to_le16(Wval); //0;
@@ -506,8 +519,8 @@ static void mos7840_interrupt_callback(struct urb *urb)
506 __u16 Data; 519 __u16 Data;
507 unsigned char *data; 520 unsigned char *data;
508 __u8 sp[5], st; 521 __u8 sp[5], st;
509 int i; 522 int i, rv = 0;
510 __u16 wval; 523 __u16 wval, wreg = 0;
511 524
512 dbg("%s", " : Entering\n"); 525 dbg("%s", " : Entering\n");
513 if (!urb) { 526 if (!urb) {
@@ -569,31 +582,34 @@ static void mos7840_interrupt_callback(struct urb *urb)
569 dbg("Serial Port %d: Receiver status error or ", i); 582 dbg("Serial Port %d: Receiver status error or ", i);
570 dbg("address bit detected in 9-bit mode\n"); 583 dbg("address bit detected in 9-bit mode\n");
571 mos7840_port->MsrLsr = 1; 584 mos7840_port->MsrLsr = 1;
572 mos7840_get_reg(mos7840_port, wval, 585 wreg = LINE_STATUS_REGISTER;
573 LINE_STATUS_REGISTER,
574 &Data);
575 break; 586 break;
576 case SERIAL_IIR_MS: 587 case SERIAL_IIR_MS:
577 dbg("Serial Port %d: Modem status change\n", i); 588 dbg("Serial Port %d: Modem status change\n", i);
578 mos7840_port->MsrLsr = 0; 589 mos7840_port->MsrLsr = 0;
579 mos7840_get_reg(mos7840_port, wval, 590 wreg = MODEM_STATUS_REGISTER;
580 MODEM_STATUS_REGISTER,
581 &Data);
582 break; 591 break;
583 } 592 }
593 spin_lock(&mos7840_port->pool_lock);
594 if (!mos7840_port->zombie) {
595 rv = mos7840_get_reg(mos7840_port, wval, wreg, &Data);
596 } else {
597 spin_unlock(&mos7840_port->pool_lock);
598 return;
599 }
600 spin_unlock(&mos7840_port->pool_lock);
584 } 601 }
585 } 602 }
586 } 603 }
587 exit: 604 if (!(rv < 0)) /* the completion handler for the control urb will resubmit */
605 return;
606exit:
588 result = usb_submit_urb(urb, GFP_ATOMIC); 607 result = usb_submit_urb(urb, GFP_ATOMIC);
589 if (result) { 608 if (result) {
590 dev_err(&urb->dev->dev, 609 dev_err(&urb->dev->dev,
591 "%s - Error %d submitting interrupt urb\n", 610 "%s - Error %d submitting interrupt urb\n",
592 __FUNCTION__, result); 611 __FUNCTION__, result);
593 } 612 }
594
595 return;
596
597} 613}
598 614
599static int mos7840_port_paranoia_check(struct usb_serial_port *port, 615static int mos7840_port_paranoia_check(struct usb_serial_port *port,
@@ -634,7 +650,8 @@ static struct usb_serial *mos7840_get_usb_serial(struct usb_serial_port *port,
634 if (!port || 650 if (!port ||
635 mos7840_port_paranoia_check(port, function) || 651 mos7840_port_paranoia_check(port, function) ||
636 mos7840_serial_paranoia_check(port->serial, function)) { 652 mos7840_serial_paranoia_check(port->serial, function)) {
637 /* then say that we don't have a valid usb_serial thing, which will * end up genrating -ENODEV return values */ 653 /* then say that we don't have a valid usb_serial thing, which will
654 * end up genrating -ENODEV return values */
638 return NULL; 655 return NULL;
639 } 656 }
640 657
@@ -699,6 +716,7 @@ static void mos7840_bulk_in_callback(struct urb *urb)
699 tty_flip_buffer_push(tty); 716 tty_flip_buffer_push(tty);
700 } 717 }
701 mos7840_port->icount.rx += urb->actual_length; 718 mos7840_port->icount.rx += urb->actual_length;
719 smp_wmb();
702 dbg("mos7840_port->icount.rx is %d:\n", 720 dbg("mos7840_port->icount.rx is %d:\n",
703 mos7840_port->icount.rx); 721 mos7840_port->icount.rx);
704 } 722 }
@@ -708,15 +726,14 @@ static void mos7840_bulk_in_callback(struct urb *urb)
708 return; 726 return;
709 } 727 }
710 728
711 if (mos7840_port->read_urb->status != -EINPROGRESS) {
712 mos7840_port->read_urb->dev = serial->dev;
713 729
714 status = usb_submit_urb(mos7840_port->read_urb, GFP_ATOMIC); 730 mos7840_port->read_urb->dev = serial->dev;
715 731
716 if (status) { 732 status = usb_submit_urb(mos7840_port->read_urb, GFP_ATOMIC);
717 dbg(" usb_submit_urb(read bulk) failed, status = %d", 733
718 status); 734 if (status) {
719 } 735 dbg(" usb_submit_urb(read bulk) failed, status = %d",
736 status);
720 } 737 }
721} 738}
722 739
@@ -730,17 +747,28 @@ static void mos7840_bulk_out_data_callback(struct urb *urb)
730{ 747{
731 struct moschip_port *mos7840_port; 748 struct moschip_port *mos7840_port;
732 struct tty_struct *tty; 749 struct tty_struct *tty;
750 int i;
751
733 if (!urb) { 752 if (!urb) {
734 dbg("%s", "Invalid Pointer !!!!:\n"); 753 dbg("%s", "Invalid Pointer !!!!:\n");
735 return; 754 return;
736 } 755 }
737 756
757 mos7840_port = (struct moschip_port *)urb->context;
758 spin_lock(&mos7840_port->pool_lock);
759 for (i = 0; i < NUM_URBS; i++) {
760 if (urb == mos7840_port->write_urb_pool[i]) {
761 mos7840_port->busy[i] = 0;
762 break;
763 }
764 }
765 spin_unlock(&mos7840_port->pool_lock);
766
738 if (urb->status) { 767 if (urb->status) {
739 dbg("nonzero write bulk status received:%d\n", urb->status); 768 dbg("nonzero write bulk status received:%d\n", urb->status);
740 return; 769 return;
741 } 770 }
742 771
743 mos7840_port = (struct moschip_port *)urb->context;
744 if (!mos7840_port) { 772 if (!mos7840_port) {
745 dbg("%s", "NULL mos7840_port pointer \n"); 773 dbg("%s", "NULL mos7840_port pointer \n");
746 return; 774 return;
@@ -792,13 +820,13 @@ static int mos7840_open(struct usb_serial_port *port, struct file *filp)
792 __u16 Data; 820 __u16 Data;
793 int status; 821 int status;
794 struct moschip_port *mos7840_port; 822 struct moschip_port *mos7840_port;
823 struct moschip_port *port0;
795 824
796 if (mos7840_port_paranoia_check(port, __FUNCTION__)) { 825 if (mos7840_port_paranoia_check(port, __FUNCTION__)) {
797 dbg("%s", "Port Paranoia failed \n"); 826 dbg("%s", "Port Paranoia failed \n");
798 return -ENODEV; 827 return -ENODEV;
799 } 828 }
800 829
801 mos7840_num_open_ports++;
802 serial = port->serial; 830 serial = port->serial;
803 831
804 if (mos7840_serial_paranoia_check(serial, __FUNCTION__)) { 832 if (mos7840_serial_paranoia_check(serial, __FUNCTION__)) {
@@ -807,16 +835,18 @@ static int mos7840_open(struct usb_serial_port *port, struct file *filp)
807 } 835 }
808 836
809 mos7840_port = mos7840_get_port_private(port); 837 mos7840_port = mos7840_get_port_private(port);
838 port0 = mos7840_get_port_private(serial->port[0]);
810 839
811 if (mos7840_port == NULL) 840 if (mos7840_port == NULL || port0 == NULL)
812 return -ENODEV; 841 return -ENODEV;
813 842
814 usb_clear_halt(serial->dev, port->write_urb->pipe); 843 usb_clear_halt(serial->dev, port->write_urb->pipe);
815 usb_clear_halt(serial->dev, port->read_urb->pipe); 844 usb_clear_halt(serial->dev, port->read_urb->pipe);
845 port0->open_ports++;
816 846
817 /* Initialising the write urb pool */ 847 /* Initialising the write urb pool */
818 for (j = 0; j < NUM_URBS; ++j) { 848 for (j = 0; j < NUM_URBS; ++j) {
819 urb = usb_alloc_urb(0, GFP_ATOMIC); 849 urb = usb_alloc_urb(0, GFP_KERNEL);
820 mos7840_port->write_urb_pool[j] = urb; 850 mos7840_port->write_urb_pool[j] = urb;
821 851
822 if (urb == NULL) { 852 if (urb == NULL) {
@@ -824,10 +854,10 @@ static int mos7840_open(struct usb_serial_port *port, struct file *filp)
824 continue; 854 continue;
825 } 855 }
826 856
827 urb->transfer_buffer = NULL; 857 urb->transfer_buffer = kmalloc(URB_TRANSFER_BUFFER_SIZE, GFP_KERNEL);
828 urb->transfer_buffer =
829 kmalloc(URB_TRANSFER_BUFFER_SIZE, GFP_KERNEL);
830 if (!urb->transfer_buffer) { 858 if (!urb->transfer_buffer) {
859 usb_free_urb(urb);
860 mos7840_port->write_urb_pool[j] = NULL;
831 err("%s-out of memory for urb buffers.", __FUNCTION__); 861 err("%s-out of memory for urb buffers.", __FUNCTION__);
832 continue; 862 continue;
833 } 863 }
@@ -879,9 +909,7 @@ static int mos7840_open(struct usb_serial_port *port, struct file *filp)
879 } 909 }
880 Data |= 0x08; //Driver done bit 910 Data |= 0x08; //Driver done bit
881 Data |= 0x20; //rx_disable 911 Data |= 0x20; //rx_disable
882 status = 0; 912 status = mos7840_set_reg_sync(port, mos7840_port->ControlRegOffset, Data);
883 status =
884 mos7840_set_reg_sync(port, mos7840_port->ControlRegOffset, Data);
885 if (status < 0) { 913 if (status < 0) {
886 dbg("writing Controlreg failed\n"); 914 dbg("writing Controlreg failed\n");
887 return -1; 915 return -1;
@@ -893,7 +921,6 @@ static int mos7840_open(struct usb_serial_port *port, struct file *filp)
893 //////////////////////////////////// 921 ////////////////////////////////////
894 922
895 Data = 0x00; 923 Data = 0x00;
896 status = 0;
897 status = mos7840_set_uart_reg(port, INTERRUPT_ENABLE_REGISTER, Data); 924 status = mos7840_set_uart_reg(port, INTERRUPT_ENABLE_REGISTER, Data);
898 if (status < 0) { 925 if (status < 0) {
899 dbg("disableing interrupts failed\n"); 926 dbg("disableing interrupts failed\n");
@@ -901,7 +928,6 @@ static int mos7840_open(struct usb_serial_port *port, struct file *filp)
901 } 928 }
902 // Set FIFO_CONTROL_REGISTER to the default value 929 // Set FIFO_CONTROL_REGISTER to the default value
903 Data = 0x00; 930 Data = 0x00;
904 status = 0;
905 status = mos7840_set_uart_reg(port, FIFO_CONTROL_REGISTER, Data); 931 status = mos7840_set_uart_reg(port, FIFO_CONTROL_REGISTER, Data);
906 if (status < 0) { 932 if (status < 0) {
907 dbg("Writing FIFO_CONTROL_REGISTER failed\n"); 933 dbg("Writing FIFO_CONTROL_REGISTER failed\n");
@@ -909,7 +935,6 @@ static int mos7840_open(struct usb_serial_port *port, struct file *filp)
909 } 935 }
910 936
911 Data = 0xcf; 937 Data = 0xcf;
912 status = 0;
913 status = mos7840_set_uart_reg(port, FIFO_CONTROL_REGISTER, Data); 938 status = mos7840_set_uart_reg(port, FIFO_CONTROL_REGISTER, Data);
914 if (status < 0) { 939 if (status < 0) {
915 dbg("Writing FIFO_CONTROL_REGISTER failed\n"); 940 dbg("Writing FIFO_CONTROL_REGISTER failed\n");
@@ -917,22 +942,18 @@ static int mos7840_open(struct usb_serial_port *port, struct file *filp)
917 } 942 }
918 943
919 Data = 0x03; 944 Data = 0x03;
920 status = 0;
921 status = mos7840_set_uart_reg(port, LINE_CONTROL_REGISTER, Data); 945 status = mos7840_set_uart_reg(port, LINE_CONTROL_REGISTER, Data);
922 mos7840_port->shadowLCR = Data; 946 mos7840_port->shadowLCR = Data;
923 947
924 Data = 0x0b; 948 Data = 0x0b;
925 status = 0;
926 status = mos7840_set_uart_reg(port, MODEM_CONTROL_REGISTER, Data); 949 status = mos7840_set_uart_reg(port, MODEM_CONTROL_REGISTER, Data);
927 mos7840_port->shadowMCR = Data; 950 mos7840_port->shadowMCR = Data;
928 951
929 Data = 0x00; 952 Data = 0x00;
930 status = 0;
931 status = mos7840_get_uart_reg(port, LINE_CONTROL_REGISTER, &Data); 953 status = mos7840_get_uart_reg(port, LINE_CONTROL_REGISTER, &Data);
932 mos7840_port->shadowLCR = Data; 954 mos7840_port->shadowLCR = Data;
933 955
934 Data |= SERIAL_LCR_DLAB; //data latch enable in LCR 0x80 956 Data |= SERIAL_LCR_DLAB; //data latch enable in LCR 0x80
935 status = 0;
936 status = mos7840_set_uart_reg(port, LINE_CONTROL_REGISTER, Data); 957 status = mos7840_set_uart_reg(port, LINE_CONTROL_REGISTER, Data);
937 958
938 Data = 0x0c; 959 Data = 0x0c;
@@ -999,7 +1020,7 @@ static int mos7840_open(struct usb_serial_port *port, struct file *filp)
999/* Check to see if we've set up our endpoint info yet * 1020/* Check to see if we've set up our endpoint info yet *
1000 * (can't set it up in mos7840_startup as the structures * 1021 * (can't set it up in mos7840_startup as the structures *
1001 * were not set up at that time.) */ 1022 * were not set up at that time.) */
1002 if (mos7840_num_open_ports == 1) { 1023 if (port0->open_ports == 1) {
1003 if (serial->port[0]->interrupt_in_buffer == NULL) { 1024 if (serial->port[0]->interrupt_in_buffer == NULL) {
1004 1025
1005 /* set up interrupt urb */ 1026 /* set up interrupt urb */
@@ -1097,6 +1118,7 @@ static int mos7840_chars_in_buffer(struct usb_serial_port *port)
1097{ 1118{
1098 int i; 1119 int i;
1099 int chars = 0; 1120 int chars = 0;
1121 unsigned long flags;
1100 struct moschip_port *mos7840_port; 1122 struct moschip_port *mos7840_port;
1101 1123
1102 dbg("%s \n", " mos7840_chars_in_buffer:entering ..........."); 1124 dbg("%s \n", " mos7840_chars_in_buffer:entering ...........");
@@ -1112,13 +1134,15 @@ static int mos7840_chars_in_buffer(struct usb_serial_port *port)
1112 return -1; 1134 return -1;
1113 } 1135 }
1114 1136
1137 spin_lock_irqsave(&mos7840_port->pool_lock,flags);
1115 for (i = 0; i < NUM_URBS; ++i) { 1138 for (i = 0; i < NUM_URBS; ++i) {
1116 if (mos7840_port->write_urb_pool[i]->status == -EINPROGRESS) { 1139 if (mos7840_port->busy[i]) {
1117 chars += URB_TRANSFER_BUFFER_SIZE; 1140 chars += URB_TRANSFER_BUFFER_SIZE;
1118 } 1141 }
1119 } 1142 }
1143 spin_unlock_irqrestore(&mos7840_port->pool_lock,flags);
1120 dbg("%s - returns %d", __FUNCTION__, chars); 1144 dbg("%s - returns %d", __FUNCTION__, chars);
1121 return (chars); 1145 return chars;
1122 1146
1123} 1147}
1124 1148
@@ -1172,6 +1196,7 @@ static void mos7840_close(struct usb_serial_port *port, struct file *filp)
1172{ 1196{
1173 struct usb_serial *serial; 1197 struct usb_serial *serial;
1174 struct moschip_port *mos7840_port; 1198 struct moschip_port *mos7840_port;
1199 struct moschip_port *port0;
1175 int j; 1200 int j;
1176 __u16 Data; 1201 __u16 Data;
1177 1202
@@ -1189,10 +1214,10 @@ static void mos7840_close(struct usb_serial_port *port, struct file *filp)
1189 } 1214 }
1190 1215
1191 mos7840_port = mos7840_get_port_private(port); 1216 mos7840_port = mos7840_get_port_private(port);
1217 port0 = mos7840_get_port_private(serial->port[0]);
1192 1218
1193 if (mos7840_port == NULL) { 1219 if (mos7840_port == NULL || port0 == NULL)
1194 return; 1220 return;
1195 }
1196 1221
1197 for (j = 0; j < NUM_URBS; ++j) 1222 for (j = 0; j < NUM_URBS; ++j)
1198 usb_kill_urb(mos7840_port->write_urb_pool[j]); 1223 usb_kill_urb(mos7840_port->write_urb_pool[j]);
@@ -1234,12 +1259,13 @@ static void mos7840_close(struct usb_serial_port *port, struct file *filp)
1234 } 1259 }
1235// if(mos7840_port->ctrl_buf != NULL) 1260// if(mos7840_port->ctrl_buf != NULL)
1236// kfree(mos7840_port->ctrl_buf); 1261// kfree(mos7840_port->ctrl_buf);
1237 mos7840_num_open_ports--; 1262 port0->open_ports--;
1238 dbg("mos7840_num_open_ports in close%d:in port%d\n", 1263 dbg("mos7840_num_open_ports in close%d:in port%d\n",
1239 mos7840_num_open_ports, port->number); 1264 port0->open_ports, port->number);
1240 if (mos7840_num_open_ports == 0) { 1265 if (port0->open_ports == 0) {
1241 if (serial->port[0]->interrupt_in_urb) { 1266 if (serial->port[0]->interrupt_in_urb) {
1242 dbg("%s", "Shutdown interrupt_in_urb\n"); 1267 dbg("%s", "Shutdown interrupt_in_urb\n");
1268 usb_kill_urb(serial->port[0]->interrupt_in_urb);
1243 } 1269 }
1244 } 1270 }
1245 1271
@@ -1368,6 +1394,7 @@ static int mos7840_write_room(struct usb_serial_port *port)
1368{ 1394{
1369 int i; 1395 int i;
1370 int room = 0; 1396 int room = 0;
1397 unsigned long flags;
1371 struct moschip_port *mos7840_port; 1398 struct moschip_port *mos7840_port;
1372 1399
1373 dbg("%s \n", " mos7840_write_room:entering ..........."); 1400 dbg("%s \n", " mos7840_write_room:entering ...........");
@@ -1384,14 +1411,17 @@ static int mos7840_write_room(struct usb_serial_port *port)
1384 return -1; 1411 return -1;
1385 } 1412 }
1386 1413
1414 spin_lock_irqsave(&mos7840_port->pool_lock, flags);
1387 for (i = 0; i < NUM_URBS; ++i) { 1415 for (i = 0; i < NUM_URBS; ++i) {
1388 if (mos7840_port->write_urb_pool[i]->status != -EINPROGRESS) { 1416 if (!mos7840_port->busy[i]) {
1389 room += URB_TRANSFER_BUFFER_SIZE; 1417 room += URB_TRANSFER_BUFFER_SIZE;
1390 } 1418 }
1391 } 1419 }
1420 spin_unlock_irqrestore(&mos7840_port->pool_lock, flags);
1392 1421
1422 room = (room == 0) ? 0 : room - URB_TRANSFER_BUFFER_SIZE + 1;
1393 dbg("%s - returns %d", __FUNCTION__, room); 1423 dbg("%s - returns %d", __FUNCTION__, room);
1394 return (room); 1424 return room;
1395 1425
1396} 1426}
1397 1427
@@ -1410,6 +1440,7 @@ static int mos7840_write(struct usb_serial_port *port,
1410 int i; 1440 int i;
1411 int bytes_sent = 0; 1441 int bytes_sent = 0;
1412 int transfer_size; 1442 int transfer_size;
1443 unsigned long flags;
1413 1444
1414 struct moschip_port *mos7840_port; 1445 struct moschip_port *mos7840_port;
1415 struct usb_serial *serial; 1446 struct usb_serial *serial;
@@ -1476,13 +1507,16 @@ static int mos7840_write(struct usb_serial_port *port,
1476 /* try to find a free urb in the list */ 1507 /* try to find a free urb in the list */
1477 urb = NULL; 1508 urb = NULL;
1478 1509
1510 spin_lock_irqsave(&mos7840_port->pool_lock, flags);
1479 for (i = 0; i < NUM_URBS; ++i) { 1511 for (i = 0; i < NUM_URBS; ++i) {
1480 if (mos7840_port->write_urb_pool[i]->status != -EINPROGRESS) { 1512 if (!mos7840_port->busy[i]) {
1513 mos7840_port->busy[i] = 1;
1481 urb = mos7840_port->write_urb_pool[i]; 1514 urb = mos7840_port->write_urb_pool[i];
1482 dbg("\nURB:%d", i); 1515 dbg("\nURB:%d", i);
1483 break; 1516 break;
1484 } 1517 }
1485 } 1518 }
1519 spin_unlock_irqrestore(&mos7840_port->pool_lock, flags);
1486 1520
1487 if (urb == NULL) { 1521 if (urb == NULL) {
1488 dbg("%s - no more free urbs", __FUNCTION__); 1522 dbg("%s - no more free urbs", __FUNCTION__);
@@ -1518,6 +1552,7 @@ static int mos7840_write(struct usb_serial_port *port,
1518 status = usb_submit_urb(urb, GFP_ATOMIC); 1552 status = usb_submit_urb(urb, GFP_ATOMIC);
1519 1553
1520 if (status) { 1554 if (status) {
1555 mos7840_port->busy[i] = 0;
1521 err("%s - usb_submit_urb(write bulk) failed with status = %d", 1556 err("%s - usb_submit_urb(write bulk) failed with status = %d",
1522 __FUNCTION__, status); 1557 __FUNCTION__, status);
1523 bytes_sent = status; 1558 bytes_sent = status;
@@ -1525,6 +1560,7 @@ static int mos7840_write(struct usb_serial_port *port,
1525 } 1560 }
1526 bytes_sent = transfer_size; 1561 bytes_sent = transfer_size;
1527 mos7840_port->icount.tx += transfer_size; 1562 mos7840_port->icount.tx += transfer_size;
1563 smp_wmb();
1528 dbg("mos7840_port->icount.tx is %d:\n", mos7840_port->icount.tx); 1564 dbg("mos7840_port->icount.tx is %d:\n", mos7840_port->icount.tx);
1529 exit: 1565 exit:
1530 1566
@@ -2490,6 +2526,7 @@ static int mos7840_ioctl(struct usb_serial_port *port, struct file *file,
2490 if (signal_pending(current)) 2526 if (signal_pending(current))
2491 return -ERESTARTSYS; 2527 return -ERESTARTSYS;
2492 cnow = mos7840_port->icount; 2528 cnow = mos7840_port->icount;
2529 smp_rmb();
2493 if (cnow.rng == cprev.rng && cnow.dsr == cprev.dsr && 2530 if (cnow.rng == cprev.rng && cnow.dsr == cprev.dsr &&
2494 cnow.dcd == cprev.dcd && cnow.cts == cprev.cts) 2531 cnow.dcd == cprev.dcd && cnow.cts == cprev.cts)
2495 return -EIO; /* no change => error */ 2532 return -EIO; /* no change => error */
@@ -2506,6 +2543,7 @@ static int mos7840_ioctl(struct usb_serial_port *port, struct file *file,
2506 2543
2507 case TIOCGICOUNT: 2544 case TIOCGICOUNT:
2508 cnow = mos7840_port->icount; 2545 cnow = mos7840_port->icount;
2546 smp_rmb();
2509 icount.cts = cnow.cts; 2547 icount.cts = cnow.cts;
2510 icount.dsr = cnow.dsr; 2548 icount.dsr = cnow.dsr;
2511 icount.rng = cnow.rng; 2549 icount.rng = cnow.rng;
@@ -2535,19 +2573,18 @@ static int mos7840_ioctl(struct usb_serial_port *port, struct file *file,
2535 2573
2536static int mos7840_calc_num_ports(struct usb_serial *serial) 2574static int mos7840_calc_num_ports(struct usb_serial *serial)
2537{ 2575{
2576 int mos7840_num_ports = 0;
2538 2577
2539 dbg("numberofendpoints: %d \n", 2578 dbg("numberofendpoints: %d \n",
2540 (int)serial->interface->cur_altsetting->desc.bNumEndpoints); 2579 (int)serial->interface->cur_altsetting->desc.bNumEndpoints);
2541 dbg("numberofendpoints: %d \n", 2580 dbg("numberofendpoints: %d \n",
2542 (int)serial->interface->altsetting->desc.bNumEndpoints); 2581 (int)serial->interface->altsetting->desc.bNumEndpoints);
2543 if (serial->interface->cur_altsetting->desc.bNumEndpoints == 5) { 2582 if (serial->interface->cur_altsetting->desc.bNumEndpoints == 5) {
2544 mos7840_num_ports = 2; 2583 mos7840_num_ports = serial->num_ports = 2;
2545 serial->type->num_ports = 2;
2546 } else if (serial->interface->cur_altsetting->desc.bNumEndpoints == 9) { 2584 } else if (serial->interface->cur_altsetting->desc.bNumEndpoints == 9) {
2547 mos7840_num_ports = 4; 2585 serial->num_bulk_in = 4;
2548 serial->type->num_bulk_in = 4; 2586 serial->num_bulk_out = 4;
2549 serial->type->num_bulk_out = 4; 2587 mos7840_num_ports = serial->num_ports = 4;
2550 serial->type->num_ports = 4;
2551 } 2588 }
2552 2589
2553 return mos7840_num_ports; 2590 return mos7840_num_ports;
@@ -2583,7 +2620,9 @@ static int mos7840_startup(struct usb_serial *serial)
2583 mos7840_port = kzalloc(sizeof(struct moschip_port), GFP_KERNEL); 2620 mos7840_port = kzalloc(sizeof(struct moschip_port), GFP_KERNEL);
2584 if (mos7840_port == NULL) { 2621 if (mos7840_port == NULL) {
2585 err("%s - Out of memory", __FUNCTION__); 2622 err("%s - Out of memory", __FUNCTION__);
2586 return -ENOMEM; 2623 status = -ENOMEM;
2624 i--; /* don't follow NULL pointer cleaning up */
2625 goto error;
2587 } 2626 }
2588 2627
2589 /* Initialize all port interrupt end point to port 0 int endpoint * 2628 /* Initialize all port interrupt end point to port 0 int endpoint *
@@ -2591,6 +2630,7 @@ static int mos7840_startup(struct usb_serial *serial)
2591 2630
2592 mos7840_port->port = serial->port[i]; 2631 mos7840_port->port = serial->port[i];
2593 mos7840_set_port_private(serial->port[i], mos7840_port); 2632 mos7840_set_port_private(serial->port[i], mos7840_port);
2633 spin_lock_init(&mos7840_port->pool_lock);
2594 2634
2595 mos7840_port->port_num = ((serial->port[i]->number - 2635 mos7840_port->port_num = ((serial->port[i]->number -
2596 (serial->port[i]->serial->minor)) + 2636 (serial->port[i]->serial->minor)) +
@@ -2601,22 +2641,22 @@ static int mos7840_startup(struct usb_serial *serial)
2601 mos7840_port->ControlRegOffset = 0x1; 2641 mos7840_port->ControlRegOffset = 0x1;
2602 mos7840_port->DcrRegOffset = 0x4; 2642 mos7840_port->DcrRegOffset = 0x4;
2603 } else if ((mos7840_port->port_num == 2) 2643 } else if ((mos7840_port->port_num == 2)
2604 && (mos7840_num_ports == 4)) { 2644 && (serial->num_ports == 4)) {
2605 mos7840_port->SpRegOffset = 0x8; 2645 mos7840_port->SpRegOffset = 0x8;
2606 mos7840_port->ControlRegOffset = 0x9; 2646 mos7840_port->ControlRegOffset = 0x9;
2607 mos7840_port->DcrRegOffset = 0x16; 2647 mos7840_port->DcrRegOffset = 0x16;
2608 } else if ((mos7840_port->port_num == 2) 2648 } else if ((mos7840_port->port_num == 2)
2609 && (mos7840_num_ports == 2)) { 2649 && (serial->num_ports == 2)) {
2610 mos7840_port->SpRegOffset = 0xa; 2650 mos7840_port->SpRegOffset = 0xa;
2611 mos7840_port->ControlRegOffset = 0xb; 2651 mos7840_port->ControlRegOffset = 0xb;
2612 mos7840_port->DcrRegOffset = 0x19; 2652 mos7840_port->DcrRegOffset = 0x19;
2613 } else if ((mos7840_port->port_num == 3) 2653 } else if ((mos7840_port->port_num == 3)
2614 && (mos7840_num_ports == 4)) { 2654 && (serial->num_ports == 4)) {
2615 mos7840_port->SpRegOffset = 0xa; 2655 mos7840_port->SpRegOffset = 0xa;
2616 mos7840_port->ControlRegOffset = 0xb; 2656 mos7840_port->ControlRegOffset = 0xb;
2617 mos7840_port->DcrRegOffset = 0x19; 2657 mos7840_port->DcrRegOffset = 0x19;
2618 } else if ((mos7840_port->port_num == 4) 2658 } else if ((mos7840_port->port_num == 4)
2619 && (mos7840_num_ports == 4)) { 2659 && (serial->num_ports == 4)) {
2620 mos7840_port->SpRegOffset = 0xc; 2660 mos7840_port->SpRegOffset = 0xc;
2621 mos7840_port->ControlRegOffset = 0xd; 2661 mos7840_port->ControlRegOffset = 0xd;
2622 mos7840_port->DcrRegOffset = 0x1c; 2662 mos7840_port->DcrRegOffset = 0x1c;
@@ -2701,21 +2741,19 @@ static int mos7840_startup(struct usb_serial *serial)
2701 dbg("CLK_START_VALUE_REGISTER Writing success status%d\n", status); 2741 dbg("CLK_START_VALUE_REGISTER Writing success status%d\n", status);
2702 2742
2703 Data = 0x20; 2743 Data = 0x20;
2704 status = 0;
2705 status = 2744 status =
2706 mos7840_set_reg_sync(serial->port[i], CLK_MULTI_REGISTER, 2745 mos7840_set_reg_sync(serial->port[i], CLK_MULTI_REGISTER,
2707 Data); 2746 Data);
2708 if (status < 0) { 2747 if (status < 0) {
2709 dbg("Writing CLK_MULTI_REGISTER failed status-0x%x\n", 2748 dbg("Writing CLK_MULTI_REGISTER failed status-0x%x\n",
2710 status); 2749 status);
2711 break; 2750 goto error;
2712 } else 2751 } else
2713 dbg("CLK_MULTI_REGISTER Writing success status%d\n", 2752 dbg("CLK_MULTI_REGISTER Writing success status%d\n",
2714 status); 2753 status);
2715 2754
2716 //write value 0x0 to scratchpad register 2755 //write value 0x0 to scratchpad register
2717 Data = 0x00; 2756 Data = 0x00;
2718 status = 0;
2719 status = 2757 status =
2720 mos7840_set_uart_reg(serial->port[i], SCRATCH_PAD_REGISTER, 2758 mos7840_set_uart_reg(serial->port[i], SCRATCH_PAD_REGISTER,
2721 Data); 2759 Data);
@@ -2729,7 +2767,7 @@ static int mos7840_startup(struct usb_serial *serial)
2729 2767
2730 //Zero Length flag register 2768 //Zero Length flag register
2731 if ((mos7840_port->port_num != 1) 2769 if ((mos7840_port->port_num != 1)
2732 && (mos7840_num_ports == 2)) { 2770 && (serial->num_ports == 2)) {
2733 2771
2734 Data = 0xff; 2772 Data = 0xff;
2735 status = 0; 2773 status = 0;
@@ -2770,14 +2808,17 @@ static int mos7840_startup(struct usb_serial *serial)
2770 i + 1, status); 2808 i + 1, status);
2771 2809
2772 } 2810 }
2773 mos7840_port->control_urb = usb_alloc_urb(0, GFP_ATOMIC); 2811 mos7840_port->control_urb = usb_alloc_urb(0, GFP_KERNEL);
2774 mos7840_port->ctrl_buf = kmalloc(16, GFP_KERNEL); 2812 mos7840_port->ctrl_buf = kmalloc(16, GFP_KERNEL);
2775 2813 mos7840_port->dr = kmalloc(sizeof(struct usb_ctrlrequest), GFP_KERNEL);
2814 if (!mos7840_port->control_urb || !mos7840_port->ctrl_buf || !mos7840_port->dr) {
2815 status = -ENOMEM;
2816 goto error;
2817 }
2776 } 2818 }
2777 2819
2778 //Zero Length flag enable 2820 //Zero Length flag enable
2779 Data = 0x0f; 2821 Data = 0x0f;
2780 status = 0;
2781 status = mos7840_set_reg_sync(serial->port[0], ZLP_REG5, Data); 2822 status = mos7840_set_reg_sync(serial->port[0], ZLP_REG5, Data);
2782 if (status < 0) { 2823 if (status < 0) {
2783 dbg("Writing ZLP_REG5 failed status-0x%x\n", status); 2824 dbg("Writing ZLP_REG5 failed status-0x%x\n", status);
@@ -2789,6 +2830,17 @@ static int mos7840_startup(struct usb_serial *serial)
2789 usb_control_msg(serial->dev, usb_sndctrlpipe(serial->dev, 0), 2830 usb_control_msg(serial->dev, usb_sndctrlpipe(serial->dev, 0),
2790 (__u8) 0x03, 0x00, 0x01, 0x00, NULL, 0x00, 5 * HZ); 2831 (__u8) 0x03, 0x00, 0x01, 0x00, NULL, 0x00, 5 * HZ);
2791 return 0; 2832 return 0;
2833error:
2834 for (/* nothing */; i >= 0; i--) {
2835 mos7840_port = mos7840_get_port_private(serial->port[i]);
2836
2837 kfree(mos7840_port->dr);
2838 kfree(mos7840_port->ctrl_buf);
2839 usb_free_urb(mos7840_port->control_urb);
2840 kfree(mos7840_port);
2841 serial->port[i] = NULL;
2842 }
2843 return status;
2792} 2844}
2793 2845
2794/**************************************************************************** 2846/****************************************************************************
@@ -2799,6 +2851,7 @@ static int mos7840_startup(struct usb_serial *serial)
2799static void mos7840_shutdown(struct usb_serial *serial) 2851static void mos7840_shutdown(struct usb_serial *serial)
2800{ 2852{
2801 int i; 2853 int i;
2854 unsigned long flags;
2802 struct moschip_port *mos7840_port; 2855 struct moschip_port *mos7840_port;
2803 dbg("%s \n", " shutdown :entering.........."); 2856 dbg("%s \n", " shutdown :entering..........");
2804 2857
@@ -2814,8 +2867,12 @@ static void mos7840_shutdown(struct usb_serial *serial)
2814 2867
2815 for (i = 0; i < serial->num_ports; ++i) { 2868 for (i = 0; i < serial->num_ports; ++i) {
2816 mos7840_port = mos7840_get_port_private(serial->port[i]); 2869 mos7840_port = mos7840_get_port_private(serial->port[i]);
2817 kfree(mos7840_port->ctrl_buf); 2870 spin_lock_irqsave(&mos7840_port->pool_lock, flags);
2871 mos7840_port->zombie = 1;
2872 spin_unlock_irqrestore(&mos7840_port->pool_lock, flags);
2818 usb_kill_urb(mos7840_port->control_urb); 2873 usb_kill_urb(mos7840_port->control_urb);
2874 kfree(mos7840_port->ctrl_buf);
2875 kfree(mos7840_port->dr);
2819 kfree(mos7840_port); 2876 kfree(mos7840_port);
2820 mos7840_set_port_private(serial->port[i], NULL); 2877 mos7840_set_port_private(serial->port[i], NULL);
2821 } 2878 }
diff --git a/drivers/usb/serial/omninet.c b/drivers/usb/serial/omninet.c
index 0216ac12a27d..4adfab988e86 100644
--- a/drivers/usb/serial/omninet.c
+++ b/drivers/usb/serial/omninet.c
@@ -69,6 +69,7 @@ static void omninet_write_bulk_callback (struct urb *urb);
69static int omninet_write (struct usb_serial_port *port, const unsigned char *buf, int count); 69static int omninet_write (struct usb_serial_port *port, const unsigned char *buf, int count);
70static int omninet_write_room (struct usb_serial_port *port); 70static int omninet_write_room (struct usb_serial_port *port);
71static void omninet_shutdown (struct usb_serial *serial); 71static void omninet_shutdown (struct usb_serial *serial);
72static int omninet_attach (struct usb_serial *serial);
72 73
73static struct usb_device_id id_table [] = { 74static struct usb_device_id id_table [] = {
74 { USB_DEVICE(ZYXEL_VENDOR_ID, ZYXEL_OMNINET_ID) }, 75 { USB_DEVICE(ZYXEL_VENDOR_ID, ZYXEL_OMNINET_ID) },
@@ -99,6 +100,7 @@ static struct usb_serial_driver zyxel_omninet_device = {
99 .num_bulk_in = 1, 100 .num_bulk_in = 1,
100 .num_bulk_out = 2, 101 .num_bulk_out = 2,
101 .num_ports = 1, 102 .num_ports = 1,
103 .attach = omninet_attach,
102 .open = omninet_open, 104 .open = omninet_open,
103 .close = omninet_close, 105 .close = omninet_close,
104 .write = omninet_write, 106 .write = omninet_write,
@@ -145,22 +147,30 @@ struct omninet_data
145 __u8 od_outseq; // Sequence number for bulk_out URBs 147 __u8 od_outseq; // Sequence number for bulk_out URBs
146}; 148};
147 149
150static int omninet_attach (struct usb_serial *serial)
151{
152 struct omninet_data *od;
153 struct usb_serial_port *port = serial->port[0];
154
155 od = kmalloc( sizeof(struct omninet_data), GFP_KERNEL );
156 if( !od ) {
157 err("%s- kmalloc(%Zd) failed.", __FUNCTION__, sizeof(struct omninet_data));
158 return -ENOMEM;
159 }
160 usb_set_serial_port_data(port, od);
161 return 0;
162}
163
148static int omninet_open (struct usb_serial_port *port, struct file *filp) 164static int omninet_open (struct usb_serial_port *port, struct file *filp)
149{ 165{
150 struct usb_serial *serial = port->serial; 166 struct usb_serial *serial = port->serial;
151 struct usb_serial_port *wport; 167 struct usb_serial_port *wport;
152 struct omninet_data *od; 168 struct omninet_data *od = usb_get_serial_port_data(port);
153 int result = 0; 169 int result = 0;
154 170
155 dbg("%s - port %d", __FUNCTION__, port->number); 171 dbg("%s - port %d", __FUNCTION__, port->number);
156 172
157 od = kmalloc( sizeof(struct omninet_data), GFP_KERNEL ); 173 od = kmalloc( sizeof(struct omninet_data), GFP_KERNEL );
158 if( !od ) {
159 err("%s- kmalloc(%Zd) failed.", __FUNCTION__, sizeof(struct omninet_data));
160 return -ENOMEM;
161 }
162
163 usb_set_serial_port_data(port, od);
164 wport = serial->port[1]; 174 wport = serial->port[1];
165 wport->tty = port->tty; 175 wport->tty = port->tty;
166 176
@@ -170,24 +180,17 @@ static int omninet_open (struct usb_serial_port *port, struct file *filp)
170 port->read_urb->transfer_buffer, port->read_urb->transfer_buffer_length, 180 port->read_urb->transfer_buffer, port->read_urb->transfer_buffer_length,
171 omninet_read_bulk_callback, port); 181 omninet_read_bulk_callback, port);
172 result = usb_submit_urb(port->read_urb, GFP_KERNEL); 182 result = usb_submit_urb(port->read_urb, GFP_KERNEL);
173 if (result) 183 if (result) {
174 err("%s - failed submitting read urb, error %d", __FUNCTION__, result); 184 err("%s - failed submitting read urb, error %d", __FUNCTION__, result);
185 }
175 186
176 return result; 187 return result;
177} 188}
178 189
179static void omninet_close (struct usb_serial_port *port, struct file * filp) 190static void omninet_close (struct usb_serial_port *port, struct file * filp)
180{ 191{
181 struct usb_serial *serial = port->serial;
182 struct usb_serial_port *wport;
183
184 dbg("%s - port %d", __FUNCTION__, port->number); 192 dbg("%s - port %d", __FUNCTION__, port->number);
185
186 wport = serial->port[1];
187 usb_kill_urb(wport->write_urb);
188 usb_kill_urb(port->read_urb); 193 usb_kill_urb(port->read_urb);
189
190 kfree(usb_get_serial_port_data(port));
191} 194}
192 195
193 196
@@ -326,7 +329,12 @@ static void omninet_write_bulk_callback (struct urb *urb)
326 329
327static void omninet_shutdown (struct usb_serial *serial) 330static void omninet_shutdown (struct usb_serial *serial)
328{ 331{
332 struct usb_serial_port *wport = serial->port[1];
333 struct usb_serial_port *port = serial->port[0];
329 dbg ("%s", __FUNCTION__); 334 dbg ("%s", __FUNCTION__);
335
336 usb_kill_urb(wport->write_urb);
337 kfree(usb_get_serial_port_data(port));
330} 338}
331 339
332 340
diff --git a/drivers/usb/serial/option.c b/drivers/usb/serial/option.c
index e178e6f40319..8c3f55b080b4 100644
--- a/drivers/usb/serial/option.c
+++ b/drivers/usb/serial/option.c
@@ -113,6 +113,12 @@ static int option_send_setup(struct usb_serial_port *port);
113#define ANYDATA_VENDOR_ID 0x16d5 113#define ANYDATA_VENDOR_ID 0x16d5
114#define ANYDATA_PRODUCT_ID 0x6501 114#define ANYDATA_PRODUCT_ID 0x6501
115 115
116#define BANDRICH_VENDOR_ID 0x1A8D
117#define BANDRICH_PRODUCT_C100_1 0x1002
118#define BANDRICH_PRODUCT_C100_2 0x1003
119
120#define DELL_VENDOR_ID 0x413C
121
116static struct usb_device_id option_ids[] = { 122static struct usb_device_id option_ids[] = {
117 { USB_DEVICE(OPTION_VENDOR_ID, OPTION_PRODUCT_COLT) }, 123 { USB_DEVICE(OPTION_VENDOR_ID, OPTION_PRODUCT_COLT) },
118 { USB_DEVICE(OPTION_VENDOR_ID, OPTION_PRODUCT_RICOLA) }, 124 { USB_DEVICE(OPTION_VENDOR_ID, OPTION_PRODUCT_RICOLA) },
@@ -165,6 +171,9 @@ static struct usb_device_id option_ids[] = {
165 { USB_DEVICE(NOVATELWIRELESS_VENDOR_ID, 0x2130) }, /* Novatel Merlin ES620 SM Bus */ 171 { USB_DEVICE(NOVATELWIRELESS_VENDOR_ID, 0x2130) }, /* Novatel Merlin ES620 SM Bus */
166 { USB_DEVICE(NOVATELWIRELESS_VENDOR_ID, 0x2410) }, /* Novatel EU740 */ 172 { USB_DEVICE(NOVATELWIRELESS_VENDOR_ID, 0x2410) }, /* Novatel EU740 */
167 { USB_DEVICE(ANYDATA_VENDOR_ID, ANYDATA_PRODUCT_ID) }, 173 { USB_DEVICE(ANYDATA_VENDOR_ID, ANYDATA_PRODUCT_ID) },
174 { USB_DEVICE(BANDRICH_VENDOR_ID, BANDRICH_PRODUCT_C100_1) },
175 { USB_DEVICE(BANDRICH_VENDOR_ID, BANDRICH_PRODUCT_C100_2) },
176 { USB_DEVICE(DELL_VENDOR_ID, 0x8118) }, /* Dell Wireless 5510 Mobile Broadband HSDPA ExpressCard */
168 { } /* Terminating entry */ 177 { } /* Terminating entry */
169}; 178};
170MODULE_DEVICE_TABLE(usb, option_ids); 179MODULE_DEVICE_TABLE(usb, option_ids);
@@ -591,12 +600,6 @@ static int option_open(struct usb_serial_port *port, struct file *filp)
591 return (0); 600 return (0);
592} 601}
593 602
594static inline void stop_urb(struct urb *urb)
595{
596 if (urb && urb->status == -EINPROGRESS)
597 usb_kill_urb(urb);
598}
599
600static void option_close(struct usb_serial_port *port, struct file *filp) 603static void option_close(struct usb_serial_port *port, struct file *filp)
601{ 604{
602 int i; 605 int i;
@@ -614,9 +617,9 @@ static void option_close(struct usb_serial_port *port, struct file *filp)
614 617
615 /* Stop reading/writing urbs */ 618 /* Stop reading/writing urbs */
616 for (i = 0; i < N_IN_URB; i++) 619 for (i = 0; i < N_IN_URB; i++)
617 stop_urb(portdata->in_urbs[i]); 620 usb_kill_urb(portdata->in_urbs[i]);
618 for (i = 0; i < N_OUT_URB; i++) 621 for (i = 0; i < N_OUT_URB; i++)
619 stop_urb(portdata->out_urbs[i]); 622 usb_kill_urb(portdata->out_urbs[i]);
620 } 623 }
621 port->tty = NULL; 624 port->tty = NULL;
622} 625}
@@ -747,9 +750,9 @@ static void option_shutdown(struct usb_serial *serial)
747 port = serial->port[i]; 750 port = serial->port[i];
748 portdata = usb_get_serial_port_data(port); 751 portdata = usb_get_serial_port_data(port);
749 for (j = 0; j < N_IN_URB; j++) 752 for (j = 0; j < N_IN_URB; j++)
750 stop_urb(portdata->in_urbs[j]); 753 usb_kill_urb(portdata->in_urbs[j]);
751 for (j = 0; j < N_OUT_URB; j++) 754 for (j = 0; j < N_OUT_URB; j++)
752 stop_urb(portdata->out_urbs[j]); 755 usb_kill_urb(portdata->out_urbs[j]);
753 } 756 }
754 757
755 /* Now free them */ 758 /* Now free them */
diff --git a/drivers/usb/serial/sierra.c b/drivers/usb/serial/sierra.c
index ecedd833818d..644607de4c11 100644
--- a/drivers/usb/serial/sierra.c
+++ b/drivers/usb/serial/sierra.c
@@ -456,12 +456,6 @@ static int sierra_open(struct usb_serial_port *port, struct file *filp)
456 return (0); 456 return (0);
457} 457}
458 458
459static inline void stop_urb(struct urb *urb)
460{
461 if (urb && urb->status == -EINPROGRESS)
462 usb_kill_urb(urb);
463}
464
465static void sierra_close(struct usb_serial_port *port, struct file *filp) 459static void sierra_close(struct usb_serial_port *port, struct file *filp)
466{ 460{
467 int i; 461 int i;
@@ -479,9 +473,9 @@ static void sierra_close(struct usb_serial_port *port, struct file *filp)
479 473
480 /* Stop reading/writing urbs */ 474 /* Stop reading/writing urbs */
481 for (i = 0; i < N_IN_URB; i++) 475 for (i = 0; i < N_IN_URB; i++)
482 stop_urb(portdata->in_urbs[i]); 476 usb_unlink_urb(portdata->in_urbs[i]);
483 for (i = 0; i < N_OUT_URB; i++) 477 for (i = 0; i < N_OUT_URB; i++)
484 stop_urb(portdata->out_urbs[i]); 478 usb_unlink_urb(portdata->out_urbs[i]);
485 } 479 }
486 port->tty = NULL; 480 port->tty = NULL;
487} 481}
@@ -583,17 +577,26 @@ static void sierra_shutdown(struct usb_serial *serial)
583 /* Stop reading/writing urbs */ 577 /* Stop reading/writing urbs */
584 for (i = 0; i < serial->num_ports; ++i) { 578 for (i = 0; i < serial->num_ports; ++i) {
585 port = serial->port[i]; 579 port = serial->port[i];
580 if (!port)
581 continue;
586 portdata = usb_get_serial_port_data(port); 582 portdata = usb_get_serial_port_data(port);
583 if (!portdata)
584 continue;
585
587 for (j = 0; j < N_IN_URB; j++) 586 for (j = 0; j < N_IN_URB; j++)
588 stop_urb(portdata->in_urbs[j]); 587 usb_unlink_urb(portdata->in_urbs[j]);
589 for (j = 0; j < N_OUT_URB; j++) 588 for (j = 0; j < N_OUT_URB; j++)
590 stop_urb(portdata->out_urbs[j]); 589 usb_unlink_urb(portdata->out_urbs[j]);
591 } 590 }
592 591
593 /* Now free them */ 592 /* Now free them */
594 for (i = 0; i < serial->num_ports; ++i) { 593 for (i = 0; i < serial->num_ports; ++i) {
595 port = serial->port[i]; 594 port = serial->port[i];
595 if (!port)
596 continue;
596 portdata = usb_get_serial_port_data(port); 597 portdata = usb_get_serial_port_data(port);
598 if (!portdata)
599 continue;
597 600
598 for (j = 0; j < N_IN_URB; j++) { 601 for (j = 0; j < N_IN_URB; j++) {
599 if (portdata->in_urbs[j]) { 602 if (portdata->in_urbs[j]) {
@@ -612,6 +615,8 @@ static void sierra_shutdown(struct usb_serial *serial)
612 /* Now free per port private data */ 615 /* Now free per port private data */
613 for (i = 0; i < serial->num_ports; i++) { 616 for (i = 0; i < serial->num_ports; i++) {
614 port = serial->port[i]; 617 port = serial->port[i];
618 if (!port)
619 continue;
615 kfree(usb_get_serial_port_data(port)); 620 kfree(usb_get_serial_port_data(port));
616 } 621 }
617} 622}
diff --git a/drivers/usb/serial/visor.c b/drivers/usb/serial/visor.c
index 2f59ff226e2c..ffbe601cde2a 100644
--- a/drivers/usb/serial/visor.c
+++ b/drivers/usb/serial/visor.c
@@ -384,19 +384,21 @@ static int visor_write (struct usb_serial_port *port, const unsigned char *buf,
384 dbg("%s - write limit hit\n", __FUNCTION__); 384 dbg("%s - write limit hit\n", __FUNCTION__);
385 return 0; 385 return 0;
386 } 386 }
387 priv->outstanding_urbs++;
387 spin_unlock_irqrestore(&priv->lock, flags); 388 spin_unlock_irqrestore(&priv->lock, flags);
388 389
389 buffer = kmalloc (count, GFP_ATOMIC); 390 buffer = kmalloc (count, GFP_ATOMIC);
390 if (!buffer) { 391 if (!buffer) {
391 dev_err(&port->dev, "out of memory\n"); 392 dev_err(&port->dev, "out of memory\n");
392 return -ENOMEM; 393 count = -ENOMEM;
394 goto error_no_buffer;
393 } 395 }
394 396
395 urb = usb_alloc_urb(0, GFP_ATOMIC); 397 urb = usb_alloc_urb(0, GFP_ATOMIC);
396 if (!urb) { 398 if (!urb) {
397 dev_err(&port->dev, "no more free urbs\n"); 399 dev_err(&port->dev, "no more free urbs\n");
398 kfree (buffer); 400 count = -ENOMEM;
399 return -ENOMEM; 401 goto error_no_urb;
400 } 402 }
401 403
402 memcpy (buffer, buf, count); 404 memcpy (buffer, buf, count);
@@ -415,19 +417,27 @@ static int visor_write (struct usb_serial_port *port, const unsigned char *buf,
415 dev_err(&port->dev, "%s - usb_submit_urb(write bulk) failed with status = %d\n", 417 dev_err(&port->dev, "%s - usb_submit_urb(write bulk) failed with status = %d\n",
416 __FUNCTION__, status); 418 __FUNCTION__, status);
417 count = status; 419 count = status;
418 kfree (buffer); 420 goto error;
419 } else { 421 } else {
420 spin_lock_irqsave(&priv->lock, flags); 422 spin_lock_irqsave(&priv->lock, flags);
421 ++priv->outstanding_urbs;
422 priv->bytes_out += count; 423 priv->bytes_out += count;
423 spin_unlock_irqrestore(&priv->lock, flags); 424 spin_unlock_irqrestore(&priv->lock, flags);
424 } 425 }
425 426
426 /* we are done with this urb, so let the host driver 427 /* we are done with this urb, so let the host driver
427 * really free it when it is finished with it */ 428 * really free it when it is finished with it */
428 usb_free_urb (urb); 429 usb_free_urb(urb);
429 430
430 return count; 431 return count;
432error:
433 usb_free_urb(urb);
434error_no_urb:
435 kfree(buffer);
436error_no_buffer:
437 spin_lock_irqsave(&priv->lock, flags);
438 --priv->outstanding_urbs;
439 spin_unlock_irqrestore(&priv->lock, flags);
440 return count;
431} 441}
432 442
433 443
diff --git a/drivers/usb/serial/whiteheat.c b/drivers/usb/serial/whiteheat.c
index bf16e9e1d84e..27c5f8f9a2d5 100644
--- a/drivers/usb/serial/whiteheat.c
+++ b/drivers/usb/serial/whiteheat.c
@@ -1109,7 +1109,7 @@ static int firm_send_command (struct usb_serial_port *port, __u8 command, __u8 *
1109 command_port = port->serial->port[COMMAND_PORT]; 1109 command_port = port->serial->port[COMMAND_PORT];
1110 command_info = usb_get_serial_port_data(command_port); 1110 command_info = usb_get_serial_port_data(command_port);
1111 spin_lock_irqsave(&command_info->lock, flags); 1111 spin_lock_irqsave(&command_info->lock, flags);
1112 command_info->command_finished = FALSE; 1112 command_info->command_finished = false;
1113 1113
1114 transfer_buffer = (__u8 *)command_port->write_urb->transfer_buffer; 1114 transfer_buffer = (__u8 *)command_port->write_urb->transfer_buffer;
1115 transfer_buffer[0] = command; 1115 transfer_buffer[0] = command;
@@ -1124,12 +1124,12 @@ static int firm_send_command (struct usb_serial_port *port, __u8 command, __u8 *
1124 spin_unlock_irqrestore(&command_info->lock, flags); 1124 spin_unlock_irqrestore(&command_info->lock, flags);
1125 1125
1126 /* wait for the command to complete */ 1126 /* wait for the command to complete */
1127 wait_event_interruptible_timeout(command_info->wait_command, 1127 wait_event_interruptible_timeout(command_info->wait_command,
1128 (command_info->command_finished != FALSE), COMMAND_TIMEOUT); 1128 (bool)command_info->command_finished, COMMAND_TIMEOUT);
1129 1129
1130 spin_lock_irqsave(&command_info->lock, flags); 1130 spin_lock_irqsave(&command_info->lock, flags);
1131 1131
1132 if (command_info->command_finished == FALSE) { 1132 if (command_info->command_finished == false) {
1133 dbg("%s - command timed out.", __FUNCTION__); 1133 dbg("%s - command timed out.", __FUNCTION__);
1134 retval = -ETIMEDOUT; 1134 retval = -ETIMEDOUT;
1135 goto exit; 1135 goto exit;
diff --git a/drivers/usb/serial/whiteheat.h b/drivers/usb/serial/whiteheat.h
index d714eff58dc0..f16079705664 100644
--- a/drivers/usb/serial/whiteheat.h
+++ b/drivers/usb/serial/whiteheat.h
@@ -20,10 +20,6 @@
20#define __LINUX_USB_SERIAL_WHITEHEAT_H 20#define __LINUX_USB_SERIAL_WHITEHEAT_H
21 21
22 22
23#define FALSE 0
24#define TRUE 1
25
26
27/* WhiteHEAT commands */ 23/* WhiteHEAT commands */
28#define WHITEHEAT_OPEN 1 /* open the port */ 24#define WHITEHEAT_OPEN 1 /* open the port */
29#define WHITEHEAT_CLOSE 2 /* close the port */ 25#define WHITEHEAT_CLOSE 2 /* close the port */