aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/usb
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@linux-foundation.org>2013-02-21 16:41:04 -0500
committerLinus Torvalds <torvalds@linux-foundation.org>2013-02-21 16:41:04 -0500
commit21eaab6d19ed43e82ed39c8deb7f192134fb4a0e (patch)
treed995205afdcb7f47462bcd28067dc0c4ab0b7b02 /drivers/usb
parent74e1a2a39355b2d3ae8c60c78d8add162c6d7183 (diff)
parent9e17df37d710f8998e9cb10a548304fe33d4a5c2 (diff)
Merge tag 'tty-3.9-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/tty
Pull tty/serial patches from Greg Kroah-Hartman: "Here's the big tty/serial driver patches for 3.9-rc1. More tty port rework and fixes from Jiri here, as well as lots of individual serial driver updates and fixes. All of these have been in the linux-next tree for a while." * tag 'tty-3.9-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/tty: (140 commits) tty: mxser: improve error handling in mxser_probe() and mxser_module_init() serial: imx: fix uninitialized variable warning serial: tegra: assume CONFIG_OF TTY: do not update atime/mtime on read/write lguest: select CONFIG_TTY to build properly. ARM defconfigs: add missing inclusions of linux/platform_device.h fb/exynos: include platform_device.h ARM: sa1100/assabet: include platform_device.h directly serial: imx: Fix recursive locking bug pps: Fix build breakage from decoupling pps from tty tty: Remove ancient hardpps() pps: Additional cleanups in uart_handle_dcd_change pps: Move timestamp read into PPS code proper pps: Don't crash the machine when exiting will do pps: Fix a use-after free bug when unregistering a source. pps: Use pps_lookup_dev to reduce ldisc coupling pps: Add pps_lookup_dev() function tty: serial: uartlite: Support uartlite on big and little endian systems tty: serial: uartlite: Fix sparse and checkpatch warnings serial/arc-uart: Miscll DT related updates (Grant's review comments) ... Fix up trivial conflicts, mostly just due to the TTY config option clashing with the EXPERIMENTAL removal.
Diffstat (limited to 'drivers/usb')
-rw-r--r--drivers/usb/class/Kconfig2
-rw-r--r--drivers/usb/class/cdc-acm.c13
-rw-r--r--drivers/usb/gadget/Kconfig6
-rw-r--r--drivers/usb/gadget/u_serial.c15
-rw-r--r--drivers/usb/serial/Kconfig2
-rw-r--r--drivers/usb/serial/aircable.c17
-rw-r--r--drivers/usb/serial/ark3116.c12
-rw-r--r--drivers/usb/serial/belkin_sa.c12
-rw-r--r--drivers/usb/serial/cyberjack.c11
-rw-r--r--drivers/usb/serial/cypress_m8.c6
-rw-r--r--drivers/usb/serial/digi_acceleport.c14
-rw-r--r--drivers/usb/serial/f81232.c15
-rw-r--r--drivers/usb/serial/ftdi_sio.c21
-rw-r--r--drivers/usb/serial/garmin_gps.c9
-rw-r--r--drivers/usb/serial/generic.c12
-rw-r--r--drivers/usb/serial/io_edgeport.c39
-rw-r--r--drivers/usb/serial/io_ti.c32
-rw-r--r--drivers/usb/serial/ir-usb.c9
-rw-r--r--drivers/usb/serial/iuu_phoenix.c9
-rw-r--r--drivers/usb/serial/keyspan.c60
-rw-r--r--drivers/usb/serial/keyspan_pda.c9
-rw-r--r--drivers/usb/serial/kl5kusb105.c10
-rw-r--r--drivers/usb/serial/kobil_sct.c9
-rw-r--r--drivers/usb/serial/mct_u232.c11
-rw-r--r--drivers/usb/serial/metro-usb.c9
-rw-r--r--drivers/usb/serial/mos7720.c9
-rw-r--r--drivers/usb/serial/mos7840.c10
-rw-r--r--drivers/usb/serial/navman.c9
-rw-r--r--drivers/usb/serial/omninet.c10
-rw-r--r--drivers/usb/serial/opticon.c11
-rw-r--r--drivers/usb/serial/oti6858.c9
-rw-r--r--drivers/usb/serial/pl2303.c15
-rw-r--r--drivers/usb/serial/quatech2.c29
-rw-r--r--drivers/usb/serial/safe_serial.c15
-rw-r--r--drivers/usb/serial/sierra.c17
-rw-r--r--drivers/usb/serial/spcp8x5.c24
-rw-r--r--drivers/usb/serial/ssu100.c31
-rw-r--r--drivers/usb/serial/symbolserial.c9
-rw-r--r--drivers/usb/serial/ti_usb_3410_5052.c44
-rw-r--r--drivers/usb/serial/usb_wwan.c17
40 files changed, 210 insertions, 413 deletions
diff --git a/drivers/usb/class/Kconfig b/drivers/usb/class/Kconfig
index 2519e320098f..316aac8e4ca1 100644
--- a/drivers/usb/class/Kconfig
+++ b/drivers/usb/class/Kconfig
@@ -6,7 +6,7 @@ comment "USB Device Class drivers"
6 6
7config USB_ACM 7config USB_ACM
8 tristate "USB Modem (CDC ACM) support" 8 tristate "USB Modem (CDC ACM) support"
9 depends on USB 9 depends on USB && TTY
10 ---help--- 10 ---help---
11 This driver supports USB modems and ISDN adapters which support the 11 This driver supports USB modems and ISDN adapters which support the
12 Communication Device Class Abstract Control Model interface. 12 Communication Device Class Abstract Control Model interface.
diff --git a/drivers/usb/class/cdc-acm.c b/drivers/usb/class/cdc-acm.c
index 2d92cce260d7..8ac25adf31b4 100644
--- a/drivers/usb/class/cdc-acm.c
+++ b/drivers/usb/class/cdc-acm.c
@@ -410,19 +410,12 @@ static int acm_submit_read_urbs(struct acm *acm, gfp_t mem_flags)
410 410
411static void acm_process_read_urb(struct acm *acm, struct urb *urb) 411static void acm_process_read_urb(struct acm *acm, struct urb *urb)
412{ 412{
413 struct tty_struct *tty;
414
415 if (!urb->actual_length) 413 if (!urb->actual_length)
416 return; 414 return;
417 415
418 tty = tty_port_tty_get(&acm->port); 416 tty_insert_flip_string(&acm->port, urb->transfer_buffer,
419 if (!tty) 417 urb->actual_length);
420 return; 418 tty_flip_buffer_push(&acm->port);
421
422 tty_insert_flip_string(tty, urb->transfer_buffer, urb->actual_length);
423 tty_flip_buffer_push(tty);
424
425 tty_kref_put(tty);
426} 419}
427 420
428static void acm_read_bulk_callback(struct urb *urb) 421static void acm_read_bulk_callback(struct urb *urb)
diff --git a/drivers/usb/gadget/Kconfig b/drivers/usb/gadget/Kconfig
index c5c6fa60910d..5a0c541daf89 100644
--- a/drivers/usb/gadget/Kconfig
+++ b/drivers/usb/gadget/Kconfig
@@ -762,6 +762,7 @@ config USB_GADGET_TARGET
762 762
763config USB_G_SERIAL 763config USB_G_SERIAL
764 tristate "Serial Gadget (with CDC ACM and CDC OBEX support)" 764 tristate "Serial Gadget (with CDC ACM and CDC OBEX support)"
765 depends on TTY
765 select USB_U_SERIAL 766 select USB_U_SERIAL
766 select USB_F_ACM 767 select USB_F_ACM
767 select USB_LIBCOMPOSITE 768 select USB_LIBCOMPOSITE
@@ -813,6 +814,8 @@ config USB_G_PRINTER
813 For more information, see Documentation/usb/gadget_printer.txt 814 For more information, see Documentation/usb/gadget_printer.txt
814 which includes sample code for accessing the device file. 815 which includes sample code for accessing the device file.
815 816
817if TTY
818
816config USB_CDC_COMPOSITE 819config USB_CDC_COMPOSITE
817 tristate "CDC Composite Device (Ethernet and ACM)" 820 tristate "CDC Composite Device (Ethernet and ACM)"
818 depends on NET 821 depends on NET
@@ -900,6 +903,8 @@ config USB_G_MULTI_CDC
900 903
901 If unsure, say "y". 904 If unsure, say "y".
902 905
906endif # TTY
907
903config USB_G_HID 908config USB_G_HID
904 tristate "HID Gadget" 909 tristate "HID Gadget"
905 select USB_LIBCOMPOSITE 910 select USB_LIBCOMPOSITE
@@ -916,6 +921,7 @@ config USB_G_HID
916# Standalone / single function gadgets 921# Standalone / single function gadgets
917config USB_G_DBGP 922config USB_G_DBGP
918 tristate "EHCI Debug Device Gadget" 923 tristate "EHCI Debug Device Gadget"
924 depends on TTY
919 select USB_LIBCOMPOSITE 925 select USB_LIBCOMPOSITE
920 help 926 help
921 This gadget emulates an EHCI Debug device. This is useful when you want 927 This gadget emulates an EHCI Debug device. This is useful when you want
diff --git a/drivers/usb/gadget/u_serial.c b/drivers/usb/gadget/u_serial.c
index 588a9be18ef8..c5034d9c946b 100644
--- a/drivers/usb/gadget/u_serial.c
+++ b/drivers/usb/gadget/u_serial.c
@@ -496,12 +496,8 @@ static void gs_rx_push(unsigned long _port)
496 496
497 req = list_first_entry(queue, struct usb_request, list); 497 req = list_first_entry(queue, struct usb_request, list);
498 498
499 /* discard data if tty was closed */
500 if (!tty)
501 goto recycle;
502
503 /* leave data queued if tty was rx throttled */ 499 /* leave data queued if tty was rx throttled */
504 if (test_bit(TTY_THROTTLED, &tty->flags)) 500 if (tty && test_bit(TTY_THROTTLED, &tty->flags))
505 break; 501 break;
506 502
507 switch (req->status) { 503 switch (req->status) {
@@ -534,7 +530,8 @@ static void gs_rx_push(unsigned long _port)
534 size -= n; 530 size -= n;
535 } 531 }
536 532
537 count = tty_insert_flip_string(tty, packet, size); 533 count = tty_insert_flip_string(&port->port, packet,
534 size);
538 if (count) 535 if (count)
539 do_push = true; 536 do_push = true;
540 if (count != size) { 537 if (count != size) {
@@ -547,7 +544,7 @@ static void gs_rx_push(unsigned long _port)
547 } 544 }
548 port->n_read = 0; 545 port->n_read = 0;
549 } 546 }
550recycle: 547
551 list_move(&req->list, &port->read_pool); 548 list_move(&req->list, &port->read_pool);
552 port->read_started--; 549 port->read_started--;
553 } 550 }
@@ -555,8 +552,8 @@ recycle:
555 /* Push from tty to ldisc; without low_latency set this is handled by 552 /* Push from tty to ldisc; without low_latency set this is handled by
556 * a workqueue, so we won't get callbacks and can hold port_lock 553 * a workqueue, so we won't get callbacks and can hold port_lock
557 */ 554 */
558 if (tty && do_push) 555 if (do_push)
559 tty_flip_buffer_push(tty); 556 tty_flip_buffer_push(&port->port);
560 557
561 558
562 /* We want our data queue to become empty ASAP, keeping data 559 /* We want our data queue to become empty ASAP, keeping data
diff --git a/drivers/usb/serial/Kconfig b/drivers/usb/serial/Kconfig
index dad8363e5b2a..17b7f9ae36ad 100644
--- a/drivers/usb/serial/Kconfig
+++ b/drivers/usb/serial/Kconfig
@@ -4,7 +4,7 @@
4 4
5menuconfig USB_SERIAL 5menuconfig USB_SERIAL
6 tristate "USB Serial Converter support" 6 tristate "USB Serial Converter support"
7 depends on USB 7 depends on USB && TTY
8 ---help--- 8 ---help---
9 Say Y here if you have a USB device that provides normal serial 9 Say Y here if you have a USB device that provides normal serial
10 ports, or acts like a serial device, and you want to connect it to 10 ports, or acts like a serial device, and you want to connect it to
diff --git a/drivers/usb/serial/aircable.c b/drivers/usb/serial/aircable.c
index 6d110a3bc7e7..6e320cec397d 100644
--- a/drivers/usb/serial/aircable.c
+++ b/drivers/usb/serial/aircable.c
@@ -119,9 +119,8 @@ static int aircable_probe(struct usb_serial *serial,
119 return 0; 119 return 0;
120} 120}
121 121
122static int aircable_process_packet(struct tty_struct *tty, 122static int aircable_process_packet(struct usb_serial_port *port,
123 struct usb_serial_port *port, int has_headers, 123 int has_headers, char *packet, int len)
124 char *packet, int len)
125{ 124{
126 if (has_headers) { 125 if (has_headers) {
127 len -= HCI_HEADER_LENGTH; 126 len -= HCI_HEADER_LENGTH;
@@ -132,7 +131,7 @@ static int aircable_process_packet(struct tty_struct *tty,
132 return 0; 131 return 0;
133 } 132 }
134 133
135 tty_insert_flip_string(tty, packet, len); 134 tty_insert_flip_string(&port->port, packet, len);
136 135
137 return len; 136 return len;
138} 137}
@@ -141,28 +140,22 @@ static void aircable_process_read_urb(struct urb *urb)
141{ 140{
142 struct usb_serial_port *port = urb->context; 141 struct usb_serial_port *port = urb->context;
143 char *data = (char *)urb->transfer_buffer; 142 char *data = (char *)urb->transfer_buffer;
144 struct tty_struct *tty;
145 int has_headers; 143 int has_headers;
146 int count; 144 int count;
147 int len; 145 int len;
148 int i; 146 int i;
149 147
150 tty = tty_port_tty_get(&port->port);
151 if (!tty)
152 return;
153
154 has_headers = (urb->actual_length > 2 && data[0] == RX_HEADER_0); 148 has_headers = (urb->actual_length > 2 && data[0] == RX_HEADER_0);
155 149
156 count = 0; 150 count = 0;
157 for (i = 0; i < urb->actual_length; i += HCI_COMPLETE_FRAME) { 151 for (i = 0; i < urb->actual_length; i += HCI_COMPLETE_FRAME) {
158 len = min_t(int, urb->actual_length - i, HCI_COMPLETE_FRAME); 152 len = min_t(int, urb->actual_length - i, HCI_COMPLETE_FRAME);
159 count += aircable_process_packet(tty, port, has_headers, 153 count += aircable_process_packet(port, has_headers,
160 &data[i], len); 154 &data[i], len);
161 } 155 }
162 156
163 if (count) 157 if (count)
164 tty_flip_buffer_push(tty); 158 tty_flip_buffer_push(&port->port);
165 tty_kref_put(tty);
166} 159}
167 160
168static 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 a88882c0e237..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;
@@ -703,12 +698,11 @@ static void ark3116_process_read_urb(struct urb *urb)
703 698
704 /* overrun is special, not associated with a char */ 699 /* overrun is special, not associated with a char */
705 if (lsr & UART_LSR_OE) 700 if (lsr & UART_LSR_OE)
706 tty_insert_flip_char(tty, 0, TTY_OVERRUN); 701 tty_insert_flip_char(&port->port, 0, TTY_OVERRUN);
707 } 702 }
708 tty_insert_flip_string_fixed_flag(tty, 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 b72a4c166705..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. */
@@ -276,13 +271,12 @@ static void belkin_sa_process_read_urb(struct urb *urb)
276 271
277 /* Overrun is special, not associated with a char. */ 272 /* Overrun is special, not associated with a char. */
278 if (status & BELKIN_SA_LSR_OE) 273 if (status & BELKIN_SA_LSR_OE)
279 tty_insert_flip_char(tty, 0, TTY_OVERRUN); 274 tty_insert_flip_char(&port->port, 0, TTY_OVERRUN);
280 } 275 }
281 276
282 tty_insert_flip_string_fixed_flag(tty, 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 69a4fa1cee25..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(tty, 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 fd8c35fd452e..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(tty, 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 45d4af62967f..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,13 +1432,13 @@ 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
1442 /* overrun is special, not associated with a char */ 1439 /* overrun is special, not associated with a char */
1443 if (port_status & DIGI_OVERRUN_ERROR) 1440 if (port_status & DIGI_OVERRUN_ERROR)
1444 tty_insert_flip_char(tty, 0, TTY_OVERRUN); 1441 tty_insert_flip_char(&port->port, 0, TTY_OVERRUN);
1445 1442
1446 /* break takes precedence over parity, */ 1443 /* break takes precedence over parity, */
1447 /* which takes precedence over framing errors */ 1444 /* which takes precedence over framing errors */
@@ -1455,13 +1452,12 @@ static int digi_read_inb_callback(struct urb *urb)
1455 /* data length is len-1 (one byte of len is port_status) */ 1452 /* data length is len-1 (one byte of len is port_status) */
1456 --len; 1453 --len;
1457 if (len > 0) { 1454 if (len > 0) {
1458 tty_insert_flip_string_fixed_flag(tty, data, flag, 1455 tty_insert_flip_string_fixed_flag(&port->port, data,
1459 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 6e4eb57d0177..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)
@@ -133,19 +128,19 @@ static void f81232_process_read_urb(struct urb *urb)
133 128
134 /* overrun is special, not associated with a char */ 129 /* overrun is special, not associated with a char */
135 if (line_status & UART_OVERRUN_ERROR) 130 if (line_status & UART_OVERRUN_ERROR)
136 tty_insert_flip_char(tty, 0, TTY_OVERRUN); 131 tty_insert_flip_char(&port->port, 0, TTY_OVERRUN);
137 132
138 if (port->port.console && port->sysrq) { 133 if (port->port.console && port->sysrq) {
139 for (i = 0; i < urb->actual_length; ++i) 134 for (i = 0; i < urb->actual_length; ++i)
140 if (!usb_serial_handle_sysrq_char(port, data[i])) 135 if (!usb_serial_handle_sysrq_char(port, data[i]))
141 tty_insert_flip_char(tty, data[i], tty_flag); 136 tty_insert_flip_char(&port->port, data[i],
137 tty_flag);
142 } else { 138 } else {
143 tty_insert_flip_string_fixed_flag(tty, data, tty_flag, 139 tty_insert_flip_string_fixed_flag(&port->port, data, tty_flag,
144 urb->actual_length); 140 urb->actual_length);
145 } 141 }
146 142
147 tty_flip_buffer_push(tty); 143 tty_flip_buffer_push(&port->port);
148 tty_kref_put(tty);
149} 144}
150 145
151static 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 d07fccf3bab5..edd162df49ca 100644
--- a/drivers/usb/serial/ftdi_sio.c
+++ b/drivers/usb/serial/ftdi_sio.c
@@ -1960,9 +1960,8 @@ static int ftdi_prepare_write_buffer(struct usb_serial_port *port,
1960 1960
1961#define FTDI_RS_ERR_MASK (FTDI_RS_BI | FTDI_RS_PE | FTDI_RS_FE | FTDI_RS_OE) 1961#define FTDI_RS_ERR_MASK (FTDI_RS_BI | FTDI_RS_PE | FTDI_RS_FE | FTDI_RS_OE)
1962 1962
1963static int ftdi_process_packet(struct tty_struct *tty, 1963static int ftdi_process_packet(struct usb_serial_port *port,
1964 struct usb_serial_port *port, struct ftdi_private *priv, 1964 struct ftdi_private *priv, char *packet, int len)
1965 char *packet, int len)
1966{ 1965{
1967 int i; 1966 int i;
1968 char status; 1967 char status;
@@ -2012,7 +2011,7 @@ static int ftdi_process_packet(struct tty_struct *tty,
2012 /* Overrun is special, not associated with a char */ 2011 /* Overrun is special, not associated with a char */
2013 if (packet[1] & FTDI_RS_OE) { 2012 if (packet[1] & FTDI_RS_OE) {
2014 priv->icount.overrun++; 2013 priv->icount.overrun++;
2015 tty_insert_flip_char(tty, 0, TTY_OVERRUN); 2014 tty_insert_flip_char(&port->port, 0, TTY_OVERRUN);
2016 } 2015 }
2017 } 2016 }
2018 2017
@@ -2031,10 +2030,10 @@ static int ftdi_process_packet(struct tty_struct *tty,
2031 if (port->port.console && port->sysrq) { 2030 if (port->port.console && port->sysrq) {
2032 for (i = 0; i < len; i++, ch++) { 2031 for (i = 0; i < len; i++, ch++) {
2033 if (!usb_serial_handle_sysrq_char(port, *ch)) 2032 if (!usb_serial_handle_sysrq_char(port, *ch))
2034 tty_insert_flip_char(tty, *ch, flag); 2033 tty_insert_flip_char(&port->port, *ch, flag);
2035 } 2034 }
2036 } else { 2035 } else {
2037 tty_insert_flip_string_fixed_flag(tty, ch, flag, len); 2036 tty_insert_flip_string_fixed_flag(&port->port, ch, flag, len);
2038 } 2037 }
2039 2038
2040 return len; 2039 return len;
@@ -2043,25 +2042,19 @@ static int ftdi_process_packet(struct tty_struct *tty,
2043static void ftdi_process_read_urb(struct urb *urb) 2042static void ftdi_process_read_urb(struct urb *urb)
2044{ 2043{
2045 struct usb_serial_port *port = urb->context; 2044 struct usb_serial_port *port = urb->context;
2046 struct tty_struct *tty;
2047 struct ftdi_private *priv = usb_get_serial_port_data(port); 2045 struct ftdi_private *priv = usb_get_serial_port_data(port);
2048 char *data = (char *)urb->transfer_buffer; 2046 char *data = (char *)urb->transfer_buffer;
2049 int i; 2047 int i;
2050 int len; 2048 int len;
2051 int count = 0; 2049 int count = 0;
2052 2050
2053 tty = tty_port_tty_get(&port->port);
2054 if (!tty)
2055 return;
2056
2057 for (i = 0; i < urb->actual_length; i += priv->max_packet_size) { 2051 for (i = 0; i < urb->actual_length; i += priv->max_packet_size) {
2058 len = min_t(int, urb->actual_length - i, priv->max_packet_size); 2052 len = min_t(int, urb->actual_length - i, priv->max_packet_size);
2059 count += ftdi_process_packet(tty, port, priv, &data[i], len); 2053 count += ftdi_process_packet(port, priv, &data[i], len);
2060 } 2054 }
2061 2055
2062 if (count) 2056 if (count)
2063 tty_flip_buffer_push(tty); 2057 tty_flip_buffer_push(&port->port);
2064 tty_kref_put(tty);
2065} 2058}
2066 2059
2067static void ftdi_break_ctl(struct tty_struct *tty, int break_state) 2060static 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 203358d7e7bc..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(tty, 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 2ea70a631996..4c5c23f1cae5 100644
--- a/drivers/usb/serial/generic.c
+++ b/drivers/usb/serial/generic.c
@@ -313,30 +313,24 @@ 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 */
330 if (!port->port.console || !port->sysrq) 325 if (!port->port.console || !port->sysrq)
331 tty_insert_flip_string(tty, ch, urb->actual_length); 326 tty_insert_flip_string(&port->port, ch, urb->actual_length);
332 else { 327 else {
333 for (i = 0; i < urb->actual_length; i++, ch++) { 328 for (i = 0; i < urb->actual_length; i++, ch++) {
334 if (!usb_serial_handle_sysrq_char(port, *ch)) 329 if (!usb_serial_handle_sysrq_char(port, *ch))
335 tty_insert_flip_char(tty, *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 7b770c7f8b11..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 device *dev, 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_serial->serial->dev->dev, 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,20 +2013,20 @@ 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 device *dev, 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
2025 cnt = tty_insert_flip_string(tty, data, length); 2021 cnt = tty_insert_flip_string(&port->port, data, length);
2026 if (cnt < length) { 2022 if (cnt < length) {
2027 dev_err(dev, "%s - dropping data, %d bytes lost\n", 2023 dev_err(&port->dev, "%s - dropping data, %d bytes lost\n",
2028 __func__, length - cnt); 2024 __func__, length - cnt);
2029 } 2025 }
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->dev, 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 641ab3da2d83..c23776679f70 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 device *dev, 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);
@@ -1484,7 +1484,6 @@ static void handle_new_lsr(struct edgeport_port *edge_port, int lsr_data,
1484 struct async_icount *icount; 1484 struct async_icount *icount;
1485 __u8 new_lsr = (__u8)(lsr & (__u8)(LSR_OVER_ERR | LSR_PAR_ERR | 1485 __u8 new_lsr = (__u8)(lsr & (__u8)(LSR_OVER_ERR | LSR_PAR_ERR |
1486 LSR_FRM_ERR | LSR_BREAK)); 1486 LSR_FRM_ERR | LSR_BREAK));
1487 struct tty_struct *tty;
1488 1487
1489 dev_dbg(&edge_port->port->dev, "%s - %02x\n", __func__, new_lsr); 1488 dev_dbg(&edge_port->port->dev, "%s - %02x\n", __func__, new_lsr);
1490 1489
@@ -1498,13 +1497,8 @@ static void handle_new_lsr(struct edgeport_port *edge_port, int lsr_data,
1498 new_lsr &= (__u8)(LSR_OVER_ERR | LSR_BREAK); 1497 new_lsr &= (__u8)(LSR_OVER_ERR | LSR_BREAK);
1499 1498
1500 /* Place LSR data byte into Rx buffer */ 1499 /* Place LSR data byte into Rx buffer */
1501 if (lsr_data) { 1500 if (lsr_data)
1502 tty = tty_port_tty_get(&edge_port->port->port); 1501 edge_tty_recv(edge_port->port, &data, 1);
1503 if (tty) {
1504 edge_tty_recv(&edge_port->port->dev, tty, &data, 1);
1505 tty_kref_put(tty);
1506 }
1507 }
1508 1502
1509 /* update input line counters */ 1503 /* update input line counters */
1510 icount = &edge_port->icount; 1504 icount = &edge_port->icount;
@@ -1620,7 +1614,6 @@ static void edge_bulk_in_callback(struct urb *urb)
1620 struct edgeport_port *edge_port = urb->context; 1614 struct edgeport_port *edge_port = urb->context;
1621 struct device *dev = &edge_port->port->dev; 1615 struct device *dev = &edge_port->port->dev;
1622 unsigned char *data = urb->transfer_buffer; 1616 unsigned char *data = urb->transfer_buffer;
1623 struct tty_struct *tty;
1624 int retval = 0; 1617 int retval = 0;
1625 int port_number; 1618 int port_number;
1626 int status = urb->status; 1619 int status = urb->status;
@@ -1659,17 +1652,16 @@ static void edge_bulk_in_callback(struct urb *urb)
1659 ++data; 1652 ++data;
1660 } 1653 }
1661 1654
1662 tty = tty_port_tty_get(&edge_port->port->port); 1655 if (urb->actual_length) {
1663 if (tty && urb->actual_length) {
1664 usb_serial_debug_data(dev, __func__, urb->actual_length, data); 1656 usb_serial_debug_data(dev, __func__, urb->actual_length, data);
1665 if (edge_port->close_pending) 1657 if (edge_port->close_pending)
1666 dev_dbg(dev, "%s - close pending, dropping data on the floor\n", 1658 dev_dbg(dev, "%s - close pending, dropping data on the floor\n",
1667 __func__); 1659 __func__);
1668 else 1660 else
1669 edge_tty_recv(dev, tty, data, urb->actual_length); 1661 edge_tty_recv(edge_port->port, data,
1662 urb->actual_length);
1670 edge_port->icount.rx += urb->actual_length; 1663 edge_port->icount.rx += urb->actual_length;
1671 } 1664 }
1672 tty_kref_put(tty);
1673 1665
1674exit: 1666exit:
1675 /* continue read unless stopped */ 1667 /* continue read unless stopped */
@@ -1684,16 +1676,16 @@ exit:
1684 dev_err(dev, "%s - usb_submit_urb failed with result %d\n", __func__, retval); 1676 dev_err(dev, "%s - usb_submit_urb failed with result %d\n", __func__, retval);
1685} 1677}
1686 1678
1687static void edge_tty_recv(struct device *dev, struct tty_struct *tty, 1679static void edge_tty_recv(struct usb_serial_port *port, unsigned char *data,
1688 unsigned char *data, int length) 1680 int length)
1689{ 1681{
1690 int queued; 1682 int queued;
1691 1683
1692 queued = tty_insert_flip_string(tty, data, length); 1684 queued = tty_insert_flip_string(&port->port, data, length);
1693 if (queued < length) 1685 if (queued < length)
1694 dev_err(dev, "%s - dropping data, %d bytes lost\n", 1686 dev_err(&port->dev, "%s - dropping data, %d bytes lost\n",
1695 __func__, length - queued); 1687 __func__, length - queued);
1696 tty_flip_buffer_push(tty); 1688 tty_flip_buffer_push(&port->port);
1697} 1689}
1698 1690
1699static void edge_bulk_out_callback(struct urb *urb) 1691static 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 e24e2d4f4c1b..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); 304 tty_insert_flip_string(&port->port, data + 1, urb->actual_length - 1);
306 if (!tty) 305 tty_flip_buffer_push(&port->port);
307 return;
308 tty_insert_flip_string(tty, data + 1, urb->actual_length - 1);
309 tty_flip_buffer_push(tty);
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 1e1fbed65ef2..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(tty, 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 3d95637f3d68..1fd1935c8316 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
@@ -315,7 +313,7 @@ static void usa26_indat_callback(struct urb *urb)
315 else 313 else
316 err = 0; 314 err = 0;
317 for (i = 1; i < urb->actual_length ; ++i) 315 for (i = 1; i < urb->actual_length ; ++i)
318 tty_insert_flip_char(tty, data[i], err); 316 tty_insert_flip_char(&port->port, data[i], err);
319 } else { 317 } else {
320 /* some bytes had errors, every byte has status */ 318 /* some bytes had errors, every byte has status */
321 dev_dbg(&port->dev, "%s - RX error!!!!\n", __func__); 319 dev_dbg(&port->dev, "%s - RX error!!!!\n", __func__);
@@ -328,12 +326,12 @@ static void usa26_indat_callback(struct urb *urb)
328 if (stat & RXERROR_PARITY) 326 if (stat & RXERROR_PARITY)
329 flag |= TTY_PARITY; 327 flag |= TTY_PARITY;
330 /* XXX should handle break (0x10) */ 328 /* XXX should handle break (0x10) */
331 tty_insert_flip_char(tty, data[i+1], flag); 329 tty_insert_flip_char(&port->port, data[i+1],
330 flag);
332 } 331 }
333 } 332 }
334 tty_flip_buffer_push(tty); 333 tty_flip_buffer_push(&port->port);
335 } 334 }
336 tty_kref_put(tty);
337 335
338 /* Resubmit urb so we continue receiving */ 336 /* Resubmit urb so we continue receiving */
339 err = usb_submit_urb(urb, GFP_ATOMIC); 337 err = usb_submit_urb(urb, GFP_ATOMIC);
@@ -446,7 +444,6 @@ static void usa28_indat_callback(struct urb *urb)
446{ 444{
447 int err; 445 int err;
448 struct usb_serial_port *port; 446 struct usb_serial_port *port;
449 struct tty_struct *tty;
450 unsigned char *data; 447 unsigned char *data;
451 struct keyspan_port_private *p_priv; 448 struct keyspan_port_private *p_priv;
452 int status = urb->status; 449 int status = urb->status;
@@ -469,12 +466,11 @@ static void usa28_indat_callback(struct urb *urb)
469 p_priv = usb_get_serial_port_data(port); 466 p_priv = usb_get_serial_port_data(port);
470 data = urb->transfer_buffer; 467 data = urb->transfer_buffer;
471 468
472 tty = tty_port_tty_get(&port->port); 469 if (urb->actual_length) {
473 if (tty && urb->actual_length) { 470 tty_insert_flip_string(&port->port, data,
474 tty_insert_flip_string(tty, data, urb->actual_length); 471 urb->actual_length);
475 tty_flip_buffer_push(tty); 472 tty_flip_buffer_push(&port->port);
476 } 473 }
477 tty_kref_put(tty);
478 474
479 /* Resubmit urb so we continue receiving */ 475 /* Resubmit urb so we continue receiving */
480 err = usb_submit_urb(urb, GFP_ATOMIC); 476 err = usb_submit_urb(urb, GFP_ATOMIC);
@@ -669,7 +665,6 @@ static void usa49_indat_callback(struct urb *urb)
669 int i, err; 665 int i, err;
670 int endpoint; 666 int endpoint;
671 struct usb_serial_port *port; 667 struct usb_serial_port *port;
672 struct tty_struct *tty;
673 unsigned char *data = urb->transfer_buffer; 668 unsigned char *data = urb->transfer_buffer;
674 int status = urb->status; 669 int status = urb->status;
675 670
@@ -682,12 +677,11 @@ static void usa49_indat_callback(struct urb *urb)
682 } 677 }
683 678
684 port = urb->context; 679 port = urb->context;
685 tty = tty_port_tty_get(&port->port); 680 if (urb->actual_length) {
686 if (tty && urb->actual_length) {
687 /* 0x80 bit is error flag */ 681 /* 0x80 bit is error flag */
688 if ((data[0] & 0x80) == 0) { 682 if ((data[0] & 0x80) == 0) {
689 /* no error on any byte */ 683 /* no error on any byte */
690 tty_insert_flip_string(tty, data + 1, 684 tty_insert_flip_string(&port->port, data + 1,
691 urb->actual_length - 1); 685 urb->actual_length - 1);
692 } else { 686 } else {
693 /* some bytes had errors, every byte has status */ 687 /* some bytes had errors, every byte has status */
@@ -700,12 +694,12 @@ static void usa49_indat_callback(struct urb *urb)
700 if (stat & RXERROR_PARITY) 694 if (stat & RXERROR_PARITY)
701 flag |= TTY_PARITY; 695 flag |= TTY_PARITY;
702 /* XXX should handle break (0x10) */ 696 /* XXX should handle break (0x10) */
703 tty_insert_flip_char(tty, data[i+1], flag); 697 tty_insert_flip_char(&port->port, data[i+1],
698 flag);
704 } 699 }
705 } 700 }
706 tty_flip_buffer_push(tty); 701 tty_flip_buffer_push(&port->port);
707 } 702 }
708 tty_kref_put(tty);
709 703
710 /* Resubmit urb so we continue receiving */ 704 /* Resubmit urb so we continue receiving */
711 err = usb_submit_urb(urb, GFP_ATOMIC); 705 err = usb_submit_urb(urb, GFP_ATOMIC);
@@ -718,7 +712,6 @@ static void usa49wg_indat_callback(struct urb *urb)
718 int i, len, x, err; 712 int i, len, x, err;
719 struct usb_serial *serial; 713 struct usb_serial *serial;
720 struct usb_serial_port *port; 714 struct usb_serial_port *port;
721 struct tty_struct *tty;
722 unsigned char *data = urb->transfer_buffer; 715 unsigned char *data = urb->transfer_buffer;
723 int status = urb->status; 716 int status = urb->status;
724 717
@@ -743,7 +736,6 @@ static void usa49wg_indat_callback(struct urb *urb)
743 return; 736 return;
744 } 737 }
745 port = serial->port[data[i++]]; 738 port = serial->port[data[i++]];
746 tty = tty_port_tty_get(&port->port);
747 len = data[i++]; 739 len = data[i++];
748 740
749 /* 0x80 bit is error flag */ 741 /* 0x80 bit is error flag */
@@ -751,7 +743,8 @@ static void usa49wg_indat_callback(struct urb *urb)
751 /* no error on any byte */ 743 /* no error on any byte */
752 i++; 744 i++;
753 for (x = 1; x < len ; ++x) 745 for (x = 1; x < len ; ++x)
754 tty_insert_flip_char(tty, data[i++], 0); 746 tty_insert_flip_char(&port->port,
747 data[i++], 0);
755 } else { 748 } else {
756 /* 749 /*
757 * some bytes had errors, every byte has status 750 * some bytes had errors, every byte has status
@@ -765,13 +758,12 @@ static void usa49wg_indat_callback(struct urb *urb)
765 if (stat & RXERROR_PARITY) 758 if (stat & RXERROR_PARITY)
766 flag |= TTY_PARITY; 759 flag |= TTY_PARITY;
767 /* XXX should handle break (0x10) */ 760 /* XXX should handle break (0x10) */
768 tty_insert_flip_char(tty, 761 tty_insert_flip_char(&port->port,
769 data[i+1], flag); 762 data[i+1], flag);
770 i += 2; 763 i += 2;
771 } 764 }
772 } 765 }
773 tty_flip_buffer_push(tty); 766 tty_flip_buffer_push(&port->port);
774 tty_kref_put(tty);
775 } 767 }
776 } 768 }
777 769
@@ -792,7 +784,6 @@ static void usa90_indat_callback(struct urb *urb)
792 int endpoint; 784 int endpoint;
793 struct usb_serial_port *port; 785 struct usb_serial_port *port;
794 struct keyspan_port_private *p_priv; 786 struct keyspan_port_private *p_priv;
795 struct tty_struct *tty;
796 unsigned char *data = urb->transfer_buffer; 787 unsigned char *data = urb->transfer_buffer;
797 int status = urb->status; 788 int status = urb->status;
798 789
@@ -808,12 +799,12 @@ static void usa90_indat_callback(struct urb *urb)
808 p_priv = usb_get_serial_port_data(port); 799 p_priv = usb_get_serial_port_data(port);
809 800
810 if (urb->actual_length) { 801 if (urb->actual_length) {
811 tty = tty_port_tty_get(&port->port);
812 /* if current mode is DMA, looks like usa28 format 802 /* if current mode is DMA, looks like usa28 format
813 otherwise looks like usa26 data format */ 803 otherwise looks like usa26 data format */
814 804
815 if (p_priv->baud > 57600) 805 if (p_priv->baud > 57600)
816 tty_insert_flip_string(tty, data, urb->actual_length); 806 tty_insert_flip_string(&port->port, data,
807 urb->actual_length);
817 else { 808 else {
818 /* 0x80 bit is error flag */ 809 /* 0x80 bit is error flag */
819 if ((data[0] & 0x80) == 0) { 810 if ((data[0] & 0x80) == 0) {
@@ -824,8 +815,8 @@ static void usa90_indat_callback(struct urb *urb)
824 else 815 else
825 err = 0; 816 err = 0;
826 for (i = 1; i < urb->actual_length ; ++i) 817 for (i = 1; i < urb->actual_length ; ++i)
827 tty_insert_flip_char(tty, data[i], 818 tty_insert_flip_char(&port->port,
828 err); 819 data[i], err);
829 } else { 820 } else {
830 /* some bytes had errors, every byte has status */ 821 /* some bytes had errors, every byte has status */
831 dev_dbg(&port->dev, "%s - RX error!!!!\n", __func__); 822 dev_dbg(&port->dev, "%s - RX error!!!!\n", __func__);
@@ -838,13 +829,12 @@ static void usa90_indat_callback(struct urb *urb)
838 if (stat & RXERROR_PARITY) 829 if (stat & RXERROR_PARITY)
839 flag |= TTY_PARITY; 830 flag |= TTY_PARITY;
840 /* XXX should handle break (0x10) */ 831 /* XXX should handle break (0x10) */
841 tty_insert_flip_char(tty, data[i+1], 832 tty_insert_flip_char(&port->port,
842 flag); 833 data[i+1], flag);
843 } 834 }
844 } 835 }
845 } 836 }
846 tty_flip_buffer_push(tty); 837 tty_flip_buffer_push(&port->port);
847 tty_kref_put(tty);
848 } 838 }
849 839
850 /* 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 41b01092af07..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(tty, 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 fc9e14a1e9b3..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,19 +400,14 @@ 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__);
411 len = urb->actual_length - KLSI_HDR_LEN; 406 len = urb->actual_length - KLSI_HDR_LEN;
412 } 407 }
413 408
414 tty_insert_flip_string(tty, 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 b747ba615d0b..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 /*
@@ -353,10 +351,9 @@ static void kobil_read_int_callback(struct urb *urb)
353 */ 351 */
354 /* END DEBUG */ 352 /* END DEBUG */
355 353
356 tty_insert_flip_string(tty, 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 d9c86516fed4..a64d420f687b 100644
--- a/drivers/usb/serial/mct_u232.c
+++ b/drivers/usb/serial/mct_u232.c
@@ -527,7 +527,6 @@ static void mct_u232_read_int_callback(struct urb *urb)
527{ 527{
528 struct usb_serial_port *port = urb->context; 528 struct usb_serial_port *port = urb->context;
529 struct mct_u232_private *priv = usb_get_serial_port_data(port); 529 struct mct_u232_private *priv = usb_get_serial_port_data(port);
530 struct tty_struct *tty;
531 unsigned char *data = urb->transfer_buffer; 530 unsigned char *data = urb->transfer_buffer;
532 int retval; 531 int retval;
533 int status = urb->status; 532 int status = urb->status;
@@ -557,13 +556,9 @@ static void mct_u232_read_int_callback(struct urb *urb)
557 */ 556 */
558 if (urb->transfer_buffer_length > 2) { 557 if (urb->transfer_buffer_length > 2) {
559 if (urb->actual_length) { 558 if (urb->actual_length) {
560 tty = tty_port_tty_get(&port->port); 559 tty_insert_flip_string(&port->port, data,
561 if (tty) { 560 urb->actual_length);
562 tty_insert_flip_string(tty, data, 561 tty_flip_buffer_push(&port->port);
563 urb->actual_length);
564 tty_flip_buffer_push(tty);
565 }
566 tty_kref_put(tty);
567 } 562 }
568 goto exit; 563 goto exit;
569 } 564 }
diff --git a/drivers/usb/serial/metro-usb.c b/drivers/usb/serial/metro-usb.c
index 3d258448c29a..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(tty, 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 f57a6b1fe787..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) { 916 tty_insert_flip_string(&port->port, data, urb->actual_length);
918 tty_insert_flip_string(tty, data, urb->actual_length); 917 tty_flip_buffer_push(&port->port);
919 tty_flip_buffer_push(tty);
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 66d9e088d9d9..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;
@@ -773,12 +772,9 @@ static void mos7840_bulk_in_callback(struct urb *urb)
773 usb_serial_debug_data(&port->dev, __func__, urb->actual_length, data); 772 usb_serial_debug_data(&port->dev, __func__, urb->actual_length, data);
774 773
775 if (urb->actual_length) { 774 if (urb->actual_length) {
776 tty = tty_port_tty_get(&mos7840_port->port->port); 775 struct tty_port *tport = &mos7840_port->port->port;
777 if (tty) { 776 tty_insert_flip_string(tport, data, urb->actual_length);
778 tty_insert_flip_string(tty, data, urb->actual_length); 777 tty_flip_buffer_push(tport);
779 tty_flip_buffer_push(tty);
780 tty_kref_put(tty);
781 }
782 mos7840_port->icount.rx += urb->actual_length; 778 mos7840_port->icount.rx += urb->actual_length;
783 smp_wmb(); 779 smp_wmb();
784 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 1566f8f500ae..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) { 58 tty_insert_flip_string(&port->port, data, urb->actual_length);
60 tty_insert_flip_string(tty, data, urb->actual_length); 59 tty_flip_buffer_push(&port->port);
61 tty_flip_buffer_push(tty);
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 7818af931a48..1e1cafe287e4 100644
--- a/drivers/usb/serial/omninet.c
+++ b/drivers/usb/serial/omninet.c
@@ -174,13 +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(tty, data + OMNINET_DATAOFFSET, 179 tty_flip_buffer_push(&port->port);
180 header->oh_len);
181 tty_flip_buffer_push(tty);
182 tty_kref_put(tty);
183 }
184 } 180 }
185 181
186 /* 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 c6bfb83efb1e..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; 54 tty_insert_flip_string(&port->port, buf, len);
55 55 tty_flip_buffer_push(&port->port);
56 tty = tty_port_tty_get(&port->port);
57 if (!tty)
58 return;
59
60 tty_insert_flip_string(tty, buf, len);
61 tty_flip_buffer_push(tty);
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 d217fd6ee43f..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) { 838 tty_insert_flip_string(&port->port, data, urb->actual_length);
840 tty_insert_flip_string(tty, data, urb->actual_length); 839 tty_flip_buffer_push(&port->port);
841 tty_flip_buffer_push(tty);
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 600241901361..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)
@@ -805,19 +800,19 @@ static void pl2303_process_read_urb(struct urb *urb)
805 800
806 /* overrun is special, not associated with a char */ 801 /* overrun is special, not associated with a char */
807 if (line_status & UART_OVERRUN_ERROR) 802 if (line_status & UART_OVERRUN_ERROR)
808 tty_insert_flip_char(tty, 0, TTY_OVERRUN); 803 tty_insert_flip_char(&port->port, 0, TTY_OVERRUN);
809 804
810 if (port->port.console && port->sysrq) { 805 if (port->port.console && port->sysrq) {
811 for (i = 0; i < urb->actual_length; ++i) 806 for (i = 0; i < urb->actual_length; ++i)
812 if (!usb_serial_handle_sysrq_char(port, data[i])) 807 if (!usb_serial_handle_sysrq_char(port, data[i]))
813 tty_insert_flip_char(tty, data[i], tty_flag); 808 tty_insert_flip_char(&port->port, data[i],
809 tty_flag);
814 } else { 810 } else {
815 tty_insert_flip_string_fixed_flag(tty, data, tty_flag, 811 tty_insert_flip_string_fixed_flag(&port->port, data, tty_flag,
816 urb->actual_length); 812 urb->actual_length);
817 } 813 }
818 814
819 tty_flip_buffer_push(tty); 815 tty_flip_buffer_push(&port->port);
820 tty_kref_put(tty);
821} 816}
822 817
823/* 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 a8d5110d4cc5..00e6c9bac8a3 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;
@@ -697,8 +685,8 @@ void qt2_process_read_urb(struct urb *urb)
697 escapeflag = true; 685 escapeflag = true;
698 break; 686 break;
699 case QT2_CONTROL_ESCAPE: 687 case QT2_CONTROL_ESCAPE:
700 tty_buffer_request_room(tty, 2); 688 tty_buffer_request_room(&port->port, 2);
701 tty_insert_flip_string(tty, ch, 2); 689 tty_insert_flip_string(&port->port, ch, 2);
702 i += 2; 690 i += 2;
703 escapeflag = true; 691 escapeflag = true;
704 break; 692 break;
@@ -712,16 +700,11 @@ void qt2_process_read_urb(struct urb *urb)
712 continue; 700 continue;
713 } 701 }
714 702
715 if (tty) { 703 tty_buffer_request_room(&port->port, 1);
716 tty_buffer_request_room(tty, 1); 704 tty_insert_flip_string(&port->port, ch, 1);
717 tty_insert_flip_string(tty, ch, 1);
718 }
719 } 705 }
720 706
721 if (tty) { 707 tty_flip_buffer_push(&port->port);
722 tty_flip_buffer_push(tty);
723 tty_kref_put(tty);
724 }
725} 708}
726 709
727static 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 c949ce6ef0c6..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(tty, 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 d4426c038c32..c13f6e747748 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(tty, 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 a42536af1256..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
@@ -498,17 +494,21 @@ static void spcp8x5_process_read_urb(struct urb *urb)
498 494
499 /* overrun is special, not associated with a char */ 495 /* overrun is special, not associated with a char */
500 if (status & UART_OVERRUN_ERROR) 496 if (status & UART_OVERRUN_ERROR)
501 tty_insert_flip_char(tty, 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(tty, 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 d938396171e8..b57cf841c5b6 100644
--- a/drivers/usb/serial/ssu100.c
+++ b/drivers/usb/serial/ssu100.c
@@ -579,8 +579,7 @@ static void ssu100_update_lsr(struct usb_serial_port *port, u8 lsr,
579 579
580} 580}
581 581
582static int ssu100_process_packet(struct urb *urb, 582static void ssu100_process_read_urb(struct urb *urb)
583 struct tty_struct *tty)
584{ 583{
585 struct usb_serial_port *port = urb->context; 584 struct usb_serial_port *port = urb->context;
586 char *packet = (char *)urb->transfer_buffer; 585 char *packet = (char *)urb->transfer_buffer;
@@ -595,7 +594,8 @@ static int ssu100_process_packet(struct urb *urb,
595 if (packet[2] == 0x00) { 594 if (packet[2] == 0x00) {
596 ssu100_update_lsr(port, packet[3], &flag); 595 ssu100_update_lsr(port, packet[3], &flag);
597 if (flag == TTY_OVERRUN) 596 if (flag == TTY_OVERRUN)
598 tty_insert_flip_char(tty, 0, TTY_OVERRUN); 597 tty_insert_flip_char(&port->port, 0,
598 TTY_OVERRUN);
599 } 599 }
600 if (packet[2] == 0x01) 600 if (packet[2] == 0x01)
601 ssu100_update_msr(port, packet[3]); 601 ssu100_update_msr(port, packet[3]);
@@ -606,34 +606,17 @@ static int ssu100_process_packet(struct urb *urb,
606 ch = packet; 606 ch = packet;
607 607
608 if (!len) 608 if (!len)
609 return 0; /* status only */ 609 return; /* status only */
610 610
611 if (port->port.console && port->sysrq) { 611 if (port->port.console && port->sysrq) {
612 for (i = 0; i < len; i++, ch++) { 612 for (i = 0; i < len; i++, ch++) {
613 if (!usb_serial_handle_sysrq_char(port, *ch)) 613 if (!usb_serial_handle_sysrq_char(port, *ch))
614 tty_insert_flip_char(tty, *ch, flag); 614 tty_insert_flip_char(&port->port, *ch, flag);
615 } 615 }
616 } else 616 } else
617 tty_insert_flip_string_fixed_flag(tty, ch, flag, len); 617 tty_insert_flip_string_fixed_flag(&port->port, ch, flag, len);
618
619 return len;
620}
621
622static void ssu100_process_read_urb(struct urb *urb)
623{
624 struct usb_serial_port *port = urb->context;
625 struct tty_struct *tty;
626 int count;
627
628 tty = tty_port_tty_get(&port->port);
629 if (!tty)
630 return;
631
632 count = ssu100_process_packet(urb, tty);
633 618
634 if (count) 619 tty_flip_buffer_push(&port->port);
635 tty_flip_buffer_push(tty);
636 tty_kref_put(tty);
637} 620}
638 621
639static struct usb_serial_driver ssu100_device = { 622static struct usb_serial_driver ssu100_device = {
diff --git a/drivers/usb/serial/symbolserial.c b/drivers/usb/serial/symbolserial.c
index 701fffa8431f..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,12 +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(tty, &data[1], data_length);
88 tty_flip_buffer_push(tty);
89 tty_kref_put(tty);
90 }
91 } else { 86 } else {
92 dev_dbg(&priv->udev->dev, 87 dev_dbg(&priv->udev->dev,
93 "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 f2530d2ef3c4..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 device *dev, 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,24 +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(&urb->dev->dev, tty, 1155 ti_recv(port, urb->transfer_buffer, urb->actual_length);
1159 urb->transfer_buffer, 1156 spin_lock(&tport->tp_lock);
1160 urb->actual_length); 1157 tport->tp_icount.rx += urb->actual_length;
1161 spin_lock(&tport->tp_lock); 1158 spin_unlock(&tport->tp_lock);
1162 tport->tp_icount.rx += urb->actual_length;
1163 spin_unlock(&tport->tp_lock);
1164 }
1165 tty_kref_put(tty);
1166 } 1159 }
1167 1160
1168exit: 1161exit:
@@ -1210,24 +1203,23 @@ static void ti_bulk_out_callback(struct urb *urb)
1210} 1203}
1211 1204
1212 1205
1213static void ti_recv(struct device *dev, struct tty_struct *tty, 1206static void ti_recv(struct usb_serial_port *port, unsigned char *data,
1214 unsigned char *data, int length) 1207 int length)
1215{ 1208{
1216 int cnt; 1209 int cnt;
1217 1210
1218 do { 1211 do {
1219 cnt = tty_insert_flip_string(tty, data, length); 1212 cnt = tty_insert_flip_string(&port->port, data, length);
1220 if (cnt < length) { 1213 if (cnt < length) {
1221 dev_err(dev, "%s - dropping data, %d bytes lost\n", 1214 dev_err(&port->dev, "%s - dropping data, %d bytes lost\n",
1222 __func__, length - cnt); 1215 __func__, length - cnt);
1223 if (cnt == 0) 1216 if (cnt == 0)
1224 break; 1217 break;
1225 } 1218 }
1226 tty_flip_buffer_push(tty); 1219 tty_flip_buffer_push(&port->port);
1227 data += cnt; 1220 data += cnt;
1228 length -= cnt; 1221 length -= cnt;
1229 } while (length > 0); 1222 } while (length > 0);
1230
1231} 1223}
1232 1224
1233 1225
diff --git a/drivers/usb/serial/usb_wwan.c b/drivers/usb/serial/usb_wwan.c
index 1355a6cd4508..571965aa1cc0 100644
--- a/drivers/usb/serial/usb_wwan.c
+++ b/drivers/usb/serial/usb_wwan.c
@@ -273,7 +273,6 @@ static void usb_wwan_indat_callback(struct urb *urb)
273 int err; 273 int err;
274 int endpoint; 274 int endpoint;
275 struct usb_serial_port *port; 275 struct usb_serial_port *port;
276 struct tty_struct *tty;
277 struct device *dev; 276 struct device *dev;
278 unsigned char *data = urb->transfer_buffer; 277 unsigned char *data = urb->transfer_buffer;
279 int status = urb->status; 278 int status = urb->status;
@@ -286,16 +285,12 @@ static void usb_wwan_indat_callback(struct urb *urb)
286 dev_dbg(dev, "%s: nonzero status: %d on endpoint %02x.\n", 285 dev_dbg(dev, "%s: nonzero status: %d on endpoint %02x.\n",
287 __func__, status, endpoint); 286 __func__, status, endpoint);
288 } else { 287 } else {
289 tty = tty_port_tty_get(&port->port); 288 if (urb->actual_length) {
290 if (tty) { 289 tty_insert_flip_string(&port->port, data,
291 if (urb->actual_length) { 290 urb->actual_length);
292 tty_insert_flip_string(tty, data, 291 tty_flip_buffer_push(&port->port);
293 urb->actual_length); 292 } else
294 tty_flip_buffer_push(tty); 293 dev_dbg(dev, "%s: empty read urb received\n", __func__);
295 } else
296 dev_dbg(dev, "%s: empty read urb received\n", __func__);
297 tty_kref_put(tty);
298 }
299 294
300 /* Resubmit urb so we continue receiving */ 295 /* Resubmit urb so we continue receiving */
301 err = usb_submit_urb(urb, GFP_ATOMIC); 296 err = usb_submit_urb(urb, GFP_ATOMIC);