aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/usb/serial
diff options
context:
space:
mode:
authorJiri Slaby <jslaby@suse.cz>2013-01-03 09:53:06 -0500
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2013-01-16 01:30:15 -0500
commit2e124b4a390ca85325fae75764bef92f0547fa25 (patch)
tree5519fbcdbe954e79b271ea6d31ac5a4dc754c4f5 /drivers/usb/serial
parentd6c53c0e9bd0a83f9f9ddbc9fd80141a54d83896 (diff)
TTY: switch tty_flip_buffer_push
Now, we start converting tty buffer functions to actually use tty_port. This will allow us to get rid of the need of tty in many call sites. Only tty_port will needed and hence no more tty_port_tty_get in those paths. Now, the one where most of tty_port_tty_get gets removed: tty_flip_buffer_push. IOW we also closed all the races in drivers not using tty_port_tty_get at all yet. Also we move tty_flip_buffer_push declaration from include/linux/tty.h to include/linux/tty_flip.h to all others while we are changing it anyway. Signed-off-by: Jiri Slaby <jslaby@suse.cz> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'drivers/usb/serial')
-rw-r--r--drivers/usb/serial/aircable.c8
-rw-r--r--drivers/usb/serial/ark3116.c8
-rw-r--r--drivers/usb/serial/belkin_sa.c8
-rw-r--r--drivers/usb/serial/cyberjack.c9
-rw-r--r--drivers/usb/serial/cypress_m8.c4
-rw-r--r--drivers/usb/serial/digi_acceleport.c8
-rw-r--r--drivers/usb/serial/f81232.c8
-rw-r--r--drivers/usb/serial/ftdi_sio.c8
-rw-r--r--drivers/usb/serial/garmin_gps.c7
-rw-r--r--drivers/usb/serial/generic.c8
-rw-r--r--drivers/usb/serial/io_edgeport.c35
-rw-r--r--drivers/usb/serial/io_ti.c27
-rw-r--r--drivers/usb/serial/ir-usb.c7
-rw-r--r--drivers/usb/serial/iuu_phoenix.c7
-rw-r--r--drivers/usb/serial/keyspan.c31
-rw-r--r--drivers/usb/serial/keyspan_pda.c7
-rw-r--r--drivers/usb/serial/kl5kusb105.c8
-rw-r--r--drivers/usb/serial/kobil_sct.c7
-rw-r--r--drivers/usb/serial/mct_u232.c11
-rw-r--r--drivers/usb/serial/metro-usb.c7
-rw-r--r--drivers/usb/serial/mos7720.c7
-rw-r--r--drivers/usb/serial/mos7840.c9
-rw-r--r--drivers/usb/serial/navman.c7
-rw-r--r--drivers/usb/serial/omninet.c11
-rw-r--r--drivers/usb/serial/opticon.c9
-rw-r--r--drivers/usb/serial/oti6858.c7
-rw-r--r--drivers/usb/serial/pl2303.c8
-rw-r--r--drivers/usb/serial/quatech2.c19
-rw-r--r--drivers/usb/serial/safe_serial.c13
-rw-r--r--drivers/usb/serial/sierra.c17
-rw-r--r--drivers/usb/serial/spcp8x5.c18
-rw-r--r--drivers/usb/serial/ssu100.c23
-rw-r--r--drivers/usb/serial/symbolserial.c10
-rw-r--r--drivers/usb/serial/ti_usb_3410_5052.c39
-rw-r--r--drivers/usb/serial/usb_wwan.c17
35 files changed, 116 insertions, 321 deletions
diff --git a/drivers/usb/serial/aircable.c b/drivers/usb/serial/aircable.c
index 3bb1f8f11fc8..6e320cec397d 100644
--- a/drivers/usb/serial/aircable.c
+++ b/drivers/usb/serial/aircable.c
@@ -140,16 +140,11 @@ static void aircable_process_read_urb(struct urb *urb)
140{ 140{
141 struct usb_serial_port *port = urb->context; 141 struct usb_serial_port *port = urb->context;
142 char *data = (char *)urb->transfer_buffer; 142 char *data = (char *)urb->transfer_buffer;
143 struct tty_struct *tty;
144 int has_headers; 143 int has_headers;
145 int count; 144 int count;
146 int len; 145 int len;
147 int i; 146 int i;
148 147
149 tty = tty_port_tty_get(&port->port);
150 if (!tty)
151 return;
152
153 has_headers = (urb->actual_length > 2 && data[0] == RX_HEADER_0); 148 has_headers = (urb->actual_length > 2 && data[0] == RX_HEADER_0);
154 149
155 count = 0; 150 count = 0;
@@ -160,8 +155,7 @@ static void aircable_process_read_urb(struct urb *urb)
160 } 155 }
161 156
162 if (count) 157 if (count)
163 tty_flip_buffer_push(tty); 158 tty_flip_buffer_push(&port->port);
164 tty_kref_put(tty);
165} 159}
166 160
167static struct usb_serial_driver aircable_device = { 161static struct usb_serial_driver aircable_device = {
diff --git a/drivers/usb/serial/ark3116.c b/drivers/usb/serial/ark3116.c
index 1614feb6a76e..cbd904b8fba5 100644
--- a/drivers/usb/serial/ark3116.c
+++ b/drivers/usb/serial/ark3116.c
@@ -674,7 +674,6 @@ static void ark3116_process_read_urb(struct urb *urb)
674{ 674{
675 struct usb_serial_port *port = urb->context; 675 struct usb_serial_port *port = urb->context;
676 struct ark3116_private *priv = usb_get_serial_port_data(port); 676 struct ark3116_private *priv = usb_get_serial_port_data(port);
677 struct tty_struct *tty;
678 unsigned char *data = urb->transfer_buffer; 677 unsigned char *data = urb->transfer_buffer;
679 char tty_flag = TTY_NORMAL; 678 char tty_flag = TTY_NORMAL;
680 unsigned long flags; 679 unsigned long flags;
@@ -689,10 +688,6 @@ static void ark3116_process_read_urb(struct urb *urb)
689 if (!urb->actual_length) 688 if (!urb->actual_length)
690 return; 689 return;
691 690
692 tty = tty_port_tty_get(&port->port);
693 if (!tty)
694 return;
695
696 if (lsr & UART_LSR_BRK_ERROR_BITS) { 691 if (lsr & UART_LSR_BRK_ERROR_BITS) {
697 if (lsr & UART_LSR_BI) 692 if (lsr & UART_LSR_BI)
698 tty_flag = TTY_BREAK; 693 tty_flag = TTY_BREAK;
@@ -707,8 +702,7 @@ static void ark3116_process_read_urb(struct urb *urb)
707 } 702 }
708 tty_insert_flip_string_fixed_flag(&port->port, data, tty_flag, 703 tty_insert_flip_string_fixed_flag(&port->port, data, tty_flag,
709 urb->actual_length); 704 urb->actual_length);
710 tty_flip_buffer_push(tty); 705 tty_flip_buffer_push(&port->port);
711 tty_kref_put(tty);
712} 706}
713 707
714static struct usb_serial_driver ark3116_device = { 708static struct usb_serial_driver ark3116_device = {
diff --git a/drivers/usb/serial/belkin_sa.c b/drivers/usb/serial/belkin_sa.c
index 7ba2c0bdcec9..84217e78ded4 100644
--- a/drivers/usb/serial/belkin_sa.c
+++ b/drivers/usb/serial/belkin_sa.c
@@ -242,7 +242,6 @@ static void belkin_sa_process_read_urb(struct urb *urb)
242{ 242{
243 struct usb_serial_port *port = urb->context; 243 struct usb_serial_port *port = urb->context;
244 struct belkin_sa_private *priv = usb_get_serial_port_data(port); 244 struct belkin_sa_private *priv = usb_get_serial_port_data(port);
245 struct tty_struct *tty;
246 unsigned char *data = urb->transfer_buffer; 245 unsigned char *data = urb->transfer_buffer;
247 unsigned long flags; 246 unsigned long flags;
248 unsigned char status; 247 unsigned char status;
@@ -259,10 +258,6 @@ static void belkin_sa_process_read_urb(struct urb *urb)
259 if (!urb->actual_length) 258 if (!urb->actual_length)
260 return; 259 return;
261 260
262 tty = tty_port_tty_get(&port->port);
263 if (!tty)
264 return;
265
266 if (status & BELKIN_SA_LSR_ERR) { 261 if (status & BELKIN_SA_LSR_ERR) {
267 /* Break takes precedence over parity, which takes precedence 262 /* Break takes precedence over parity, which takes precedence
268 * over framing errors. */ 263 * over framing errors. */
@@ -281,8 +276,7 @@ static void belkin_sa_process_read_urb(struct urb *urb)
281 276
282 tty_insert_flip_string_fixed_flag(&port->port, data, tty_flag, 277 tty_insert_flip_string_fixed_flag(&port->port, data, tty_flag,
283 urb->actual_length); 278 urb->actual_length);
284 tty_flip_buffer_push(tty); 279 tty_flip_buffer_push(&port->port);
285 tty_kref_put(tty);
286} 280}
287 281
288static void belkin_sa_set_termios(struct tty_struct *tty, 282static void belkin_sa_set_termios(struct tty_struct *tty,
diff --git a/drivers/usb/serial/cyberjack.c b/drivers/usb/serial/cyberjack.c
index e6976a974472..629bd2894506 100644
--- a/drivers/usb/serial/cyberjack.c
+++ b/drivers/usb/serial/cyberjack.c
@@ -324,7 +324,6 @@ static void cyberjack_read_bulk_callback(struct urb *urb)
324 struct usb_serial_port *port = urb->context; 324 struct usb_serial_port *port = urb->context;
325 struct cyberjack_private *priv = usb_get_serial_port_data(port); 325 struct cyberjack_private *priv = usb_get_serial_port_data(port);
326 struct device *dev = &port->dev; 326 struct device *dev = &port->dev;
327 struct tty_struct *tty;
328 unsigned char *data = urb->transfer_buffer; 327 unsigned char *data = urb->transfer_buffer;
329 short todo; 328 short todo;
330 int result; 329 int result;
@@ -337,16 +336,10 @@ static void cyberjack_read_bulk_callback(struct urb *urb)
337 return; 336 return;
338 } 337 }
339 338
340 tty = tty_port_tty_get(&port->port);
341 if (!tty) {
342 dev_dbg(dev, "%s - ignoring since device not open\n", __func__);
343 return;
344 }
345 if (urb->actual_length) { 339 if (urb->actual_length) {
346 tty_insert_flip_string(&port->port, data, urb->actual_length); 340 tty_insert_flip_string(&port->port, data, urb->actual_length);
347 tty_flip_buffer_push(tty); 341 tty_flip_buffer_push(&port->port);
348 } 342 }
349 tty_kref_put(tty);
350 343
351 spin_lock(&priv->lock); 344 spin_lock(&priv->lock);
352 345
diff --git a/drivers/usb/serial/cypress_m8.c b/drivers/usb/serial/cypress_m8.c
index ac14e3eb95ea..8efa19d0e9fb 100644
--- a/drivers/usb/serial/cypress_m8.c
+++ b/drivers/usb/serial/cypress_m8.c
@@ -1214,10 +1214,10 @@ static void cypress_read_int_callback(struct urb *urb)
1214 spin_unlock_irqrestore(&priv->lock, flags); 1214 spin_unlock_irqrestore(&priv->lock, flags);
1215 1215
1216 /* process read if there is data other than line status */ 1216 /* process read if there is data other than line status */
1217 if (tty && bytes > i) { 1217 if (bytes > i) {
1218 tty_insert_flip_string_fixed_flag(&port->port, data + i, 1218 tty_insert_flip_string_fixed_flag(&port->port, data + i,
1219 tty_flag, bytes - i); 1219 tty_flag, bytes - i);
1220 tty_flip_buffer_push(tty); 1220 tty_flip_buffer_push(&port->port);
1221 } 1221 }
1222 1222
1223 spin_lock_irqsave(&priv->lock, flags); 1223 spin_lock_irqsave(&priv->lock, flags);
diff --git a/drivers/usb/serial/digi_acceleport.c b/drivers/usb/serial/digi_acceleport.c
index b5fa738512ca..ebe45fa0ed50 100644
--- a/drivers/usb/serial/digi_acceleport.c
+++ b/drivers/usb/serial/digi_acceleport.c
@@ -1399,9 +1399,7 @@ static void digi_read_bulk_callback(struct urb *urb)
1399 1399
1400static int digi_read_inb_callback(struct urb *urb) 1400static int digi_read_inb_callback(struct urb *urb)
1401{ 1401{
1402
1403 struct usb_serial_port *port = urb->context; 1402 struct usb_serial_port *port = urb->context;
1404 struct tty_struct *tty;
1405 struct digi_port *priv = usb_get_serial_port_data(port); 1403 struct digi_port *priv = usb_get_serial_port_data(port);
1406 int opcode = ((unsigned char *)urb->transfer_buffer)[0]; 1404 int opcode = ((unsigned char *)urb->transfer_buffer)[0];
1407 int len = ((unsigned char *)urb->transfer_buffer)[1]; 1405 int len = ((unsigned char *)urb->transfer_buffer)[1];
@@ -1425,7 +1423,6 @@ static int digi_read_inb_callback(struct urb *urb)
1425 return -1; 1423 return -1;
1426 } 1424 }
1427 1425
1428 tty = tty_port_tty_get(&port->port);
1429 spin_lock(&priv->dp_port_lock); 1426 spin_lock(&priv->dp_port_lock);
1430 1427
1431 /* check for throttle; if set, do not resubmit read urb */ 1428 /* check for throttle; if set, do not resubmit read urb */
@@ -1435,7 +1432,7 @@ static int digi_read_inb_callback(struct urb *urb)
1435 priv->dp_throttle_restart = 1; 1432 priv->dp_throttle_restart = 1;
1436 1433
1437 /* receive data */ 1434 /* receive data */
1438 if (tty && opcode == DIGI_CMD_RECEIVE_DATA) { 1435 if (opcode == DIGI_CMD_RECEIVE_DATA) {
1439 /* get flag from port_status */ 1436 /* get flag from port_status */
1440 flag = 0; 1437 flag = 0;
1441 1438
@@ -1457,11 +1454,10 @@ static int digi_read_inb_callback(struct urb *urb)
1457 if (len > 0) { 1454 if (len > 0) {
1458 tty_insert_flip_string_fixed_flag(&port->port, data, 1455 tty_insert_flip_string_fixed_flag(&port->port, data,
1459 flag, len); 1456 flag, len);
1460 tty_flip_buffer_push(tty); 1457 tty_flip_buffer_push(&port->port);
1461 } 1458 }
1462 } 1459 }
1463 spin_unlock(&priv->dp_port_lock); 1460 spin_unlock(&priv->dp_port_lock);
1464 tty_kref_put(tty);
1465 1461
1466 if (opcode == DIGI_CMD_RECEIVE_DISABLE) 1462 if (opcode == DIGI_CMD_RECEIVE_DISABLE)
1467 dev_dbg(&port->dev, "%s: got RECEIVE_DISABLE\n", __func__); 1463 dev_dbg(&port->dev, "%s: got RECEIVE_DISABLE\n", __func__);
diff --git a/drivers/usb/serial/f81232.c b/drivers/usb/serial/f81232.c
index 6b880c33d258..b1b2dc64b50b 100644
--- a/drivers/usb/serial/f81232.c
+++ b/drivers/usb/serial/f81232.c
@@ -100,7 +100,6 @@ static void f81232_process_read_urb(struct urb *urb)
100{ 100{
101 struct usb_serial_port *port = urb->context; 101 struct usb_serial_port *port = urb->context;
102 struct f81232_private *priv = usb_get_serial_port_data(port); 102 struct f81232_private *priv = usb_get_serial_port_data(port);
103 struct tty_struct *tty;
104 unsigned char *data = urb->transfer_buffer; 103 unsigned char *data = urb->transfer_buffer;
105 char tty_flag = TTY_NORMAL; 104 char tty_flag = TTY_NORMAL;
106 unsigned long flags; 105 unsigned long flags;
@@ -117,10 +116,6 @@ static void f81232_process_read_urb(struct urb *urb)
117 if (!urb->actual_length) 116 if (!urb->actual_length)
118 return; 117 return;
119 118
120 tty = tty_port_tty_get(&port->port);
121 if (!tty)
122 return;
123
124 /* break takes precedence over parity, */ 119 /* break takes precedence over parity, */
125 /* which takes precedence over framing errors */ 120 /* which takes precedence over framing errors */
126 if (line_status & UART_BREAK_ERROR) 121 if (line_status & UART_BREAK_ERROR)
@@ -145,8 +140,7 @@ static void f81232_process_read_urb(struct urb *urb)
145 urb->actual_length); 140 urb->actual_length);
146 } 141 }
147 142
148 tty_flip_buffer_push(tty); 143 tty_flip_buffer_push(&port->port);
149 tty_kref_put(tty);
150} 144}
151 145
152static int set_control_lines(struct usb_device *dev, u8 value) 146static int set_control_lines(struct usb_device *dev, u8 value)
diff --git a/drivers/usb/serial/ftdi_sio.c b/drivers/usb/serial/ftdi_sio.c
index eb59ba3789ad..a96083b7fabc 100644
--- a/drivers/usb/serial/ftdi_sio.c
+++ b/drivers/usb/serial/ftdi_sio.c
@@ -2040,25 +2040,19 @@ static int ftdi_process_packet(struct usb_serial_port *port,
2040static void ftdi_process_read_urb(struct urb *urb) 2040static void ftdi_process_read_urb(struct urb *urb)
2041{ 2041{
2042 struct usb_serial_port *port = urb->context; 2042 struct usb_serial_port *port = urb->context;
2043 struct tty_struct *tty;
2044 struct ftdi_private *priv = usb_get_serial_port_data(port); 2043 struct ftdi_private *priv = usb_get_serial_port_data(port);
2045 char *data = (char *)urb->transfer_buffer; 2044 char *data = (char *)urb->transfer_buffer;
2046 int i; 2045 int i;
2047 int len; 2046 int len;
2048 int count = 0; 2047 int count = 0;
2049 2048
2050 tty = tty_port_tty_get(&port->port);
2051 if (!tty)
2052 return;
2053
2054 for (i = 0; i < urb->actual_length; i += priv->max_packet_size) { 2049 for (i = 0; i < urb->actual_length; i += priv->max_packet_size) {
2055 len = min_t(int, urb->actual_length - i, priv->max_packet_size); 2050 len = min_t(int, urb->actual_length - i, priv->max_packet_size);
2056 count += ftdi_process_packet(port, priv, &data[i], len); 2051 count += ftdi_process_packet(port, priv, &data[i], len);
2057 } 2052 }
2058 2053
2059 if (count) 2054 if (count)
2060 tty_flip_buffer_push(tty); 2055 tty_flip_buffer_push(&port->port);
2061 tty_kref_put(tty);
2062} 2056}
2063 2057
2064static void ftdi_break_ctl(struct tty_struct *tty, int break_state) 2058static void ftdi_break_ctl(struct tty_struct *tty, int break_state)
diff --git a/drivers/usb/serial/garmin_gps.c b/drivers/usb/serial/garmin_gps.c
index 498b5f0da639..1a07b12ef341 100644
--- a/drivers/usb/serial/garmin_gps.c
+++ b/drivers/usb/serial/garmin_gps.c
@@ -252,14 +252,11 @@ static inline int isAbortTrfCmnd(const unsigned char *buf)
252static void send_to_tty(struct usb_serial_port *port, 252static void send_to_tty(struct usb_serial_port *port,
253 char *data, unsigned int actual_length) 253 char *data, unsigned int actual_length)
254{ 254{
255 struct tty_struct *tty = tty_port_tty_get(&port->port); 255 if (actual_length) {
256
257 if (tty && actual_length) {
258 usb_serial_debug_data(&port->dev, __func__, actual_length, data); 256 usb_serial_debug_data(&port->dev, __func__, actual_length, data);
259 tty_insert_flip_string(&port->port, data, actual_length); 257 tty_insert_flip_string(&port->port, data, actual_length);
260 tty_flip_buffer_push(tty); 258 tty_flip_buffer_push(&port->port);
261 } 259 }
262 tty_kref_put(tty);
263} 260}
264 261
265 262
diff --git a/drivers/usb/serial/generic.c b/drivers/usb/serial/generic.c
index 3780f6a501b3..4c5c23f1cae5 100644
--- a/drivers/usb/serial/generic.c
+++ b/drivers/usb/serial/generic.c
@@ -313,17 +313,12 @@ EXPORT_SYMBOL_GPL(usb_serial_generic_submit_read_urbs);
313void usb_serial_generic_process_read_urb(struct urb *urb) 313void usb_serial_generic_process_read_urb(struct urb *urb)
314{ 314{
315 struct usb_serial_port *port = urb->context; 315 struct usb_serial_port *port = urb->context;
316 struct tty_struct *tty;
317 char *ch = (char *)urb->transfer_buffer; 316 char *ch = (char *)urb->transfer_buffer;
318 int i; 317 int i;
319 318
320 if (!urb->actual_length) 319 if (!urb->actual_length)
321 return; 320 return;
322 321
323 tty = tty_port_tty_get(&port->port);
324 if (!tty)
325 return;
326
327 /* The per character mucking around with sysrq path it too slow for 322 /* The per character mucking around with sysrq path it too slow for
328 stuff like 3G modems, so shortcircuit it in the 99.9999999% of cases 323 stuff like 3G modems, so shortcircuit it in the 99.9999999% of cases
329 where the USB serial is not a console anyway */ 324 where the USB serial is not a console anyway */
@@ -335,8 +330,7 @@ void usb_serial_generic_process_read_urb(struct urb *urb)
335 tty_insert_flip_char(&port->port, *ch, TTY_NORMAL); 330 tty_insert_flip_char(&port->port, *ch, TTY_NORMAL);
336 } 331 }
337 } 332 }
338 tty_flip_buffer_push(tty); 333 tty_flip_buffer_push(&port->port);
339 tty_kref_put(tty);
340} 334}
341EXPORT_SYMBOL_GPL(usb_serial_generic_process_read_urb); 335EXPORT_SYMBOL_GPL(usb_serial_generic_process_read_urb);
342 336
diff --git a/drivers/usb/serial/io_edgeport.c b/drivers/usb/serial/io_edgeport.c
index f96b91da964f..b00e5cbf741f 100644
--- a/drivers/usb/serial/io_edgeport.c
+++ b/drivers/usb/serial/io_edgeport.c
@@ -232,8 +232,8 @@ static void process_rcvd_data(struct edgeport_serial *edge_serial,
232 unsigned char *buffer, __u16 bufferLength); 232 unsigned char *buffer, __u16 bufferLength);
233static void process_rcvd_status(struct edgeport_serial *edge_serial, 233static void process_rcvd_status(struct edgeport_serial *edge_serial,
234 __u8 byte2, __u8 byte3); 234 __u8 byte2, __u8 byte3);
235static void edge_tty_recv(struct usb_serial_port *port, struct tty_struct *tty, 235static void edge_tty_recv(struct usb_serial_port *port, unsigned char *data,
236 unsigned char *data, int length); 236 int length);
237static void handle_new_msr(struct edgeport_port *edge_port, __u8 newMsr); 237static void handle_new_msr(struct edgeport_port *edge_port, __u8 newMsr);
238static void handle_new_lsr(struct edgeport_port *edge_port, __u8 lsrData, 238static void handle_new_lsr(struct edgeport_port *edge_port, __u8 lsrData,
239 __u8 lsr, __u8 data); 239 __u8 lsr, __u8 data);
@@ -1752,7 +1752,6 @@ static void process_rcvd_data(struct edgeport_serial *edge_serial,
1752 struct device *dev = &edge_serial->serial->dev->dev; 1752 struct device *dev = &edge_serial->serial->dev->dev;
1753 struct usb_serial_port *port; 1753 struct usb_serial_port *port;
1754 struct edgeport_port *edge_port; 1754 struct edgeport_port *edge_port;
1755 struct tty_struct *tty;
1756 __u16 lastBufferLength; 1755 __u16 lastBufferLength;
1757 __u16 rxLen; 1756 __u16 rxLen;
1758 1757
@@ -1860,14 +1859,11 @@ static void process_rcvd_data(struct edgeport_serial *edge_serial,
1860 edge_serial->rxPort]; 1859 edge_serial->rxPort];
1861 edge_port = usb_get_serial_port_data(port); 1860 edge_port = usb_get_serial_port_data(port);
1862 if (edge_port->open) { 1861 if (edge_port->open) {
1863 tty = tty_port_tty_get( 1862 dev_dbg(dev, "%s - Sending %d bytes to TTY for port %d\n",
1864 &edge_port->port->port); 1863 __func__, rxLen,
1865 if (tty) { 1864 edge_serial->rxPort);
1866 dev_dbg(dev, "%s - Sending %d bytes to TTY for port %d\n", 1865 edge_tty_recv(edge_port->port, buffer,
1867 __func__, rxLen, edge_serial->rxPort); 1866 rxLen);
1868 edge_tty_recv(edge_port->port, tty, buffer, rxLen);
1869 tty_kref_put(tty);
1870 }
1871 edge_port->icount.rx += rxLen; 1867 edge_port->icount.rx += rxLen;
1872 } 1868 }
1873 buffer += rxLen; 1869 buffer += rxLen;
@@ -2017,8 +2013,8 @@ static void process_rcvd_status(struct edgeport_serial *edge_serial,
2017 * edge_tty_recv 2013 * edge_tty_recv
2018 * this function passes data on to the tty flip buffer 2014 * this function passes data on to the tty flip buffer
2019 *****************************************************************************/ 2015 *****************************************************************************/
2020static void edge_tty_recv(struct usb_serial_port *port, struct tty_struct *tty, 2016static void edge_tty_recv(struct usb_serial_port *port, unsigned char *data,
2021 unsigned char *data, int length) 2017 int length)
2022{ 2018{
2023 int cnt; 2019 int cnt;
2024 2020
@@ -2030,7 +2026,7 @@ static void edge_tty_recv(struct usb_serial_port *port, struct tty_struct *tty,
2030 data += cnt; 2026 data += cnt;
2031 length -= cnt; 2027 length -= cnt;
2032 2028
2033 tty_flip_buffer_push(tty); 2029 tty_flip_buffer_push(&port->port);
2034} 2030}
2035 2031
2036 2032
@@ -2086,14 +2082,9 @@ static void handle_new_lsr(struct edgeport_port *edge_port, __u8 lsrData,
2086 } 2082 }
2087 2083
2088 /* Place LSR data byte into Rx buffer */ 2084 /* Place LSR data byte into Rx buffer */
2089 if (lsrData) { 2085 if (lsrData)
2090 struct tty_struct *tty = 2086 edge_tty_recv(edge_port->port, &data, 1);
2091 tty_port_tty_get(&edge_port->port->port); 2087
2092 if (tty) {
2093 edge_tty_recv(edge_port->port, tty, &data, 1);
2094 tty_kref_put(tty);
2095 }
2096 }
2097 /* update input line counters */ 2088 /* update input line counters */
2098 icount = &edge_port->icount; 2089 icount = &edge_port->icount;
2099 if (newLsr & LSR_BREAK) 2090 if (newLsr & LSR_BREAK)
diff --git a/drivers/usb/serial/io_ti.c b/drivers/usb/serial/io_ti.c
index 1286a0b2e2b7..d6485be49ebf 100644
--- a/drivers/usb/serial/io_ti.c
+++ b/drivers/usb/serial/io_ti.c
@@ -201,8 +201,8 @@ static int closing_wait = EDGE_CLOSING_WAIT;
201static bool ignore_cpu_rev; 201static bool ignore_cpu_rev;
202static int default_uart_mode; /* RS232 */ 202static int default_uart_mode; /* RS232 */
203 203
204static void edge_tty_recv(struct usb_serial_port *port, struct tty_struct *tty, 204static void edge_tty_recv(struct usb_serial_port *port, unsigned char *data,
205 unsigned char *data, int length); 205 int length);
206 206
207static void stop_read(struct edgeport_port *edge_port); 207static void stop_read(struct edgeport_port *edge_port);
208static int restart_read(struct edgeport_port *edge_port); 208static int restart_read(struct edgeport_port *edge_port);
@@ -1540,7 +1540,6 @@ static void handle_new_lsr(struct edgeport_port *edge_port, int lsr_data,
1540 struct async_icount *icount; 1540 struct async_icount *icount;
1541 __u8 new_lsr = (__u8)(lsr & (__u8)(LSR_OVER_ERR | LSR_PAR_ERR | 1541 __u8 new_lsr = (__u8)(lsr & (__u8)(LSR_OVER_ERR | LSR_PAR_ERR |
1542 LSR_FRM_ERR | LSR_BREAK)); 1542 LSR_FRM_ERR | LSR_BREAK));
1543 struct tty_struct *tty;
1544 1543
1545 dev_dbg(&edge_port->port->dev, "%s - %02x\n", __func__, new_lsr); 1544 dev_dbg(&edge_port->port->dev, "%s - %02x\n", __func__, new_lsr);
1546 1545
@@ -1554,13 +1553,8 @@ static void handle_new_lsr(struct edgeport_port *edge_port, int lsr_data,
1554 new_lsr &= (__u8)(LSR_OVER_ERR | LSR_BREAK); 1553 new_lsr &= (__u8)(LSR_OVER_ERR | LSR_BREAK);
1555 1554
1556 /* Place LSR data byte into Rx buffer */ 1555 /* Place LSR data byte into Rx buffer */
1557 if (lsr_data) { 1556 if (lsr_data)
1558 tty = tty_port_tty_get(&edge_port->port->port); 1557 edge_tty_recv(edge_port->port, &data, 1);
1559 if (tty) {
1560 edge_tty_recv(edge_port->port, tty, &data, 1);
1561 tty_kref_put(tty);
1562 }
1563 }
1564 1558
1565 /* update input line counters */ 1559 /* update input line counters */
1566 icount = &edge_port->icount; 1560 icount = &edge_port->icount;
@@ -1676,7 +1670,6 @@ static void edge_bulk_in_callback(struct urb *urb)
1676 struct edgeport_port *edge_port = urb->context; 1670 struct edgeport_port *edge_port = urb->context;
1677 struct device *dev = &edge_port->port->dev; 1671 struct device *dev = &edge_port->port->dev;
1678 unsigned char *data = urb->transfer_buffer; 1672 unsigned char *data = urb->transfer_buffer;
1679 struct tty_struct *tty;
1680 int retval = 0; 1673 int retval = 0;
1681 int port_number; 1674 int port_number;
1682 int status = urb->status; 1675 int status = urb->status;
@@ -1715,18 +1708,16 @@ static void edge_bulk_in_callback(struct urb *urb)
1715 ++data; 1708 ++data;
1716 } 1709 }
1717 1710
1718 tty = tty_port_tty_get(&edge_port->port->port); 1711 if (urb->actual_length) {
1719 if (tty && urb->actual_length) {
1720 usb_serial_debug_data(dev, __func__, urb->actual_length, data); 1712 usb_serial_debug_data(dev, __func__, urb->actual_length, data);
1721 if (edge_port->close_pending) 1713 if (edge_port->close_pending)
1722 dev_dbg(dev, "%s - close pending, dropping data on the floor\n", 1714 dev_dbg(dev, "%s - close pending, dropping data on the floor\n",
1723 __func__); 1715 __func__);
1724 else 1716 else
1725 edge_tty_recv(edge_port->port, tty, data, 1717 edge_tty_recv(edge_port->port, data,
1726 urb->actual_length); 1718 urb->actual_length);
1727 edge_port->icount.rx += urb->actual_length; 1719 edge_port->icount.rx += urb->actual_length;
1728 } 1720 }
1729 tty_kref_put(tty);
1730 1721
1731exit: 1722exit:
1732 /* continue read unless stopped */ 1723 /* continue read unless stopped */
@@ -1741,8 +1732,8 @@ exit:
1741 dev_err(dev, "%s - usb_submit_urb failed with result %d\n", __func__, retval); 1732 dev_err(dev, "%s - usb_submit_urb failed with result %d\n", __func__, retval);
1742} 1733}
1743 1734
1744static void edge_tty_recv(struct usb_serial_port *port, struct tty_struct *tty, 1735static void edge_tty_recv(struct usb_serial_port *port, unsigned char *data,
1745 unsigned char *data, int length) 1736 int length)
1746{ 1737{
1747 int queued; 1738 int queued;
1748 1739
@@ -1750,7 +1741,7 @@ static void edge_tty_recv(struct usb_serial_port *port, struct tty_struct *tty,
1750 if (queued < length) 1741 if (queued < length)
1751 dev_err(&port->dev, "%s - dropping data, %d bytes lost\n", 1742 dev_err(&port->dev, "%s - dropping data, %d bytes lost\n",
1752 __func__, length - queued); 1743 __func__, length - queued);
1753 tty_flip_buffer_push(tty); 1744 tty_flip_buffer_push(&port->port);
1754} 1745}
1755 1746
1756static void edge_bulk_out_callback(struct urb *urb) 1747static void edge_bulk_out_callback(struct urb *urb)
diff --git a/drivers/usb/serial/ir-usb.c b/drivers/usb/serial/ir-usb.c
index 171dae1f4a62..716930ab1bb1 100644
--- a/drivers/usb/serial/ir-usb.c
+++ b/drivers/usb/serial/ir-usb.c
@@ -287,7 +287,6 @@ static void ir_process_read_urb(struct urb *urb)
287{ 287{
288 struct usb_serial_port *port = urb->context; 288 struct usb_serial_port *port = urb->context;
289 unsigned char *data = urb->transfer_buffer; 289 unsigned char *data = urb->transfer_buffer;
290 struct tty_struct *tty;
291 290
292 if (!urb->actual_length) 291 if (!urb->actual_length)
293 return; 292 return;
@@ -302,12 +301,8 @@ static void ir_process_read_urb(struct urb *urb)
302 if (urb->actual_length == 1) 301 if (urb->actual_length == 1)
303 return; 302 return;
304 303
305 tty = tty_port_tty_get(&port->port);
306 if (!tty)
307 return;
308 tty_insert_flip_string(&port->port, data + 1, urb->actual_length - 1); 304 tty_insert_flip_string(&port->port, data + 1, urb->actual_length - 1);
309 tty_flip_buffer_push(tty); 305 tty_flip_buffer_push(&port->port);
310 tty_kref_put(tty);
311} 306}
312 307
313static void ir_set_termios_callback(struct urb *urb) 308static void ir_set_termios_callback(struct urb *urb)
diff --git a/drivers/usb/serial/iuu_phoenix.c b/drivers/usb/serial/iuu_phoenix.c
index dd0d910730c7..ff77027160aa 100644
--- a/drivers/usb/serial/iuu_phoenix.c
+++ b/drivers/usb/serial/iuu_phoenix.c
@@ -581,7 +581,6 @@ static void read_buf_callback(struct urb *urb)
581{ 581{
582 struct usb_serial_port *port = urb->context; 582 struct usb_serial_port *port = urb->context;
583 unsigned char *data = urb->transfer_buffer; 583 unsigned char *data = urb->transfer_buffer;
584 struct tty_struct *tty;
585 int status = urb->status; 584 int status = urb->status;
586 585
587 if (status) { 586 if (status) {
@@ -592,14 +591,12 @@ static void read_buf_callback(struct urb *urb)
592 } 591 }
593 592
594 dev_dbg(&port->dev, "%s - %i chars to write\n", __func__, urb->actual_length); 593 dev_dbg(&port->dev, "%s - %i chars to write\n", __func__, urb->actual_length);
595 tty = tty_port_tty_get(&port->port);
596 if (data == NULL) 594 if (data == NULL)
597 dev_dbg(&port->dev, "%s - data is NULL !!!\n", __func__); 595 dev_dbg(&port->dev, "%s - data is NULL !!!\n", __func__);
598 if (tty && urb->actual_length && data) { 596 if (urb->actual_length && data) {
599 tty_insert_flip_string(&port->port, data, urb->actual_length); 597 tty_insert_flip_string(&port->port, data, urb->actual_length);
600 tty_flip_buffer_push(tty); 598 tty_flip_buffer_push(&port->port);
601 } 599 }
602 tty_kref_put(tty);
603 iuu_led_activity_on(urb); 600 iuu_led_activity_on(urb);
604} 601}
605 602
diff --git a/drivers/usb/serial/keyspan.c b/drivers/usb/serial/keyspan.c
index 14a219ba4ee6..f6d7f68fa43c 100644
--- a/drivers/usb/serial/keyspan.c
+++ b/drivers/usb/serial/keyspan.c
@@ -291,7 +291,6 @@ static void usa26_indat_callback(struct urb *urb)
291 int i, err; 291 int i, err;
292 int endpoint; 292 int endpoint;
293 struct usb_serial_port *port; 293 struct usb_serial_port *port;
294 struct tty_struct *tty;
295 unsigned char *data = urb->transfer_buffer; 294 unsigned char *data = urb->transfer_buffer;
296 int status = urb->status; 295 int status = urb->status;
297 296
@@ -304,8 +303,7 @@ static void usa26_indat_callback(struct urb *urb)
304 } 303 }
305 304
306 port = urb->context; 305 port = urb->context;
307 tty = tty_port_tty_get(&port->port); 306 if (urb->actual_length) {
308 if (tty && urb->actual_length) {
309 /* 0x80 bit is error flag */ 307 /* 0x80 bit is error flag */
310 if ((data[0] & 0x80) == 0) { 308 if ((data[0] & 0x80) == 0) {
311 /* no errors on individual bytes, only 309 /* no errors on individual bytes, only
@@ -332,9 +330,8 @@ static void usa26_indat_callback(struct urb *urb)
332 flag); 330 flag);
333 } 331 }
334 } 332 }
335 tty_flip_buffer_push(tty); 333 tty_flip_buffer_push(&port->port);
336 } 334 }
337 tty_kref_put(tty);
338 335
339 /* Resubmit urb so we continue receiving */ 336 /* Resubmit urb so we continue receiving */
340 err = usb_submit_urb(urb, GFP_ATOMIC); 337 err = usb_submit_urb(urb, GFP_ATOMIC);
@@ -447,7 +444,6 @@ static void usa28_indat_callback(struct urb *urb)
447{ 444{
448 int err; 445 int err;
449 struct usb_serial_port *port; 446 struct usb_serial_port *port;
450 struct tty_struct *tty;
451 unsigned char *data; 447 unsigned char *data;
452 struct keyspan_port_private *p_priv; 448 struct keyspan_port_private *p_priv;
453 int status = urb->status; 449 int status = urb->status;
@@ -470,13 +466,11 @@ static void usa28_indat_callback(struct urb *urb)
470 p_priv = usb_get_serial_port_data(port); 466 p_priv = usb_get_serial_port_data(port);
471 data = urb->transfer_buffer; 467 data = urb->transfer_buffer;
472 468
473 tty = tty_port_tty_get(&port->port); 469 if (urb->actual_length) {
474 if (tty && urb->actual_length) {
475 tty_insert_flip_string(&port->port, data, 470 tty_insert_flip_string(&port->port, data,
476 urb->actual_length); 471 urb->actual_length);
477 tty_flip_buffer_push(tty); 472 tty_flip_buffer_push(&port->port);
478 } 473 }
479 tty_kref_put(tty);
480 474
481 /* Resubmit urb so we continue receiving */ 475 /* Resubmit urb so we continue receiving */
482 err = usb_submit_urb(urb, GFP_ATOMIC); 476 err = usb_submit_urb(urb, GFP_ATOMIC);
@@ -671,7 +665,6 @@ static void usa49_indat_callback(struct urb *urb)
671 int i, err; 665 int i, err;
672 int endpoint; 666 int endpoint;
673 struct usb_serial_port *port; 667 struct usb_serial_port *port;
674 struct tty_struct *tty;
675 unsigned char *data = urb->transfer_buffer; 668 unsigned char *data = urb->transfer_buffer;
676 int status = urb->status; 669 int status = urb->status;
677 670
@@ -684,8 +677,7 @@ static void usa49_indat_callback(struct urb *urb)
684 } 677 }
685 678
686 port = urb->context; 679 port = urb->context;
687 tty = tty_port_tty_get(&port->port); 680 if (urb->actual_length) {
688 if (tty && urb->actual_length) {
689 /* 0x80 bit is error flag */ 681 /* 0x80 bit is error flag */
690 if ((data[0] & 0x80) == 0) { 682 if ((data[0] & 0x80) == 0) {
691 /* no error on any byte */ 683 /* no error on any byte */
@@ -706,9 +698,8 @@ static void usa49_indat_callback(struct urb *urb)
706 flag); 698 flag);
707 } 699 }
708 } 700 }
709 tty_flip_buffer_push(tty); 701 tty_flip_buffer_push(&port->port);
710 } 702 }
711 tty_kref_put(tty);
712 703
713 /* Resubmit urb so we continue receiving */ 704 /* Resubmit urb so we continue receiving */
714 err = usb_submit_urb(urb, GFP_ATOMIC); 705 err = usb_submit_urb(urb, GFP_ATOMIC);
@@ -721,7 +712,6 @@ static void usa49wg_indat_callback(struct urb *urb)
721 int i, len, x, err; 712 int i, len, x, err;
722 struct usb_serial *serial; 713 struct usb_serial *serial;
723 struct usb_serial_port *port; 714 struct usb_serial_port *port;
724 struct tty_struct *tty;
725 unsigned char *data = urb->transfer_buffer; 715 unsigned char *data = urb->transfer_buffer;
726 int status = urb->status; 716 int status = urb->status;
727 717
@@ -746,7 +736,6 @@ static void usa49wg_indat_callback(struct urb *urb)
746 return; 736 return;
747 } 737 }
748 port = serial->port[data[i++]]; 738 port = serial->port[data[i++]];
749 tty = tty_port_tty_get(&port->port);
750 len = data[i++]; 739 len = data[i++];
751 740
752 /* 0x80 bit is error flag */ 741 /* 0x80 bit is error flag */
@@ -774,8 +763,7 @@ static void usa49wg_indat_callback(struct urb *urb)
774 i += 2; 763 i += 2;
775 } 764 }
776 } 765 }
777 tty_flip_buffer_push(tty); 766 tty_flip_buffer_push(&port->port);
778 tty_kref_put(tty);
779 } 767 }
780 } 768 }
781 769
@@ -796,7 +784,6 @@ static void usa90_indat_callback(struct urb *urb)
796 int endpoint; 784 int endpoint;
797 struct usb_serial_port *port; 785 struct usb_serial_port *port;
798 struct keyspan_port_private *p_priv; 786 struct keyspan_port_private *p_priv;
799 struct tty_struct *tty;
800 unsigned char *data = urb->transfer_buffer; 787 unsigned char *data = urb->transfer_buffer;
801 int status = urb->status; 788 int status = urb->status;
802 789
@@ -812,7 +799,6 @@ static void usa90_indat_callback(struct urb *urb)
812 p_priv = usb_get_serial_port_data(port); 799 p_priv = usb_get_serial_port_data(port);
813 800
814 if (urb->actual_length) { 801 if (urb->actual_length) {
815 tty = tty_port_tty_get(&port->port);
816 /* if current mode is DMA, looks like usa28 format 802 /* if current mode is DMA, looks like usa28 format
817 otherwise looks like usa26 data format */ 803 otherwise looks like usa26 data format */
818 804
@@ -848,8 +834,7 @@ static void usa90_indat_callback(struct urb *urb)
848 } 834 }
849 } 835 }
850 } 836 }
851 tty_flip_buffer_push(tty); 837 tty_flip_buffer_push(&port->port);
852 tty_kref_put(tty);
853 } 838 }
854 839
855 /* Resubmit urb so we continue receiving */ 840 /* Resubmit urb so we continue receiving */
diff --git a/drivers/usb/serial/keyspan_pda.c b/drivers/usb/serial/keyspan_pda.c
index 334b1a295c6b..3b17d5d13dc8 100644
--- a/drivers/usb/serial/keyspan_pda.c
+++ b/drivers/usb/serial/keyspan_pda.c
@@ -138,7 +138,6 @@ static void keyspan_pda_request_unthrottle(struct work_struct *work)
138static void keyspan_pda_rx_interrupt(struct urb *urb) 138static void keyspan_pda_rx_interrupt(struct urb *urb)
139{ 139{
140 struct usb_serial_port *port = urb->context; 140 struct usb_serial_port *port = urb->context;
141 struct tty_struct *tty;
142 unsigned char *data = urb->transfer_buffer; 141 unsigned char *data = urb->transfer_buffer;
143 int retval; 142 int retval;
144 int status = urb->status; 143 int status = urb->status;
@@ -163,14 +162,12 @@ static void keyspan_pda_rx_interrupt(struct urb *urb)
163 /* see if the message is data or a status interrupt */ 162 /* see if the message is data or a status interrupt */
164 switch (data[0]) { 163 switch (data[0]) {
165 case 0: 164 case 0:
166 tty = tty_port_tty_get(&port->port);
167 /* rest of message is rx data */ 165 /* rest of message is rx data */
168 if (tty && urb->actual_length) { 166 if (urb->actual_length) {
169 tty_insert_flip_string(&port->port, data + 1, 167 tty_insert_flip_string(&port->port, data + 1,
170 urb->actual_length - 1); 168 urb->actual_length - 1);
171 tty_flip_buffer_push(tty); 169 tty_flip_buffer_push(&port->port);
172 } 170 }
173 tty_kref_put(tty);
174 break; 171 break;
175 case 1: 172 case 1:
176 /* status interrupt */ 173 /* status interrupt */
diff --git a/drivers/usb/serial/kl5kusb105.c b/drivers/usb/serial/kl5kusb105.c
index 8ee0825ad700..769d910ae0a5 100644
--- a/drivers/usb/serial/kl5kusb105.c
+++ b/drivers/usb/serial/kl5kusb105.c
@@ -389,7 +389,6 @@ static void klsi_105_process_read_urb(struct urb *urb)
389{ 389{
390 struct usb_serial_port *port = urb->context; 390 struct usb_serial_port *port = urb->context;
391 unsigned char *data = urb->transfer_buffer; 391 unsigned char *data = urb->transfer_buffer;
392 struct tty_struct *tty;
393 unsigned len; 392 unsigned len;
394 393
395 /* empty urbs seem to happen, we ignore them */ 394 /* empty urbs seem to happen, we ignore them */
@@ -401,10 +400,6 @@ static void klsi_105_process_read_urb(struct urb *urb)
401 return; 400 return;
402 } 401 }
403 402
404 tty = tty_port_tty_get(&port->port);
405 if (!tty)
406 return;
407
408 len = get_unaligned_le16(data); 403 len = get_unaligned_le16(data);
409 if (len > urb->actual_length - KLSI_HDR_LEN) { 404 if (len > urb->actual_length - KLSI_HDR_LEN) {
410 dev_dbg(&port->dev, "%s - packet length mismatch\n", __func__); 405 dev_dbg(&port->dev, "%s - packet length mismatch\n", __func__);
@@ -412,8 +407,7 @@ static void klsi_105_process_read_urb(struct urb *urb)
412 } 407 }
413 408
414 tty_insert_flip_string(&port->port, data + KLSI_HDR_LEN, len); 409 tty_insert_flip_string(&port->port, data + KLSI_HDR_LEN, len);
415 tty_flip_buffer_push(tty); 410 tty_flip_buffer_push(&port->port);
416 tty_kref_put(tty);
417} 411}
418 412
419static void klsi_105_set_termios(struct tty_struct *tty, 413static void klsi_105_set_termios(struct tty_struct *tty,
diff --git a/drivers/usb/serial/kobil_sct.c b/drivers/usb/serial/kobil_sct.c
index 135c8b4b26f7..903d938e174b 100644
--- a/drivers/usb/serial/kobil_sct.c
+++ b/drivers/usb/serial/kobil_sct.c
@@ -324,7 +324,6 @@ static void kobil_read_int_callback(struct urb *urb)
324{ 324{
325 int result; 325 int result;
326 struct usb_serial_port *port = urb->context; 326 struct usb_serial_port *port = urb->context;
327 struct tty_struct *tty;
328 unsigned char *data = urb->transfer_buffer; 327 unsigned char *data = urb->transfer_buffer;
329 int status = urb->status; 328 int status = urb->status;
330 329
@@ -333,8 +332,7 @@ static void kobil_read_int_callback(struct urb *urb)
333 return; 332 return;
334 } 333 }
335 334
336 tty = tty_port_tty_get(&port->port); 335 if (urb->actual_length) {
337 if (tty && urb->actual_length) {
338 336
339 /* BEGIN DEBUG */ 337 /* BEGIN DEBUG */
340 /* 338 /*
@@ -354,9 +352,8 @@ static void kobil_read_int_callback(struct urb *urb)
354 /* END DEBUG */ 352 /* END DEBUG */
355 353
356 tty_insert_flip_string(&port->port, data, urb->actual_length); 354 tty_insert_flip_string(&port->port, data, urb->actual_length);
357 tty_flip_buffer_push(tty); 355 tty_flip_buffer_push(&port->port);
358 } 356 }
359 tty_kref_put(tty);
360 357
361 result = usb_submit_urb(port->interrupt_in_urb, GFP_ATOMIC); 358 result = usb_submit_urb(port->interrupt_in_urb, GFP_ATOMIC);
362 dev_dbg(&port->dev, "%s - Send read URB returns: %i\n", __func__, result); 359 dev_dbg(&port->dev, "%s - Send read URB returns: %i\n", __func__, result);
diff --git a/drivers/usb/serial/mct_u232.c b/drivers/usb/serial/mct_u232.c
index ba20bb037b28..f42528e05d7b 100644
--- a/drivers/usb/serial/mct_u232.c
+++ b/drivers/usb/serial/mct_u232.c
@@ -531,7 +531,6 @@ static void mct_u232_read_int_callback(struct urb *urb)
531{ 531{
532 struct usb_serial_port *port = urb->context; 532 struct usb_serial_port *port = urb->context;
533 struct mct_u232_private *priv = usb_get_serial_port_data(port); 533 struct mct_u232_private *priv = usb_get_serial_port_data(port);
534 struct tty_struct *tty;
535 unsigned char *data = urb->transfer_buffer; 534 unsigned char *data = urb->transfer_buffer;
536 int retval; 535 int retval;
537 int status = urb->status; 536 int status = urb->status;
@@ -561,13 +560,9 @@ static void mct_u232_read_int_callback(struct urb *urb)
561 */ 560 */
562 if (urb->transfer_buffer_length > 2) { 561 if (urb->transfer_buffer_length > 2) {
563 if (urb->actual_length) { 562 if (urb->actual_length) {
564 tty = tty_port_tty_get(&port->port); 563 tty_insert_flip_string(&port->port, data,
565 if (tty) { 564 urb->actual_length);
566 tty_insert_flip_string(&port->port, data, 565 tty_flip_buffer_push(&port->port);
567 urb->actual_length);
568 tty_flip_buffer_push(tty);
569 }
570 tty_kref_put(tty);
571 } 566 }
572 goto exit; 567 goto exit;
573 } 568 }
diff --git a/drivers/usb/serial/metro-usb.c b/drivers/usb/serial/metro-usb.c
index 6264f3974ea7..bf3c7a23553e 100644
--- a/drivers/usb/serial/metro-usb.c
+++ b/drivers/usb/serial/metro-usb.c
@@ -95,7 +95,6 @@ static void metrousb_read_int_callback(struct urb *urb)
95{ 95{
96 struct usb_serial_port *port = urb->context; 96 struct usb_serial_port *port = urb->context;
97 struct metrousb_private *metro_priv = usb_get_serial_port_data(port); 97 struct metrousb_private *metro_priv = usb_get_serial_port_data(port);
98 struct tty_struct *tty;
99 unsigned char *data = urb->transfer_buffer; 98 unsigned char *data = urb->transfer_buffer;
100 int throttled = 0; 99 int throttled = 0;
101 int result = 0; 100 int result = 0;
@@ -124,15 +123,13 @@ static void metrousb_read_int_callback(struct urb *urb)
124 123
125 124
126 /* Set the data read from the usb port into the serial port buffer. */ 125 /* Set the data read from the usb port into the serial port buffer. */
127 tty = tty_port_tty_get(&port->port); 126 if (urb->actual_length) {
128 if (tty && urb->actual_length) {
129 /* Loop through the data copying each byte to the tty layer. */ 127 /* Loop through the data copying each byte to the tty layer. */
130 tty_insert_flip_string(&port->port, data, urb->actual_length); 128 tty_insert_flip_string(&port->port, data, urb->actual_length);
131 129
132 /* Force the data to the tty layer. */ 130 /* Force the data to the tty layer. */
133 tty_flip_buffer_push(tty); 131 tty_flip_buffer_push(&port->port);
134 } 132 }
135 tty_kref_put(tty);
136 133
137 /* Set any port variables. */ 134 /* Set any port variables. */
138 spin_lock_irqsave(&metro_priv->lock, flags); 135 spin_lock_irqsave(&metro_priv->lock, flags);
diff --git a/drivers/usb/serial/mos7720.c b/drivers/usb/serial/mos7720.c
index 22818fb765e0..e0ebec3b5d6a 100644
--- a/drivers/usb/serial/mos7720.c
+++ b/drivers/usb/serial/mos7720.c
@@ -899,7 +899,6 @@ static void mos7720_bulk_in_callback(struct urb *urb)
899 int retval; 899 int retval;
900 unsigned char *data ; 900 unsigned char *data ;
901 struct usb_serial_port *port; 901 struct usb_serial_port *port;
902 struct tty_struct *tty;
903 int status = urb->status; 902 int status = urb->status;
904 903
905 if (status) { 904 if (status) {
@@ -913,12 +912,10 @@ static void mos7720_bulk_in_callback(struct urb *urb)
913 912
914 data = urb->transfer_buffer; 913 data = urb->transfer_buffer;
915 914
916 tty = tty_port_tty_get(&port->port); 915 if (urb->actual_length) {
917 if (tty && urb->actual_length) {
918 tty_insert_flip_string(&port->port, data, urb->actual_length); 916 tty_insert_flip_string(&port->port, data, urb->actual_length);
919 tty_flip_buffer_push(tty); 917 tty_flip_buffer_push(&port->port);
920 } 918 }
921 tty_kref_put(tty);
922 919
923 if (port->read_urb->status != -EINPROGRESS) { 920 if (port->read_urb->status != -EINPROGRESS) {
924 retval = usb_submit_urb(port->read_urb, GFP_ATOMIC); 921 retval = usb_submit_urb(port->read_urb, GFP_ATOMIC);
diff --git a/drivers/usb/serial/mos7840.c b/drivers/usb/serial/mos7840.c
index 3ddd7a1f7ff3..809fb329eca5 100644
--- a/drivers/usb/serial/mos7840.c
+++ b/drivers/usb/serial/mos7840.c
@@ -744,7 +744,6 @@ static void mos7840_bulk_in_callback(struct urb *urb)
744 struct usb_serial *serial; 744 struct usb_serial *serial;
745 struct usb_serial_port *port; 745 struct usb_serial_port *port;
746 struct moschip_port *mos7840_port; 746 struct moschip_port *mos7840_port;
747 struct tty_struct *tty;
748 int status = urb->status; 747 int status = urb->status;
749 748
750 mos7840_port = urb->context; 749 mos7840_port = urb->context;
@@ -774,12 +773,8 @@ static void mos7840_bulk_in_callback(struct urb *urb)
774 773
775 if (urb->actual_length) { 774 if (urb->actual_length) {
776 struct tty_port *tport = &mos7840_port->port->port; 775 struct tty_port *tport = &mos7840_port->port->port;
777 tty = tty_port_tty_get(tport); 776 tty_insert_flip_string(tport, data, urb->actual_length);
778 if (tty) { 777 tty_flip_buffer_push(tport);
779 tty_insert_flip_string(tport, data, urb->actual_length);
780 tty_flip_buffer_push(tty);
781 tty_kref_put(tty);
782 }
783 mos7840_port->icount.rx += urb->actual_length; 778 mos7840_port->icount.rx += urb->actual_length;
784 smp_wmb(); 779 smp_wmb();
785 dev_dbg(&port->dev, "mos7840_port->icount.rx is %d:\n", mos7840_port->icount.rx); 780 dev_dbg(&port->dev, "mos7840_port->icount.rx is %d:\n", mos7840_port->icount.rx);
diff --git a/drivers/usb/serial/navman.c b/drivers/usb/serial/navman.c
index 0d96a1a7b9e5..38725fc8c2c8 100644
--- a/drivers/usb/serial/navman.c
+++ b/drivers/usb/serial/navman.c
@@ -32,7 +32,6 @@ static void navman_read_int_callback(struct urb *urb)
32{ 32{
33 struct usb_serial_port *port = urb->context; 33 struct usb_serial_port *port = urb->context;
34 unsigned char *data = urb->transfer_buffer; 34 unsigned char *data = urb->transfer_buffer;
35 struct tty_struct *tty;
36 int status = urb->status; 35 int status = urb->status;
37 int result; 36 int result;
38 37
@@ -55,12 +54,10 @@ static void navman_read_int_callback(struct urb *urb)
55 54
56 usb_serial_debug_data(&port->dev, __func__, urb->actual_length, data); 55 usb_serial_debug_data(&port->dev, __func__, urb->actual_length, data);
57 56
58 tty = tty_port_tty_get(&port->port); 57 if (urb->actual_length) {
59 if (tty && urb->actual_length) {
60 tty_insert_flip_string(&port->port, data, urb->actual_length); 58 tty_insert_flip_string(&port->port, data, urb->actual_length);
61 tty_flip_buffer_push(tty); 59 tty_flip_buffer_push(&port->port);
62 } 60 }
63 tty_kref_put(tty);
64 61
65exit: 62exit:
66 result = usb_submit_urb(urb, GFP_ATOMIC); 63 result = usb_submit_urb(urb, GFP_ATOMIC);
diff --git a/drivers/usb/serial/omninet.c b/drivers/usb/serial/omninet.c
index 338191bae5a3..1e1cafe287e4 100644
--- a/drivers/usb/serial/omninet.c
+++ b/drivers/usb/serial/omninet.c
@@ -174,14 +174,9 @@ static void omninet_read_bulk_callback(struct urb *urb)
174 } 174 }
175 175
176 if (urb->actual_length && header->oh_len) { 176 if (urb->actual_length && header->oh_len) {
177 struct tty_struct *tty = tty_port_tty_get(&port->port); 177 tty_insert_flip_string(&port->port, data + OMNINET_DATAOFFSET,
178 if (tty) { 178 header->oh_len);
179 tty_insert_flip_string(&port->port, 179 tty_flip_buffer_push(&port->port);
180 data + OMNINET_DATAOFFSET,
181 header->oh_len);
182 tty_flip_buffer_push(tty);
183 tty_kref_put(tty);
184 }
185 } 180 }
186 181
187 /* Continue trying to always read */ 182 /* Continue trying to always read */
diff --git a/drivers/usb/serial/opticon.c b/drivers/usb/serial/opticon.c
index d3b74e50aff1..e13e1a4d3e1e 100644
--- a/drivers/usb/serial/opticon.c
+++ b/drivers/usb/serial/opticon.c
@@ -51,15 +51,8 @@ struct opticon_private {
51static void opticon_process_data_packet(struct usb_serial_port *port, 51static void opticon_process_data_packet(struct usb_serial_port *port,
52 const unsigned char *buf, size_t len) 52 const unsigned char *buf, size_t len)
53{ 53{
54 struct tty_struct *tty;
55
56 tty = tty_port_tty_get(&port->port);
57 if (!tty)
58 return;
59
60 tty_insert_flip_string(&port->port, buf, len); 54 tty_insert_flip_string(&port->port, buf, len);
61 tty_flip_buffer_push(tty); 55 tty_flip_buffer_push(&port->port);
62 tty_kref_put(tty);
63} 56}
64 57
65static void opticon_process_status_packet(struct usb_serial_port *port, 58static void opticon_process_status_packet(struct usb_serial_port *port,
diff --git a/drivers/usb/serial/oti6858.c b/drivers/usb/serial/oti6858.c
index 7a53fe9f3af3..a958fd41b5b3 100644
--- a/drivers/usb/serial/oti6858.c
+++ b/drivers/usb/serial/oti6858.c
@@ -820,7 +820,6 @@ static void oti6858_read_bulk_callback(struct urb *urb)
820{ 820{
821 struct usb_serial_port *port = urb->context; 821 struct usb_serial_port *port = urb->context;
822 struct oti6858_private *priv = usb_get_serial_port_data(port); 822 struct oti6858_private *priv = usb_get_serial_port_data(port);
823 struct tty_struct *tty;
824 unsigned char *data = urb->transfer_buffer; 823 unsigned char *data = urb->transfer_buffer;
825 unsigned long flags; 824 unsigned long flags;
826 int status = urb->status; 825 int status = urb->status;
@@ -835,12 +834,10 @@ static void oti6858_read_bulk_callback(struct urb *urb)
835 return; 834 return;
836 } 835 }
837 836
838 tty = tty_port_tty_get(&port->port); 837 if (urb->actual_length > 0) {
839 if (tty != NULL && urb->actual_length > 0) {
840 tty_insert_flip_string(&port->port, data, urb->actual_length); 838 tty_insert_flip_string(&port->port, data, urb->actual_length);
841 tty_flip_buffer_push(tty); 839 tty_flip_buffer_push(&port->port);
842 } 840 }
843 tty_kref_put(tty);
844 841
845 /* schedule the interrupt urb */ 842 /* schedule the interrupt urb */
846 result = usb_submit_urb(port->interrupt_in_urb, GFP_ATOMIC); 843 result = usb_submit_urb(port->interrupt_in_urb, GFP_ATOMIC);
diff --git a/drivers/usb/serial/pl2303.c b/drivers/usb/serial/pl2303.c
index 00047f3c7293..54adc9125e5c 100644
--- a/drivers/usb/serial/pl2303.c
+++ b/drivers/usb/serial/pl2303.c
@@ -772,7 +772,6 @@ static void pl2303_process_read_urb(struct urb *urb)
772{ 772{
773 struct usb_serial_port *port = urb->context; 773 struct usb_serial_port *port = urb->context;
774 struct pl2303_private *priv = usb_get_serial_port_data(port); 774 struct pl2303_private *priv = usb_get_serial_port_data(port);
775 struct tty_struct *tty;
776 unsigned char *data = urb->transfer_buffer; 775 unsigned char *data = urb->transfer_buffer;
777 char tty_flag = TTY_NORMAL; 776 char tty_flag = TTY_NORMAL;
778 unsigned long flags; 777 unsigned long flags;
@@ -789,10 +788,6 @@ static void pl2303_process_read_urb(struct urb *urb)
789 if (!urb->actual_length) 788 if (!urb->actual_length)
790 return; 789 return;
791 790
792 tty = tty_port_tty_get(&port->port);
793 if (!tty)
794 return;
795
796 /* break takes precedence over parity, */ 791 /* break takes precedence over parity, */
797 /* which takes precedence over framing errors */ 792 /* which takes precedence over framing errors */
798 if (line_status & UART_BREAK_ERROR) 793 if (line_status & UART_BREAK_ERROR)
@@ -817,8 +812,7 @@ static void pl2303_process_read_urb(struct urb *urb)
817 urb->actual_length); 812 urb->actual_length);
818 } 813 }
819 814
820 tty_flip_buffer_push(tty); 815 tty_flip_buffer_push(&port->port);
821 tty_kref_put(tty);
822} 816}
823 817
824/* All of the device info needed for the PL2303 SIO serial converter */ 818/* All of the device info needed for the PL2303 SIO serial converter */
diff --git a/drivers/usb/serial/quatech2.c b/drivers/usb/serial/quatech2.c
index 5dccc4f957df..6850745808c3 100644
--- a/drivers/usb/serial/quatech2.c
+++ b/drivers/usb/serial/quatech2.c
@@ -609,7 +609,6 @@ void qt2_process_read_urb(struct urb *urb)
609 struct qt2_serial_private *serial_priv; 609 struct qt2_serial_private *serial_priv;
610 struct usb_serial_port *port; 610 struct usb_serial_port *port;
611 struct qt2_port_private *port_priv; 611 struct qt2_port_private *port_priv;
612 struct tty_struct *tty;
613 bool escapeflag; 612 bool escapeflag;
614 unsigned char *ch; 613 unsigned char *ch;
615 int i; 614 int i;
@@ -620,15 +619,11 @@ void qt2_process_read_urb(struct urb *urb)
620 return; 619 return;
621 620
622 ch = urb->transfer_buffer; 621 ch = urb->transfer_buffer;
623 tty = NULL;
624 serial = urb->context; 622 serial = urb->context;
625 serial_priv = usb_get_serial_data(serial); 623 serial_priv = usb_get_serial_data(serial);
626 port = serial->port[serial_priv->current_port]; 624 port = serial->port[serial_priv->current_port];
627 port_priv = usb_get_serial_port_data(port); 625 port_priv = usb_get_serial_port_data(port);
628 626
629 if (port_priv->is_open)
630 tty = tty_port_tty_get(&port->port);
631
632 for (i = 0; i < urb->actual_length; i++) { 627 for (i = 0; i < urb->actual_length; i++) {
633 ch = (unsigned char *)urb->transfer_buffer + i; 628 ch = (unsigned char *)urb->transfer_buffer + i;
634 if ((i <= (len - 3)) && 629 if ((i <= (len - 3)) &&
@@ -666,10 +661,7 @@ void qt2_process_read_urb(struct urb *urb)
666 __func__); 661 __func__);
667 break; 662 break;
668 } 663 }
669 if (tty) { 664 tty_flip_buffer_push(&port->port);
670 tty_flip_buffer_push(tty);
671 tty_kref_put(tty);
672 }
673 665
674 newport = *(ch + 3); 666 newport = *(ch + 3);
675 667
@@ -683,10 +675,6 @@ void qt2_process_read_urb(struct urb *urb)
683 serial_priv->current_port = newport; 675 serial_priv->current_port = newport;
684 port = serial->port[serial_priv->current_port]; 676 port = serial->port[serial_priv->current_port];
685 port_priv = usb_get_serial_port_data(port); 677 port_priv = usb_get_serial_port_data(port);
686 if (port_priv->is_open)
687 tty = tty_port_tty_get(&port->port);
688 else
689 tty = NULL;
690 i += 3; 678 i += 3;
691 escapeflag = true; 679 escapeflag = true;
692 break; 680 break;
@@ -716,10 +704,7 @@ void qt2_process_read_urb(struct urb *urb)
716 tty_insert_flip_string(&port->port, ch, 1); 704 tty_insert_flip_string(&port->port, ch, 1);
717 } 705 }
718 706
719 if (tty) { 707 tty_flip_buffer_push(&port->port);
720 tty_flip_buffer_push(tty);
721 tty_kref_put(tty);
722 }
723} 708}
724 709
725static void qt2_write_bulk_callback(struct urb *urb) 710static void qt2_write_bulk_callback(struct urb *urb)
diff --git a/drivers/usb/serial/safe_serial.c b/drivers/usb/serial/safe_serial.c
index ad12e9e2c7ee..21cd7bf2a8cc 100644
--- a/drivers/usb/serial/safe_serial.c
+++ b/drivers/usb/serial/safe_serial.c
@@ -207,38 +207,31 @@ static void safe_process_read_urb(struct urb *urb)
207 unsigned char *data = urb->transfer_buffer; 207 unsigned char *data = urb->transfer_buffer;
208 unsigned char length = urb->actual_length; 208 unsigned char length = urb->actual_length;
209 int actual_length; 209 int actual_length;
210 struct tty_struct *tty;
211 __u16 fcs; 210 __u16 fcs;
212 211
213 if (!length) 212 if (!length)
214 return; 213 return;
215 214
216 tty = tty_port_tty_get(&port->port);
217 if (!tty)
218 return;
219
220 if (!safe) 215 if (!safe)
221 goto out; 216 goto out;
222 217
223 fcs = fcs_compute10(data, length, CRC10_INITFCS); 218 fcs = fcs_compute10(data, length, CRC10_INITFCS);
224 if (fcs) { 219 if (fcs) {
225 dev_err(&port->dev, "%s - bad CRC %x\n", __func__, fcs); 220 dev_err(&port->dev, "%s - bad CRC %x\n", __func__, fcs);
226 goto err; 221 return;
227 } 222 }
228 223
229 actual_length = data[length - 2] >> 2; 224 actual_length = data[length - 2] >> 2;
230 if (actual_length > (length - 2)) { 225 if (actual_length > (length - 2)) {
231 dev_err(&port->dev, "%s - inconsistent lengths %d:%d\n", 226 dev_err(&port->dev, "%s - inconsistent lengths %d:%d\n",
232 __func__, actual_length, length); 227 __func__, actual_length, length);
233 goto err; 228 return;
234 } 229 }
235 dev_info(&urb->dev->dev, "%s - actual: %d\n", __func__, actual_length); 230 dev_info(&urb->dev->dev, "%s - actual: %d\n", __func__, actual_length);
236 length = actual_length; 231 length = actual_length;
237out: 232out:
238 tty_insert_flip_string(&port->port, data, length); 233 tty_insert_flip_string(&port->port, data, length);
239 tty_flip_buffer_push(tty); 234 tty_flip_buffer_push(&port->port);
240err:
241 tty_kref_put(tty);
242} 235}
243 236
244static int safe_prepare_write_buffer(struct usb_serial_port *port, 237static int safe_prepare_write_buffer(struct usb_serial_port *port,
diff --git a/drivers/usb/serial/sierra.c b/drivers/usb/serial/sierra.c
index 64e53fda149b..70aee8d59f23 100644
--- a/drivers/usb/serial/sierra.c
+++ b/drivers/usb/serial/sierra.c
@@ -569,7 +569,6 @@ static void sierra_indat_callback(struct urb *urb)
569 int err; 569 int err;
570 int endpoint; 570 int endpoint;
571 struct usb_serial_port *port; 571 struct usb_serial_port *port;
572 struct tty_struct *tty;
573 unsigned char *data = urb->transfer_buffer; 572 unsigned char *data = urb->transfer_buffer;
574 int status = urb->status; 573 int status = urb->status;
575 574
@@ -581,16 +580,12 @@ static void sierra_indat_callback(struct urb *urb)
581 " endpoint %02x\n", __func__, status, endpoint); 580 " endpoint %02x\n", __func__, status, endpoint);
582 } else { 581 } else {
583 if (urb->actual_length) { 582 if (urb->actual_length) {
584 tty = tty_port_tty_get(&port->port); 583 tty_insert_flip_string(&port->port, data,
585 if (tty) { 584 urb->actual_length);
586 tty_insert_flip_string(&port->port, data, 585 tty_flip_buffer_push(&port->port);
587 urb->actual_length); 586
588 tty_flip_buffer_push(tty); 587 usb_serial_debug_data(&port->dev, __func__,
589 588 urb->actual_length, data);
590 tty_kref_put(tty);
591 usb_serial_debug_data(&port->dev, __func__,
592 urb->actual_length, data);
593 }
594 } else { 589 } else {
595 dev_dbg(&port->dev, "%s: empty read urb" 590 dev_dbg(&port->dev, "%s: empty read urb"
596 " received\n", __func__); 591 " received\n", __func__);
diff --git a/drivers/usb/serial/spcp8x5.c b/drivers/usb/serial/spcp8x5.c
index 04e373152724..91ff8e3bddbd 100644
--- a/drivers/usb/serial/spcp8x5.c
+++ b/drivers/usb/serial/spcp8x5.c
@@ -462,7 +462,6 @@ static void spcp8x5_process_read_urb(struct urb *urb)
462{ 462{
463 struct usb_serial_port *port = urb->context; 463 struct usb_serial_port *port = urb->context;
464 struct spcp8x5_private *priv = usb_get_serial_port_data(port); 464 struct spcp8x5_private *priv = usb_get_serial_port_data(port);
465 struct tty_struct *tty;
466 unsigned char *data = urb->transfer_buffer; 465 unsigned char *data = urb->transfer_buffer;
467 unsigned long flags; 466 unsigned long flags;
468 u8 status; 467 u8 status;
@@ -481,9 +480,6 @@ static void spcp8x5_process_read_urb(struct urb *urb)
481 if (!urb->actual_length) 480 if (!urb->actual_length)
482 return; 481 return;
483 482
484 tty = tty_port_tty_get(&port->port);
485 if (!tty)
486 return;
487 483
488 if (status & UART_STATE_TRANSIENT_MASK) { 484 if (status & UART_STATE_TRANSIENT_MASK) {
489 /* break takes precedence over parity, which takes precedence 485 /* break takes precedence over parity, which takes precedence
@@ -500,15 +496,19 @@ static void spcp8x5_process_read_urb(struct urb *urb)
500 if (status & UART_OVERRUN_ERROR) 496 if (status & UART_OVERRUN_ERROR)
501 tty_insert_flip_char(&port->port, 0, TTY_OVERRUN); 497 tty_insert_flip_char(&port->port, 0, TTY_OVERRUN);
502 498
503 if (status & UART_DCD) 499 if (status & UART_DCD) {
504 usb_serial_handle_dcd_change(port, tty, 500 struct tty_struct *tty = tty_port_tty_get(&port->port);
505 priv->line_status & MSR_STATUS_LINE_DCD); 501 if (tty) {
502 usb_serial_handle_dcd_change(port, tty,
503 priv->line_status & MSR_STATUS_LINE_DCD);
504 tty_kref_put(tty);
505 }
506 }
506 } 507 }
507 508
508 tty_insert_flip_string_fixed_flag(&port->port, data, tty_flag, 509 tty_insert_flip_string_fixed_flag(&port->port, data, tty_flag,
509 urb->actual_length); 510 urb->actual_length);
510 tty_flip_buffer_push(tty); 511 tty_flip_buffer_push(&port->port);
511 tty_kref_put(tty);
512} 512}
513 513
514static int spcp8x5_wait_modem_info(struct usb_serial_port *port, 514static int spcp8x5_wait_modem_info(struct usb_serial_port *port,
diff --git a/drivers/usb/serial/ssu100.c b/drivers/usb/serial/ssu100.c
index 38713156e957..58bc7e793524 100644
--- a/drivers/usb/serial/ssu100.c
+++ b/drivers/usb/serial/ssu100.c
@@ -582,7 +582,7 @@ static void ssu100_update_lsr(struct usb_serial_port *port, u8 lsr,
582 582
583} 583}
584 584
585static int ssu100_process_packet(struct urb *urb) 585static void ssu100_process_read_urb(struct urb *urb)
586{ 586{
587 struct usb_serial_port *port = urb->context; 587 struct usb_serial_port *port = urb->context;
588 char *packet = (char *)urb->transfer_buffer; 588 char *packet = (char *)urb->transfer_buffer;
@@ -609,7 +609,7 @@ static int ssu100_process_packet(struct urb *urb)
609 ch = packet; 609 ch = packet;
610 610
611 if (!len) 611 if (!len)
612 return 0; /* status only */ 612 return; /* status only */
613 613
614 if (port->port.console && port->sysrq) { 614 if (port->port.console && port->sysrq) {
615 for (i = 0; i < len; i++, ch++) { 615 for (i = 0; i < len; i++, ch++) {
@@ -619,24 +619,7 @@ static int ssu100_process_packet(struct urb *urb)
619 } else 619 } else
620 tty_insert_flip_string_fixed_flag(&port->port, ch, flag, len); 620 tty_insert_flip_string_fixed_flag(&port->port, ch, flag, len);
621 621
622 return len; 622 tty_flip_buffer_push(&port->port);
623}
624
625static void ssu100_process_read_urb(struct urb *urb)
626{
627 struct usb_serial_port *port = urb->context;
628 struct tty_struct *tty;
629 int count;
630
631 tty = tty_port_tty_get(&port->port);
632 if (!tty)
633 return;
634
635 count = ssu100_process_packet(urb);
636
637 if (count)
638 tty_flip_buffer_push(tty);
639 tty_kref_put(tty);
640} 623}
641 624
642static struct usb_serial_driver ssu100_device = { 625static struct usb_serial_driver ssu100_device = {
diff --git a/drivers/usb/serial/symbolserial.c b/drivers/usb/serial/symbolserial.c
index 2ffa6ae3b5ed..be05e6caf9a3 100644
--- a/drivers/usb/serial/symbolserial.c
+++ b/drivers/usb/serial/symbolserial.c
@@ -48,7 +48,6 @@ static void symbol_int_callback(struct urb *urb)
48 unsigned char *data = urb->transfer_buffer; 48 unsigned char *data = urb->transfer_buffer;
49 struct usb_serial_port *port = priv->port; 49 struct usb_serial_port *port = priv->port;
50 int status = urb->status; 50 int status = urb->status;
51 struct tty_struct *tty;
52 int result; 51 int result;
53 int data_length; 52 int data_length;
54 53
@@ -82,13 +81,8 @@ static void symbol_int_callback(struct urb *urb)
82 * we pretty much just ignore the size and send everything 81 * we pretty much just ignore the size and send everything
83 * else to the tty layer. 82 * else to the tty layer.
84 */ 83 */
85 tty = tty_port_tty_get(&port->port); 84 tty_insert_flip_string(&port->port, &data[1], data_length);
86 if (tty) { 85 tty_flip_buffer_push(&port->port);
87 tty_insert_flip_string(&port->port, &data[1],
88 data_length);
89 tty_flip_buffer_push(tty);
90 tty_kref_put(tty);
91 }
92 } else { 86 } else {
93 dev_dbg(&priv->udev->dev, 87 dev_dbg(&priv->udev->dev,
94 "Improper amount of data received from the device, " 88 "Improper amount of data received from the device, "
diff --git a/drivers/usb/serial/ti_usb_3410_5052.c b/drivers/usb/serial/ti_usb_3410_5052.c
index 05077e3c7631..39cb9b807c3c 100644
--- a/drivers/usb/serial/ti_usb_3410_5052.c
+++ b/drivers/usb/serial/ti_usb_3410_5052.c
@@ -121,8 +121,8 @@ static void ti_interrupt_callback(struct urb *urb);
121static void ti_bulk_in_callback(struct urb *urb); 121static void ti_bulk_in_callback(struct urb *urb);
122static void ti_bulk_out_callback(struct urb *urb); 122static void ti_bulk_out_callback(struct urb *urb);
123 123
124static void ti_recv(struct usb_serial_port *port, struct tty_struct *tty, 124static void ti_recv(struct usb_serial_port *port, unsigned char *data,
125 unsigned char *data, int length); 125 int length);
126static void ti_send(struct ti_port *tport); 126static void ti_send(struct ti_port *tport);
127static int ti_set_mcr(struct ti_port *tport, unsigned int mcr); 127static int ti_set_mcr(struct ti_port *tport, unsigned int mcr);
128static int ti_get_lsr(struct ti_port *tport); 128static int ti_get_lsr(struct ti_port *tport);
@@ -1118,7 +1118,6 @@ static void ti_bulk_in_callback(struct urb *urb)
1118 struct device *dev = &urb->dev->dev; 1118 struct device *dev = &urb->dev->dev;
1119 int status = urb->status; 1119 int status = urb->status;
1120 int retval = 0; 1120 int retval = 0;
1121 struct tty_struct *tty;
1122 1121
1123 switch (status) { 1122 switch (status) {
1124 case 0: 1123 case 0:
@@ -1145,23 +1144,18 @@ static void ti_bulk_in_callback(struct urb *urb)
1145 return; 1144 return;
1146 } 1145 }
1147 1146
1148 tty = tty_port_tty_get(&port->port); 1147 if (urb->actual_length) {
1149 if (tty) { 1148 usb_serial_debug_data(dev, __func__, urb->actual_length,
1150 if (urb->actual_length) { 1149 urb->transfer_buffer);
1151 usb_serial_debug_data(dev, __func__, urb->actual_length,
1152 urb->transfer_buffer);
1153 1150
1154 if (!tport->tp_is_open) 1151 if (!tport->tp_is_open)
1155 dev_dbg(dev, "%s - port closed, dropping data\n", 1152 dev_dbg(dev, "%s - port closed, dropping data\n",
1156 __func__); 1153 __func__);
1157 else 1154 else
1158 ti_recv(port, tty, urb->transfer_buffer, 1155 ti_recv(port, urb->transfer_buffer, urb->actual_length);
1159 urb->actual_length); 1156 spin_lock(&tport->tp_lock);
1160 spin_lock(&tport->tp_lock); 1157 tport->tp_icount.rx += urb->actual_length;
1161 tport->tp_icount.rx += urb->actual_length; 1158 spin_unlock(&tport->tp_lock);
1162 spin_unlock(&tport->tp_lock);
1163 }
1164 tty_kref_put(tty);
1165 } 1159 }
1166 1160
1167exit: 1161exit:
@@ -1209,8 +1203,8 @@ static void ti_bulk_out_callback(struct urb *urb)
1209} 1203}
1210 1204
1211 1205
1212static void ti_recv(struct usb_serial_port *port, struct tty_struct *tty, 1206static void ti_recv(struct usb_serial_port *port, unsigned char *data,
1213 unsigned char *data, int length) 1207 int length)
1214{ 1208{
1215 int cnt; 1209 int cnt;
1216 1210
@@ -1222,11 +1216,10 @@ static void ti_recv(struct usb_serial_port *port, struct tty_struct *tty,
1222 if (cnt == 0) 1216 if (cnt == 0)
1223 break; 1217 break;
1224 } 1218 }
1225 tty_flip_buffer_push(tty); 1219 tty_flip_buffer_push(&port->port);
1226 data += cnt; 1220 data += cnt;
1227 length -= cnt; 1221 length -= cnt;
1228 } while (length > 0); 1222 } while (length > 0);
1229
1230} 1223}
1231 1224
1232 1225
diff --git a/drivers/usb/serial/usb_wwan.c b/drivers/usb/serial/usb_wwan.c
index 293b460030cb..a547c91e3c05 100644
--- a/drivers/usb/serial/usb_wwan.c
+++ b/drivers/usb/serial/usb_wwan.c
@@ -275,7 +275,6 @@ static void usb_wwan_indat_callback(struct urb *urb)
275 int err; 275 int err;
276 int endpoint; 276 int endpoint;
277 struct usb_serial_port *port; 277 struct usb_serial_port *port;
278 struct tty_struct *tty;
279 struct device *dev; 278 struct device *dev;
280 unsigned char *data = urb->transfer_buffer; 279 unsigned char *data = urb->transfer_buffer;
281 int status = urb->status; 280 int status = urb->status;
@@ -288,16 +287,12 @@ static void usb_wwan_indat_callback(struct urb *urb)
288 dev_dbg(dev, "%s: nonzero status: %d on endpoint %02x.\n", 287 dev_dbg(dev, "%s: nonzero status: %d on endpoint %02x.\n",
289 __func__, status, endpoint); 288 __func__, status, endpoint);
290 } else { 289 } else {
291 tty = tty_port_tty_get(&port->port); 290 if (urb->actual_length) {
292 if (tty) { 291 tty_insert_flip_string(&port->port, data,
293 if (urb->actual_length) { 292 urb->actual_length);
294 tty_insert_flip_string(&port->port, data, 293 tty_flip_buffer_push(&port->port);
295 urb->actual_length); 294 } else
296 tty_flip_buffer_push(tty); 295 dev_dbg(dev, "%s: empty read urb received\n", __func__);
297 } else
298 dev_dbg(dev, "%s: empty read urb received\n", __func__);
299 tty_kref_put(tty);
300 }
301 296
302 /* Resubmit urb so we continue receiving */ 297 /* Resubmit urb so we continue receiving */
303 err = usb_submit_urb(urb, GFP_ATOMIC); 298 err = usb_submit_urb(urb, GFP_ATOMIC);