aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJiri Slaby <jslaby@suse.cz>2013-01-03 09:53:01 -0500
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2013-01-16 01:17:28 -0500
commit227434f8986c3827a1faedd1feb437acd6285315 (patch)
treee96f6c6a800b81d096be73c1b7943c7aa24aa632
parentea28fd56fcde69af768135e428093f94c5ca6a88 (diff)
TTY: switch tty_buffer_request_room to tty_port
Now, we start converting tty buffer functions to actually use tty_port. This will allow us to get rid of the need of tty pointer in many call sites. Only tty_port will be needed and hence no more tty_port_tty_get calls in those paths. Here we start with tty_buffer_request_room. Signed-off-by: Jiri Slaby <jslaby@suse.cz> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
-rw-r--r--arch/mn10300/kernel/mn10300-serial.c5
-rw-r--r--arch/um/drivers/chan_kern.c3
-rw-r--r--drivers/char/pcmcia/synclink_cs.c3
-rw-r--r--drivers/isdn/i4l/isdn_common.c3
-rw-r--r--drivers/isdn/i4l/isdn_tty.c12
-rw-r--r--drivers/staging/dgrp/dgrp_net_ops.c4
-rw-r--r--drivers/tty/cyclades.c13
-rw-r--r--drivers/tty/ehv_bytechan.c2
-rw-r--r--drivers/tty/hvc/hvc_console.c2
-rw-r--r--drivers/tty/hvc/hvcs.c2
-rw-r--r--drivers/tty/serial/cpm_uart/cpm_uart_core.c5
-rw-r--r--drivers/tty/serial/ioc4_serial.c2
-rw-r--r--drivers/tty/serial/jsm/jsm_tty.c6
-rw-r--r--drivers/tty/serial/mpsc.c6
-rw-r--r--drivers/tty/serial/mrst_max3110.c6
-rw-r--r--drivers/tty/serial/pch_uart.c5
-rw-r--r--drivers/tty/serial/sh-sci.c8
-rw-r--r--drivers/tty/serial/ucc_uart.c5
-rw-r--r--drivers/tty/tty_buffer.c5
-rw-r--r--drivers/usb/serial/quatech2.c4
-rw-r--r--include/linux/tty_flip.h2
21 files changed, 60 insertions, 43 deletions
diff --git a/arch/mn10300/kernel/mn10300-serial.c b/arch/mn10300/kernel/mn10300-serial.c
index 81d5cb9b6569..9b2232a78ff9 100644
--- a/arch/mn10300/kernel/mn10300-serial.c
+++ b/arch/mn10300/kernel/mn10300-serial.c
@@ -524,7 +524,8 @@ static int mask_test_and_clear(volatile u8 *ptr, u8 mask)
524static void mn10300_serial_receive_interrupt(struct mn10300_serial_port *port) 524static void mn10300_serial_receive_interrupt(struct mn10300_serial_port *port)
525{ 525{
526 struct uart_icount *icount = &port->uart.icount; 526 struct uart_icount *icount = &port->uart.icount;
527 struct tty_struct *tty = port->uart.state->port.tty; 527 struct tty_port *port = &port->uart.state->port;
528 struct tty_struct *tty = port->tty;
528 unsigned ix; 529 unsigned ix;
529 int count; 530 int count;
530 u8 st, ch, push, status, overrun; 531 u8 st, ch, push, status, overrun;
@@ -534,7 +535,7 @@ static void mn10300_serial_receive_interrupt(struct mn10300_serial_port *port)
534 push = 0; 535 push = 0;
535 536
536 count = CIRC_CNT(port->rx_inp, port->rx_outp, MNSC_BUFFER_SIZE); 537 count = CIRC_CNT(port->rx_inp, port->rx_outp, MNSC_BUFFER_SIZE);
537 count = tty_buffer_request_room(tty, count); 538 count = tty_buffer_request_room(port, count);
538 if (count == 0) { 539 if (count == 0) {
539 if (!tty->low_latency) 540 if (!tty->low_latency)
540 tty_flip_buffer_push(tty); 541 tty_flip_buffer_push(tty);
diff --git a/arch/um/drivers/chan_kern.c b/arch/um/drivers/chan_kern.c
index e9a0abc6a32f..4ff2503a1bb8 100644
--- a/arch/um/drivers/chan_kern.c
+++ b/arch/um/drivers/chan_kern.c
@@ -554,6 +554,7 @@ int parse_chan_pair(char *str, struct line *line, int device,
554 554
555void chan_interrupt(struct line *line, struct tty_struct *tty, int irq) 555void chan_interrupt(struct line *line, struct tty_struct *tty, int irq)
556{ 556{
557 struct tty_port *port = &line->port;
557 struct chan *chan = line->chan_in; 558 struct chan *chan = line->chan_in;
558 int err; 559 int err;
559 char c; 560 char c;
@@ -562,7 +563,7 @@ void chan_interrupt(struct line *line, struct tty_struct *tty, int irq)
562 goto out; 563 goto out;
563 564
564 do { 565 do {
565 if (tty && !tty_buffer_request_room(tty, 1)) { 566 if (!tty_buffer_request_room(port, 1)) {
566 schedule_delayed_work(&line->task, 1); 567 schedule_delayed_work(&line->task, 1);
567 goto out; 568 goto out;
568 } 569 }
diff --git a/drivers/char/pcmcia/synclink_cs.c b/drivers/char/pcmcia/synclink_cs.c
index b2f35d786025..0b1de715f097 100644
--- a/drivers/char/pcmcia/synclink_cs.c
+++ b/drivers/char/pcmcia/synclink_cs.c
@@ -888,6 +888,7 @@ static void rx_ready_hdlc(MGSLPC_INFO *info, int eom)
888 888
889static void rx_ready_async(MGSLPC_INFO *info, int tcd, struct tty_struct *tty) 889static void rx_ready_async(MGSLPC_INFO *info, int tcd, struct tty_struct *tty)
890{ 890{
891 struct tty_port *port = &info->port;
891 unsigned char data, status, flag; 892 unsigned char data, status, flag;
892 int fifo_count; 893 int fifo_count;
893 int work = 0; 894 int work = 0;
@@ -913,7 +914,7 @@ static void rx_ready_async(MGSLPC_INFO *info, int tcd, struct tty_struct *tty)
913 } else 914 } else
914 fifo_count = 32; 915 fifo_count = 32;
915 916
916 tty_buffer_request_room(tty, fifo_count); 917 tty_buffer_request_room(port, fifo_count);
917 /* Flush received async data to receive data buffer. */ 918 /* Flush received async data to receive data buffer. */
918 while (fifo_count) { 919 while (fifo_count) {
919 data = read_reg(info, CHA + RXFIFO); 920 data = read_reg(info, CHA + RXFIFO);
diff --git a/drivers/isdn/i4l/isdn_common.c b/drivers/isdn/i4l/isdn_common.c
index e2a945ee9f05..7093169ee0c9 100644
--- a/drivers/isdn/i4l/isdn_common.c
+++ b/drivers/isdn/i4l/isdn_common.c
@@ -878,6 +878,7 @@ isdn_readbchan(int di, int channel, u_char *buf, u_char *fp, int len, wait_queue
878int 878int
879isdn_readbchan_tty(int di, int channel, struct tty_struct *tty, int cisco_hack) 879isdn_readbchan_tty(int di, int channel, struct tty_struct *tty, int cisco_hack)
880{ 880{
881 struct tty_port *port = tty->port;
881 int count; 882 int count;
882 int count_pull; 883 int count_pull;
883 int count_put; 884 int count_put;
@@ -891,7 +892,7 @@ isdn_readbchan_tty(int di, int channel, struct tty_struct *tty, int cisco_hack)
891 if (skb_queue_empty(&dev->drv[di]->rpqueue[channel])) 892 if (skb_queue_empty(&dev->drv[di]->rpqueue[channel]))
892 return 0; 893 return 0;
893 894
894 len = tty_buffer_request_room(tty, dev->drv[di]->rcvcount[channel]); 895 len = tty_buffer_request_room(port, dev->drv[di]->rcvcount[channel]);
895 if (len == 0) 896 if (len == 0)
896 return len; 897 return len;
897 898
diff --git a/drivers/isdn/i4l/isdn_tty.c b/drivers/isdn/i4l/isdn_tty.c
index e09dc8a5e743..4f5bcee7cf32 100644
--- a/drivers/isdn/i4l/isdn_tty.c
+++ b/drivers/isdn/i4l/isdn_tty.c
@@ -60,6 +60,7 @@ static int si2bit[8] =
60static int 60static int
61isdn_tty_try_read(modem_info *info, struct sk_buff *skb) 61isdn_tty_try_read(modem_info *info, struct sk_buff *skb)
62{ 62{
63 struct tty_port *port = &info->port;
63 int c; 64 int c;
64 int len; 65 int len;
65 struct tty_struct *tty; 66 struct tty_struct *tty;
@@ -68,7 +69,7 @@ isdn_tty_try_read(modem_info *info, struct sk_buff *skb)
68 if (!info->online) 69 if (!info->online)
69 return 0; 70 return 0;
70 71
71 tty = info->port.tty; 72 tty = port->tty;
72 if (!tty) 73 if (!tty)
73 return 0; 74 return 0;
74 75
@@ -81,7 +82,7 @@ isdn_tty_try_read(modem_info *info, struct sk_buff *skb)
81#endif 82#endif
82 ; 83 ;
83 84
84 c = tty_buffer_request_room(tty, len); 85 c = tty_buffer_request_room(port, len);
85 if (c < len) 86 if (c < len)
86 return 0; 87 return 0;
87 88
@@ -2230,6 +2231,7 @@ void
2230isdn_tty_at_cout(char *msg, modem_info *info) 2231isdn_tty_at_cout(char *msg, modem_info *info)
2231{ 2232{
2232 struct tty_struct *tty; 2233 struct tty_struct *tty;
2234 struct tty_port *port = &info->port;
2233 atemu *m = &info->emu; 2235 atemu *m = &info->emu;
2234 char *p; 2236 char *p;
2235 char c; 2237 char c;
@@ -2246,15 +2248,15 @@ isdn_tty_at_cout(char *msg, modem_info *info)
2246 l = strlen(msg); 2248 l = strlen(msg);
2247 2249
2248 spin_lock_irqsave(&info->readlock, flags); 2250 spin_lock_irqsave(&info->readlock, flags);
2249 tty = info->port.tty; 2251 tty = port->tty;
2250 if ((info->port.flags & ASYNC_CLOSING) || (!tty)) { 2252 if ((port->flags & ASYNC_CLOSING) || (!tty)) {
2251 spin_unlock_irqrestore(&info->readlock, flags); 2253 spin_unlock_irqrestore(&info->readlock, flags);
2252 return; 2254 return;
2253 } 2255 }
2254 2256
2255 /* use queue instead of direct, if online and */ 2257 /* use queue instead of direct, if online and */
2256 /* data is in queue or buffer is full */ 2258 /* data is in queue or buffer is full */
2257 if (info->online && ((tty_buffer_request_room(tty, l) < l) || 2259 if (info->online && ((tty_buffer_request_room(port, l) < l) ||
2258 !skb_queue_empty(&dev->drv[info->isdn_driver]->rpqueue[info->isdn_channel]))) { 2260 !skb_queue_empty(&dev->drv[info->isdn_driver]->rpqueue[info->isdn_channel]))) {
2259 skb = alloc_skb(l, GFP_ATOMIC); 2261 skb = alloc_skb(l, GFP_ATOMIC);
2260 if (!skb) { 2262 if (!skb) {
diff --git a/drivers/staging/dgrp/dgrp_net_ops.c b/drivers/staging/dgrp/dgrp_net_ops.c
index 2d1bbfd5b67c..c0aeaaa094f1 100644
--- a/drivers/staging/dgrp/dgrp_net_ops.c
+++ b/drivers/staging/dgrp/dgrp_net_ops.c
@@ -211,7 +211,7 @@ static void dgrp_input(struct ch_struct *ch)
211 data_len = (ch->ch_rin - ch->ch_rout) & RBUF_MASK; 211 data_len = (ch->ch_rin - ch->ch_rout) & RBUF_MASK;
212 212
213 /* len is the amount of data we are going to transfer here */ 213 /* len is the amount of data we are going to transfer here */
214 len = tty_buffer_request_room(tty, data_len); 214 len = tty_buffer_request_room(&ch->port, data_len);
215 215
216 /* Check DPA flow control */ 216 /* Check DPA flow control */
217 if ((nd->nd_dpa_debug) && 217 if ((nd->nd_dpa_debug) &&
@@ -2956,7 +2956,7 @@ check_query:
2956 I_BRKINT(ch->ch_tun.un_tty) && 2956 I_BRKINT(ch->ch_tun.un_tty) &&
2957 !(I_IGNBRK(ch->ch_tun.un_tty))) { 2957 !(I_IGNBRK(ch->ch_tun.un_tty))) {
2958 2958
2959 tty_buffer_request_room(ch->ch_tun.un_tty, 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->ch_tun.un_tty, 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
diff --git a/drivers/tty/cyclades.c b/drivers/tty/cyclades.c
index b09c8d1f9a66..b85acc74eb0d 100644
--- a/drivers/tty/cyclades.c
+++ b/drivers/tty/cyclades.c
@@ -442,6 +442,7 @@ static void cyy_chip_rx(struct cyclades_card *cinfo, int chip,
442{ 442{
443 struct cyclades_port *info; 443 struct cyclades_port *info;
444 struct tty_struct *tty; 444 struct tty_struct *tty;
445 struct tty_port *port;
445 int len, index = cinfo->bus_index; 446 int len, index = cinfo->bus_index;
446 u8 ivr, save_xir, channel, save_car, data, char_count; 447 u8 ivr, save_xir, channel, save_car, data, char_count;
447 448
@@ -452,11 +453,12 @@ static void cyy_chip_rx(struct cyclades_card *cinfo, int chip,
452 save_xir = readb(base_addr + (CyRIR << index)); 453 save_xir = readb(base_addr + (CyRIR << index));
453 channel = save_xir & CyIRChannel; 454 channel = save_xir & CyIRChannel;
454 info = &cinfo->ports[channel + chip * 4]; 455 info = &cinfo->ports[channel + chip * 4];
456 port = &info->port;
455 save_car = cyy_readb(info, CyCAR); 457 save_car = cyy_readb(info, CyCAR);
456 cyy_writeb(info, CyCAR, save_xir); 458 cyy_writeb(info, CyCAR, save_xir);
457 ivr = cyy_readb(info, CyRIVR) & CyIVRMask; 459 ivr = cyy_readb(info, CyRIVR) & CyIVRMask;
458 460
459 tty = tty_port_tty_get(&info->port); 461 tty = tty_port_tty_get(port);
460 /* if there is nowhere to put the data, discard it */ 462 /* if there is nowhere to put the data, discard it */
461 if (tty == NULL) { 463 if (tty == NULL) {
462 if (ivr == CyIVRRxEx) { /* exception */ 464 if (ivr == CyIVRRxEx) { /* exception */
@@ -487,14 +489,14 @@ static void cyy_chip_rx(struct cyclades_card *cinfo, int chip,
487 tty_kref_put(tty); 489 tty_kref_put(tty);
488 return; 490 return;
489 } 491 }
490 if (tty_buffer_request_room(tty, 1)) { 492 if (tty_buffer_request_room(port, 1)) {
491 if (data & info->read_status_mask) { 493 if (data & info->read_status_mask) {
492 if (data & CyBREAK) { 494 if (data & CyBREAK) {
493 tty_insert_flip_char(tty, 495 tty_insert_flip_char(tty,
494 cyy_readb(info, CyRDSR), 496 cyy_readb(info, CyRDSR),
495 TTY_BREAK); 497 TTY_BREAK);
496 info->icount.rx++; 498 info->icount.rx++;
497 if (info->port.flags & ASYNC_SAK) 499 if (port->flags & ASYNC_SAK)
498 do_SAK(tty); 500 do_SAK(tty);
499 } else if (data & CyFRAME) { 501 } else if (data & CyFRAME) {
500 tty_insert_flip_char(tty, 502 tty_insert_flip_char(tty,
@@ -552,7 +554,7 @@ static void cyy_chip_rx(struct cyclades_card *cinfo, int chip,
552 info->mon.char_max = char_count; 554 info->mon.char_max = char_count;
553 info->mon.char_last = char_count; 555 info->mon.char_last = char_count;
554#endif 556#endif
555 len = tty_buffer_request_room(tty, char_count); 557 len = tty_buffer_request_room(port, char_count);
556 while (len--) { 558 while (len--) {
557 data = cyy_readb(info, CyRDSR); 559 data = cyy_readb(info, CyRDSR);
558 tty_insert_flip_char(tty, data, TTY_NORMAL); 560 tty_insert_flip_char(tty, data, TTY_NORMAL);
@@ -928,6 +930,7 @@ static void cyz_handle_rx(struct cyclades_port *info, struct tty_struct *tty)
928{ 930{
929 struct BUF_CTRL __iomem *buf_ctrl = info->u.cyz.buf_ctrl; 931 struct BUF_CTRL __iomem *buf_ctrl = info->u.cyz.buf_ctrl;
930 struct cyclades_card *cinfo = info->card; 932 struct cyclades_card *cinfo = info->card;
933 struct tty_port *port = &info->port;
931 unsigned int char_count; 934 unsigned int char_count;
932 int len; 935 int len;
933#ifdef BLOCKMOVE 936#ifdef BLOCKMOVE
@@ -983,7 +986,7 @@ static void cyz_handle_rx(struct cyclades_port *info, struct tty_struct *tty)
983 info->idle_stats.recv_bytes += len; 986 info->idle_stats.recv_bytes += len;
984 } 987 }
985#else 988#else
986 len = tty_buffer_request_room(tty, char_count); 989 len = tty_buffer_request_room(port, char_count);
987 while (len--) { 990 while (len--) {
988 data = readb(cinfo->base_addr + rx_bufaddr + 991 data = readb(cinfo->base_addr + rx_bufaddr +
989 new_rx_get); 992 new_rx_get);
diff --git a/drivers/tty/ehv_bytechan.c b/drivers/tty/ehv_bytechan.c
index c117d775a22f..af97e39d641c 100644
--- a/drivers/tty/ehv_bytechan.c
+++ b/drivers/tty/ehv_bytechan.c
@@ -386,7 +386,7 @@ static irqreturn_t ehv_bc_tty_rx_isr(int irq, void *data)
386 * read from the byte channel will be accepted by the TTY layer. 386 * read from the byte channel will be accepted by the TTY layer.
387 */ 387 */
388 ev_byte_channel_poll(bc->handle, &rx_count, &tx_count); 388 ev_byte_channel_poll(bc->handle, &rx_count, &tx_count);
389 count = tty_buffer_request_room(ttys, rx_count); 389 count = tty_buffer_request_room(&bc->port, rx_count);
390 390
391 /* 'count' is the maximum amount of data the TTY layer can accept at 391 /* 'count' is the maximum amount of data the TTY layer can accept at
392 * this time. However, during testing, I was never able to get 'count' 392 * this time. However, during testing, I was never able to get 'count'
diff --git a/drivers/tty/hvc/hvc_console.c b/drivers/tty/hvc/hvc_console.c
index 13ee53bd0bf6..3d2ea92b8505 100644
--- a/drivers/tty/hvc/hvc_console.c
+++ b/drivers/tty/hvc/hvc_console.c
@@ -629,7 +629,7 @@ int hvc_poll(struct hvc_struct *hp)
629 629
630 /* Read data if any */ 630 /* Read data if any */
631 for (;;) { 631 for (;;) {
632 int count = tty_buffer_request_room(tty, N_INBUF); 632 int count = tty_buffer_request_room(&hp->port, N_INBUF);
633 633
634 /* If flip is full, just reschedule a later read */ 634 /* If flip is full, just reschedule a later read */
635 if (count == 0) { 635 if (count == 0) {
diff --git a/drivers/tty/hvc/hvcs.c b/drivers/tty/hvc/hvcs.c
index 877635733952..4a0ab98e9a63 100644
--- a/drivers/tty/hvc/hvcs.c
+++ b/drivers/tty/hvc/hvcs.c
@@ -609,7 +609,7 @@ static int hvcs_io(struct hvcs_struct *hvcsd)
609 /* remove the read masks */ 609 /* remove the read masks */
610 hvcsd->todo_mask &= ~(HVCS_READ_MASK); 610 hvcsd->todo_mask &= ~(HVCS_READ_MASK);
611 611
612 if (tty_buffer_request_room(tty, HVCS_BUFF_LEN) >= HVCS_BUFF_LEN) { 612 if (tty_buffer_request_room(&hvcsd->port, HVCS_BUFF_LEN) >= HVCS_BUFF_LEN) {
613 got = hvc_get_chars(unit_address, 613 got = hvc_get_chars(unit_address,
614 &buf[0], 614 &buf[0],
615 HVCS_BUFF_LEN); 615 HVCS_BUFF_LEN);
diff --git a/drivers/tty/serial/cpm_uart/cpm_uart_core.c b/drivers/tty/serial/cpm_uart/cpm_uart_core.c
index ad0caf176808..42d5eb0125b3 100644
--- a/drivers/tty/serial/cpm_uart/cpm_uart_core.c
+++ b/drivers/tty/serial/cpm_uart/cpm_uart_core.c
@@ -245,7 +245,8 @@ static void cpm_uart_int_rx(struct uart_port *port)
245 int i; 245 int i;
246 unsigned char ch; 246 unsigned char ch;
247 u8 *cp; 247 u8 *cp;
248 struct tty_struct *tty = port->state->port.tty; 248 struct tty_port *tport = &port->state->port;
249 struct tty_struct *tty = tport->tty;
249 struct uart_cpm_port *pinfo = (struct uart_cpm_port *)port; 250 struct uart_cpm_port *pinfo = (struct uart_cpm_port *)port;
250 cbd_t __iomem *bdp; 251 cbd_t __iomem *bdp;
251 u16 status; 252 u16 status;
@@ -276,7 +277,7 @@ static void cpm_uart_int_rx(struct uart_port *port)
276 /* If we have not enough room in tty flip buffer, then we try 277 /* If we have not enough room in tty flip buffer, then we try
277 * later, which will be the next rx-interrupt or a timeout 278 * later, which will be the next rx-interrupt or a timeout
278 */ 279 */
279 if(tty_buffer_request_room(tty, i) < i) { 280 if (tty_buffer_request_room(tport, i) < i) {
280 printk(KERN_WARNING "No room in flip buffer\n"); 281 printk(KERN_WARNING "No room in flip buffer\n");
281 return; 282 return;
282 } 283 }
diff --git a/drivers/tty/serial/ioc4_serial.c b/drivers/tty/serial/ioc4_serial.c
index c4e30b841f94..710ce87ffbeb 100644
--- a/drivers/tty/serial/ioc4_serial.c
+++ b/drivers/tty/serial/ioc4_serial.c
@@ -2356,7 +2356,7 @@ static void receive_chars(struct uart_port *the_port)
2356 spin_lock_irqsave(&the_port->lock, pflags); 2356 spin_lock_irqsave(&the_port->lock, pflags);
2357 tty = state->port.tty; 2357 tty = state->port.tty;
2358 2358
2359 request_count = tty_buffer_request_room(tty, IOC4_MAX_CHARS); 2359 request_count = tty_buffer_request_room(&state->port, IOC4_MAX_CHARS);
2360 2360
2361 if (request_count > 0) { 2361 if (request_count > 0) {
2362 icount = &the_port->icount; 2362 icount = &the_port->icount;
diff --git a/drivers/tty/serial/jsm/jsm_tty.c b/drivers/tty/serial/jsm/jsm_tty.c
index 4c00c5550b1a..3969e54744cc 100644
--- a/drivers/tty/serial/jsm/jsm_tty.c
+++ b/drivers/tty/serial/jsm/jsm_tty.c
@@ -521,6 +521,7 @@ void jsm_input(struct jsm_channel *ch)
521{ 521{
522 struct jsm_board *bd; 522 struct jsm_board *bd;
523 struct tty_struct *tp; 523 struct tty_struct *tp;
524 struct tty_port *port;
524 u32 rmask; 525 u32 rmask;
525 u16 head; 526 u16 head;
526 u16 tail; 527 u16 tail;
@@ -536,7 +537,8 @@ void jsm_input(struct jsm_channel *ch)
536 if (!ch) 537 if (!ch)
537 return; 538 return;
538 539
539 tp = ch->uart_port.state->port.tty; 540 port = &ch->uart_port.state->port;
541 tp = port->tty;
540 542
541 bd = ch->ch_bd; 543 bd = ch->ch_bd;
542 if(!bd) 544 if(!bd)
@@ -600,7 +602,7 @@ void jsm_input(struct jsm_channel *ch)
600 return; 602 return;
601 } 603 }
602 604
603 len = tty_buffer_request_room(tp, data_len); 605 len = tty_buffer_request_room(port, data_len);
604 n = len; 606 n = len;
605 607
606 /* 608 /*
diff --git a/drivers/tty/serial/mpsc.c b/drivers/tty/serial/mpsc.c
index 6a9c6605666a..50366863cfa3 100644
--- a/drivers/tty/serial/mpsc.c
+++ b/drivers/tty/serial/mpsc.c
@@ -937,7 +937,8 @@ static int serial_polled;
937static int mpsc_rx_intr(struct mpsc_port_info *pi) 937static int mpsc_rx_intr(struct mpsc_port_info *pi)
938{ 938{
939 struct mpsc_rx_desc *rxre; 939 struct mpsc_rx_desc *rxre;
940 struct tty_struct *tty = pi->port.state->port.tty; 940 struct tty_port *port = &pi->port.state->port;
941 struct tty_struct *tty = port->tty;
941 u32 cmdstat, bytes_in, i; 942 u32 cmdstat, bytes_in, i;
942 int rc = 0; 943 int rc = 0;
943 u8 *bp; 944 u8 *bp;
@@ -968,8 +969,7 @@ static int mpsc_rx_intr(struct mpsc_port_info *pi)
968 } 969 }
969#endif 970#endif
970 /* Following use of tty struct directly is deprecated */ 971 /* Following use of tty struct directly is deprecated */
971 if (unlikely(tty_buffer_request_room(tty, bytes_in) 972 if (tty_buffer_request_room(port, bytes_in) < bytes_in) {
972 < bytes_in)) {
973 if (tty->low_latency) 973 if (tty->low_latency)
974 tty_flip_buffer_push(tty); 974 tty_flip_buffer_push(tty);
975 /* 975 /*
diff --git a/drivers/tty/serial/mrst_max3110.c b/drivers/tty/serial/mrst_max3110.c
index 58734d7e746d..776431ff0190 100644
--- a/drivers/tty/serial/mrst_max3110.c
+++ b/drivers/tty/serial/mrst_max3110.c
@@ -339,6 +339,7 @@ static int
339receive_chars(struct uart_max3110 *max, unsigned short *str, int len) 339receive_chars(struct uart_max3110 *max, unsigned short *str, int len)
340{ 340{
341 struct uart_port *port = &max->port; 341 struct uart_port *port = &max->port;
342 struct tty_port *tport;
342 struct tty_struct *tty; 343 struct tty_struct *tty;
343 char buf[M3110_RX_FIFO_DEPTH]; 344 char buf[M3110_RX_FIFO_DEPTH];
344 int r, w, usable; 345 int r, w, usable;
@@ -347,7 +348,8 @@ receive_chars(struct uart_max3110 *max, unsigned short *str, int len)
347 if (!port->state) 348 if (!port->state)
348 return 0; 349 return 0;
349 350
350 tty = tty_port_tty_get(&port->state->port); 351 tport = &port->state->port;
352 tty = tty_port_tty_get(tport);
351 if (!tty) 353 if (!tty)
352 return 0; 354 return 0;
353 355
@@ -370,7 +372,7 @@ receive_chars(struct uart_max3110 *max, unsigned short *str, int len)
370 } 372 }
371 373
372 for (r = 0; w; r += usable, w -= usable) { 374 for (r = 0; w; r += usable, w -= usable) {
373 usable = tty_buffer_request_room(tty, w); 375 usable = tty_buffer_request_room(tport, w);
374 if (usable) { 376 if (usable) {
375 tty_insert_flip_string(tty, buf + r, usable); 377 tty_insert_flip_string(tty, buf + r, usable);
376 port->icount.rx += usable; 378 port->icount.rx += usable;
diff --git a/drivers/tty/serial/pch_uart.c b/drivers/tty/serial/pch_uart.c
index 8318925fbf6b..4f1774be2a8c 100644
--- a/drivers/tty/serial/pch_uart.c
+++ b/drivers/tty/serial/pch_uart.c
@@ -629,15 +629,16 @@ static int dma_push_rx(struct eg20t_port *priv, int size)
629 struct tty_struct *tty; 629 struct tty_struct *tty;
630 int room; 630 int room;
631 struct uart_port *port = &priv->port; 631 struct uart_port *port = &priv->port;
632 struct tty_port *tport = &port->state->port;
632 633
633 port = &priv->port; 634 port = &priv->port;
634 tty = tty_port_tty_get(&port->state->port); 635 tty = tty_port_tty_get(tport);
635 if (!tty) { 636 if (!tty) {
636 dev_dbg(priv->port.dev, "%s:tty is busy now", __func__); 637 dev_dbg(priv->port.dev, "%s:tty is busy now", __func__);
637 return 0; 638 return 0;
638 } 639 }
639 640
640 room = tty_buffer_request_room(tty, size); 641 room = tty_buffer_request_room(tport, size);
641 642
642 if (room < size) 643 if (room < size)
643 dev_warn(port->dev, "Rx overrun: dropping %u bytes\n", 644 dev_warn(port->dev, "Rx overrun: dropping %u bytes\n",
diff --git a/drivers/tty/serial/sh-sci.c b/drivers/tty/serial/sh-sci.c
index 61477567423f..cf96314770fb 100644
--- a/drivers/tty/serial/sh-sci.c
+++ b/drivers/tty/serial/sh-sci.c
@@ -596,7 +596,8 @@ static void sci_transmit_chars(struct uart_port *port)
596static void sci_receive_chars(struct uart_port *port) 596static void sci_receive_chars(struct uart_port *port)
597{ 597{
598 struct sci_port *sci_port = to_sci_port(port); 598 struct sci_port *sci_port = to_sci_port(port);
599 struct tty_struct *tty = port->state->port.tty; 599 struct tty_port *tport = &port->state->port;
600 struct tty_struct *tty = tport->tty;
600 int i, count, copied = 0; 601 int i, count, copied = 0;
601 unsigned short status; 602 unsigned short status;
602 unsigned char flag; 603 unsigned char flag;
@@ -607,7 +608,7 @@ static void sci_receive_chars(struct uart_port *port)
607 608
608 while (1) { 609 while (1) {
609 /* Don't copy more bytes than there is room for in the buffer */ 610 /* Don't copy more bytes than there is room for in the buffer */
610 count = tty_buffer_request_room(tty, sci_rxfill(port)); 611 count = tty_buffer_request_room(tport, sci_rxfill(port));
611 612
612 /* If for any reason we can't copy more data, we're done! */ 613 /* If for any reason we can't copy more data, we're done! */
613 if (count == 0) 614 if (count == 0)
@@ -1263,9 +1264,10 @@ static int sci_dma_rx_push(struct sci_port *s, struct tty_struct *tty,
1263 size_t count) 1264 size_t count)
1264{ 1265{
1265 struct uart_port *port = &s->port; 1266 struct uart_port *port = &s->port;
1267 struct tty_port *tport = &port->state->port;
1266 int i, active, room; 1268 int i, active, room;
1267 1269
1268 room = tty_buffer_request_room(tty, count); 1270 room = tty_buffer_request_room(tport, count);
1269 1271
1270 if (s->active_rx == s->cookie_rx[0]) { 1272 if (s->active_rx == s->cookie_rx[0]) {
1271 active = 0; 1273 active = 0;
diff --git a/drivers/tty/serial/ucc_uart.c b/drivers/tty/serial/ucc_uart.c
index f99b0c965f85..ed047d9ab1e2 100644
--- a/drivers/tty/serial/ucc_uart.c
+++ b/drivers/tty/serial/ucc_uart.c
@@ -469,7 +469,8 @@ static void qe_uart_int_rx(struct uart_qe_port *qe_port)
469 int i; 469 int i;
470 unsigned char ch, *cp; 470 unsigned char ch, *cp;
471 struct uart_port *port = &qe_port->port; 471 struct uart_port *port = &qe_port->port;
472 struct tty_struct *tty = port->state->port.tty; 472 struct tty_port *tport = &port->state->port;
473 struct tty_struct *tty = tport->tty;
473 struct qe_bd *bdp; 474 struct qe_bd *bdp;
474 u16 status; 475 u16 status;
475 unsigned int flg; 476 unsigned int flg;
@@ -491,7 +492,7 @@ static void qe_uart_int_rx(struct uart_qe_port *qe_port)
491 /* If we don't have enough room in RX buffer for the entire BD, 492 /* If we don't have enough room in RX buffer for the entire BD,
492 * then we try later, which will be the next RX interrupt. 493 * then we try later, which will be the next RX interrupt.
493 */ 494 */
494 if (tty_buffer_request_room(tty, i) < i) { 495 if (tty_buffer_request_room(tport, i) < i) {
495 dev_dbg(port->dev, "ucc-uart: no room in RX buffer\n"); 496 dev_dbg(port->dev, "ucc-uart: no room in RX buffer\n");
496 return; 497 return;
497 } 498 }
diff --git a/drivers/tty/tty_buffer.c b/drivers/tty/tty_buffer.c
index 45d916198f78..f897332fb4ee 100644
--- a/drivers/tty/tty_buffer.c
+++ b/drivers/tty/tty_buffer.c
@@ -235,7 +235,7 @@ static int __tty_buffer_request_room(struct tty_port *port, size_t size)
235 235
236/** 236/**
237 * tty_buffer_request_room - grow tty buffer if needed 237 * tty_buffer_request_room - grow tty buffer if needed
238 * @tty: tty structure 238 * @port: tty port structure
239 * @size: size desired 239 * @size: size desired
240 * 240 *
241 * Make at least size bytes of linear space available for the tty 241 * Make at least size bytes of linear space available for the tty
@@ -243,9 +243,8 @@ static int __tty_buffer_request_room(struct tty_port *port, size_t size)
243 * 243 *
244 * Locking: Takes port->buf.lock 244 * Locking: Takes port->buf.lock
245 */ 245 */
246int tty_buffer_request_room(struct tty_struct *tty, size_t size) 246int tty_buffer_request_room(struct tty_port *port, size_t size)
247{ 247{
248 struct tty_port *port = tty->port;
249 unsigned long flags; 248 unsigned long flags;
250 int length; 249 int length;
251 250
diff --git a/drivers/usb/serial/quatech2.c b/drivers/usb/serial/quatech2.c
index d152be97d041..1e67fd89e346 100644
--- a/drivers/usb/serial/quatech2.c
+++ b/drivers/usb/serial/quatech2.c
@@ -697,7 +697,7 @@ void qt2_process_read_urb(struct urb *urb)
697 escapeflag = true; 697 escapeflag = true;
698 break; 698 break;
699 case QT2_CONTROL_ESCAPE: 699 case QT2_CONTROL_ESCAPE:
700 tty_buffer_request_room(tty, 2); 700 tty_buffer_request_room(&port->port, 2);
701 tty_insert_flip_string(tty, ch, 2); 701 tty_insert_flip_string(tty, ch, 2);
702 i += 2; 702 i += 2;
703 escapeflag = true; 703 escapeflag = true;
@@ -713,7 +713,7 @@ void qt2_process_read_urb(struct urb *urb)
713 } 713 }
714 714
715 if (tty) { 715 if (tty) {
716 tty_buffer_request_room(tty, 1); 716 tty_buffer_request_room(&port->port, 1);
717 tty_insert_flip_string(tty, ch, 1); 717 tty_insert_flip_string(tty, ch, 1);
718 } 718 }
719 } 719 }
diff --git a/include/linux/tty_flip.h b/include/linux/tty_flip.h
index 2002344ed36a..78207ca8fab1 100644
--- a/include/linux/tty_flip.h
+++ b/include/linux/tty_flip.h
@@ -1,7 +1,7 @@
1#ifndef _LINUX_TTY_FLIP_H 1#ifndef _LINUX_TTY_FLIP_H
2#define _LINUX_TTY_FLIP_H 2#define _LINUX_TTY_FLIP_H
3 3
4extern int tty_buffer_request_room(struct tty_struct *tty, size_t size); 4extern int tty_buffer_request_room(struct tty_port *port, size_t size);
5extern int tty_insert_flip_string_flags(struct tty_struct *tty, const unsigned char *chars, const char *flags, size_t size); 5extern int tty_insert_flip_string_flags(struct tty_struct *tty, const unsigned char *chars, const char *flags, size_t size);
6extern int tty_insert_flip_string_fixed_flag(struct tty_struct *tty, const unsigned char *chars, char flag, size_t size); 6extern int tty_insert_flip_string_fixed_flag(struct tty_struct *tty, const unsigned char *chars, char flag, size_t size);
7extern int tty_prepare_flip_string(struct tty_struct *tty, unsigned char **chars, size_t size); 7extern int tty_prepare_flip_string(struct tty_struct *tty, unsigned char **chars, size_t size);