aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--arch/alpha/kernel/srmcons.c3
-rw-r--r--arch/ia64/hp/sim/simserial.c3
-rw-r--r--arch/mn10300/kernel/mn10300-serial.c4
-rw-r--r--arch/parisc/kernel/pdc_cons.c2
-rw-r--r--arch/um/drivers/chan_kern.c8
-rw-r--r--arch/xtensa/platforms/iss/console.c3
-rw-r--r--drivers/char/pcmcia/synclink_cs.c2
-rw-r--r--drivers/ipack/devices/ipoctal.c5
-rw-r--r--drivers/isdn/i4l/isdn_common.c8
-rw-r--r--drivers/isdn/i4l/isdn_tty.c12
-rw-r--r--drivers/mmc/card/sdio_uart.c5
-rw-r--r--drivers/s390/char/con3215.c3
-rw-r--r--drivers/s390/char/keyboard.h4
-rw-r--r--drivers/s390/char/sclp_tty.c4
-rw-r--r--drivers/staging/dgrp/dgrp_net_ops.c2
-rw-r--r--drivers/staging/fwserial/fwserial.c2
-rw-r--r--drivers/staging/serqt_usb2/serqt_usb2.c13
-rw-r--r--drivers/tty/amiserial.c4
-rw-r--r--drivers/tty/cyclades.c24
-rw-r--r--drivers/tty/hvc/hvc_console.c2
-rw-r--r--drivers/tty/hvc/hvsi.c22
-rw-r--r--drivers/tty/isicom.c4
-rw-r--r--drivers/tty/moxa.c2
-rw-r--r--drivers/tty/mxser.c4
-rw-r--r--drivers/tty/n_gsm.c24
-rw-r--r--drivers/tty/nozomi.c2
-rw-r--r--drivers/tty/rocket.c3
-rw-r--r--drivers/tty/serial/68328serial.c2
-rw-r--r--drivers/tty/serial/ar933x_uart.c10
-rw-r--r--drivers/tty/serial/bcm63xx_uart.c7
-rw-r--r--drivers/tty/serial/bfin_sport_uart.c10
-rw-r--r--drivers/tty/serial/cpm_uart/cpm_uart_core.c2
-rw-r--r--drivers/tty/serial/crisv10.c10
-rw-r--r--drivers/tty/serial/efm32-uart.c15
-rw-r--r--drivers/tty/serial/icom.c7
-rw-r--r--drivers/tty/serial/imx.c4
-rw-r--r--drivers/tty/serial/jsm/jsm_tty.c8
-rw-r--r--drivers/tty/serial/kgdb_nmi.c2
-rw-r--r--drivers/tty/serial/lantiq.c7
-rw-r--r--drivers/tty/serial/lpc32xx_hs.c12
-rw-r--r--drivers/tty/serial/m32r_sio.c7
-rw-r--r--drivers/tty/serial/mpc52xx_uart.c7
-rw-r--r--drivers/tty/serial/mpsc.c4
-rw-r--r--drivers/tty/serial/msm_serial.c12
-rw-r--r--drivers/tty/serial/msm_serial_hs.c12
-rw-r--r--drivers/tty/serial/mux.c5
-rw-r--r--drivers/tty/serial/nwpserial.c5
-rw-r--r--drivers/tty/serial/pmac_zilog.c8
-rw-r--r--drivers/tty/serial/sc26xx.c10
-rw-r--r--drivers/tty/serial/serial_core.c6
-rw-r--r--drivers/tty/serial/sh-sci.c34
-rw-r--r--drivers/tty/serial/sn_console.c6
-rw-r--r--drivers/tty/serial/sunhv.c4
-rw-r--r--drivers/tty/serial/sunsab.c16
-rw-r--r--drivers/tty/serial/sunsu.c7
-rw-r--r--drivers/tty/serial/sunzilog.c17
-rw-r--r--drivers/tty/serial/timbuart.c4
-rw-r--r--drivers/tty/serial/uartlite.c8
-rw-r--r--drivers/tty/serial/ucc_uart.c4
-rw-r--r--drivers/tty/serial/vt8500_serial.c7
-rw-r--r--drivers/tty/synclink.c4
-rw-r--r--drivers/tty/synclink_gt.c8
-rw-r--r--drivers/tty/synclinkmp.c42
-rw-r--r--drivers/tty/vt/keyboard.c6
-rw-r--r--drivers/tty/vt/vt.c2
-rw-r--r--drivers/usb/serial/ark3116.c2
-rw-r--r--drivers/usb/serial/belkin_sa.c2
-rw-r--r--drivers/usb/serial/digi_acceleport.c2
-rw-r--r--drivers/usb/serial/f81232.c5
-rw-r--r--drivers/usb/serial/ftdi_sio.c11
-rw-r--r--drivers/usb/serial/generic.c2
-rw-r--r--drivers/usb/serial/keyspan.c21
-rw-r--r--drivers/usb/serial/pl2303.c5
-rw-r--r--drivers/usb/serial/spcp8x5.c2
-rw-r--r--drivers/usb/serial/ssu100.c10
-rw-r--r--include/linux/tty_flip.h6
76 files changed, 297 insertions, 286 deletions
diff --git a/arch/alpha/kernel/srmcons.c b/arch/alpha/kernel/srmcons.c
index 59b7bbad8394..21b57a66e809 100644
--- a/arch/alpha/kernel/srmcons.c
+++ b/arch/alpha/kernel/srmcons.c
@@ -46,13 +46,14 @@ typedef union _srmcons_result {
46static int 46static int
47srmcons_do_receive_chars(struct tty_struct *tty) 47srmcons_do_receive_chars(struct tty_struct *tty)
48{ 48{
49 struct tty_port *port = tty->port;
49 srmcons_result result; 50 srmcons_result result;
50 int count = 0, loops = 0; 51 int count = 0, loops = 0;
51 52
52 do { 53 do {
53 result.as_long = callback_getc(0); 54 result.as_long = callback_getc(0);
54 if (result.bits.status < 2) { 55 if (result.bits.status < 2) {
55 tty_insert_flip_char(tty, (char)result.bits.c, 0); 56 tty_insert_flip_char(port, (char)result.bits.c, 0);
56 count++; 57 count++;
57 } 58 }
58 } while((result.bits.status & 1) && (++loops < 10)); 59 } while((result.bits.status & 1) && (++loops < 10));
diff --git a/arch/ia64/hp/sim/simserial.c b/arch/ia64/hp/sim/simserial.c
index fc3924d18c1f..f8ae5d8eb106 100644
--- a/arch/ia64/hp/sim/simserial.c
+++ b/arch/ia64/hp/sim/simserial.c
@@ -55,6 +55,7 @@ static struct console *console;
55 55
56static void receive_chars(struct tty_struct *tty) 56static void receive_chars(struct tty_struct *tty)
57{ 57{
58 struct tty_port *port = tty->port;
58 unsigned char ch; 59 unsigned char ch;
59 static unsigned char seen_esc = 0; 60 static unsigned char seen_esc = 0;
60 61
@@ -81,7 +82,7 @@ static void receive_chars(struct tty_struct *tty)
81 } 82 }
82 seen_esc = 0; 83 seen_esc = 0;
83 84
84 if (tty_insert_flip_char(tty, ch, TTY_NORMAL) == 0) 85 if (tty_insert_flip_char(port, ch, TTY_NORMAL) == 0)
85 break; 86 break;
86 } 87 }
87 tty_flip_buffer_push(tty); 88 tty_flip_buffer_push(tty);
diff --git a/arch/mn10300/kernel/mn10300-serial.c b/arch/mn10300/kernel/mn10300-serial.c
index 9b2232a78ff9..54ef40ceaaed 100644
--- a/arch/mn10300/kernel/mn10300-serial.c
+++ b/arch/mn10300/kernel/mn10300-serial.c
@@ -667,14 +667,14 @@ insert:
667 else 667 else
668 flag = TTY_NORMAL; 668 flag = TTY_NORMAL;
669 669
670 tty_insert_flip_char(tty, ch, flag); 670 tty_insert_flip_char(port, ch, flag);
671 } 671 }
672 672
673 /* overrun is special, since it's reported immediately, and doesn't 673 /* overrun is special, since it's reported immediately, and doesn't
674 * affect the current character 674 * affect the current character
675 */ 675 */
676 if (overrun) 676 if (overrun)
677 tty_insert_flip_char(tty, 0, TTY_OVERRUN); 677 tty_insert_flip_char(port, 0, TTY_OVERRUN);
678 678
679 count--; 679 count--;
680 if (count <= 0) { 680 if (count <= 0) {
diff --git a/arch/parisc/kernel/pdc_cons.c b/arch/parisc/kernel/pdc_cons.c
index efc5e7d30530..4d92a379eb21 100644
--- a/arch/parisc/kernel/pdc_cons.c
+++ b/arch/parisc/kernel/pdc_cons.c
@@ -147,7 +147,7 @@ static void pdc_console_poll(unsigned long unused)
147 data = pdc_console_poll_key(NULL); 147 data = pdc_console_poll_key(NULL);
148 if (data == -1) 148 if (data == -1)
149 break; 149 break;
150 tty_insert_flip_char(tty, data & 0xFF, TTY_NORMAL); 150 tty_insert_flip_char(&tty_port, data & 0xFF, TTY_NORMAL);
151 count ++; 151 count ++;
152 } 152 }
153 153
diff --git a/arch/um/drivers/chan_kern.c b/arch/um/drivers/chan_kern.c
index 4ff2503a1bb8..795bd8102205 100644
--- a/arch/um/drivers/chan_kern.c
+++ b/arch/um/drivers/chan_kern.c
@@ -81,12 +81,6 @@ static const struct chan_ops not_configged_ops = {
81}; 81};
82#endif /* CONFIG_NOCONFIG_CHAN */ 82#endif /* CONFIG_NOCONFIG_CHAN */
83 83
84static void tty_receive_char(struct tty_struct *tty, char ch)
85{
86 if (tty)
87 tty_insert_flip_char(tty, ch, TTY_NORMAL);
88}
89
90static int open_one_chan(struct chan *chan) 84static int open_one_chan(struct chan *chan)
91{ 85{
92 int fd, err; 86 int fd, err;
@@ -569,7 +563,7 @@ void chan_interrupt(struct line *line, struct tty_struct *tty, int irq)
569 } 563 }
570 err = chan->ops->read(chan->fd, &c, chan->data); 564 err = chan->ops->read(chan->fd, &c, chan->data);
571 if (err > 0) 565 if (err > 0)
572 tty_receive_char(tty, c); 566 tty_insert_flip_char(port, c, TTY_NORMAL);
573 } while (err > 0); 567 } while (err > 0);
574 568
575 if (err == 0) 569 if (err == 0)
diff --git a/arch/xtensa/platforms/iss/console.c b/arch/xtensa/platforms/iss/console.c
index 8207a119eee9..62447d63890c 100644
--- a/arch/xtensa/platforms/iss/console.c
+++ b/arch/xtensa/platforms/iss/console.c
@@ -98,6 +98,7 @@ static int rs_write(struct tty_struct * tty,
98static void rs_poll(unsigned long priv) 98static void rs_poll(unsigned long priv)
99{ 99{
100 struct tty_struct* tty = (struct tty_struct*) priv; 100 struct tty_struct* tty = (struct tty_struct*) priv;
101 struct tty_port *port = tty->port;
101 102
102 struct timeval tv = { .tv_sec = 0, .tv_usec = 0 }; 103 struct timeval tv = { .tv_sec = 0, .tv_usec = 0 };
103 int i = 0; 104 int i = 0;
@@ -107,7 +108,7 @@ static void rs_poll(unsigned long priv)
107 108
108 while (__simc(SYS_select_one, 0, XTISS_SELECT_ONE_READ, (int)&tv,0,0)){ 109 while (__simc(SYS_select_one, 0, XTISS_SELECT_ONE_READ, (int)&tv,0,0)){
109 __simc (SYS_read, 0, (unsigned long)&c, 1, 0, 0); 110 __simc (SYS_read, 0, (unsigned long)&c, 1, 0, 0);
110 tty_insert_flip_char(tty, c, TTY_NORMAL); 111 tty_insert_flip_char(port, c, TTY_NORMAL);
111 i++; 112 i++;
112 } 113 }
113 114
diff --git a/drivers/char/pcmcia/synclink_cs.c b/drivers/char/pcmcia/synclink_cs.c
index 0b1de715f097..9bdfe27b2413 100644
--- a/drivers/char/pcmcia/synclink_cs.c
+++ b/drivers/char/pcmcia/synclink_cs.c
@@ -945,7 +945,7 @@ static void rx_ready_async(MGSLPC_INFO *info, int tcd, struct tty_struct *tty)
945 else if (status & BIT6) 945 else if (status & BIT6)
946 flag = TTY_FRAME; 946 flag = TTY_FRAME;
947 } 947 }
948 work += tty_insert_flip_char(tty, data, flag); 948 work += tty_insert_flip_char(port, data, flag);
949 } 949 }
950 issue_command(info, CHA, CMD_RXFIFO); 950 issue_command(info, CHA, CMD_RXFIFO);
951 951
diff --git a/drivers/ipack/devices/ipoctal.c b/drivers/ipack/devices/ipoctal.c
index 576d53d92677..8e0ed663ba9b 100644
--- a/drivers/ipack/devices/ipoctal.c
+++ b/drivers/ipack/devices/ipoctal.c
@@ -136,6 +136,7 @@ static int ipoctal_get_icount(struct tty_struct *tty,
136static void ipoctal_irq_rx(struct ipoctal_channel *channel, 136static void ipoctal_irq_rx(struct ipoctal_channel *channel,
137 struct tty_struct *tty, u8 sr) 137 struct tty_struct *tty, u8 sr)
138{ 138{
139 struct tty_port *port = &channel->tty_port;
139 unsigned char value; 140 unsigned char value;
140 unsigned char flag = TTY_NORMAL; 141 unsigned char flag = TTY_NORMAL;
141 u8 isr; 142 u8 isr;
@@ -149,7 +150,7 @@ static void ipoctal_irq_rx(struct ipoctal_channel *channel,
149 if (sr & SR_OVERRUN_ERROR) { 150 if (sr & SR_OVERRUN_ERROR) {
150 channel->stats.overrun_err++; 151 channel->stats.overrun_err++;
151 /* Overrun doesn't affect the current character*/ 152 /* Overrun doesn't affect the current character*/
152 tty_insert_flip_char(tty, 0, TTY_OVERRUN); 153 tty_insert_flip_char(port, 0, TTY_OVERRUN);
153 } 154 }
154 if (sr & SR_PARITY_ERROR) { 155 if (sr & SR_PARITY_ERROR) {
155 channel->stats.parity_err++; 156 channel->stats.parity_err++;
@@ -165,7 +166,7 @@ static void ipoctal_irq_rx(struct ipoctal_channel *channel,
165 flag = TTY_BREAK; 166 flag = TTY_BREAK;
166 } 167 }
167 } 168 }
168 tty_insert_flip_char(tty, value, flag); 169 tty_insert_flip_char(port, value, flag);
169 170
170 /* Check if there are more characters in RX FIFO 171 /* Check if there are more characters in RX FIFO
171 * If there are more, the isr register for this channel 172 * If there are more, the isr register for this channel
diff --git a/drivers/isdn/i4l/isdn_common.c b/drivers/isdn/i4l/isdn_common.c
index 7093169ee0c9..4a387ec021ad 100644
--- a/drivers/isdn/i4l/isdn_common.c
+++ b/drivers/isdn/i4l/isdn_common.c
@@ -913,7 +913,7 @@ isdn_readbchan_tty(int di, int channel, struct tty_struct *tty, int cisco_hack)
913 while ((count_pull < skb->len) && (len > 0)) { 913 while ((count_pull < skb->len) && (len > 0)) {
914 /* push every character but the last to the tty buffer directly */ 914 /* push every character but the last to the tty buffer directly */
915 if (count_put) 915 if (count_put)
916 tty_insert_flip_char(tty, last, TTY_NORMAL); 916 tty_insert_flip_char(port, last, TTY_NORMAL);
917 len--; 917 len--;
918 if (dev->drv[di]->DLEflag & DLEmask) { 918 if (dev->drv[di]->DLEflag & DLEmask) {
919 last = DLE; 919 last = DLE;
@@ -953,16 +953,16 @@ isdn_readbchan_tty(int di, int channel, struct tty_struct *tty, int cisco_hack)
953 * Now we can dequeue it. 953 * Now we can dequeue it.
954 */ 954 */
955 if (cisco_hack) 955 if (cisco_hack)
956 tty_insert_flip_char(tty, last, 0xFF); 956 tty_insert_flip_char(port, last, 0xFF);
957 else 957 else
958 tty_insert_flip_char(tty, last, TTY_NORMAL); 958 tty_insert_flip_char(port, last, TTY_NORMAL);
959#ifdef CONFIG_ISDN_AUDIO 959#ifdef CONFIG_ISDN_AUDIO
960 ISDN_AUDIO_SKB_LOCK(skb) = 0; 960 ISDN_AUDIO_SKB_LOCK(skb) = 0;
961#endif 961#endif
962 skb = skb_dequeue(&dev->drv[di]->rpqueue[channel]); 962 skb = skb_dequeue(&dev->drv[di]->rpqueue[channel]);
963 dev_kfree_skb(skb); 963 dev_kfree_skb(skb);
964 } else { 964 } else {
965 tty_insert_flip_char(tty, last, TTY_NORMAL); 965 tty_insert_flip_char(port, last, TTY_NORMAL);
966 /* Not yet emptied this buff, so it 966 /* Not yet emptied this buff, so it
967 * must stay in the queue, for further calls 967 * must stay in the queue, for further calls
968 * but we pull off the data we got until now. 968 * but we pull off the data we got until now.
diff --git a/drivers/isdn/i4l/isdn_tty.c b/drivers/isdn/i4l/isdn_tty.c
index 4f5bcee7cf32..32d65d4bc848 100644
--- a/drivers/isdn/i4l/isdn_tty.c
+++ b/drivers/isdn/i4l/isdn_tty.c
@@ -92,11 +92,11 @@ isdn_tty_try_read(modem_info *info, struct sk_buff *skb)
92 unsigned char *dp = skb->data; 92 unsigned char *dp = skb->data;
93 while (--l) { 93 while (--l) {
94 if (*dp == DLE) 94 if (*dp == DLE)
95 tty_insert_flip_char(tty, DLE, 0); 95 tty_insert_flip_char(port, DLE, 0);
96 tty_insert_flip_char(tty, *dp++, 0); 96 tty_insert_flip_char(port, *dp++, 0);
97 } 97 }
98 if (*dp == DLE) 98 if (*dp == DLE)
99 tty_insert_flip_char(tty, DLE, 0); 99 tty_insert_flip_char(port, DLE, 0);
100 last = *dp; 100 last = *dp;
101 } else { 101 } else {
102#endif 102#endif
@@ -107,9 +107,9 @@ isdn_tty_try_read(modem_info *info, struct sk_buff *skb)
107 } 107 }
108#endif 108#endif
109 if (info->emu.mdmreg[REG_CPPP] & BIT_CPPP) 109 if (info->emu.mdmreg[REG_CPPP] & BIT_CPPP)
110 tty_insert_flip_char(tty, last, 0xFF); 110 tty_insert_flip_char(port, last, 0xFF);
111 else 111 else
112 tty_insert_flip_char(tty, last, TTY_NORMAL); 112 tty_insert_flip_char(port, last, TTY_NORMAL);
113 tty_flip_buffer_push(tty); 113 tty_flip_buffer_push(tty);
114 kfree_skb(skb); 114 kfree_skb(skb);
115 115
@@ -2287,7 +2287,7 @@ isdn_tty_at_cout(char *msg, modem_info *info)
2287 if (skb) { 2287 if (skb) {
2288 *sp++ = c; 2288 *sp++ = c;
2289 } else { 2289 } else {
2290 if (tty_insert_flip_char(tty, c, TTY_NORMAL) == 0) 2290 if (tty_insert_flip_char(port, c, TTY_NORMAL) == 0)
2291 break; 2291 break;
2292 } 2292 }
2293 } 2293 }
diff --git a/drivers/mmc/card/sdio_uart.c b/drivers/mmc/card/sdio_uart.c
index bd57a11acc79..894078be0b96 100644
--- a/drivers/mmc/card/sdio_uart.c
+++ b/drivers/mmc/card/sdio_uart.c
@@ -419,7 +419,7 @@ static void sdio_uart_receive_chars(struct sdio_uart_port *port,
419 419
420 if ((*status & port->ignore_status_mask & ~UART_LSR_OE) == 0) 420 if ((*status & port->ignore_status_mask & ~UART_LSR_OE) == 0)
421 if (tty) 421 if (tty)
422 tty_insert_flip_char(tty, ch, flag); 422 tty_insert_flip_char(&port->port, ch, flag);
423 423
424 /* 424 /*
425 * Overrun is special. Since it's reported immediately, 425 * Overrun is special. Since it's reported immediately,
@@ -427,7 +427,8 @@ static void sdio_uart_receive_chars(struct sdio_uart_port *port,
427 */ 427 */
428 if (*status & ~port->ignore_status_mask & UART_LSR_OE) 428 if (*status & ~port->ignore_status_mask & UART_LSR_OE)
429 if (tty) 429 if (tty)
430 tty_insert_flip_char(tty, 0, TTY_OVERRUN); 430 tty_insert_flip_char(&port->port, 0,
431 TTY_OVERRUN);
431 432
432 *status = sdio_in(port, UART_LSR); 433 *status = sdio_in(port, UART_LSR);
433 } while ((*status & UART_LSR_DR) && (max_count-- > 0)); 434 } while ((*status & UART_LSR_DR) && (max_count-- > 0));
diff --git a/drivers/s390/char/con3215.c b/drivers/s390/char/con3215.c
index 40084501c31b..7c7294590880 100644
--- a/drivers/s390/char/con3215.c
+++ b/drivers/s390/char/con3215.c
@@ -411,7 +411,8 @@ static void raw3215_irq(struct ccw_device *cdev, unsigned long intparm,
411 break; 411 break;
412 412
413 case CTRLCHAR_CTRL: 413 case CTRLCHAR_CTRL:
414 tty_insert_flip_char(tty, cchar, TTY_NORMAL); 414 tty_insert_flip_char(&raw->port, cchar,
415 TTY_NORMAL);
415 tty_flip_buffer_push(tty); 416 tty_flip_buffer_push(tty);
416 break; 417 break;
417 418
diff --git a/drivers/s390/char/keyboard.h b/drivers/s390/char/keyboard.h
index d0ae2be58191..acab28d4f06b 100644
--- a/drivers/s390/char/keyboard.h
+++ b/drivers/s390/char/keyboard.h
@@ -46,7 +46,7 @@ kbd_put_queue(struct tty_port *port, int ch)
46 struct tty_struct *tty = tty_port_tty_get(port); 46 struct tty_struct *tty = tty_port_tty_get(port);
47 if (!tty) 47 if (!tty)
48 return; 48 return;
49 tty_insert_flip_char(tty, ch, 0); 49 tty_insert_flip_char(port, ch, 0);
50 tty_schedule_flip(tty); 50 tty_schedule_flip(tty);
51 tty_kref_put(tty); 51 tty_kref_put(tty);
52} 52}
@@ -58,7 +58,7 @@ kbd_puts_queue(struct tty_port *port, char *cp)
58 if (!tty) 58 if (!tty)
59 return; 59 return;
60 while (*cp) 60 while (*cp)
61 tty_insert_flip_char(tty, *cp++, 0); 61 tty_insert_flip_char(port, *cp++, 0);
62 tty_schedule_flip(tty); 62 tty_schedule_flip(tty);
63 tty_kref_put(tty); 63 tty_kref_put(tty);
64} 64}
diff --git a/drivers/s390/char/sclp_tty.c b/drivers/s390/char/sclp_tty.c
index 877fbc37c1e7..c03863a7d455 100644
--- a/drivers/s390/char/sclp_tty.c
+++ b/drivers/s390/char/sclp_tty.c
@@ -342,7 +342,7 @@ sclp_tty_input(unsigned char* buf, unsigned int count)
342 case CTRLCHAR_SYSRQ: 342 case CTRLCHAR_SYSRQ:
343 break; 343 break;
344 case CTRLCHAR_CTRL: 344 case CTRLCHAR_CTRL:
345 tty_insert_flip_char(tty, cchar, TTY_NORMAL); 345 tty_insert_flip_char(&sclp_port, cchar, TTY_NORMAL);
346 tty_flip_buffer_push(tty); 346 tty_flip_buffer_push(tty);
347 break; 347 break;
348 case CTRLCHAR_NONE: 348 case CTRLCHAR_NONE:
@@ -352,7 +352,7 @@ sclp_tty_input(unsigned char* buf, unsigned int count)
352 strncmp((const char *) buf + count - 2, "\252n", 2))) { 352 strncmp((const char *) buf + count - 2, "\252n", 2))) {
353 /* add the auto \n */ 353 /* add the auto \n */
354 tty_insert_flip_string(tty, buf, count); 354 tty_insert_flip_string(tty, buf, count);
355 tty_insert_flip_char(tty, '\n', TTY_NORMAL); 355 tty_insert_flip_char(&sclp_port, '\n', TTY_NORMAL);
356 } else 356 } else
357 tty_insert_flip_string(tty, buf, count - 2); 357 tty_insert_flip_string(tty, buf, count - 2);
358 tty_flip_buffer_push(tty); 358 tty_flip_buffer_push(tty);
diff --git a/drivers/staging/dgrp/dgrp_net_ops.c b/drivers/staging/dgrp/dgrp_net_ops.c
index df3ebcdf7ed8..e618a667d84c 100644
--- a/drivers/staging/dgrp/dgrp_net_ops.c
+++ b/drivers/staging/dgrp/dgrp_net_ops.c
@@ -2957,7 +2957,7 @@ check_query:
2957 !(I_IGNBRK(ch->ch_tun.un_tty))) { 2957 !(I_IGNBRK(ch->ch_tun.un_tty))) {
2958 2958
2959 tty_buffer_request_room(&ch->port, 1); 2959 tty_buffer_request_room(&ch->port, 1);
2960 tty_insert_flip_char(ch->ch_tun.un_tty, 0, TTY_BREAK); 2960 tty_insert_flip_char(&ch->port, 0, TTY_BREAK);
2961 tty_flip_buffer_push(ch->ch_tun.un_tty); 2961 tty_flip_buffer_push(ch->ch_tun.un_tty);
2962 2962
2963 } 2963 }
diff --git a/drivers/staging/fwserial/fwserial.c b/drivers/staging/fwserial/fwserial.c
index 85dbdc1eccec..a2a0c43dec1c 100644
--- a/drivers/staging/fwserial/fwserial.c
+++ b/drivers/staging/fwserial/fwserial.c
@@ -617,7 +617,7 @@ static int fwtty_rx(struct fwtty_port *port, unsigned char *data, size_t len)
617 617
618 lsr &= port->status_mask; 618 lsr &= port->status_mask;
619 if (lsr & ~port->ignore_mask & UART_LSR_OE) { 619 if (lsr & ~port->ignore_mask & UART_LSR_OE) {
620 if (!tty_insert_flip_char(tty, 0, TTY_OVERRUN)) { 620 if (!tty_insert_flip_char(&port->port, 0, TTY_OVERRUN)) {
621 err = -EIO; 621 err = -EIO;
622 goto out; 622 goto out;
623 } 623 }
diff --git a/drivers/staging/serqt_usb2/serqt_usb2.c b/drivers/staging/serqt_usb2/serqt_usb2.c
index 1b3e995d3a27..14965662d09c 100644
--- a/drivers/staging/serqt_usb2/serqt_usb2.c
+++ b/drivers/staging/serqt_usb2/serqt_usb2.c
@@ -255,12 +255,11 @@ static void ProcessModemStatus(struct quatech_port *qt_port,
255 wake_up_interruptible(&qt_port->wait); 255 wake_up_interruptible(&qt_port->wait);
256} 256}
257 257
258static void ProcessRxChar(struct tty_struct *tty, struct usb_serial_port *port, 258static void ProcessRxChar(struct usb_serial_port *port, unsigned char data)
259 unsigned char data)
260{ 259{
261 struct urb *urb = port->read_urb; 260 struct urb *urb = port->read_urb;
262 if (urb->actual_length) 261 if (urb->actual_length)
263 tty_insert_flip_char(tty, data, TTY_NORMAL); 262 tty_insert_flip_char(&port->port, data, TTY_NORMAL);
264} 263}
265 264
266static void qt_write_bulk_callback(struct urb *urb) 265static void qt_write_bulk_callback(struct urb *urb)
@@ -335,8 +334,8 @@ static void qt_status_change_check(struct tty_struct *tty,
335 case 0xff: 334 case 0xff:
336 dev_dbg(&port->dev, "No status sequence.\n"); 335 dev_dbg(&port->dev, "No status sequence.\n");
337 336
338 ProcessRxChar(tty, port, data[i]); 337 ProcessRxChar(port, data[i]);
339 ProcessRxChar(tty, port, data[i + 1]); 338 ProcessRxChar(port, data[i + 1]);
340 339
341 i += 2; 340 i += 2;
342 break; 341 break;
@@ -345,8 +344,8 @@ static void qt_status_change_check(struct tty_struct *tty,
345 continue; 344 continue;
346 } 345 }
347 346
348 if (tty && urb->actual_length) 347 if (urb->actual_length)
349 tty_insert_flip_char(tty, data[i], TTY_NORMAL); 348 tty_insert_flip_char(&port->port, data[i], TTY_NORMAL);
350 349
351 } 350 }
352 tty_flip_buffer_push(tty); 351 tty_flip_buffer_push(tty);
diff --git a/drivers/tty/amiserial.c b/drivers/tty/amiserial.c
index 9d7d00cdfecb..2e670d0c5366 100644
--- a/drivers/tty/amiserial.c
+++ b/drivers/tty/amiserial.c
@@ -328,9 +328,9 @@ static void receive_chars(struct serial_state *info)
328 oe = 1; 328 oe = 1;
329 } 329 }
330 } 330 }
331 tty_insert_flip_char(tty, ch, flag); 331 tty_insert_flip_char(&info->tport, ch, flag);
332 if (oe == 1) 332 if (oe == 1)
333 tty_insert_flip_char(tty, 0, TTY_OVERRUN); 333 tty_insert_flip_char(&info->tport, 0, TTY_OVERRUN);
334 tty_flip_buffer_push(tty); 334 tty_flip_buffer_push(tty);
335out: 335out:
336 return; 336 return;
diff --git a/drivers/tty/cyclades.c b/drivers/tty/cyclades.c
index 0b7573dbf439..d1fe9a1f8475 100644
--- a/drivers/tty/cyclades.c
+++ b/drivers/tty/cyclades.c
@@ -492,34 +492,34 @@ static void cyy_chip_rx(struct cyclades_card *cinfo, int chip,
492 if (tty_buffer_request_room(port, 1)) { 492 if (tty_buffer_request_room(port, 1)) {
493 if (data & info->read_status_mask) { 493 if (data & info->read_status_mask) {
494 if (data & CyBREAK) { 494 if (data & CyBREAK) {
495 tty_insert_flip_char(tty, 495 tty_insert_flip_char(port,
496 cyy_readb(info, CyRDSR), 496 cyy_readb(info, CyRDSR),
497 TTY_BREAK); 497 TTY_BREAK);
498 info->icount.rx++; 498 info->icount.rx++;
499 if (port->flags & ASYNC_SAK) 499 if (port->flags & ASYNC_SAK)
500 do_SAK(tty); 500 do_SAK(tty);
501 } else if (data & CyFRAME) { 501 } else if (data & CyFRAME) {
502 tty_insert_flip_char(tty, 502 tty_insert_flip_char(port,
503 cyy_readb(info, CyRDSR), 503 cyy_readb(info, CyRDSR),
504 TTY_FRAME); 504 TTY_FRAME);
505 info->icount.rx++; 505 info->icount.rx++;
506 info->idle_stats.frame_errs++; 506 info->idle_stats.frame_errs++;
507 } else if (data & CyPARITY) { 507 } else if (data & CyPARITY) {
508 /* Pieces of seven... */ 508 /* Pieces of seven... */
509 tty_insert_flip_char(tty, 509 tty_insert_flip_char(port,
510 cyy_readb(info, CyRDSR), 510 cyy_readb(info, CyRDSR),
511 TTY_PARITY); 511 TTY_PARITY);
512 info->icount.rx++; 512 info->icount.rx++;
513 info->idle_stats.parity_errs++; 513 info->idle_stats.parity_errs++;
514 } else if (data & CyOVERRUN) { 514 } else if (data & CyOVERRUN) {
515 tty_insert_flip_char(tty, 0, 515 tty_insert_flip_char(port, 0,
516 TTY_OVERRUN); 516 TTY_OVERRUN);
517 info->icount.rx++; 517 info->icount.rx++;
518 /* If the flip buffer itself is 518 /* If the flip buffer itself is
519 overflowing, we still lose 519 overflowing, we still lose
520 the next incoming character. 520 the next incoming character.
521 */ 521 */
522 tty_insert_flip_char(tty, 522 tty_insert_flip_char(port,
523 cyy_readb(info, CyRDSR), 523 cyy_readb(info, CyRDSR),
524 TTY_FRAME); 524 TTY_FRAME);
525 info->icount.rx++; 525 info->icount.rx++;
@@ -529,12 +529,12 @@ static void cyy_chip_rx(struct cyclades_card *cinfo, int chip,
529 /* } else if(data & CyTIMEOUT) { */ 529 /* } else if(data & CyTIMEOUT) { */
530 /* } else if(data & CySPECHAR) { */ 530 /* } else if(data & CySPECHAR) { */
531 } else { 531 } else {
532 tty_insert_flip_char(tty, 0, 532 tty_insert_flip_char(port, 0,
533 TTY_NORMAL); 533 TTY_NORMAL);
534 info->icount.rx++; 534 info->icount.rx++;
535 } 535 }
536 } else { 536 } else {
537 tty_insert_flip_char(tty, 0, TTY_NORMAL); 537 tty_insert_flip_char(port, 0, TTY_NORMAL);
538 info->icount.rx++; 538 info->icount.rx++;
539 } 539 }
540 } else { 540 } else {
@@ -557,7 +557,7 @@ static void cyy_chip_rx(struct cyclades_card *cinfo, int chip,
557 len = tty_buffer_request_room(port, char_count); 557 len = tty_buffer_request_room(port, char_count);
558 while (len--) { 558 while (len--) {
559 data = cyy_readb(info, CyRDSR); 559 data = cyy_readb(info, CyRDSR);
560 tty_insert_flip_char(tty, data, TTY_NORMAL); 560 tty_insert_flip_char(port, data, TTY_NORMAL);
561 info->idle_stats.recv_bytes++; 561 info->idle_stats.recv_bytes++;
562 info->icount.rx++; 562 info->icount.rx++;
563#ifdef CY_16Y_HACK 563#ifdef CY_16Y_HACK
@@ -992,7 +992,7 @@ static void cyz_handle_rx(struct cyclades_port *info, struct tty_struct *tty)
992 new_rx_get); 992 new_rx_get);
993 new_rx_get = (new_rx_get + 1) & 993 new_rx_get = (new_rx_get + 1) &
994 (rx_bufsize - 1); 994 (rx_bufsize - 1);
995 tty_insert_flip_char(tty, data, TTY_NORMAL); 995 tty_insert_flip_char(port, data, TTY_NORMAL);
996 info->idle_stats.recv_bytes++; 996 info->idle_stats.recv_bytes++;
997 info->icount.rx++; 997 info->icount.rx++;
998 } 998 }
@@ -1117,17 +1117,17 @@ static void cyz_handle_cmd(struct cyclades_card *cinfo)
1117 1117
1118 switch (cmd) { 1118 switch (cmd) {
1119 case C_CM_PR_ERROR: 1119 case C_CM_PR_ERROR:
1120 tty_insert_flip_char(tty, 0, TTY_PARITY); 1120 tty_insert_flip_char(&info->port, 0, TTY_PARITY);
1121 info->icount.rx++; 1121 info->icount.rx++;
1122 special_count++; 1122 special_count++;
1123 break; 1123 break;
1124 case C_CM_FR_ERROR: 1124 case C_CM_FR_ERROR:
1125 tty_insert_flip_char(tty, 0, TTY_FRAME); 1125 tty_insert_flip_char(&info->port, 0, TTY_FRAME);
1126 info->icount.rx++; 1126 info->icount.rx++;
1127 special_count++; 1127 special_count++;
1128 break; 1128 break;
1129 case C_CM_RXBRK: 1129 case C_CM_RXBRK:
1130 tty_insert_flip_char(tty, 0, TTY_BREAK); 1130 tty_insert_flip_char(&info->port, 0, TTY_BREAK);
1131 info->icount.rx++; 1131 info->icount.rx++;
1132 special_count++; 1132 special_count++;
1133 break; 1133 break;
diff --git a/drivers/tty/hvc/hvc_console.c b/drivers/tty/hvc/hvc_console.c
index 3d2ea92b8505..8c2fe3a0e091 100644
--- a/drivers/tty/hvc/hvc_console.c
+++ b/drivers/tty/hvc/hvc_console.c
@@ -672,7 +672,7 @@ int hvc_poll(struct hvc_struct *hp)
672 } 672 }
673 } 673 }
674#endif /* CONFIG_MAGIC_SYSRQ */ 674#endif /* CONFIG_MAGIC_SYSRQ */
675 tty_insert_flip_char(tty, buf[i], 0); 675 tty_insert_flip_char(&hp->port, buf[i], 0);
676 } 676 }
677 677
678 read_total += n; 678 read_total += n;
diff --git a/drivers/tty/hvc/hvsi.c b/drivers/tty/hvc/hvsi.c
index 68357a6e4de9..1f528b8ebf5f 100644
--- a/drivers/tty/hvc/hvsi.c
+++ b/drivers/tty/hvc/hvsi.c
@@ -329,8 +329,7 @@ static void hvsi_recv_query(struct hvsi_struct *hp, uint8_t *packet)
329 } 329 }
330} 330}
331 331
332static void hvsi_insert_chars(struct hvsi_struct *hp, struct tty_struct *tty, 332static void hvsi_insert_chars(struct hvsi_struct *hp, const char *buf, int len)
333 const char *buf, int len)
334{ 333{
335 int i; 334 int i;
336 335
@@ -346,7 +345,7 @@ static void hvsi_insert_chars(struct hvsi_struct *hp, struct tty_struct *tty,
346 continue; 345 continue;
347 } 346 }
348#endif /* CONFIG_MAGIC_SYSRQ */ 347#endif /* CONFIG_MAGIC_SYSRQ */
349 tty_insert_flip_char(tty, c, 0); 348 tty_insert_flip_char(&hp->port, c, 0);
350 } 349 }
351} 350}
352 351
@@ -359,8 +358,7 @@ static void hvsi_insert_chars(struct hvsi_struct *hp, struct tty_struct *tty,
359 * revisited. 358 * revisited.
360 */ 359 */
361#define TTY_THRESHOLD_THROTTLE 128 360#define TTY_THRESHOLD_THROTTLE 128
362static bool hvsi_recv_data(struct hvsi_struct *hp, struct tty_struct *tty, 361static bool hvsi_recv_data(struct hvsi_struct *hp, const uint8_t *packet)
363 const uint8_t *packet)
364{ 362{
365 const struct hvsi_header *header = (const struct hvsi_header *)packet; 363 const struct hvsi_header *header = (const struct hvsi_header *)packet;
366 const uint8_t *data = packet + sizeof(struct hvsi_header); 364 const uint8_t *data = packet + sizeof(struct hvsi_header);
@@ -377,7 +375,7 @@ static bool hvsi_recv_data(struct hvsi_struct *hp, struct tty_struct *tty,
377 datalen = TTY_THRESHOLD_THROTTLE; 375 datalen = TTY_THRESHOLD_THROTTLE;
378 } 376 }
379 377
380 hvsi_insert_chars(hp, tty, data, datalen); 378 hvsi_insert_chars(hp, data, datalen);
381 379
382 if (overflow > 0) { 380 if (overflow > 0) {
383 /* 381 /*
@@ -438,9 +436,7 @@ static int hvsi_load_chunk(struct hvsi_struct *hp, struct tty_struct *tty,
438 case VS_DATA_PACKET_HEADER: 436 case VS_DATA_PACKET_HEADER:
439 if (!is_open(hp)) 437 if (!is_open(hp))
440 break; 438 break;
441 if (tty == NULL) 439 flip = hvsi_recv_data(hp, packet);
442 break; /* no tty buffer to put data in */
443 flip = hvsi_recv_data(hp, tty, packet);
444 break; 440 break;
445 case VS_CONTROL_PACKET_HEADER: 441 case VS_CONTROL_PACKET_HEADER:
446 hvsi_recv_control(hp, packet, tty, handshake); 442 hvsi_recv_control(hp, packet, tty, handshake);
@@ -474,12 +470,12 @@ static int hvsi_load_chunk(struct hvsi_struct *hp, struct tty_struct *tty,
474 return 1; 470 return 1;
475} 471}
476 472
477static void hvsi_send_overflow(struct hvsi_struct *hp, struct tty_struct *tty) 473static void hvsi_send_overflow(struct hvsi_struct *hp)
478{ 474{
479 pr_debug("%s: delivering %i bytes overflow\n", __func__, 475 pr_debug("%s: delivering %i bytes overflow\n", __func__,
480 hp->n_throttle); 476 hp->n_throttle);
481 477
482 hvsi_insert_chars(hp, tty, hp->throttle_buf, hp->n_throttle); 478 hvsi_insert_chars(hp, hp->throttle_buf, hp->n_throttle);
483 hp->n_throttle = 0; 479 hp->n_throttle = 0;
484} 480}
485 481
@@ -514,7 +510,7 @@ static irqreturn_t hvsi_interrupt(int irq, void *arg)
514 if (tty && hp->n_throttle && !test_bit(TTY_THROTTLED, &tty->flags)) { 510 if (tty && hp->n_throttle && !test_bit(TTY_THROTTLED, &tty->flags)) {
515 /* we weren't hung up and we weren't throttled, so we can 511 /* we weren't hung up and we weren't throttled, so we can
516 * deliver the rest now */ 512 * deliver the rest now */
517 hvsi_send_overflow(hp, tty); 513 hvsi_send_overflow(hp);
518 tty_flip_buffer_push(tty); 514 tty_flip_buffer_push(tty);
519 } 515 }
520 spin_unlock_irqrestore(&hp->lock, flags); 516 spin_unlock_irqrestore(&hp->lock, flags);
@@ -1001,7 +997,7 @@ static void hvsi_unthrottle(struct tty_struct *tty)
1001 997
1002 spin_lock_irqsave(&hp->lock, flags); 998 spin_lock_irqsave(&hp->lock, flags);
1003 if (hp->n_throttle) { 999 if (hp->n_throttle) {
1004 hvsi_send_overflow(hp, tty); 1000 hvsi_send_overflow(hp);
1005 tty_flip_buffer_push(tty); 1001 tty_flip_buffer_push(tty);
1006 } 1002 }
1007 spin_unlock_irqrestore(&hp->lock, flags); 1003 spin_unlock_irqrestore(&hp->lock, flags);
diff --git a/drivers/tty/isicom.c b/drivers/tty/isicom.c
index e9fc15f00f48..c70144f55fc0 100644
--- a/drivers/tty/isicom.c
+++ b/drivers/tty/isicom.c
@@ -634,7 +634,7 @@ static irqreturn_t isicom_interrupt(int irq, void *dev_id)
634 break; 634 break;
635 635
636 case 1: /* Received Break !!! */ 636 case 1: /* Received Break !!! */
637 tty_insert_flip_char(tty, 0, TTY_BREAK); 637 tty_insert_flip_char(&port->port, 0, TTY_BREAK);
638 if (port->port.flags & ASYNC_SAK) 638 if (port->port.flags & ASYNC_SAK)
639 do_SAK(tty); 639 do_SAK(tty);
640 tty_flip_buffer_push(tty); 640 tty_flip_buffer_push(tty);
@@ -658,7 +658,7 @@ static irqreturn_t isicom_interrupt(int irq, void *dev_id)
658 insw(base, rp, word_count); 658 insw(base, rp, word_count);
659 byte_count -= (word_count << 1); 659 byte_count -= (word_count << 1);
660 if (count & 0x0001) { 660 if (count & 0x0001) {
661 tty_insert_flip_char(tty, inw(base) & 0xff, 661 tty_insert_flip_char(&port->port, inw(base) & 0xff,
662 TTY_NORMAL); 662 TTY_NORMAL);
663 byte_count -= 2; 663 byte_count -= 2;
664 } 664 }
diff --git a/drivers/tty/moxa.c b/drivers/tty/moxa.c
index fcaac4870d5f..f42492db31c9 100644
--- a/drivers/tty/moxa.c
+++ b/drivers/tty/moxa.c
@@ -1429,7 +1429,7 @@ static int moxa_poll_port(struct moxa_port *p, unsigned int handle,
1429 goto put; 1429 goto put;
1430 1430
1431 if (tty && (intr & IntrBreak) && !I_IGNBRK(tty)) { /* BREAK */ 1431 if (tty && (intr & IntrBreak) && !I_IGNBRK(tty)) { /* BREAK */
1432 tty_insert_flip_char(tty, 0, TTY_BREAK); 1432 tty_insert_flip_char(&p->port, 0, TTY_BREAK);
1433 tty_schedule_flip(tty); 1433 tty_schedule_flip(tty);
1434 } 1434 }
1435 1435
diff --git a/drivers/tty/mxser.c b/drivers/tty/mxser.c
index 40113868bec2..450c4507cb5b 100644
--- a/drivers/tty/mxser.c
+++ b/drivers/tty/mxser.c
@@ -2079,7 +2079,7 @@ static void mxser_receive_chars(struct tty_struct *tty,
2079 } 2079 }
2080 while (gdl--) { 2080 while (gdl--) {
2081 ch = inb(port->ioaddr + UART_RX); 2081 ch = inb(port->ioaddr + UART_RX);
2082 tty_insert_flip_char(tty, ch, 0); 2082 tty_insert_flip_char(&port->port, ch, 0);
2083 cnt++; 2083 cnt++;
2084 } 2084 }
2085 goto end_intr; 2085 goto end_intr;
@@ -2118,7 +2118,7 @@ intr_old:
2118 } else 2118 } else
2119 flag = TTY_BREAK; 2119 flag = TTY_BREAK;
2120 } 2120 }
2121 tty_insert_flip_char(tty, ch, flag); 2121 tty_insert_flip_char(&port->port, ch, flag);
2122 cnt++; 2122 cnt++;
2123 if (cnt >= recv_room) { 2123 if (cnt >= recv_room) {
2124 if (!port->ldisc_stop_rx) 2124 if (!port->ldisc_stop_rx)
diff --git a/drivers/tty/n_gsm.c b/drivers/tty/n_gsm.c
index 4572117988f8..769016504c88 100644
--- a/drivers/tty/n_gsm.c
+++ b/drivers/tty/n_gsm.c
@@ -1070,9 +1070,9 @@ static void gsm_process_modem(struct tty_struct *tty, struct gsm_dlci *dlci,
1070 if ((mlines & TIOCM_CD) == 0 && (dlci->modem_rx & TIOCM_CD)) 1070 if ((mlines & TIOCM_CD) == 0 && (dlci->modem_rx & TIOCM_CD))
1071 if (!(tty->termios.c_cflag & CLOCAL)) 1071 if (!(tty->termios.c_cflag & CLOCAL))
1072 tty_hangup(tty); 1072 tty_hangup(tty);
1073 if (brk & 0x01)
1074 tty_insert_flip_char(tty, 0, TTY_BREAK);
1075 } 1073 }
1074 if (brk & 0x01)
1075 tty_insert_flip_char(&dlci->port, 0, TTY_BREAK);
1076 dlci->modem_rx = mlines; 1076 dlci->modem_rx = mlines;
1077} 1077}
1078 1078
@@ -1140,6 +1140,7 @@ static void gsm_control_modem(struct gsm_mux *gsm, u8 *data, int clen)
1140 1140
1141static void gsm_control_rls(struct gsm_mux *gsm, u8 *data, int clen) 1141static void gsm_control_rls(struct gsm_mux *gsm, u8 *data, int clen)
1142{ 1142{
1143 struct tty_port *port;
1143 struct tty_struct *tty; 1144 struct tty_struct *tty;
1144 unsigned int addr = 0 ; 1145 unsigned int addr = 0 ;
1145 u8 bits; 1146 u8 bits;
@@ -1163,16 +1164,19 @@ static void gsm_control_rls(struct gsm_mux *gsm, u8 *data, int clen)
1163 bits = *dp; 1164 bits = *dp;
1164 if ((bits & 1) == 0) 1165 if ((bits & 1) == 0)
1165 return; 1166 return;
1166 /* See if we have an uplink tty */
1167 tty = tty_port_tty_get(&gsm->dlci[addr]->port);
1168 1167
1168 port = &gsm->dlci[addr]->port;
1169
1170 if (bits & 2)
1171 tty_insert_flip_char(port, 0, TTY_OVERRUN);
1172 if (bits & 4)
1173 tty_insert_flip_char(port, 0, TTY_PARITY);
1174 if (bits & 8)
1175 tty_insert_flip_char(port, 0, TTY_FRAME);
1176
1177 /* See if we have an uplink tty */
1178 tty = tty_port_tty_get(port);
1169 if (tty) { 1179 if (tty) {
1170 if (bits & 2)
1171 tty_insert_flip_char(tty, 0, TTY_OVERRUN);
1172 if (bits & 4)
1173 tty_insert_flip_char(tty, 0, TTY_PARITY);
1174 if (bits & 8)
1175 tty_insert_flip_char(tty, 0, TTY_FRAME);
1176 tty_flip_buffer_push(tty); 1180 tty_flip_buffer_push(tty);
1177 tty_kref_put(tty); 1181 tty_kref_put(tty);
1178 } 1182 }
diff --git a/drivers/tty/nozomi.c b/drivers/tty/nozomi.c
index a0c69ab04399..437a6366fb7b 100644
--- a/drivers/tty/nozomi.c
+++ b/drivers/tty/nozomi.c
@@ -855,7 +855,7 @@ static int receive_data(enum port_type index, struct nozomi *dc)
855 read_mem32((u32 *) buf, addr + offset, RECEIVE_BUF_MAX); 855 read_mem32((u32 *) buf, addr + offset, RECEIVE_BUF_MAX);
856 856
857 if (size == 1) { 857 if (size == 1) {
858 tty_insert_flip_char(tty, buf[0], TTY_NORMAL); 858 tty_insert_flip_char(&port->port, buf[0], TTY_NORMAL);
859 size = 0; 859 size = 0;
860 } else if (size < RECEIVE_BUF_MAX) { 860 } else if (size < RECEIVE_BUF_MAX) {
861 size -= tty_insert_flip_string(tty, (char *) buf, size); 861 size -= tty_insert_flip_string(tty, (char *) buf, size);
diff --git a/drivers/tty/rocket.c b/drivers/tty/rocket.c
index 77d7bc94afaa..5848a767001a 100644
--- a/drivers/tty/rocket.c
+++ b/drivers/tty/rocket.c
@@ -379,7 +379,8 @@ static void rp_do_receive(struct r_port *info,
379 flag = TTY_OVERRUN; 379 flag = TTY_OVERRUN;
380 else 380 else
381 flag = TTY_NORMAL; 381 flag = TTY_NORMAL;
382 tty_insert_flip_char(tty, CharNStat & 0xff, flag); 382 tty_insert_flip_char(&info->port, CharNStat & 0xff,
383 flag);
383 ToRecv--; 384 ToRecv--;
384 } 385 }
385 386
diff --git a/drivers/tty/serial/68328serial.c b/drivers/tty/serial/68328serial.c
index f99a84526f82..3719273cf0be 100644
--- a/drivers/tty/serial/68328serial.c
+++ b/drivers/tty/serial/68328serial.c
@@ -305,7 +305,7 @@ static void receive_chars(struct m68k_serial *info, struct tty_struct *tty,
305 else if (rx & URX_FRAME_ERROR) 305 else if (rx & URX_FRAME_ERROR)
306 flag = TTY_FRAME; 306 flag = TTY_FRAME;
307 307
308 tty_insert_flip_char(tty, ch, flag); 308 tty_insert_flip_char(&info->tport, ch, flag);
309#ifndef CONFIG_XCOPILOT_BUGS 309#ifndef CONFIG_XCOPILOT_BUGS
310 } while((rx = uart->urx.w) & URX_DATA_READY); 310 } while((rx = uart->urx.w) & URX_DATA_READY);
311#endif 311#endif
diff --git a/drivers/tty/serial/ar933x_uart.c b/drivers/tty/serial/ar933x_uart.c
index 505c490c0b44..6ca5dd615f9e 100644
--- a/drivers/tty/serial/ar933x_uart.c
+++ b/drivers/tty/serial/ar933x_uart.c
@@ -297,10 +297,11 @@ static void ar933x_uart_set_termios(struct uart_port *port,
297 297
298static void ar933x_uart_rx_chars(struct ar933x_uart_port *up) 298static void ar933x_uart_rx_chars(struct ar933x_uart_port *up)
299{ 299{
300 struct tty_port *port = &up->port.state->port;
300 struct tty_struct *tty; 301 struct tty_struct *tty;
301 int max_count = 256; 302 int max_count = 256;
302 303
303 tty = tty_port_tty_get(&up->port.state->port); 304 tty = tty_port_tty_get(port);
304 do { 305 do {
305 unsigned int rdata; 306 unsigned int rdata;
306 unsigned char ch; 307 unsigned char ch;
@@ -313,11 +314,6 @@ static void ar933x_uart_rx_chars(struct ar933x_uart_port *up)
313 ar933x_uart_write(up, AR933X_UART_DATA_REG, 314 ar933x_uart_write(up, AR933X_UART_DATA_REG,
314 AR933X_UART_DATA_RX_CSR); 315 AR933X_UART_DATA_RX_CSR);
315 316
316 if (!tty) {
317 /* discard the data if no tty available */
318 continue;
319 }
320
321 up->port.icount.rx++; 317 up->port.icount.rx++;
322 ch = rdata & AR933X_UART_DATA_TX_RX_MASK; 318 ch = rdata & AR933X_UART_DATA_TX_RX_MASK;
323 319
@@ -325,7 +321,7 @@ static void ar933x_uart_rx_chars(struct ar933x_uart_port *up)
325 continue; 321 continue;
326 322
327 if ((up->port.ignore_status_mask & AR933X_DUMMY_STATUS_RD) == 0) 323 if ((up->port.ignore_status_mask & AR933X_DUMMY_STATUS_RD) == 0)
328 tty_insert_flip_char(tty, ch, TTY_NORMAL); 324 tty_insert_flip_char(port, ch, TTY_NORMAL);
329 } while (max_count-- > 0); 325 } while (max_count-- > 0);
330 326
331 if (tty) { 327 if (tty) {
diff --git a/drivers/tty/serial/bcm63xx_uart.c b/drivers/tty/serial/bcm63xx_uart.c
index c76a226080f2..de30b1909728 100644
--- a/drivers/tty/serial/bcm63xx_uart.c
+++ b/drivers/tty/serial/bcm63xx_uart.c
@@ -235,6 +235,7 @@ static const char *bcm_uart_type(struct uart_port *port)
235 */ 235 */
236static void bcm_uart_do_rx(struct uart_port *port) 236static void bcm_uart_do_rx(struct uart_port *port)
237{ 237{
238 struct tty_port *port = &port->state->port;
238 struct tty_struct *tty; 239 struct tty_struct *tty;
239 unsigned int max_count; 240 unsigned int max_count;
240 241
@@ -242,7 +243,7 @@ static void bcm_uart_do_rx(struct uart_port *port)
242 * higher than fifo size anyway since we're much faster than 243 * higher than fifo size anyway since we're much faster than
243 * serial port */ 244 * serial port */
244 max_count = 32; 245 max_count = 32;
245 tty = port->state->port.tty; 246 tty = port->tty;
246 do { 247 do {
247 unsigned int iestat, c, cstat; 248 unsigned int iestat, c, cstat;
248 char flag; 249 char flag;
@@ -261,7 +262,7 @@ static void bcm_uart_do_rx(struct uart_port *port)
261 bcm_uart_writel(port, val, UART_CTL_REG); 262 bcm_uart_writel(port, val, UART_CTL_REG);
262 263
263 port->icount.overrun++; 264 port->icount.overrun++;
264 tty_insert_flip_char(tty, 0, TTY_OVERRUN); 265 tty_insert_flip_char(port, 0, TTY_OVERRUN);
265 } 266 }
266 267
267 if (!(iestat & UART_IR_STAT(UART_IR_RXNOTEMPTY))) 268 if (!(iestat & UART_IR_STAT(UART_IR_RXNOTEMPTY)))
@@ -300,7 +301,7 @@ static void bcm_uart_do_rx(struct uart_port *port)
300 301
301 302
302 if ((cstat & port->ignore_status_mask) == 0) 303 if ((cstat & port->ignore_status_mask) == 0)
303 tty_insert_flip_char(tty, c, flag); 304 tty_insert_flip_char(port, c, flag);
304 305
305 } while (--max_count); 306 } while (--max_count);
306 307
diff --git a/drivers/tty/serial/bfin_sport_uart.c b/drivers/tty/serial/bfin_sport_uart.c
index f5d117379b60..e4d3ac2e8992 100644
--- a/drivers/tty/serial/bfin_sport_uart.c
+++ b/drivers/tty/serial/bfin_sport_uart.c
@@ -149,7 +149,8 @@ static int sport_uart_setup(struct sport_uart_port *up, int size, int baud_rate)
149static irqreturn_t sport_uart_rx_irq(int irq, void *dev_id) 149static irqreturn_t sport_uart_rx_irq(int irq, void *dev_id)
150{ 150{
151 struct sport_uart_port *up = dev_id; 151 struct sport_uart_port *up = dev_id;
152 struct tty_struct *tty = up->port.state->port.tty; 152 struct tty_port *port = &up->port.state->port;
153 struct tty_struct *tty = tport->tty;
153 unsigned int ch; 154 unsigned int ch;
154 155
155 spin_lock(&up->port.lock); 156 spin_lock(&up->port.lock);
@@ -159,7 +160,7 @@ static irqreturn_t sport_uart_rx_irq(int irq, void *dev_id)
159 up->port.icount.rx++; 160 up->port.icount.rx++;
160 161
161 if (!uart_handle_sysrq_char(&up->port, ch)) 162 if (!uart_handle_sysrq_char(&up->port, ch))
162 tty_insert_flip_char(tty, ch, TTY_NORMAL); 163 tty_insert_flip_char(port, ch, TTY_NORMAL);
163 } 164 }
164 tty_flip_buffer_push(tty); 165 tty_flip_buffer_push(tty);
165 166
@@ -182,7 +183,6 @@ static irqreturn_t sport_uart_tx_irq(int irq, void *dev_id)
182static irqreturn_t sport_uart_err_irq(int irq, void *dev_id) 183static irqreturn_t sport_uart_err_irq(int irq, void *dev_id)
183{ 184{
184 struct sport_uart_port *up = dev_id; 185 struct sport_uart_port *up = dev_id;
185 struct tty_struct *tty = up->port.state->port.tty;
186 unsigned int stat = SPORT_GET_STAT(up); 186 unsigned int stat = SPORT_GET_STAT(up);
187 187
188 spin_lock(&up->port.lock); 188 spin_lock(&up->port.lock);
@@ -190,7 +190,7 @@ static irqreturn_t sport_uart_err_irq(int irq, void *dev_id)
190 /* Overflow in RX FIFO */ 190 /* Overflow in RX FIFO */
191 if (stat & ROVF) { 191 if (stat & ROVF) {
192 up->port.icount.overrun++; 192 up->port.icount.overrun++;
193 tty_insert_flip_char(tty, 0, TTY_OVERRUN); 193 tty_insert_flip_char(&up->port.state->port, 0, TTY_OVERRUN);
194 SPORT_PUT_STAT(up, ROVF); /* Clear ROVF bit */ 194 SPORT_PUT_STAT(up, ROVF); /* Clear ROVF bit */
195 } 195 }
196 /* These should not happen */ 196 /* These should not happen */
@@ -205,6 +205,8 @@ static irqreturn_t sport_uart_err_irq(int irq, void *dev_id)
205 SSYNC(); 205 SSYNC();
206 206
207 spin_unlock(&up->port.lock); 207 spin_unlock(&up->port.lock);
208 /* XXX we don't push the overrun bit to TTY? */
209
208 return IRQ_HANDLED; 210 return IRQ_HANDLED;
209} 211}
210 212
diff --git a/drivers/tty/serial/cpm_uart/cpm_uart_core.c b/drivers/tty/serial/cpm_uart/cpm_uart_core.c
index 42d5eb0125b3..108122f8f3c2 100644
--- a/drivers/tty/serial/cpm_uart/cpm_uart_core.c
+++ b/drivers/tty/serial/cpm_uart/cpm_uart_core.c
@@ -303,7 +303,7 @@ static void cpm_uart_int_rx(struct uart_port *port)
303 } 303 }
304#endif 304#endif
305 error_return: 305 error_return:
306 tty_insert_flip_char(tty, ch, flg); 306 tty_insert_flip_char(tport, ch, flg);
307 307
308 } /* End while (i--) */ 308 } /* End while (i--) */
309 309
diff --git a/drivers/tty/serial/crisv10.c b/drivers/tty/serial/crisv10.c
index 35ee6a2c6877..d12306625458 100644
--- a/drivers/tty/serial/crisv10.c
+++ b/drivers/tty/serial/crisv10.c
@@ -1760,8 +1760,7 @@ add_char_and_flag(struct e100_serial *info, unsigned char data, unsigned char fl
1760 1760
1761 info->icount.rx++; 1761 info->icount.rx++;
1762 } else { 1762 } else {
1763 struct tty_struct *tty = info->port.tty; 1763 tty_insert_flip_char(&info->port, data, flag);
1764 tty_insert_flip_char(tty, data, flag);
1765 info->icount.rx++; 1764 info->icount.rx++;
1766 } 1765 }
1767 1766
@@ -2338,8 +2337,7 @@ more_data:
2338 data_in, data_read); 2337 data_in, data_read);
2339 char flag = TTY_NORMAL; 2338 char flag = TTY_NORMAL;
2340 if (info->errorcode == ERRCODE_INSERT_BREAK) { 2339 if (info->errorcode == ERRCODE_INSERT_BREAK) {
2341 struct tty_struct *tty = info->port.tty; 2340 tty_insert_flip_char(&info->port, 0, flag);
2342 tty_insert_flip_char(tty, 0, flag);
2343 info->icount.rx++; 2341 info->icount.rx++;
2344 } 2342 }
2345 2343
@@ -2353,7 +2351,7 @@ more_data:
2353 info->icount.frame++; 2351 info->icount.frame++;
2354 flag = TTY_FRAME; 2352 flag = TTY_FRAME;
2355 } 2353 }
2356 tty_insert_flip_char(tty, data, flag); 2354 tty_insert_flip_char(&info->port, data, flag);
2357 info->errorcode = 0; 2355 info->errorcode = 0;
2358 } 2356 }
2359 info->break_detected_cnt = 0; 2357 info->break_detected_cnt = 0;
@@ -2369,7 +2367,7 @@ more_data:
2369 log_int(rdpc(), 0, 0); 2367 log_int(rdpc(), 0, 0);
2370 } 2368 }
2371 ); 2369 );
2372 tty_insert_flip_char(tty, 2370 tty_insert_flip_char(&info->port,
2373 IO_EXTRACT(R_SERIAL0_READ, data_in, data_read), 2371 IO_EXTRACT(R_SERIAL0_READ, data_in, data_read),
2374 TTY_NORMAL); 2372 TTY_NORMAL);
2375 } else { 2373 } else {
diff --git a/drivers/tty/serial/efm32-uart.c b/drivers/tty/serial/efm32-uart.c
index a8cbb2670521..bdf67b0cb8b6 100644
--- a/drivers/tty/serial/efm32-uart.c
+++ b/drivers/tty/serial/efm32-uart.c
@@ -194,8 +194,7 @@ static void efm32_uart_break_ctl(struct uart_port *port, int ctl)
194 /* not possible without fiddling with gpios */ 194 /* not possible without fiddling with gpios */
195} 195}
196 196
197static void efm32_uart_rx_chars(struct efm32_uart_port *efm_port, 197static void efm32_uart_rx_chars(struct efm32_uart_port *efm_port)
198 struct tty_struct *tty)
199{ 198{
200 struct uart_port *port = &efm_port->port; 199 struct uart_port *port = &efm_port->port;
201 200
@@ -237,8 +236,8 @@ static void efm32_uart_rx_chars(struct efm32_uart_port *efm_port,
237 rxdata & UARTn_RXDATAX_RXDATA__MASK)) 236 rxdata & UARTn_RXDATAX_RXDATA__MASK))
238 continue; 237 continue;
239 238
240 if (tty && (rxdata & port->ignore_status_mask) == 0) 239 if ((rxdata & port->ignore_status_mask) == 0)
241 tty_insert_flip_char(tty, 240 tty_insert_flip_char(&port->state->port,
242 rxdata & UARTn_RXDATAX_RXDATA__MASK, flag); 241 rxdata & UARTn_RXDATAX_RXDATA__MASK, flag);
243 } 242 }
244} 243}
@@ -249,15 +248,16 @@ static irqreturn_t efm32_uart_rxirq(int irq, void *data)
249 u32 irqflag = efm32_uart_read32(efm_port, UARTn_IF); 248 u32 irqflag = efm32_uart_read32(efm_port, UARTn_IF);
250 int handled = IRQ_NONE; 249 int handled = IRQ_NONE;
251 struct uart_port *port = &efm_port->port; 250 struct uart_port *port = &efm_port->port;
251 struct tty_port *tport = &port->state->port;
252 struct tty_struct *tty; 252 struct tty_struct *tty;
253 253
254 spin_lock(&port->lock); 254 spin_lock(&port->lock);
255 255
256 tty = tty_kref_get(port->state->port.tty); 256 tty = tty_kref_get(tport->tty);
257 257
258 if (irqflag & UARTn_IF_RXDATAV) { 258 if (irqflag & UARTn_IF_RXDATAV) {
259 efm32_uart_write32(efm_port, UARTn_IF_RXDATAV, UARTn_IFC); 259 efm32_uart_write32(efm_port, UARTn_IF_RXDATAV, UARTn_IFC);
260 efm32_uart_rx_chars(efm_port, tty); 260 efm32_uart_rx_chars(efm_port);
261 261
262 handled = IRQ_HANDLED; 262 handled = IRQ_HANDLED;
263 } 263 }
@@ -265,8 +265,7 @@ static irqreturn_t efm32_uart_rxirq(int irq, void *data)
265 if (irqflag & UARTn_IF_RXOF) { 265 if (irqflag & UARTn_IF_RXOF) {
266 efm32_uart_write32(efm_port, UARTn_IF_RXOF, UARTn_IFC); 266 efm32_uart_write32(efm_port, UARTn_IF_RXOF, UARTn_IFC);
267 port->icount.overrun++; 267 port->icount.overrun++;
268 if (tty) 268 tty_insert_flip_char(tport, 0, TTY_OVERRUN);
269 tty_insert_flip_char(tty, 0, TTY_OVERRUN);
270 269
271 handled = IRQ_HANDLED; 270 handled = IRQ_HANDLED;
272 } 271 }
diff --git a/drivers/tty/serial/icom.c b/drivers/tty/serial/icom.c
index 72b6334bcf1a..2b0b60ff7f01 100644
--- a/drivers/tty/serial/icom.c
+++ b/drivers/tty/serial/icom.c
@@ -734,7 +734,8 @@ static void xmit_interrupt(u16 port_int_reg, struct icom_port *icom_port)
734static void recv_interrupt(u16 port_int_reg, struct icom_port *icom_port) 734static void recv_interrupt(u16 port_int_reg, struct icom_port *icom_port)
735{ 735{
736 short int count, rcv_buff; 736 short int count, rcv_buff;
737 struct tty_struct *tty = icom_port->uart_port.state->port.tty; 737 struct tty_port *port = &icom_port->uart_port.state->port;
738 struct tty_struct *tty = port->tty;
738 unsigned short int status; 739 unsigned short int status;
739 struct uart_icount *icount; 740 struct uart_icount *icount;
740 unsigned long offset; 741 unsigned long offset;
@@ -812,7 +813,7 @@ static void recv_interrupt(u16 port_int_reg, struct icom_port *icom_port)
812 813
813 } 814 }
814 815
815 tty_insert_flip_char(tty, *(icom_port->recv_buf + offset + count - 1), flag); 816 tty_insert_flip_char(port, *(icom_port->recv_buf + offset + count - 1), flag);
816 817
817 if (status & SA_FLAGS_OVERRUN) 818 if (status & SA_FLAGS_OVERRUN)
818 /* 819 /*
@@ -820,7 +821,7 @@ static void recv_interrupt(u16 port_int_reg, struct icom_port *icom_port)
820 * reported immediately, and doesn't 821 * reported immediately, and doesn't
821 * affect the current character 822 * affect the current character
822 */ 823 */
823 tty_insert_flip_char(tty, 0, TTY_OVERRUN); 824 tty_insert_flip_char(port, 0, TTY_OVERRUN);
824ignore_char: 825ignore_char:
825 icom_port->statStg->rcv[rcv_buff].flags = 0; 826 icom_port->statStg->rcv[rcv_buff].flags = 0;
826 icom_port->statStg->rcv[rcv_buff].leLength = 0; 827 icom_port->statStg->rcv[rcv_buff].leLength = 0;
diff --git a/drivers/tty/serial/imx.c b/drivers/tty/serial/imx.c
index 1a2488495f69..f60c4028b6e1 100644
--- a/drivers/tty/serial/imx.c
+++ b/drivers/tty/serial/imx.c
@@ -517,6 +517,8 @@ static irqreturn_t imx_rxint(int irq, void *dev_id)
517 struct imx_port *sport = dev_id; 517 struct imx_port *sport = dev_id;
518 unsigned int rx, flg, ignored = 0; 518 unsigned int rx, flg, ignored = 0;
519 struct tty_struct *tty = sport->port.state->port.tty; 519 struct tty_struct *tty = sport->port.state->port.tty;
520 struct tty_port *port = &sport->port.state->port;
521 struct tty_struct *tty = port->tty;
520 unsigned long flags, temp; 522 unsigned long flags, temp;
521 523
522 spin_lock_irqsave(&sport->port.lock, flags); 524 spin_lock_irqsave(&sport->port.lock, flags);
@@ -569,7 +571,7 @@ static irqreturn_t imx_rxint(int irq, void *dev_id)
569#endif 571#endif
570 } 572 }
571 573
572 tty_insert_flip_char(tty, rx, flg); 574 tty_insert_flip_char(port, rx, flg);
573 } 575 }
574 576
575out: 577out:
diff --git a/drivers/tty/serial/jsm/jsm_tty.c b/drivers/tty/serial/jsm/jsm_tty.c
index 3969e54744cc..ac1d36cb2032 100644
--- a/drivers/tty/serial/jsm/jsm_tty.c
+++ b/drivers/tty/serial/jsm/jsm_tty.c
@@ -631,13 +631,13 @@ void jsm_input(struct jsm_channel *ch)
631 * format it likes. 631 * format it likes.
632 */ 632 */
633 if (*(ch->ch_equeue +tail +i) & UART_LSR_BI) 633 if (*(ch->ch_equeue +tail +i) & UART_LSR_BI)
634 tty_insert_flip_char(tp, *(ch->ch_rqueue +tail +i), TTY_BREAK); 634 tty_insert_flip_char(port, *(ch->ch_rqueue +tail +i), TTY_BREAK);
635 else if (*(ch->ch_equeue +tail +i) & UART_LSR_PE) 635 else if (*(ch->ch_equeue +tail +i) & UART_LSR_PE)
636 tty_insert_flip_char(tp, *(ch->ch_rqueue +tail +i), TTY_PARITY); 636 tty_insert_flip_char(port, *(ch->ch_rqueue +tail +i), TTY_PARITY);
637 else if (*(ch->ch_equeue +tail +i) & UART_LSR_FE) 637 else if (*(ch->ch_equeue +tail +i) & UART_LSR_FE)
638 tty_insert_flip_char(tp, *(ch->ch_rqueue +tail +i), TTY_FRAME); 638 tty_insert_flip_char(port, *(ch->ch_rqueue +tail +i), TTY_FRAME);
639 else 639 else
640 tty_insert_flip_char(tp, *(ch->ch_rqueue +tail +i), TTY_NORMAL); 640 tty_insert_flip_char(port, *(ch->ch_rqueue +tail +i), TTY_NORMAL);
641 } 641 }
642 } else { 642 } else {
643 tty_insert_flip_string(tp, ch->ch_rqueue + tail, s) ; 643 tty_insert_flip_string(tp, ch->ch_rqueue + tail, s) ;
diff --git a/drivers/tty/serial/kgdb_nmi.c b/drivers/tty/serial/kgdb_nmi.c
index 6ac2b797a764..ba2ef627d9c6 100644
--- a/drivers/tty/serial/kgdb_nmi.c
+++ b/drivers/tty/serial/kgdb_nmi.c
@@ -216,7 +216,7 @@ static void kgdb_nmi_tty_receiver(unsigned long data)
216 return; 216 return;
217 217
218 while (kfifo_out(&priv->fifo, &ch, 1)) 218 while (kfifo_out(&priv->fifo, &ch, 1))
219 tty_insert_flip_char(priv->port.tty, ch, TTY_NORMAL); 219 tty_insert_flip_char(&priv->port, ch, TTY_NORMAL);
220 tty_flip_buffer_push(priv->port.tty); 220 tty_flip_buffer_push(priv->port.tty);
221 221
222 tty_kref_put(tty); 222 tty_kref_put(tty);
diff --git a/drivers/tty/serial/lantiq.c b/drivers/tty/serial/lantiq.c
index 02da071fe1e7..1933fe3c98dd 100644
--- a/drivers/tty/serial/lantiq.c
+++ b/drivers/tty/serial/lantiq.c
@@ -162,7 +162,8 @@ lqasc_enable_ms(struct uart_port *port)
162static int 162static int
163lqasc_rx_chars(struct uart_port *port) 163lqasc_rx_chars(struct uart_port *port)
164{ 164{
165 struct tty_struct *tty = tty_port_tty_get(&port->state->port); 165 struct tty_port *tport = &port->state->port;
166 struct tty_struct *tty = tty_port_tty_get(tport);
166 unsigned int ch = 0, rsr = 0, fifocnt; 167 unsigned int ch = 0, rsr = 0, fifocnt;
167 168
168 if (!tty) { 169 if (!tty) {
@@ -208,7 +209,7 @@ lqasc_rx_chars(struct uart_port *port)
208 } 209 }
209 210
210 if ((rsr & port->ignore_status_mask) == 0) 211 if ((rsr & port->ignore_status_mask) == 0)
211 tty_insert_flip_char(tty, ch, flag); 212 tty_insert_flip_char(tport, ch, flag);
212 213
213 if (rsr & ASCSTATE_ROE) 214 if (rsr & ASCSTATE_ROE)
214 /* 215 /*
@@ -216,7 +217,7 @@ lqasc_rx_chars(struct uart_port *port)
216 * immediately, and doesn't affect the current 217 * immediately, and doesn't affect the current
217 * character 218 * character
218 */ 219 */
219 tty_insert_flip_char(tty, 0, TTY_OVERRUN); 220 tty_insert_flip_char(tport, 0, TTY_OVERRUN);
220 } 221 }
221 if (ch != 0) 222 if (ch != 0)
222 tty_flip_buffer_push(tty); 223 tty_flip_buffer_push(tty);
diff --git a/drivers/tty/serial/lpc32xx_hs.c b/drivers/tty/serial/lpc32xx_hs.c
index 0e86bff3fe2a..5cd180564c03 100644
--- a/drivers/tty/serial/lpc32xx_hs.c
+++ b/drivers/tty/serial/lpc32xx_hs.c
@@ -257,8 +257,9 @@ static void __serial_uart_flush(struct uart_port *port)
257 257
258static void __serial_lpc32xx_rx(struct uart_port *port) 258static void __serial_lpc32xx_rx(struct uart_port *port)
259{ 259{
260 struct tty_port *tport = &port->state->port;
260 unsigned int tmp, flag; 261 unsigned int tmp, flag;
261 struct tty_struct *tty = tty_port_tty_get(&port->state->port); 262 struct tty_struct *tty = tty_port_tty_get(tport);
262 263
263 if (!tty) { 264 if (!tty) {
264 /* Discard data: no tty available */ 265 /* Discard data: no tty available */
@@ -281,10 +282,10 @@ static void __serial_lpc32xx_rx(struct uart_port *port)
281 LPC32XX_HSUART_IIR(port->membase)); 282 LPC32XX_HSUART_IIR(port->membase));
282 port->icount.frame++; 283 port->icount.frame++;
283 flag = TTY_FRAME; 284 flag = TTY_FRAME;
284 tty_insert_flip_char(tty, 0, TTY_FRAME); 285 tty_insert_flip_char(tport, 0, TTY_FRAME);
285 } 286 }
286 287
287 tty_insert_flip_char(tty, (tmp & 0xFF), flag); 288 tty_insert_flip_char(tport, (tmp & 0xFF), flag);
288 289
289 tmp = readl(LPC32XX_HSUART_FIFO(port->membase)); 290 tmp = readl(LPC32XX_HSUART_FIFO(port->membase));
290 } 291 }
@@ -332,7 +333,8 @@ exit_tx:
332static irqreturn_t serial_lpc32xx_interrupt(int irq, void *dev_id) 333static irqreturn_t serial_lpc32xx_interrupt(int irq, void *dev_id)
333{ 334{
334 struct uart_port *port = dev_id; 335 struct uart_port *port = dev_id;
335 struct tty_struct *tty = tty_port_tty_get(&port->state->port); 336 struct tty_port *port = &port->state->port;
337 struct tty_struct *tty = tty_port_tty_get(tport);
336 u32 status; 338 u32 status;
337 339
338 spin_lock(&port->lock); 340 spin_lock(&port->lock);
@@ -356,8 +358,8 @@ static irqreturn_t serial_lpc32xx_interrupt(int irq, void *dev_id)
356 writel(LPC32XX_HSU_RX_OE_INT, 358 writel(LPC32XX_HSU_RX_OE_INT,
357 LPC32XX_HSUART_IIR(port->membase)); 359 LPC32XX_HSUART_IIR(port->membase));
358 port->icount.overrun++; 360 port->icount.overrun++;
361 tty_insert_flip_char(tport, 0, TTY_OVERRUN);
359 if (tty) { 362 if (tty) {
360 tty_insert_flip_char(tty, 0, TTY_OVERRUN);
361 tty_schedule_flip(tty); 363 tty_schedule_flip(tty);
362 } 364 }
363 } 365 }
diff --git a/drivers/tty/serial/m32r_sio.c b/drivers/tty/serial/m32r_sio.c
index b13949ad3408..2e9a390f2ac4 100644
--- a/drivers/tty/serial/m32r_sio.c
+++ b/drivers/tty/serial/m32r_sio.c
@@ -300,7 +300,8 @@ static void m32r_sio_enable_ms(struct uart_port *port)
300 300
301static void receive_chars(struct uart_sio_port *up, int *status) 301static void receive_chars(struct uart_sio_port *up, int *status)
302{ 302{
303 struct tty_struct *tty = up->port.state->port.tty; 303 struct tty_port *port = &up->port.state->port;
304 struct tty_struct *tty = tport->tty;
304 unsigned char ch; 305 unsigned char ch;
305 unsigned char flag; 306 unsigned char flag;
306 int max_count = 256; 307 int max_count = 256;
@@ -355,7 +356,7 @@ static void receive_chars(struct uart_sio_port *up, int *status)
355 if (uart_handle_sysrq_char(&up->port, ch)) 356 if (uart_handle_sysrq_char(&up->port, ch))
356 goto ignore_char; 357 goto ignore_char;
357 if ((*status & up->port.ignore_status_mask) == 0) 358 if ((*status & up->port.ignore_status_mask) == 0)
358 tty_insert_flip_char(tty, ch, flag); 359 tty_insert_flip_char(port, ch, flag);
359 360
360 if (*status & UART_LSR_OE) { 361 if (*status & UART_LSR_OE) {
361 /* 362 /*
@@ -363,7 +364,7 @@ static void receive_chars(struct uart_sio_port *up, int *status)
363 * immediately, and doesn't affect the current 364 * immediately, and doesn't affect the current
364 * character. 365 * character.
365 */ 366 */
366 tty_insert_flip_char(tty, 0, TTY_OVERRUN); 367 tty_insert_flip_char(port, 0, TTY_OVERRUN);
367 } 368 }
368 ignore_char: 369 ignore_char:
369 *status = serial_in(up, UART_LSR); 370 *status = serial_in(up, UART_LSR);
diff --git a/drivers/tty/serial/mpc52xx_uart.c b/drivers/tty/serial/mpc52xx_uart.c
index 7c23c4f4c58d..0145aeb7721c 100644
--- a/drivers/tty/serial/mpc52xx_uart.c
+++ b/drivers/tty/serial/mpc52xx_uart.c
@@ -941,7 +941,8 @@ static struct uart_ops mpc52xx_uart_ops = {
941static inline int 941static inline int
942mpc52xx_uart_int_rx_chars(struct uart_port *port) 942mpc52xx_uart_int_rx_chars(struct uart_port *port)
943{ 943{
944 struct tty_struct *tty = port->state->port.tty; 944 struct tty_port *tport = &port->state->port;
945 struct tty_struct *tty = tport->tty;
945 unsigned char ch, flag; 946 unsigned char ch, flag;
946 unsigned short status; 947 unsigned short status;
947 948
@@ -986,14 +987,14 @@ mpc52xx_uart_int_rx_chars(struct uart_port *port)
986 out_8(&PSC(port)->command, MPC52xx_PSC_RST_ERR_STAT); 987 out_8(&PSC(port)->command, MPC52xx_PSC_RST_ERR_STAT);
987 988
988 } 989 }
989 tty_insert_flip_char(tty, ch, flag); 990 tty_insert_flip_char(tport, ch, flag);
990 if (status & MPC52xx_PSC_SR_OE) { 991 if (status & MPC52xx_PSC_SR_OE) {
991 /* 992 /*
992 * Overrun is special, since it's 993 * Overrun is special, since it's
993 * reported immediately, and doesn't 994 * reported immediately, and doesn't
994 * affect the current character 995 * affect the current character
995 */ 996 */
996 tty_insert_flip_char(tty, 0, TTY_OVERRUN); 997 tty_insert_flip_char(tport, 0, TTY_OVERRUN);
997 port->icount.overrun++; 998 port->icount.overrun++;
998 } 999 }
999 } 1000 }
diff --git a/drivers/tty/serial/mpsc.c b/drivers/tty/serial/mpsc.c
index 50366863cfa3..4bcbc66c48c4 100644
--- a/drivers/tty/serial/mpsc.c
+++ b/drivers/tty/serial/mpsc.c
@@ -1040,10 +1040,10 @@ static int mpsc_rx_intr(struct mpsc_port_info *pi)
1040 | SDMA_DESC_CMDSTAT_FR 1040 | SDMA_DESC_CMDSTAT_FR
1041 | SDMA_DESC_CMDSTAT_OR))) 1041 | SDMA_DESC_CMDSTAT_OR)))
1042 && !(cmdstat & pi->port.ignore_status_mask)) { 1042 && !(cmdstat & pi->port.ignore_status_mask)) {
1043 tty_insert_flip_char(tty, *bp, flag); 1043 tty_insert_flip_char(port, *bp, flag);
1044 } else { 1044 } else {
1045 for (i=0; i<bytes_in; i++) 1045 for (i=0; i<bytes_in; i++)
1046 tty_insert_flip_char(tty, *bp++, TTY_NORMAL); 1046 tty_insert_flip_char(port, *bp++, TTY_NORMAL);
1047 1047
1048 pi->port.icount.rx += bytes_in; 1048 pi->port.icount.rx += bytes_in;
1049 } 1049 }
diff --git a/drivers/tty/serial/msm_serial.c b/drivers/tty/serial/msm_serial.c
index 95fd39be2934..e4eb81a12793 100644
--- a/drivers/tty/serial/msm_serial.c
+++ b/drivers/tty/serial/msm_serial.c
@@ -91,14 +91,15 @@ static void msm_enable_ms(struct uart_port *port)
91 91
92static void handle_rx_dm(struct uart_port *port, unsigned int misr) 92static void handle_rx_dm(struct uart_port *port, unsigned int misr)
93{ 93{
94 struct tty_struct *tty = port->state->port.tty; 94 struct tty_port *tport = &port->state->port;
95 struct tty_struct *tty = tport->tty;
95 unsigned int sr; 96 unsigned int sr;
96 int count = 0; 97 int count = 0;
97 struct msm_port *msm_port = UART_TO_MSM(port); 98 struct msm_port *msm_port = UART_TO_MSM(port);
98 99
99 if ((msm_read(port, UART_SR) & UART_SR_OVERRUN)) { 100 if ((msm_read(port, UART_SR) & UART_SR_OVERRUN)) {
100 port->icount.overrun++; 101 port->icount.overrun++;
101 tty_insert_flip_char(tty, 0, TTY_OVERRUN); 102 tty_insert_flip_char(tport, 0, TTY_OVERRUN);
102 msm_write(port, UART_CR_CMD_RESET_ERR, UART_CR); 103 msm_write(port, UART_CR_CMD_RESET_ERR, UART_CR);
103 } 104 }
104 105
@@ -146,7 +147,8 @@ static void handle_rx_dm(struct uart_port *port, unsigned int misr)
146 147
147static void handle_rx(struct uart_port *port) 148static void handle_rx(struct uart_port *port)
148{ 149{
149 struct tty_struct *tty = port->state->port.tty; 150 struct tty_port *tport = &port->state->port;
151 struct tty_struct *tty = tport->tty;
150 unsigned int sr; 152 unsigned int sr;
151 153
152 /* 154 /*
@@ -155,7 +157,7 @@ static void handle_rx(struct uart_port *port)
155 */ 157 */
156 if ((msm_read(port, UART_SR) & UART_SR_OVERRUN)) { 158 if ((msm_read(port, UART_SR) & UART_SR_OVERRUN)) {
157 port->icount.overrun++; 159 port->icount.overrun++;
158 tty_insert_flip_char(tty, 0, TTY_OVERRUN); 160 tty_insert_flip_char(tport, 0, TTY_OVERRUN);
159 msm_write(port, UART_CR_CMD_RESET_ERR, UART_CR); 161 msm_write(port, UART_CR_CMD_RESET_ERR, UART_CR);
160 } 162 }
161 163
@@ -186,7 +188,7 @@ static void handle_rx(struct uart_port *port)
186 } 188 }
187 189
188 if (!uart_handle_sysrq_char(port, c)) 190 if (!uart_handle_sysrq_char(port, c))
189 tty_insert_flip_char(tty, c, flag); 191 tty_insert_flip_char(tport, c, flag);
190 } 192 }
191 193
192 tty_flip_buffer_push(tty); 194 tty_flip_buffer_push(tty);
diff --git a/drivers/tty/serial/msm_serial_hs.c b/drivers/tty/serial/msm_serial_hs.c
index 1fa92284ade0..6aa9d470ef54 100644
--- a/drivers/tty/serial/msm_serial_hs.c
+++ b/drivers/tty/serial/msm_serial_hs.c
@@ -908,6 +908,7 @@ static void msm_hs_dmov_rx_callback(struct msm_dmov_cmd *cmd_ptr,
908 unsigned long flags; 908 unsigned long flags;
909 unsigned int flush; 909 unsigned int flush;
910 struct tty_struct *tty; 910 struct tty_struct *tty;
911 struct tty_port *port;
911 struct uart_port *uport; 912 struct uart_port *uport;
912 struct msm_hs_port *msm_uport; 913 struct msm_hs_port *msm_uport;
913 914
@@ -917,7 +918,8 @@ static void msm_hs_dmov_rx_callback(struct msm_dmov_cmd *cmd_ptr,
917 spin_lock_irqsave(&uport->lock, flags); 918 spin_lock_irqsave(&uport->lock, flags);
918 clk_enable(msm_uport->clk); 919 clk_enable(msm_uport->clk);
919 920
920 tty = uport->state->port.tty; 921 port = &uport->state->port;
922 tty = port->tty;
921 923
922 msm_hs_write(uport, UARTDM_CR_ADDR, STALE_EVENT_DISABLE); 924 msm_hs_write(uport, UARTDM_CR_ADDR, STALE_EVENT_DISABLE);
923 925
@@ -926,7 +928,7 @@ static void msm_hs_dmov_rx_callback(struct msm_dmov_cmd *cmd_ptr,
926 /* overflow is not connect to data in a FIFO */ 928 /* overflow is not connect to data in a FIFO */
927 if (unlikely((status & UARTDM_SR_OVERRUN_BMSK) && 929 if (unlikely((status & UARTDM_SR_OVERRUN_BMSK) &&
928 (uport->read_status_mask & CREAD))) { 930 (uport->read_status_mask & CREAD))) {
929 tty_insert_flip_char(tty, 0, TTY_OVERRUN); 931 tty_insert_flip_char(port, 0, TTY_OVERRUN);
930 uport->icount.buf_overrun++; 932 uport->icount.buf_overrun++;
931 error_f = 1; 933 error_f = 1;
932 } 934 }
@@ -939,7 +941,7 @@ static void msm_hs_dmov_rx_callback(struct msm_dmov_cmd *cmd_ptr,
939 uport->icount.parity++; 941 uport->icount.parity++;
940 error_f = 1; 942 error_f = 1;
941 if (uport->ignore_status_mask & IGNPAR) 943 if (uport->ignore_status_mask & IGNPAR)
942 tty_insert_flip_char(tty, 0, TTY_PARITY); 944 tty_insert_flip_char(port, 0, TTY_PARITY);
943 } 945 }
944 946
945 if (error_f) 947 if (error_f)
@@ -1344,7 +1346,6 @@ static irqreturn_t msm_hs_rx_wakeup_isr(int irq, void *dev)
1344 unsigned long flags; 1346 unsigned long flags;
1345 struct msm_hs_port *msm_uport = dev; 1347 struct msm_hs_port *msm_uport = dev;
1346 struct uart_port *uport = &msm_uport->uport; 1348 struct uart_port *uport = &msm_uport->uport;
1347 struct tty_struct *tty = NULL;
1348 1349
1349 spin_lock_irqsave(&uport->lock, flags); 1350 spin_lock_irqsave(&uport->lock, flags);
1350 if (msm_uport->clk_state == MSM_HS_CLK_OFF) { 1351 if (msm_uport->clk_state == MSM_HS_CLK_OFF) {
@@ -1361,8 +1362,7 @@ static irqreturn_t msm_hs_rx_wakeup_isr(int irq, void *dev)
1361 * optionally inject char into tty rx */ 1362 * optionally inject char into tty rx */
1362 msm_hs_request_clock_on_locked(uport); 1363 msm_hs_request_clock_on_locked(uport);
1363 if (msm_uport->rx_wakeup.inject_rx) { 1364 if (msm_uport->rx_wakeup.inject_rx) {
1364 tty = uport->state->port.tty; 1365 tty_insert_flip_char(&uport->state->port,
1365 tty_insert_flip_char(tty,
1366 msm_uport->rx_wakeup.rx_to_inject, 1366 msm_uport->rx_wakeup.rx_to_inject,
1367 TTY_NORMAL); 1367 TTY_NORMAL);
1368 queue_work(msm_hs_workqueue, &msm_uport->rx.tty_work); 1368 queue_work(msm_hs_workqueue, &msm_uport->rx.tty_work);
diff --git a/drivers/tty/serial/mux.c b/drivers/tty/serial/mux.c
index e2775b6df5a5..83b21686020e 100644
--- a/drivers/tty/serial/mux.c
+++ b/drivers/tty/serial/mux.c
@@ -242,8 +242,9 @@ static void mux_write(struct uart_port *port)
242 */ 242 */
243static void mux_read(struct uart_port *port) 243static void mux_read(struct uart_port *port)
244{ 244{
245 struct tty_port *tport = &port->state->port;
245 int data; 246 int data;
246 struct tty_struct *tty = port->state->port.tty; 247 struct tty_struct *tty = tport->tty;
247 __u32 start_count = port->icount.rx; 248 __u32 start_count = port->icount.rx;
248 249
249 while(1) { 250 while(1) {
@@ -266,7 +267,7 @@ static void mux_read(struct uart_port *port)
266 if (uart_handle_sysrq_char(port, data & 0xffu)) 267 if (uart_handle_sysrq_char(port, data & 0xffu))
267 continue; 268 continue;
268 269
269 tty_insert_flip_char(tty, data & 0xFF, TTY_NORMAL); 270 tty_insert_flip_char(tport, data & 0xFF, TTY_NORMAL);
270 } 271 }
271 272
272 if (start_count != port->icount.rx) { 273 if (start_count != port->icount.rx) {
diff --git a/drivers/tty/serial/nwpserial.c b/drivers/tty/serial/nwpserial.c
index dd4c31d1aee5..10d64a3697fb 100644
--- a/drivers/tty/serial/nwpserial.c
+++ b/drivers/tty/serial/nwpserial.c
@@ -128,7 +128,8 @@ static void nwpserial_config_port(struct uart_port *port, int flags)
128static irqreturn_t nwpserial_interrupt(int irq, void *dev_id) 128static irqreturn_t nwpserial_interrupt(int irq, void *dev_id)
129{ 129{
130 struct nwpserial_port *up = dev_id; 130 struct nwpserial_port *up = dev_id;
131 struct tty_struct *tty = up->port.state->port.tty; 131 struct tty_port *port = &up->port.state->port;
132 struct tty_struct *tty = port->tty;
132 irqreturn_t ret; 133 irqreturn_t ret;
133 unsigned int iir; 134 unsigned int iir;
134 unsigned char ch; 135 unsigned char ch;
@@ -146,7 +147,7 @@ static irqreturn_t nwpserial_interrupt(int irq, void *dev_id)
146 up->port.icount.rx++; 147 up->port.icount.rx++;
147 ch = dcr_read(up->dcr_host, UART_RX); 148 ch = dcr_read(up->dcr_host, UART_RX);
148 if (up->port.ignore_status_mask != NWPSERIAL_STATUS_RXVALID) 149 if (up->port.ignore_status_mask != NWPSERIAL_STATUS_RXVALID)
149 tty_insert_flip_char(tty, ch, TTY_NORMAL); 150 tty_insert_flip_char(port, ch, TTY_NORMAL);
150 } while (dcr_read(up->dcr_host, UART_LSR) & UART_LSR_DR); 151 } while (dcr_read(up->dcr_host, UART_LSR) & UART_LSR_DR);
151 152
152 tty_flip_buffer_push(tty); 153 tty_flip_buffer_push(tty);
diff --git a/drivers/tty/serial/pmac_zilog.c b/drivers/tty/serial/pmac_zilog.c
index 333c8d012b0e..73a3f295e7c4 100644
--- a/drivers/tty/serial/pmac_zilog.c
+++ b/drivers/tty/serial/pmac_zilog.c
@@ -229,6 +229,7 @@ static void pmz_interrupt_control(struct uart_pmac_port *uap, int enable)
229 229
230static struct tty_struct *pmz_receive_chars(struct uart_pmac_port *uap) 230static struct tty_struct *pmz_receive_chars(struct uart_pmac_port *uap)
231{ 231{
232 struct tty_port *port;
232 struct tty_struct *tty = NULL; 233 struct tty_struct *tty = NULL;
233 unsigned char ch, r1, drop, error, flag; 234 unsigned char ch, r1, drop, error, flag;
234 int loops = 0; 235 int loops = 0;
@@ -239,7 +240,8 @@ static struct tty_struct *pmz_receive_chars(struct uart_pmac_port *uap)
239 (void)read_zsdata(uap); 240 (void)read_zsdata(uap);
240 return NULL; 241 return NULL;
241 } 242 }
242 tty = uap->port.state->port.tty; 243 port = &uap->port.state->port;
244 tty = port->tty; /* TOCTOU above */
243 245
244 while (1) { 246 while (1) {
245 error = 0; 247 error = 0;
@@ -309,10 +311,10 @@ static struct tty_struct *pmz_receive_chars(struct uart_pmac_port *uap)
309 311
310 if (uap->port.ignore_status_mask == 0xff || 312 if (uap->port.ignore_status_mask == 0xff ||
311 (r1 & uap->port.ignore_status_mask) == 0) { 313 (r1 & uap->port.ignore_status_mask) == 0) {
312 tty_insert_flip_char(tty, ch, flag); 314 tty_insert_flip_char(port, ch, flag);
313 } 315 }
314 if (r1 & Rx_OVR) 316 if (r1 & Rx_OVR)
315 tty_insert_flip_char(tty, 0, TTY_OVERRUN); 317 tty_insert_flip_char(port, 0, TTY_OVERRUN);
316 next_char: 318 next_char:
317 /* We can get stuck in an infinite loop getting char 0 when the 319 /* We can get stuck in an infinite loop getting char 0 when the
318 * line is in a wrong HW state, we break that here. 320 * line is in a wrong HW state, we break that here.
diff --git a/drivers/tty/serial/sc26xx.c b/drivers/tty/serial/sc26xx.c
index aced1dd923d8..0cd0e4ac12a6 100644
--- a/drivers/tty/serial/sc26xx.c
+++ b/drivers/tty/serial/sc26xx.c
@@ -138,14 +138,18 @@ static void sc26xx_disable_irq(struct uart_port *port, int mask)
138 138
139static struct tty_struct *receive_chars(struct uart_port *port) 139static struct tty_struct *receive_chars(struct uart_port *port)
140{ 140{
141 struct tty_port *tport = NULL;
141 struct tty_struct *tty = NULL; 142 struct tty_struct *tty = NULL;
142 int limit = 10000; 143 int limit = 10000;
143 unsigned char ch; 144 unsigned char ch;
144 char flag; 145 char flag;
145 u8 status; 146 u8 status;
146 147
147 if (port->state != NULL) /* Unopened serial console */ 148 /* FIXME what is this trying to achieve? */
148 tty = port->state->port.tty; 149 if (port->state != NULL) { /* Unopened serial console */
150 tport = &port->state->port;
151 tty = tport->tty;
152 }
149 153
150 while (limit-- > 0) { 154 while (limit-- > 0) {
151 status = READ_SC_PORT(port, SR); 155 status = READ_SC_PORT(port, SR);
@@ -185,7 +189,7 @@ static struct tty_struct *receive_chars(struct uart_port *port)
185 if (status & port->ignore_status_mask) 189 if (status & port->ignore_status_mask)
186 continue; 190 continue;
187 191
188 tty_insert_flip_char(tty, ch, flag); 192 tty_insert_flip_char(tport, ch, flag);
189 } 193 }
190 return tty; 194 return tty;
191} 195}
diff --git a/drivers/tty/serial/serial_core.c b/drivers/tty/serial/serial_core.c
index ba7863bbbb4d..675343a20f24 100644
--- a/drivers/tty/serial/serial_core.c
+++ b/drivers/tty/serial/serial_core.c
@@ -2792,10 +2792,10 @@ EXPORT_SYMBOL_GPL(uart_handle_cts_change);
2792void uart_insert_char(struct uart_port *port, unsigned int status, 2792void uart_insert_char(struct uart_port *port, unsigned int status,
2793 unsigned int overrun, unsigned int ch, unsigned int flag) 2793 unsigned int overrun, unsigned int ch, unsigned int flag)
2794{ 2794{
2795 struct tty_struct *tty = port->state->port.tty; 2795 struct tty_port *tport = &port->state->port;
2796 2796
2797 if ((status & port->ignore_status_mask & ~overrun) == 0) 2797 if ((status & port->ignore_status_mask & ~overrun) == 0)
2798 if (tty_insert_flip_char(tty, ch, flag) == 0) 2798 if (tty_insert_flip_char(tport, ch, flag) == 0)
2799 ++port->icount.buf_overrun; 2799 ++port->icount.buf_overrun;
2800 2800
2801 /* 2801 /*
@@ -2803,7 +2803,7 @@ void uart_insert_char(struct uart_port *port, unsigned int status,
2803 * it doesn't affect the current character. 2803 * it doesn't affect the current character.
2804 */ 2804 */
2805 if (status & ~port->ignore_status_mask & overrun) 2805 if (status & ~port->ignore_status_mask & overrun)
2806 if (tty_insert_flip_char(tty, 0, TTY_OVERRUN) == 0) 2806 if (tty_insert_flip_char(tport, 0, TTY_OVERRUN) == 0)
2807 ++port->icount.buf_overrun; 2807 ++port->icount.buf_overrun;
2808} 2808}
2809EXPORT_SYMBOL_GPL(uart_insert_char); 2809EXPORT_SYMBOL_GPL(uart_insert_char);
diff --git a/drivers/tty/serial/sh-sci.c b/drivers/tty/serial/sh-sci.c
index cf96314770fb..ecef748f5385 100644
--- a/drivers/tty/serial/sh-sci.c
+++ b/drivers/tty/serial/sh-sci.c
@@ -620,7 +620,7 @@ static void sci_receive_chars(struct uart_port *port)
620 sci_port->break_flag) 620 sci_port->break_flag)
621 count = 0; 621 count = 0;
622 else 622 else
623 tty_insert_flip_char(tty, c, TTY_NORMAL); 623 tty_insert_flip_char(tport, c, TTY_NORMAL);
624 } else { 624 } else {
625 for (i = 0; i < count; i++) { 625 for (i = 0; i < count; i++) {
626 char c = serial_port_in(port, SCxRDR); 626 char c = serial_port_in(port, SCxRDR);
@@ -662,7 +662,7 @@ static void sci_receive_chars(struct uart_port *port)
662 } else 662 } else
663 flag = TTY_NORMAL; 663 flag = TTY_NORMAL;
664 664
665 tty_insert_flip_char(tty, c, flag); 665 tty_insert_flip_char(tport, c, flag);
666 } 666 }
667 } 667 }
668 668
@@ -721,7 +721,8 @@ static int sci_handle_errors(struct uart_port *port)
721{ 721{
722 int copied = 0; 722 int copied = 0;
723 unsigned short status = serial_port_in(port, SCxSR); 723 unsigned short status = serial_port_in(port, SCxSR);
724 struct tty_struct *tty = port->state->port.tty; 724 struct tty_port *tport = &port->state->port;
725 struct tty_struct *tty = tport->tty;
725 struct sci_port *s = to_sci_port(port); 726 struct sci_port *s = to_sci_port(port);
726 727
727 /* 728 /*
@@ -732,7 +733,7 @@ static int sci_handle_errors(struct uart_port *port)
732 port->icount.overrun++; 733 port->icount.overrun++;
733 734
734 /* overrun error */ 735 /* overrun error */
735 if (tty_insert_flip_char(tty, 0, TTY_OVERRUN)) 736 if (tty_insert_flip_char(tport, 0, TTY_OVERRUN))
736 copied++; 737 copied++;
737 738
738 dev_notice(port->dev, "overrun error"); 739 dev_notice(port->dev, "overrun error");
@@ -756,7 +757,7 @@ static int sci_handle_errors(struct uart_port *port)
756 757
757 dev_dbg(port->dev, "BREAK detected\n"); 758 dev_dbg(port->dev, "BREAK detected\n");
758 759
759 if (tty_insert_flip_char(tty, 0, TTY_BREAK)) 760 if (tty_insert_flip_char(tport, 0, TTY_BREAK))
760 copied++; 761 copied++;
761 } 762 }
762 763
@@ -764,7 +765,7 @@ static int sci_handle_errors(struct uart_port *port)
764 /* frame error */ 765 /* frame error */
765 port->icount.frame++; 766 port->icount.frame++;
766 767
767 if (tty_insert_flip_char(tty, 0, TTY_FRAME)) 768 if (tty_insert_flip_char(tport, 0, TTY_FRAME))
768 copied++; 769 copied++;
769 770
770 dev_notice(port->dev, "frame error\n"); 771 dev_notice(port->dev, "frame error\n");
@@ -775,7 +776,7 @@ static int sci_handle_errors(struct uart_port *port)
775 /* parity error */ 776 /* parity error */
776 port->icount.parity++; 777 port->icount.parity++;
777 778
778 if (tty_insert_flip_char(tty, 0, TTY_PARITY)) 779 if (tty_insert_flip_char(tport, 0, TTY_PARITY))
779 copied++; 780 copied++;
780 781
781 dev_notice(port->dev, "parity error"); 782 dev_notice(port->dev, "parity error");
@@ -789,7 +790,8 @@ static int sci_handle_errors(struct uart_port *port)
789 790
790static int sci_handle_fifo_overrun(struct uart_port *port) 791static int sci_handle_fifo_overrun(struct uart_port *port)
791{ 792{
792 struct tty_struct *tty = port->state->port.tty; 793 struct tty_port *tport = &port->state->port;
794 struct tty_struct *tty = tport->tty;
793 struct sci_port *s = to_sci_port(port); 795 struct sci_port *s = to_sci_port(port);
794 struct plat_sci_reg *reg; 796 struct plat_sci_reg *reg;
795 int copied = 0; 797 int copied = 0;
@@ -803,7 +805,7 @@ static int sci_handle_fifo_overrun(struct uart_port *port)
803 805
804 port->icount.overrun++; 806 port->icount.overrun++;
805 807
806 tty_insert_flip_char(tty, 0, TTY_OVERRUN); 808 tty_insert_flip_char(tport, 0, TTY_OVERRUN);
807 tty_flip_buffer_push(tty); 809 tty_flip_buffer_push(tty);
808 810
809 dev_notice(port->dev, "overrun error\n"); 811 dev_notice(port->dev, "overrun error\n");
@@ -817,7 +819,8 @@ static int sci_handle_breaks(struct uart_port *port)
817{ 819{
818 int copied = 0; 820 int copied = 0;
819 unsigned short status = serial_port_in(port, SCxSR); 821 unsigned short status = serial_port_in(port, SCxSR);
820 struct tty_struct *tty = port->state->port.tty; 822 struct tty_port *tport = &port->state->port;
823 struct tty_struct *tty = tport->tty;
821 struct sci_port *s = to_sci_port(port); 824 struct sci_port *s = to_sci_port(port);
822 825
823 if (uart_handle_break(port)) 826 if (uart_handle_break(port))
@@ -832,7 +835,7 @@ static int sci_handle_breaks(struct uart_port *port)
832 port->icount.brk++; 835 port->icount.brk++;
833 836
834 /* Notify of BREAK */ 837 /* Notify of BREAK */
835 if (tty_insert_flip_char(tty, 0, TTY_BREAK)) 838 if (tty_insert_flip_char(tport, 0, TTY_BREAK))
836 copied++; 839 copied++;
837 840
838 dev_dbg(port->dev, "BREAK detected\n"); 841 dev_dbg(port->dev, "BREAK detected\n");
@@ -1260,8 +1263,7 @@ static void sci_dma_tx_complete(void *arg)
1260} 1263}
1261 1264
1262/* Locking: called with port lock held */ 1265/* Locking: called with port lock held */
1263static int sci_dma_rx_push(struct sci_port *s, struct tty_struct *tty, 1266static int sci_dma_rx_push(struct sci_port *s, size_t count)
1264 size_t count)
1265{ 1267{
1266 struct uart_port *port = &s->port; 1268 struct uart_port *port = &s->port;
1267 struct tty_port *tport = &port->state->port; 1269 struct tty_port *tport = &port->state->port;
@@ -1285,7 +1287,7 @@ static int sci_dma_rx_push(struct sci_port *s, struct tty_struct *tty,
1285 return room; 1287 return room;
1286 1288
1287 for (i = 0; i < room; i++) 1289 for (i = 0; i < room; i++)
1288 tty_insert_flip_char(tty, ((u8 *)sg_virt(&s->sg_rx[active]))[i], 1290 tty_insert_flip_char(tport, ((u8 *)sg_virt(&s->sg_rx[active]))[i],
1289 TTY_NORMAL); 1291 TTY_NORMAL);
1290 1292
1291 port->icount.rx += room; 1293 port->icount.rx += room;
@@ -1305,7 +1307,7 @@ static void sci_dma_rx_complete(void *arg)
1305 1307
1306 spin_lock_irqsave(&port->lock, flags); 1308 spin_lock_irqsave(&port->lock, flags);
1307 1309
1308 count = sci_dma_rx_push(s, tty, s->buf_len_rx); 1310 count = sci_dma_rx_push(s, s->buf_len_rx);
1309 1311
1310 mod_timer(&s->rx_timer, jiffies + s->rx_timeout); 1312 mod_timer(&s->rx_timer, jiffies + s->rx_timeout);
1311 1313
@@ -1418,7 +1420,7 @@ static void work_fn_rx(struct work_struct *work)
1418 sh_desc->partial, sh_desc->cookie); 1420 sh_desc->partial, sh_desc->cookie);
1419 1421
1420 spin_lock_irqsave(&port->lock, flags); 1422 spin_lock_irqsave(&port->lock, flags);
1421 count = sci_dma_rx_push(s, tty, sh_desc->partial); 1423 count = sci_dma_rx_push(s, sh_desc->partial);
1422 spin_unlock_irqrestore(&port->lock, flags); 1424 spin_unlock_irqrestore(&port->lock, flags);
1423 1425
1424 if (count) 1426 if (count)
diff --git a/drivers/tty/serial/sn_console.c b/drivers/tty/serial/sn_console.c
index 1c6de9f58699..283232c64656 100644
--- a/drivers/tty/serial/sn_console.c
+++ b/drivers/tty/serial/sn_console.c
@@ -457,6 +457,7 @@ static int sn_debug_printf(const char *fmt, ...)
457static void 457static void
458sn_receive_chars(struct sn_cons_port *port, unsigned long flags) 458sn_receive_chars(struct sn_cons_port *port, unsigned long flags)
459{ 459{
460 struct tty_port *tport = NULL;
460 int ch; 461 int ch;
461 struct tty_struct *tty; 462 struct tty_struct *tty;
462 463
@@ -472,7 +473,8 @@ sn_receive_chars(struct sn_cons_port *port, unsigned long flags)
472 473
473 if (port->sc_port.state) { 474 if (port->sc_port.state) {
474 /* The serial_core stuffs are initialized, use them */ 475 /* The serial_core stuffs are initialized, use them */
475 tty = port->sc_port.state->port.tty; 476 tport = &port->sc_port.state->port;
477 tty = tport->tty;
476 } 478 }
477 else { 479 else {
478 /* Not registered yet - can't pass to tty layer. */ 480 /* Not registered yet - can't pass to tty layer. */
@@ -517,7 +519,7 @@ sn_receive_chars(struct sn_cons_port *port, unsigned long flags)
517 519
518 /* record the character to pass up to the tty layer */ 520 /* record the character to pass up to the tty layer */
519 if (tty) { 521 if (tty) {
520 if(tty_insert_flip_char(tty, ch, TTY_NORMAL) == 0) 522 if (tty_insert_flip_char(tport, ch, TTY_NORMAL) == 0)
521 break; 523 break;
522 } 524 }
523 port->sc_port.icount.rx++; 525 port->sc_port.icount.rx++;
diff --git a/drivers/tty/serial/sunhv.c b/drivers/tty/serial/sunhv.c
index b9bf9c53f7fd..bbb102e3c035 100644
--- a/drivers/tty/serial/sunhv.c
+++ b/drivers/tty/serial/sunhv.c
@@ -99,7 +99,7 @@ static int receive_chars_getchar(struct uart_port *port, struct tty_struct *tty)
99 uart_handle_dcd_change(port, 1); 99 uart_handle_dcd_change(port, 1);
100 } 100 }
101 101
102 if (tty == NULL) { 102 if (port->state == NULL) {
103 uart_handle_sysrq_char(port, c); 103 uart_handle_sysrq_char(port, c);
104 continue; 104 continue;
105 } 105 }
@@ -109,7 +109,7 @@ static int receive_chars_getchar(struct uart_port *port, struct tty_struct *tty)
109 if (uart_handle_sysrq_char(port, c)) 109 if (uart_handle_sysrq_char(port, c))
110 continue; 110 continue;
111 111
112 tty_insert_flip_char(tty, c, TTY_NORMAL); 112 tty_insert_flip_char(&port->state->port, c, TTY_NORMAL);
113 } 113 }
114 114
115 return saw_console_brk; 115 return saw_console_brk;
diff --git a/drivers/tty/serial/sunsab.c b/drivers/tty/serial/sunsab.c
index bd8b3b634103..4abc4d43a8e8 100644
--- a/drivers/tty/serial/sunsab.c
+++ b/drivers/tty/serial/sunsab.c
@@ -111,6 +111,7 @@ static struct tty_struct *
111receive_chars(struct uart_sunsab_port *up, 111receive_chars(struct uart_sunsab_port *up,
112 union sab82532_irq_status *stat) 112 union sab82532_irq_status *stat)
113{ 113{
114 struct tty_port *port = NULL;
114 struct tty_struct *tty = NULL; 115 struct tty_struct *tty = NULL;
115 unsigned char buf[32]; 116 unsigned char buf[32];
116 int saw_console_brk = 0; 117 int saw_console_brk = 0;
@@ -118,8 +119,10 @@ receive_chars(struct uart_sunsab_port *up,
118 int count = 0; 119 int count = 0;
119 int i; 120 int i;
120 121
121 if (up->port.state != NULL) /* Unopened serial console */ 122 if (up->port.state != NULL) { /* Unopened serial console */
122 tty = up->port.state->port.tty; 123 port = &up->port.state->port;
124 tty = port->tty;
125 }
123 126
124 /* Read number of BYTES (Character + Status) available. */ 127 /* Read number of BYTES (Character + Status) available. */
125 if (stat->sreg.isr0 & SAB82532_ISR0_RPF) { 128 if (stat->sreg.isr0 & SAB82532_ISR0_RPF) {
@@ -160,11 +163,6 @@ receive_chars(struct uart_sunsab_port *up,
160 for (i = 0; i < count; i++) { 163 for (i = 0; i < count; i++) {
161 unsigned char ch = buf[i], flag; 164 unsigned char ch = buf[i], flag;
162 165
163 if (tty == NULL) {
164 uart_handle_sysrq_char(&up->port, ch);
165 continue;
166 }
167
168 flag = TTY_NORMAL; 166 flag = TTY_NORMAL;
169 up->port.icount.rx++; 167 up->port.icount.rx++;
170 168
@@ -213,9 +211,9 @@ receive_chars(struct uart_sunsab_port *up,
213 211
214 if ((stat->sreg.isr0 & (up->port.ignore_status_mask & 0xff)) == 0 && 212 if ((stat->sreg.isr0 & (up->port.ignore_status_mask & 0xff)) == 0 &&
215 (stat->sreg.isr1 & ((up->port.ignore_status_mask >> 8) & 0xff)) == 0) 213 (stat->sreg.isr1 & ((up->port.ignore_status_mask >> 8) & 0xff)) == 0)
216 tty_insert_flip_char(tty, ch, flag); 214 tty_insert_flip_char(port, ch, flag);
217 if (stat->sreg.isr0 & SAB82532_ISR0_RFO) 215 if (stat->sreg.isr0 & SAB82532_ISR0_RFO)
218 tty_insert_flip_char(tty, 0, TTY_OVERRUN); 216 tty_insert_flip_char(port, 0, TTY_OVERRUN);
219 } 217 }
220 218
221 if (saw_console_brk) 219 if (saw_console_brk)
diff --git a/drivers/tty/serial/sunsu.c b/drivers/tty/serial/sunsu.c
index 220da3f9724f..52325968b06c 100644
--- a/drivers/tty/serial/sunsu.c
+++ b/drivers/tty/serial/sunsu.c
@@ -318,7 +318,8 @@ static void sunsu_enable_ms(struct uart_port *port)
318static struct tty_struct * 318static struct tty_struct *
319receive_chars(struct uart_sunsu_port *up, unsigned char *status) 319receive_chars(struct uart_sunsu_port *up, unsigned char *status)
320{ 320{
321 struct tty_struct *tty = up->port.state->port.tty; 321 struct tty_port *port = &up->port.state->port;
322 struct tty_struct *tty = port->tty;
322 unsigned char ch, flag; 323 unsigned char ch, flag;
323 int max_count = 256; 324 int max_count = 256;
324 int saw_console_brk = 0; 325 int saw_console_brk = 0;
@@ -376,14 +377,14 @@ receive_chars(struct uart_sunsu_port *up, unsigned char *status)
376 if (uart_handle_sysrq_char(&up->port, ch)) 377 if (uart_handle_sysrq_char(&up->port, ch))
377 goto ignore_char; 378 goto ignore_char;
378 if ((*status & up->port.ignore_status_mask) == 0) 379 if ((*status & up->port.ignore_status_mask) == 0)
379 tty_insert_flip_char(tty, ch, flag); 380 tty_insert_flip_char(port, ch, flag);
380 if (*status & UART_LSR_OE) 381 if (*status & UART_LSR_OE)
381 /* 382 /*
382 * Overrun is special, since it's reported 383 * Overrun is special, since it's reported
383 * immediately, and doesn't affect the current 384 * immediately, and doesn't affect the current
384 * character. 385 * character.
385 */ 386 */
386 tty_insert_flip_char(tty, 0, TTY_OVERRUN); 387 tty_insert_flip_char(port, 0, TTY_OVERRUN);
387 ignore_char: 388 ignore_char:
388 *status = serial_inp(up, UART_LSR); 389 *status = serial_inp(up, UART_LSR);
389 } while ((*status & UART_LSR_DR) && (max_count-- > 0)); 390 } while ((*status & UART_LSR_DR) && (max_count-- > 0));
diff --git a/drivers/tty/serial/sunzilog.c b/drivers/tty/serial/sunzilog.c
index aef4fab957c3..4a11be3849f6 100644
--- a/drivers/tty/serial/sunzilog.c
+++ b/drivers/tty/serial/sunzilog.c
@@ -327,13 +327,15 @@ static struct tty_struct *
327sunzilog_receive_chars(struct uart_sunzilog_port *up, 327sunzilog_receive_chars(struct uart_sunzilog_port *up,
328 struct zilog_channel __iomem *channel) 328 struct zilog_channel __iomem *channel)
329{ 329{
330 struct tty_port *port = NULL;
330 struct tty_struct *tty; 331 struct tty_struct *tty;
331 unsigned char ch, r1, flag; 332 unsigned char ch, r1, flag;
332 333
333 tty = NULL; 334 tty = NULL;
334 if (up->port.state != NULL && /* Unopened serial console */ 335 if (up->port.state != NULL) { /* Unopened serial console */
335 up->port.state->port.tty != NULL) /* Keyboard || mouse */ 336 port = &up->port.state->port;
336 tty = up->port.state->port.tty; 337 tty = port->tty; /* mouse => tty is NULL */
338 }
337 339
338 for (;;) { 340 for (;;) {
339 341
@@ -366,11 +368,6 @@ sunzilog_receive_chars(struct uart_sunzilog_port *up,
366 continue; 368 continue;
367 } 369 }
368 370
369 if (tty == NULL) {
370 uart_handle_sysrq_char(&up->port, ch);
371 continue;
372 }
373
374 /* A real serial line, record the character and status. */ 371 /* A real serial line, record the character and status. */
375 flag = TTY_NORMAL; 372 flag = TTY_NORMAL;
376 up->port.icount.rx++; 373 up->port.icount.rx++;
@@ -400,10 +397,10 @@ sunzilog_receive_chars(struct uart_sunzilog_port *up,
400 397
401 if (up->port.ignore_status_mask == 0xff || 398 if (up->port.ignore_status_mask == 0xff ||
402 (r1 & up->port.ignore_status_mask) == 0) { 399 (r1 & up->port.ignore_status_mask) == 0) {
403 tty_insert_flip_char(tty, ch, flag); 400 tty_insert_flip_char(port, ch, flag);
404 } 401 }
405 if (r1 & Rx_OVR) 402 if (r1 & Rx_OVR)
406 tty_insert_flip_char(tty, 0, TTY_OVERRUN); 403 tty_insert_flip_char(port, 0, TTY_OVERRUN);
407 } 404 }
408 405
409 return tty; 406 return tty;
diff --git a/drivers/tty/serial/timbuart.c b/drivers/tty/serial/timbuart.c
index 5be0d68feceb..f40c634f7528 100644
--- a/drivers/tty/serial/timbuart.c
+++ b/drivers/tty/serial/timbuart.c
@@ -91,12 +91,12 @@ static void timbuart_flush_buffer(struct uart_port *port)
91 91
92static void timbuart_rx_chars(struct uart_port *port) 92static void timbuart_rx_chars(struct uart_port *port)
93{ 93{
94 struct tty_struct *tty = port->state->port.tty; 94 struct tty_port *tport = &port->state->port;
95 95
96 while (ioread32(port->membase + TIMBUART_ISR) & RXDP) { 96 while (ioread32(port->membase + TIMBUART_ISR) & RXDP) {
97 u8 ch = ioread8(port->membase + TIMBUART_RXFIFO); 97 u8 ch = ioread8(port->membase + TIMBUART_RXFIFO);
98 port->icount.rx++; 98 port->icount.rx++;
99 tty_insert_flip_char(tty, ch, TTY_NORMAL); 99 tty_insert_flip_char(tport, ch, TTY_NORMAL);
100 } 100 }
101 101
102 spin_unlock(&port->lock); 102 spin_unlock(&port->lock);
diff --git a/drivers/tty/serial/uartlite.c b/drivers/tty/serial/uartlite.c
index 89eee43c4e2d..5caf1f0ebc82 100644
--- a/drivers/tty/serial/uartlite.c
+++ b/drivers/tty/serial/uartlite.c
@@ -66,7 +66,7 @@ static struct uart_port ulite_ports[ULITE_NR_UARTS];
66 66
67static int ulite_receive(struct uart_port *port, int stat) 67static int ulite_receive(struct uart_port *port, int stat)
68{ 68{
69 struct tty_struct *tty = port->state->port.tty; 69 struct tty_port *tport = &port->state->port;
70 unsigned char ch = 0; 70 unsigned char ch = 0;
71 char flag = TTY_NORMAL; 71 char flag = TTY_NORMAL;
72 72
@@ -103,13 +103,13 @@ static int ulite_receive(struct uart_port *port, int stat)
103 stat &= ~port->ignore_status_mask; 103 stat &= ~port->ignore_status_mask;
104 104
105 if (stat & ULITE_STATUS_RXVALID) 105 if (stat & ULITE_STATUS_RXVALID)
106 tty_insert_flip_char(tty, ch, flag); 106 tty_insert_flip_char(tport, ch, flag);
107 107
108 if (stat & ULITE_STATUS_FRAME) 108 if (stat & ULITE_STATUS_FRAME)
109 tty_insert_flip_char(tty, 0, TTY_FRAME); 109 tty_insert_flip_char(tport, 0, TTY_FRAME);
110 110
111 if (stat & ULITE_STATUS_OVERRUN) 111 if (stat & ULITE_STATUS_OVERRUN)
112 tty_insert_flip_char(tty, 0, TTY_OVERRUN); 112 tty_insert_flip_char(tport, 0, TTY_OVERRUN);
113 113
114 return 1; 114 return 1;
115} 115}
diff --git a/drivers/tty/serial/ucc_uart.c b/drivers/tty/serial/ucc_uart.c
index ed047d9ab1e2..7a2378627fa5 100644
--- a/drivers/tty/serial/ucc_uart.c
+++ b/drivers/tty/serial/ucc_uart.c
@@ -513,7 +513,7 @@ static void qe_uart_int_rx(struct uart_qe_port *qe_port)
513 continue; 513 continue;
514 514
515error_return: 515error_return:
516 tty_insert_flip_char(tty, ch, flg); 516 tty_insert_flip_char(tport, ch, flg);
517 517
518 } 518 }
519 519
@@ -561,7 +561,7 @@ handle_error:
561 561
562 /* Overrun does not affect the current character ! */ 562 /* Overrun does not affect the current character ! */
563 if (status & BD_SC_OV) 563 if (status & BD_SC_OV)
564 tty_insert_flip_char(tty, 0, TTY_OVERRUN); 564 tty_insert_flip_char(tport, 0, TTY_OVERRUN);
565#ifdef SUPPORT_SYSRQ 565#ifdef SUPPORT_SYSRQ
566 port->sysrq = 0; 566 port->sysrq = 0;
567#endif 567#endif
diff --git a/drivers/tty/serial/vt8500_serial.c b/drivers/tty/serial/vt8500_serial.c
index 8fd181436a6b..7f4112423f3d 100644
--- a/drivers/tty/serial/vt8500_serial.c
+++ b/drivers/tty/serial/vt8500_serial.c
@@ -136,7 +136,8 @@ static void vt8500_enable_ms(struct uart_port *port)
136 136
137static void handle_rx(struct uart_port *port) 137static void handle_rx(struct uart_port *port)
138{ 138{
139 struct tty_struct *tty = tty_port_tty_get(&port->state->port); 139 struct tty_port *tport = &port->state->port;
140 struct tty_struct *tty = tty_port_tty_get(tport);
140 if (!tty) { 141 if (!tty) {
141 /* Discard data: no tty available */ 142 /* Discard data: no tty available */
142 int count = (vt8500_read(port, VT8500_URFIDX) & 0x1f00) >> 8; 143 int count = (vt8500_read(port, VT8500_URFIDX) & 0x1f00) >> 8;
@@ -151,7 +152,7 @@ static void handle_rx(struct uart_port *port)
151 */ 152 */
152 if ((vt8500_read(port, VT8500_URISR) & RXOVER)) { 153 if ((vt8500_read(port, VT8500_URISR) & RXOVER)) {
153 port->icount.overrun++; 154 port->icount.overrun++;
154 tty_insert_flip_char(tty, 0, TTY_OVERRUN); 155 tty_insert_flip_char(tport, 0, TTY_OVERRUN);
155 } 156 }
156 157
157 /* and now the main RX loop */ 158 /* and now the main RX loop */
@@ -174,7 +175,7 @@ static void handle_rx(struct uart_port *port)
174 port->icount.rx++; 175 port->icount.rx++;
175 176
176 if (!uart_handle_sysrq_char(port, c)) 177 if (!uart_handle_sysrq_char(port, c))
177 tty_insert_flip_char(tty, c, flag); 178 tty_insert_flip_char(tport, c, flag);
178 } 179 }
179 180
180 tty_flip_buffer_push(tty); 181 tty_flip_buffer_push(tty);
diff --git a/drivers/tty/synclink.c b/drivers/tty/synclink.c
index d42b66195a49..33656b35db05 100644
--- a/drivers/tty/synclink.c
+++ b/drivers/tty/synclink.c
@@ -1507,13 +1507,13 @@ static void mgsl_isr_receive_data( struct mgsl_struct *info )
1507 else if (status & RXSTATUS_FRAMING_ERROR) 1507 else if (status & RXSTATUS_FRAMING_ERROR)
1508 flag = TTY_FRAME; 1508 flag = TTY_FRAME;
1509 } /* end of if (error) */ 1509 } /* end of if (error) */
1510 tty_insert_flip_char(tty, DataByte, flag); 1510 tty_insert_flip_char(&info->port, DataByte, flag);
1511 if (status & RXSTATUS_OVERRUN) { 1511 if (status & RXSTATUS_OVERRUN) {
1512 /* Overrun is special, since it's 1512 /* Overrun is special, since it's
1513 * reported immediately, and doesn't 1513 * reported immediately, and doesn't
1514 * affect the current character 1514 * affect the current character
1515 */ 1515 */
1516 work += tty_insert_flip_char(tty, 0, TTY_OVERRUN); 1516 work += tty_insert_flip_char(&info->port, 0, TTY_OVERRUN);
1517 } 1517 }
1518 } 1518 }
1519 1519
diff --git a/drivers/tty/synclink_gt.c b/drivers/tty/synclink_gt.c
index 62a0db7ead07..473d7406db83 100644
--- a/drivers/tty/synclink_gt.c
+++ b/drivers/tty/synclink_gt.c
@@ -1893,10 +1893,8 @@ static void rx_async(struct slgt_info *info)
1893 else if (status & BIT0) 1893 else if (status & BIT0)
1894 stat = TTY_FRAME; 1894 stat = TTY_FRAME;
1895 } 1895 }
1896 if (tty) { 1896 tty_insert_flip_char(&info->port, ch, stat);
1897 tty_insert_flip_char(tty, ch, stat); 1897 chars++;
1898 chars++;
1899 }
1900 } 1898 }
1901 1899
1902 if (i < count) { 1900 if (i < count) {
@@ -2182,7 +2180,7 @@ static void isr_serial(struct slgt_info *info)
2182 if (info->port.tty) { 2180 if (info->port.tty) {
2183 if (!(status & info->ignore_status_mask)) { 2181 if (!(status & info->ignore_status_mask)) {
2184 if (info->read_status_mask & MASK_BREAK) { 2182 if (info->read_status_mask & MASK_BREAK) {
2185 tty_insert_flip_char(info->port.tty, 0, TTY_BREAK); 2183 tty_insert_flip_char(&info->port, 0, TTY_BREAK);
2186 if (info->port.flags & ASYNC_SAK) 2184 if (info->port.flags & ASYNC_SAK)
2187 do_SAK(info->port.tty); 2185 do_SAK(info->port.tty);
2188 } 2186 }
diff --git a/drivers/tty/synclinkmp.c b/drivers/tty/synclinkmp.c
index 33b7314cc6c7..f5794f3d840f 100644
--- a/drivers/tty/synclinkmp.c
+++ b/drivers/tty/synclinkmp.c
@@ -2131,13 +2131,11 @@ static void isr_rxint(SLMP_INFO * info)
2131 /* process break detection if tty control 2131 /* process break detection if tty control
2132 * is not set to ignore it 2132 * is not set to ignore it
2133 */ 2133 */
2134 if ( tty ) { 2134 if (!(status & info->ignore_status_mask1)) {
2135 if (!(status & info->ignore_status_mask1)) { 2135 if (info->read_status_mask1 & BRKD) {
2136 if (info->read_status_mask1 & BRKD) { 2136 tty_insert_flip_char(&info->port, 0, TTY_BREAK);
2137 tty_insert_flip_char(tty, 0, TTY_BREAK); 2137 if (tty && (info->port.flags & ASYNC_SAK))
2138 if (info->port.flags & ASYNC_SAK) 2138 do_SAK(tty);
2139 do_SAK(tty);
2140 }
2141 } 2139 }
2142 } 2140 }
2143 } 2141 }
@@ -2202,26 +2200,22 @@ static void isr_rxrdy(SLMP_INFO * info)
2202 2200
2203 status &= info->read_status_mask2; 2201 status &= info->read_status_mask2;
2204 2202
2205 if ( tty ) { 2203 if (status & PE)
2206 if (status & PE) 2204 flag = TTY_PARITY;
2207 flag = TTY_PARITY; 2205 else if (status & FRME)
2208 else if (status & FRME) 2206 flag = TTY_FRAME;
2209 flag = TTY_FRAME; 2207 if (status & OVRN) {
2210 if (status & OVRN) { 2208 /* Overrun is special, since it's
2211 /* Overrun is special, since it's 2209 * reported immediately, and doesn't
2212 * reported immediately, and doesn't 2210 * affect the current character
2213 * affect the current character 2211 */
2214 */ 2212 over = true;
2215 over = true;
2216 }
2217 } 2213 }
2218 } /* end of if (error) */ 2214 } /* end of if (error) */
2219 2215
2220 if ( tty ) { 2216 tty_insert_flip_char(&info->port, DataByte, flag);
2221 tty_insert_flip_char(tty, DataByte, flag); 2217 if (over)
2222 if (over) 2218 tty_insert_flip_char(&info->port, 0, TTY_OVERRUN);
2223 tty_insert_flip_char(tty, 0, TTY_OVERRUN);
2224 }
2225 } 2219 }
2226 2220
2227 if ( debug_level >= DEBUG_LEVEL_ISR ) { 2221 if ( debug_level >= DEBUG_LEVEL_ISR ) {
diff --git a/drivers/tty/vt/keyboard.c b/drivers/tty/vt/keyboard.c
index 681765baef69..5aace4d47cb6 100644
--- a/drivers/tty/vt/keyboard.c
+++ b/drivers/tty/vt/keyboard.c
@@ -309,8 +309,8 @@ static void put_queue(struct vc_data *vc, int ch)
309{ 309{
310 struct tty_struct *tty = vc->port.tty; 310 struct tty_struct *tty = vc->port.tty;
311 311
312 tty_insert_flip_char(&vc->port, ch, 0);
312 if (tty) { 313 if (tty) {
313 tty_insert_flip_char(tty, ch, 0);
314 tty_schedule_flip(tty); 314 tty_schedule_flip(tty);
315 } 315 }
316} 316}
@@ -323,7 +323,7 @@ static void puts_queue(struct vc_data *vc, char *cp)
323 return; 323 return;
324 324
325 while (*cp) { 325 while (*cp) {
326 tty_insert_flip_char(tty, *cp, 0); 326 tty_insert_flip_char(&vc->port, *cp, 0);
327 cp++; 327 cp++;
328 } 328 }
329 tty_schedule_flip(tty); 329 tty_schedule_flip(tty);
@@ -586,7 +586,7 @@ static void fn_send_intr(struct vc_data *vc)
586 586
587 if (!tty) 587 if (!tty)
588 return; 588 return;
589 tty_insert_flip_char(tty, 0, TTY_BREAK); 589 tty_insert_flip_char(&vc->port, 0, TTY_BREAK);
590 tty_schedule_flip(tty); 590 tty_schedule_flip(tty);
591} 591}
592 592
diff --git a/drivers/tty/vt/vt.c b/drivers/tty/vt/vt.c
index 8fd89687d068..811f2505e9ee 100644
--- a/drivers/tty/vt/vt.c
+++ b/drivers/tty/vt/vt.c
@@ -1336,7 +1336,7 @@ static void csi_m(struct vc_data *vc)
1336static void respond_string(const char *p, struct tty_struct *tty) 1336static void respond_string(const char *p, struct tty_struct *tty)
1337{ 1337{
1338 while (*p) { 1338 while (*p) {
1339 tty_insert_flip_char(tty, *p, 0); 1339 tty_insert_flip_char(tty->port, *p, 0);
1340 p++; 1340 p++;
1341 } 1341 }
1342 tty_schedule_flip(tty); 1342 tty_schedule_flip(tty);
diff --git a/drivers/usb/serial/ark3116.c b/drivers/usb/serial/ark3116.c
index e2d653d00ea2..1614feb6a76e 100644
--- a/drivers/usb/serial/ark3116.c
+++ b/drivers/usb/serial/ark3116.c
@@ -703,7 +703,7 @@ static void ark3116_process_read_urb(struct urb *urb)
703 703
704 /* overrun is special, not associated with a char */ 704 /* overrun is special, not associated with a char */
705 if (lsr & UART_LSR_OE) 705 if (lsr & UART_LSR_OE)
706 tty_insert_flip_char(tty, 0, TTY_OVERRUN); 706 tty_insert_flip_char(&port->port, 0, TTY_OVERRUN);
707 } 707 }
708 tty_insert_flip_string_fixed_flag(&port->port, data, tty_flag, 708 tty_insert_flip_string_fixed_flag(&port->port, data, tty_flag,
709 urb->actual_length); 709 urb->actual_length);
diff --git a/drivers/usb/serial/belkin_sa.c b/drivers/usb/serial/belkin_sa.c
index a213d1be9462..7ba2c0bdcec9 100644
--- a/drivers/usb/serial/belkin_sa.c
+++ b/drivers/usb/serial/belkin_sa.c
@@ -276,7 +276,7 @@ static void belkin_sa_process_read_urb(struct urb *urb)
276 276
277 /* Overrun is special, not associated with a char. */ 277 /* Overrun is special, not associated with a char. */
278 if (status & BELKIN_SA_LSR_OE) 278 if (status & BELKIN_SA_LSR_OE)
279 tty_insert_flip_char(tty, 0, TTY_OVERRUN); 279 tty_insert_flip_char(&port->port, 0, TTY_OVERRUN);
280 } 280 }
281 281
282 tty_insert_flip_string_fixed_flag(&port->port, data, tty_flag, 282 tty_insert_flip_string_fixed_flag(&port->port, data, tty_flag,
diff --git a/drivers/usb/serial/digi_acceleport.c b/drivers/usb/serial/digi_acceleport.c
index efbc4035410c..b5fa738512ca 100644
--- a/drivers/usb/serial/digi_acceleport.c
+++ b/drivers/usb/serial/digi_acceleport.c
@@ -1441,7 +1441,7 @@ static int digi_read_inb_callback(struct urb *urb)
1441 1441
1442 /* overrun is special, not associated with a char */ 1442 /* overrun is special, not associated with a char */
1443 if (port_status & DIGI_OVERRUN_ERROR) 1443 if (port_status & DIGI_OVERRUN_ERROR)
1444 tty_insert_flip_char(tty, 0, TTY_OVERRUN); 1444 tty_insert_flip_char(&port->port, 0, TTY_OVERRUN);
1445 1445
1446 /* break takes precedence over parity, */ 1446 /* break takes precedence over parity, */
1447 /* which takes precedence over framing errors */ 1447 /* which takes precedence over framing errors */
diff --git a/drivers/usb/serial/f81232.c b/drivers/usb/serial/f81232.c
index a8c6430bf1b3..6b880c33d258 100644
--- a/drivers/usb/serial/f81232.c
+++ b/drivers/usb/serial/f81232.c
@@ -133,12 +133,13 @@ static void f81232_process_read_urb(struct urb *urb)
133 133
134 /* overrun is special, not associated with a char */ 134 /* overrun is special, not associated with a char */
135 if (line_status & UART_OVERRUN_ERROR) 135 if (line_status & UART_OVERRUN_ERROR)
136 tty_insert_flip_char(tty, 0, TTY_OVERRUN); 136 tty_insert_flip_char(&port->port, 0, TTY_OVERRUN);
137 137
138 if (port->port.console && port->sysrq) { 138 if (port->port.console && port->sysrq) {
139 for (i = 0; i < urb->actual_length; ++i) 139 for (i = 0; i < urb->actual_length; ++i)
140 if (!usb_serial_handle_sysrq_char(port, data[i])) 140 if (!usb_serial_handle_sysrq_char(port, data[i]))
141 tty_insert_flip_char(tty, data[i], tty_flag); 141 tty_insert_flip_char(&port->port, data[i],
142 tty_flag);
142 } else { 143 } else {
143 tty_insert_flip_string_fixed_flag(&port->port, data, tty_flag, 144 tty_insert_flip_string_fixed_flag(&port->port, data, tty_flag,
144 urb->actual_length); 145 urb->actual_length);
diff --git a/drivers/usb/serial/ftdi_sio.c b/drivers/usb/serial/ftdi_sio.c
index 0416d952a448..eb59ba3789ad 100644
--- a/drivers/usb/serial/ftdi_sio.c
+++ b/drivers/usb/serial/ftdi_sio.c
@@ -1958,9 +1958,8 @@ static int ftdi_prepare_write_buffer(struct usb_serial_port *port,
1958 1958
1959#define FTDI_RS_ERR_MASK (FTDI_RS_BI | FTDI_RS_PE | FTDI_RS_FE | FTDI_RS_OE) 1959#define FTDI_RS_ERR_MASK (FTDI_RS_BI | FTDI_RS_PE | FTDI_RS_FE | FTDI_RS_OE)
1960 1960
1961static int ftdi_process_packet(struct tty_struct *tty, 1961static int ftdi_process_packet(struct usb_serial_port *port,
1962 struct usb_serial_port *port, struct ftdi_private *priv, 1962 struct ftdi_private *priv, char *packet, int len)
1963 char *packet, int len)
1964{ 1963{
1965 int i; 1964 int i;
1966 char status; 1965 char status;
@@ -2010,7 +2009,7 @@ static int ftdi_process_packet(struct tty_struct *tty,
2010 /* Overrun is special, not associated with a char */ 2009 /* Overrun is special, not associated with a char */
2011 if (packet[1] & FTDI_RS_OE) { 2010 if (packet[1] & FTDI_RS_OE) {
2012 priv->icount.overrun++; 2011 priv->icount.overrun++;
2013 tty_insert_flip_char(tty, 0, TTY_OVERRUN); 2012 tty_insert_flip_char(&port->port, 0, TTY_OVERRUN);
2014 } 2013 }
2015 } 2014 }
2016 2015
@@ -2029,7 +2028,7 @@ static int ftdi_process_packet(struct tty_struct *tty,
2029 if (port->port.console && port->sysrq) { 2028 if (port->port.console && port->sysrq) {
2030 for (i = 0; i < len; i++, ch++) { 2029 for (i = 0; i < len; i++, ch++) {
2031 if (!usb_serial_handle_sysrq_char(port, *ch)) 2030 if (!usb_serial_handle_sysrq_char(port, *ch))
2032 tty_insert_flip_char(tty, *ch, flag); 2031 tty_insert_flip_char(&port->port, *ch, flag);
2033 } 2032 }
2034 } else { 2033 } else {
2035 tty_insert_flip_string_fixed_flag(&port->port, ch, flag, len); 2034 tty_insert_flip_string_fixed_flag(&port->port, ch, flag, len);
@@ -2054,7 +2053,7 @@ static void ftdi_process_read_urb(struct urb *urb)
2054 2053
2055 for (i = 0; i < urb->actual_length; i += priv->max_packet_size) { 2054 for (i = 0; i < urb->actual_length; i += priv->max_packet_size) {
2056 len = min_t(int, urb->actual_length - i, priv->max_packet_size); 2055 len = min_t(int, urb->actual_length - i, priv->max_packet_size);
2057 count += ftdi_process_packet(tty, port, priv, &data[i], len); 2056 count += ftdi_process_packet(port, priv, &data[i], len);
2058 } 2057 }
2059 2058
2060 if (count) 2059 if (count)
diff --git a/drivers/usb/serial/generic.c b/drivers/usb/serial/generic.c
index 2ea70a631996..b00110cd5689 100644
--- a/drivers/usb/serial/generic.c
+++ b/drivers/usb/serial/generic.c
@@ -332,7 +332,7 @@ void usb_serial_generic_process_read_urb(struct urb *urb)
332 else { 332 else {
333 for (i = 0; i < urb->actual_length; i++, ch++) { 333 for (i = 0; i < urb->actual_length; i++, ch++) {
334 if (!usb_serial_handle_sysrq_char(port, *ch)) 334 if (!usb_serial_handle_sysrq_char(port, *ch))
335 tty_insert_flip_char(tty, *ch, TTY_NORMAL); 335 tty_insert_flip_char(&port->port, *ch, TTY_NORMAL);
336 } 336 }
337 } 337 }
338 tty_flip_buffer_push(tty); 338 tty_flip_buffer_push(tty);
diff --git a/drivers/usb/serial/keyspan.c b/drivers/usb/serial/keyspan.c
index 97bc49f68efd..a4f5caebda43 100644
--- a/drivers/usb/serial/keyspan.c
+++ b/drivers/usb/serial/keyspan.c
@@ -315,7 +315,7 @@ static void usa26_indat_callback(struct urb *urb)
315 else 315 else
316 err = 0; 316 err = 0;
317 for (i = 1; i < urb->actual_length ; ++i) 317 for (i = 1; i < urb->actual_length ; ++i)
318 tty_insert_flip_char(tty, data[i], err); 318 tty_insert_flip_char(&port->port, data[i], err);
319 } else { 319 } else {
320 /* some bytes had errors, every byte has status */ 320 /* some bytes had errors, every byte has status */
321 dev_dbg(&port->dev, "%s - RX error!!!!\n", __func__); 321 dev_dbg(&port->dev, "%s - RX error!!!!\n", __func__);
@@ -328,7 +328,8 @@ static void usa26_indat_callback(struct urb *urb)
328 if (stat & RXERROR_PARITY) 328 if (stat & RXERROR_PARITY)
329 flag |= TTY_PARITY; 329 flag |= TTY_PARITY;
330 /* XXX should handle break (0x10) */ 330 /* XXX should handle break (0x10) */
331 tty_insert_flip_char(tty, data[i+1], flag); 331 tty_insert_flip_char(&port->port, data[i+1],
332 flag);
332 } 333 }
333 } 334 }
334 tty_flip_buffer_push(tty); 335 tty_flip_buffer_push(tty);
@@ -700,7 +701,8 @@ static void usa49_indat_callback(struct urb *urb)
700 if (stat & RXERROR_PARITY) 701 if (stat & RXERROR_PARITY)
701 flag |= TTY_PARITY; 702 flag |= TTY_PARITY;
702 /* XXX should handle break (0x10) */ 703 /* XXX should handle break (0x10) */
703 tty_insert_flip_char(tty, data[i+1], flag); 704 tty_insert_flip_char(&port->port, data[i+1],
705 flag);
704 } 706 }
705 } 707 }
706 tty_flip_buffer_push(tty); 708 tty_flip_buffer_push(tty);
@@ -751,7 +753,8 @@ static void usa49wg_indat_callback(struct urb *urb)
751 /* no error on any byte */ 753 /* no error on any byte */
752 i++; 754 i++;
753 for (x = 1; x < len ; ++x) 755 for (x = 1; x < len ; ++x)
754 tty_insert_flip_char(tty, data[i++], 0); 756 tty_insert_flip_char(&port->port,
757 data[i++], 0);
755 } else { 758 } else {
756 /* 759 /*
757 * some bytes had errors, every byte has status 760 * some bytes had errors, every byte has status
@@ -765,7 +768,7 @@ static void usa49wg_indat_callback(struct urb *urb)
765 if (stat & RXERROR_PARITY) 768 if (stat & RXERROR_PARITY)
766 flag |= TTY_PARITY; 769 flag |= TTY_PARITY;
767 /* XXX should handle break (0x10) */ 770 /* XXX should handle break (0x10) */
768 tty_insert_flip_char(tty, 771 tty_insert_flip_char(&port->port,
769 data[i+1], flag); 772 data[i+1], flag);
770 i += 2; 773 i += 2;
771 } 774 }
@@ -824,8 +827,8 @@ static void usa90_indat_callback(struct urb *urb)
824 else 827 else
825 err = 0; 828 err = 0;
826 for (i = 1; i < urb->actual_length ; ++i) 829 for (i = 1; i < urb->actual_length ; ++i)
827 tty_insert_flip_char(tty, data[i], 830 tty_insert_flip_char(&port->port,
828 err); 831 data[i], err);
829 } else { 832 } else {
830 /* some bytes had errors, every byte has status */ 833 /* some bytes had errors, every byte has status */
831 dev_dbg(&port->dev, "%s - RX error!!!!\n", __func__); 834 dev_dbg(&port->dev, "%s - RX error!!!!\n", __func__);
@@ -838,8 +841,8 @@ static void usa90_indat_callback(struct urb *urb)
838 if (stat & RXERROR_PARITY) 841 if (stat & RXERROR_PARITY)
839 flag |= TTY_PARITY; 842 flag |= TTY_PARITY;
840 /* XXX should handle break (0x10) */ 843 /* XXX should handle break (0x10) */
841 tty_insert_flip_char(tty, data[i+1], 844 tty_insert_flip_char(&port->port,
842 flag); 845 data[i+1], flag);
843 } 846 }
844 } 847 }
845 } 848 }
diff --git a/drivers/usb/serial/pl2303.c b/drivers/usb/serial/pl2303.c
index 86789b0477c5..00047f3c7293 100644
--- a/drivers/usb/serial/pl2303.c
+++ b/drivers/usb/serial/pl2303.c
@@ -805,12 +805,13 @@ static void pl2303_process_read_urb(struct urb *urb)
805 805
806 /* overrun is special, not associated with a char */ 806 /* overrun is special, not associated with a char */
807 if (line_status & UART_OVERRUN_ERROR) 807 if (line_status & UART_OVERRUN_ERROR)
808 tty_insert_flip_char(tty, 0, TTY_OVERRUN); 808 tty_insert_flip_char(&port->port, 0, TTY_OVERRUN);
809 809
810 if (port->port.console && port->sysrq) { 810 if (port->port.console && port->sysrq) {
811 for (i = 0; i < urb->actual_length; ++i) 811 for (i = 0; i < urb->actual_length; ++i)
812 if (!usb_serial_handle_sysrq_char(port, data[i])) 812 if (!usb_serial_handle_sysrq_char(port, data[i]))
813 tty_insert_flip_char(tty, data[i], tty_flag); 813 tty_insert_flip_char(&port->port, data[i],
814 tty_flag);
814 } else { 815 } else {
815 tty_insert_flip_string_fixed_flag(&port->port, data, tty_flag, 816 tty_insert_flip_string_fixed_flag(&port->port, data, tty_flag,
816 urb->actual_length); 817 urb->actual_length);
diff --git a/drivers/usb/serial/spcp8x5.c b/drivers/usb/serial/spcp8x5.c
index fa42f1b907d0..04e373152724 100644
--- a/drivers/usb/serial/spcp8x5.c
+++ b/drivers/usb/serial/spcp8x5.c
@@ -498,7 +498,7 @@ static void spcp8x5_process_read_urb(struct urb *urb)
498 498
499 /* overrun is special, not associated with a char */ 499 /* overrun is special, not associated with a char */
500 if (status & UART_OVERRUN_ERROR) 500 if (status & UART_OVERRUN_ERROR)
501 tty_insert_flip_char(tty, 0, TTY_OVERRUN); 501 tty_insert_flip_char(&port->port, 0, TTY_OVERRUN);
502 502
503 if (status & UART_DCD) 503 if (status & UART_DCD)
504 usb_serial_handle_dcd_change(port, tty, 504 usb_serial_handle_dcd_change(port, tty,
diff --git a/drivers/usb/serial/ssu100.c b/drivers/usb/serial/ssu100.c
index 37476c6240c2..38713156e957 100644
--- a/drivers/usb/serial/ssu100.c
+++ b/drivers/usb/serial/ssu100.c
@@ -582,8 +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 int ssu100_process_packet(struct urb *urb)
586 struct tty_struct *tty)
587{ 586{
588 struct usb_serial_port *port = urb->context; 587 struct usb_serial_port *port = urb->context;
589 char *packet = (char *)urb->transfer_buffer; 588 char *packet = (char *)urb->transfer_buffer;
@@ -598,7 +597,8 @@ static int ssu100_process_packet(struct urb *urb,
598 if (packet[2] == 0x00) { 597 if (packet[2] == 0x00) {
599 ssu100_update_lsr(port, packet[3], &flag); 598 ssu100_update_lsr(port, packet[3], &flag);
600 if (flag == TTY_OVERRUN) 599 if (flag == TTY_OVERRUN)
601 tty_insert_flip_char(tty, 0, TTY_OVERRUN); 600 tty_insert_flip_char(&port->port, 0,
601 TTY_OVERRUN);
602 } 602 }
603 if (packet[2] == 0x01) 603 if (packet[2] == 0x01)
604 ssu100_update_msr(port, packet[3]); 604 ssu100_update_msr(port, packet[3]);
@@ -614,7 +614,7 @@ static int ssu100_process_packet(struct urb *urb,
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++) {
616 if (!usb_serial_handle_sysrq_char(port, *ch)) 616 if (!usb_serial_handle_sysrq_char(port, *ch))
617 tty_insert_flip_char(tty, *ch, flag); 617 tty_insert_flip_char(&port->port, *ch, flag);
618 } 618 }
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);
@@ -632,7 +632,7 @@ static void ssu100_process_read_urb(struct urb *urb)
632 if (!tty) 632 if (!tty)
633 return; 633 return;
634 634
635 count = ssu100_process_packet(urb, tty); 635 count = ssu100_process_packet(urb);
636 636
637 if (count) 637 if (count)
638 tty_flip_buffer_push(tty); 638 tty_flip_buffer_push(tty);
diff --git a/include/linux/tty_flip.h b/include/linux/tty_flip.h
index 743f1d076467..f9acb578c6ad 100644
--- a/include/linux/tty_flip.h
+++ b/include/linux/tty_flip.h
@@ -12,16 +12,16 @@ extern int tty_prepare_flip_string_flags(struct tty_port *port,
12 unsigned char **chars, char **flags, size_t size); 12 unsigned char **chars, char **flags, size_t size);
13void tty_schedule_flip(struct tty_struct *tty); 13void tty_schedule_flip(struct tty_struct *tty);
14 14
15static inline int tty_insert_flip_char(struct tty_struct *tty, 15static inline int tty_insert_flip_char(struct tty_port *port,
16 unsigned char ch, char flag) 16 unsigned char ch, char flag)
17{ 17{
18 struct tty_buffer *tb = tty->port->buf.tail; 18 struct tty_buffer *tb = port->buf.tail;
19 if (tb && tb->used < tb->size) { 19 if (tb && tb->used < tb->size) {
20 tb->flag_buf_ptr[tb->used] = flag; 20 tb->flag_buf_ptr[tb->used] = flag;
21 tb->char_buf_ptr[tb->used++] = ch; 21 tb->char_buf_ptr[tb->used++] = ch;
22 return 1; 22 return 1;
23 } 23 }
24 return tty_insert_flip_string_flags(tty->port, &ch, &flag, 1); 24 return tty_insert_flip_string_flags(port, &ch, &flag, 1);
25} 25}
26 26
27static inline int tty_insert_flip_string(struct tty_struct *tty, const unsigned char *chars, size_t size) 27static inline int tty_insert_flip_string(struct tty_struct *tty, const unsigned char *chars, size_t size)