TTY: switch tty_insert_flip_char

Now, we start converting tty buffer functions to actually use
tty_port. This will allow us to get rid of the need of tty in many
call sites. Only tty_port will needed and hence no more
tty_port_tty_get in those paths.

tty_insert_flip_char is the next one to proceed. This one is used all
over the code, so the patch is huge.

Signed-off-by: Jiri Slaby <jslaby@suse.cz>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
This commit is contained in:
Jiri Slaby
2013-01-03 15:53:03 +01:00
committed by Greg Kroah-Hartman
parent 2f69335710
commit 92a19f9cec
76 changed files with 297 additions and 286 deletions
+2 -1
View File
@@ -46,13 +46,14 @@ typedef union _srmcons_result {
static int static int
srmcons_do_receive_chars(struct tty_struct *tty) srmcons_do_receive_chars(struct tty_struct *tty)
{ {
struct tty_port *port = tty->port;
srmcons_result result; srmcons_result result;
int count = 0, loops = 0; int count = 0, loops = 0;
do { do {
result.as_long = callback_getc(0); result.as_long = callback_getc(0);
if (result.bits.status < 2) { if (result.bits.status < 2) {
tty_insert_flip_char(tty, (char)result.bits.c, 0); tty_insert_flip_char(port, (char)result.bits.c, 0);
count++; count++;
} }
} while((result.bits.status & 1) && (++loops < 10)); } while((result.bits.status & 1) && (++loops < 10));
+2 -1
View File
@@ -55,6 +55,7 @@ static struct console *console;
static void receive_chars(struct tty_struct *tty) static void receive_chars(struct tty_struct *tty)
{ {
struct tty_port *port = tty->port;
unsigned char ch; unsigned char ch;
static unsigned char seen_esc = 0; static unsigned char seen_esc = 0;
@@ -81,7 +82,7 @@ static void receive_chars(struct tty_struct *tty)
} }
seen_esc = 0; seen_esc = 0;
if (tty_insert_flip_char(tty, ch, TTY_NORMAL) == 0) if (tty_insert_flip_char(port, ch, TTY_NORMAL) == 0)
break; break;
} }
tty_flip_buffer_push(tty); tty_flip_buffer_push(tty);
+2 -2
View File
@@ -667,14 +667,14 @@ insert:
else else
flag = TTY_NORMAL; flag = TTY_NORMAL;
tty_insert_flip_char(tty, ch, flag); tty_insert_flip_char(port, ch, flag);
} }
/* overrun is special, since it's reported immediately, and doesn't /* overrun is special, since it's reported immediately, and doesn't
* affect the current character * affect the current character
*/ */
if (overrun) if (overrun)
tty_insert_flip_char(tty, 0, TTY_OVERRUN); tty_insert_flip_char(port, 0, TTY_OVERRUN);
count--; count--;
if (count <= 0) { if (count <= 0) {
+1 -1
View File
@@ -147,7 +147,7 @@ static void pdc_console_poll(unsigned long unused)
data = pdc_console_poll_key(NULL); data = pdc_console_poll_key(NULL);
if (data == -1) if (data == -1)
break; break;
tty_insert_flip_char(tty, data & 0xFF, TTY_NORMAL); tty_insert_flip_char(&tty_port, data & 0xFF, TTY_NORMAL);
count ++; count ++;
} }
+1 -7
View File
@@ -81,12 +81,6 @@ static const struct chan_ops not_configged_ops = {
}; };
#endif /* CONFIG_NOCONFIG_CHAN */ #endif /* CONFIG_NOCONFIG_CHAN */
static void tty_receive_char(struct tty_struct *tty, char ch)
{
if (tty)
tty_insert_flip_char(tty, ch, TTY_NORMAL);
}
static int open_one_chan(struct chan *chan) static int open_one_chan(struct chan *chan)
{ {
int fd, err; int fd, err;
@@ -569,7 +563,7 @@ void chan_interrupt(struct line *line, struct tty_struct *tty, int irq)
} }
err = chan->ops->read(chan->fd, &c, chan->data); err = chan->ops->read(chan->fd, &c, chan->data);
if (err > 0) if (err > 0)
tty_receive_char(tty, c); tty_insert_flip_char(port, c, TTY_NORMAL);
} while (err > 0); } while (err > 0);
if (err == 0) if (err == 0)
+2 -1
View File
@@ -98,6 +98,7 @@ static int rs_write(struct tty_struct * tty,
static void rs_poll(unsigned long priv) static void rs_poll(unsigned long priv)
{ {
struct tty_struct* tty = (struct tty_struct*) priv; struct tty_struct* tty = (struct tty_struct*) priv;
struct tty_port *port = tty->port;
struct timeval tv = { .tv_sec = 0, .tv_usec = 0 }; struct timeval tv = { .tv_sec = 0, .tv_usec = 0 };
int i = 0; int i = 0;
@@ -107,7 +108,7 @@ static void rs_poll(unsigned long priv)
while (__simc(SYS_select_one, 0, XTISS_SELECT_ONE_READ, (int)&tv,0,0)){ while (__simc(SYS_select_one, 0, XTISS_SELECT_ONE_READ, (int)&tv,0,0)){
__simc (SYS_read, 0, (unsigned long)&c, 1, 0, 0); __simc (SYS_read, 0, (unsigned long)&c, 1, 0, 0);
tty_insert_flip_char(tty, c, TTY_NORMAL); tty_insert_flip_char(port, c, TTY_NORMAL);
i++; i++;
} }
+1 -1
View File
@@ -945,7 +945,7 @@ static void rx_ready_async(MGSLPC_INFO *info, int tcd, struct tty_struct *tty)
else if (status & BIT6) else if (status & BIT6)
flag = TTY_FRAME; flag = TTY_FRAME;
} }
work += tty_insert_flip_char(tty, data, flag); work += tty_insert_flip_char(port, data, flag);
} }
issue_command(info, CHA, CMD_RXFIFO); issue_command(info, CHA, CMD_RXFIFO);
+3 -2
View File
@@ -136,6 +136,7 @@ static int ipoctal_get_icount(struct tty_struct *tty,
static void ipoctal_irq_rx(struct ipoctal_channel *channel, static void ipoctal_irq_rx(struct ipoctal_channel *channel,
struct tty_struct *tty, u8 sr) struct tty_struct *tty, u8 sr)
{ {
struct tty_port *port = &channel->tty_port;
unsigned char value; unsigned char value;
unsigned char flag = TTY_NORMAL; unsigned char flag = TTY_NORMAL;
u8 isr; u8 isr;
@@ -149,7 +150,7 @@ static void ipoctal_irq_rx(struct ipoctal_channel *channel,
if (sr & SR_OVERRUN_ERROR) { if (sr & SR_OVERRUN_ERROR) {
channel->stats.overrun_err++; channel->stats.overrun_err++;
/* Overrun doesn't affect the current character*/ /* Overrun doesn't affect the current character*/
tty_insert_flip_char(tty, 0, TTY_OVERRUN); tty_insert_flip_char(port, 0, TTY_OVERRUN);
} }
if (sr & SR_PARITY_ERROR) { if (sr & SR_PARITY_ERROR) {
channel->stats.parity_err++; channel->stats.parity_err++;
@@ -165,7 +166,7 @@ static void ipoctal_irq_rx(struct ipoctal_channel *channel,
flag = TTY_BREAK; flag = TTY_BREAK;
} }
} }
tty_insert_flip_char(tty, value, flag); tty_insert_flip_char(port, value, flag);
/* Check if there are more characters in RX FIFO /* Check if there are more characters in RX FIFO
* If there are more, the isr register for this channel * If there are more, the isr register for this channel
+4 -4
View File
@@ -913,7 +913,7 @@ isdn_readbchan_tty(int di, int channel, struct tty_struct *tty, int cisco_hack)
while ((count_pull < skb->len) && (len > 0)) { while ((count_pull < skb->len) && (len > 0)) {
/* push every character but the last to the tty buffer directly */ /* push every character but the last to the tty buffer directly */
if (count_put) if (count_put)
tty_insert_flip_char(tty, last, TTY_NORMAL); tty_insert_flip_char(port, last, TTY_NORMAL);
len--; len--;
if (dev->drv[di]->DLEflag & DLEmask) { if (dev->drv[di]->DLEflag & DLEmask) {
last = DLE; last = DLE;
@@ -953,16 +953,16 @@ isdn_readbchan_tty(int di, int channel, struct tty_struct *tty, int cisco_hack)
* Now we can dequeue it. * Now we can dequeue it.
*/ */
if (cisco_hack) if (cisco_hack)
tty_insert_flip_char(tty, last, 0xFF); tty_insert_flip_char(port, last, 0xFF);
else else
tty_insert_flip_char(tty, last, TTY_NORMAL); tty_insert_flip_char(port, last, TTY_NORMAL);
#ifdef CONFIG_ISDN_AUDIO #ifdef CONFIG_ISDN_AUDIO
ISDN_AUDIO_SKB_LOCK(skb) = 0; ISDN_AUDIO_SKB_LOCK(skb) = 0;
#endif #endif
skb = skb_dequeue(&dev->drv[di]->rpqueue[channel]); skb = skb_dequeue(&dev->drv[di]->rpqueue[channel]);
dev_kfree_skb(skb); dev_kfree_skb(skb);
} else { } else {
tty_insert_flip_char(tty, last, TTY_NORMAL); tty_insert_flip_char(port, last, TTY_NORMAL);
/* Not yet emptied this buff, so it /* Not yet emptied this buff, so it
* must stay in the queue, for further calls * must stay in the queue, for further calls
* but we pull off the data we got until now. * but we pull off the data we got until now.
+6 -6
View File
@@ -92,11 +92,11 @@ isdn_tty_try_read(modem_info *info, struct sk_buff *skb)
unsigned char *dp = skb->data; unsigned char *dp = skb->data;
while (--l) { while (--l) {
if (*dp == DLE) if (*dp == DLE)
tty_insert_flip_char(tty, DLE, 0); tty_insert_flip_char(port, DLE, 0);
tty_insert_flip_char(tty, *dp++, 0); tty_insert_flip_char(port, *dp++, 0);
} }
if (*dp == DLE) if (*dp == DLE)
tty_insert_flip_char(tty, DLE, 0); tty_insert_flip_char(port, DLE, 0);
last = *dp; last = *dp;
} else { } else {
#endif #endif
@@ -107,9 +107,9 @@ isdn_tty_try_read(modem_info *info, struct sk_buff *skb)
} }
#endif #endif
if (info->emu.mdmreg[REG_CPPP] & BIT_CPPP) if (info->emu.mdmreg[REG_CPPP] & BIT_CPPP)
tty_insert_flip_char(tty, last, 0xFF); tty_insert_flip_char(port, last, 0xFF);
else else
tty_insert_flip_char(tty, last, TTY_NORMAL); tty_insert_flip_char(port, last, TTY_NORMAL);
tty_flip_buffer_push(tty); tty_flip_buffer_push(tty);
kfree_skb(skb); kfree_skb(skb);
@@ -2287,7 +2287,7 @@ isdn_tty_at_cout(char *msg, modem_info *info)
if (skb) { if (skb) {
*sp++ = c; *sp++ = c;
} else { } else {
if (tty_insert_flip_char(tty, c, TTY_NORMAL) == 0) if (tty_insert_flip_char(port, c, TTY_NORMAL) == 0)
break; break;
} }
} }
+3 -2
View File
@@ -419,7 +419,7 @@ static void sdio_uart_receive_chars(struct sdio_uart_port *port,
if ((*status & port->ignore_status_mask & ~UART_LSR_OE) == 0) if ((*status & port->ignore_status_mask & ~UART_LSR_OE) == 0)
if (tty) if (tty)
tty_insert_flip_char(tty, ch, flag); tty_insert_flip_char(&port->port, ch, flag);
/* /*
* Overrun is special. Since it's reported immediately, * Overrun is special. Since it's reported immediately,
@@ -427,7 +427,8 @@ static void sdio_uart_receive_chars(struct sdio_uart_port *port,
*/ */
if (*status & ~port->ignore_status_mask & UART_LSR_OE) if (*status & ~port->ignore_status_mask & UART_LSR_OE)
if (tty) if (tty)
tty_insert_flip_char(tty, 0, TTY_OVERRUN); tty_insert_flip_char(&port->port, 0,
TTY_OVERRUN);
*status = sdio_in(port, UART_LSR); *status = sdio_in(port, UART_LSR);
} while ((*status & UART_LSR_DR) && (max_count-- > 0)); } while ((*status & UART_LSR_DR) && (max_count-- > 0));
+2 -1
View File
@@ -411,7 +411,8 @@ static void raw3215_irq(struct ccw_device *cdev, unsigned long intparm,
break; break;
case CTRLCHAR_CTRL: case CTRLCHAR_CTRL:
tty_insert_flip_char(tty, cchar, TTY_NORMAL); tty_insert_flip_char(&raw->port, cchar,
TTY_NORMAL);
tty_flip_buffer_push(tty); tty_flip_buffer_push(tty);
break; break;
+2 -2
View File
@@ -46,7 +46,7 @@ kbd_put_queue(struct tty_port *port, int ch)
struct tty_struct *tty = tty_port_tty_get(port); struct tty_struct *tty = tty_port_tty_get(port);
if (!tty) if (!tty)
return; return;
tty_insert_flip_char(tty, ch, 0); tty_insert_flip_char(port, ch, 0);
tty_schedule_flip(tty); tty_schedule_flip(tty);
tty_kref_put(tty); tty_kref_put(tty);
} }
@@ -58,7 +58,7 @@ kbd_puts_queue(struct tty_port *port, char *cp)
if (!tty) if (!tty)
return; return;
while (*cp) while (*cp)
tty_insert_flip_char(tty, *cp++, 0); tty_insert_flip_char(port, *cp++, 0);
tty_schedule_flip(tty); tty_schedule_flip(tty);
tty_kref_put(tty); tty_kref_put(tty);
} }
+2 -2
View File
@@ -342,7 +342,7 @@ sclp_tty_input(unsigned char* buf, unsigned int count)
case CTRLCHAR_SYSRQ: case CTRLCHAR_SYSRQ:
break; break;
case CTRLCHAR_CTRL: case CTRLCHAR_CTRL:
tty_insert_flip_char(tty, cchar, TTY_NORMAL); tty_insert_flip_char(&sclp_port, cchar, TTY_NORMAL);
tty_flip_buffer_push(tty); tty_flip_buffer_push(tty);
break; break;
case CTRLCHAR_NONE: case CTRLCHAR_NONE:
@@ -352,7 +352,7 @@ sclp_tty_input(unsigned char* buf, unsigned int count)
strncmp((const char *) buf + count - 2, "\252n", 2))) { strncmp((const char *) buf + count - 2, "\252n", 2))) {
/* add the auto \n */ /* add the auto \n */
tty_insert_flip_string(tty, buf, count); tty_insert_flip_string(tty, buf, count);
tty_insert_flip_char(tty, '\n', TTY_NORMAL); tty_insert_flip_char(&sclp_port, '\n', TTY_NORMAL);
} else } else
tty_insert_flip_string(tty, buf, count - 2); tty_insert_flip_string(tty, buf, count - 2);
tty_flip_buffer_push(tty); tty_flip_buffer_push(tty);
+1 -1
View File
@@ -2957,7 +2957,7 @@ check_query:
!(I_IGNBRK(ch->ch_tun.un_tty))) { !(I_IGNBRK(ch->ch_tun.un_tty))) {
tty_buffer_request_room(&ch->port, 1); tty_buffer_request_room(&ch->port, 1);
tty_insert_flip_char(ch->ch_tun.un_tty, 0, TTY_BREAK); tty_insert_flip_char(&ch->port, 0, TTY_BREAK);
tty_flip_buffer_push(ch->ch_tun.un_tty); tty_flip_buffer_push(ch->ch_tun.un_tty);
} }
+1 -1
View File
@@ -617,7 +617,7 @@ static int fwtty_rx(struct fwtty_port *port, unsigned char *data, size_t len)
lsr &= port->status_mask; lsr &= port->status_mask;
if (lsr & ~port->ignore_mask & UART_LSR_OE) { if (lsr & ~port->ignore_mask & UART_LSR_OE) {
if (!tty_insert_flip_char(tty, 0, TTY_OVERRUN)) { if (!tty_insert_flip_char(&port->port, 0, TTY_OVERRUN)) {
err = -EIO; err = -EIO;
goto out; goto out;
} }
+6 -7
View File
@@ -255,12 +255,11 @@ static void ProcessModemStatus(struct quatech_port *qt_port,
wake_up_interruptible(&qt_port->wait); wake_up_interruptible(&qt_port->wait);
} }
static void ProcessRxChar(struct tty_struct *tty, struct usb_serial_port *port, static void ProcessRxChar(struct usb_serial_port *port, unsigned char data)
unsigned char data)
{ {
struct urb *urb = port->read_urb; struct urb *urb = port->read_urb;
if (urb->actual_length) if (urb->actual_length)
tty_insert_flip_char(tty, data, TTY_NORMAL); tty_insert_flip_char(&port->port, data, TTY_NORMAL);
} }
static void qt_write_bulk_callback(struct urb *urb) static void qt_write_bulk_callback(struct urb *urb)
@@ -335,8 +334,8 @@ static void qt_status_change_check(struct tty_struct *tty,
case 0xff: case 0xff:
dev_dbg(&port->dev, "No status sequence.\n"); dev_dbg(&port->dev, "No status sequence.\n");
ProcessRxChar(tty, port, data[i]); ProcessRxChar(port, data[i]);
ProcessRxChar(tty, port, data[i + 1]); ProcessRxChar(port, data[i + 1]);
i += 2; i += 2;
break; break;
@@ -345,8 +344,8 @@ static void qt_status_change_check(struct tty_struct *tty,
continue; continue;
} }
if (tty && urb->actual_length) if (urb->actual_length)
tty_insert_flip_char(tty, data[i], TTY_NORMAL); tty_insert_flip_char(&port->port, data[i], TTY_NORMAL);
} }
tty_flip_buffer_push(tty); tty_flip_buffer_push(tty);
+2 -2
View File
@@ -328,9 +328,9 @@ static void receive_chars(struct serial_state *info)
oe = 1; oe = 1;
} }
} }
tty_insert_flip_char(tty, ch, flag); tty_insert_flip_char(&info->tport, ch, flag);
if (oe == 1) if (oe == 1)
tty_insert_flip_char(tty, 0, TTY_OVERRUN); tty_insert_flip_char(&info->tport, 0, TTY_OVERRUN);
tty_flip_buffer_push(tty); tty_flip_buffer_push(tty);
out: out:
return; return;
+12 -12
View File
@@ -492,34 +492,34 @@ static void cyy_chip_rx(struct cyclades_card *cinfo, int chip,
if (tty_buffer_request_room(port, 1)) { if (tty_buffer_request_room(port, 1)) {
if (data & info->read_status_mask) { if (data & info->read_status_mask) {
if (data & CyBREAK) { if (data & CyBREAK) {
tty_insert_flip_char(tty, tty_insert_flip_char(port,
cyy_readb(info, CyRDSR), cyy_readb(info, CyRDSR),
TTY_BREAK); TTY_BREAK);
info->icount.rx++; info->icount.rx++;
if (port->flags & ASYNC_SAK) if (port->flags & ASYNC_SAK)
do_SAK(tty); do_SAK(tty);
} else if (data & CyFRAME) { } else if (data & CyFRAME) {
tty_insert_flip_char(tty, tty_insert_flip_char(port,
cyy_readb(info, CyRDSR), cyy_readb(info, CyRDSR),
TTY_FRAME); TTY_FRAME);
info->icount.rx++; info->icount.rx++;
info->idle_stats.frame_errs++; info->idle_stats.frame_errs++;
} else if (data & CyPARITY) { } else if (data & CyPARITY) {
/* Pieces of seven... */ /* Pieces of seven... */
tty_insert_flip_char(tty, tty_insert_flip_char(port,
cyy_readb(info, CyRDSR), cyy_readb(info, CyRDSR),
TTY_PARITY); TTY_PARITY);
info->icount.rx++; info->icount.rx++;
info->idle_stats.parity_errs++; info->idle_stats.parity_errs++;
} else if (data & CyOVERRUN) { } else if (data & CyOVERRUN) {
tty_insert_flip_char(tty, 0, tty_insert_flip_char(port, 0,
TTY_OVERRUN); TTY_OVERRUN);
info->icount.rx++; info->icount.rx++;
/* If the flip buffer itself is /* If the flip buffer itself is
overflowing, we still lose overflowing, we still lose
the next incoming character. the next incoming character.
*/ */
tty_insert_flip_char(tty, tty_insert_flip_char(port,
cyy_readb(info, CyRDSR), cyy_readb(info, CyRDSR),
TTY_FRAME); TTY_FRAME);
info->icount.rx++; info->icount.rx++;
@@ -529,12 +529,12 @@ static void cyy_chip_rx(struct cyclades_card *cinfo, int chip,
/* } else if(data & CyTIMEOUT) { */ /* } else if(data & CyTIMEOUT) { */
/* } else if(data & CySPECHAR) { */ /* } else if(data & CySPECHAR) { */
} else { } else {
tty_insert_flip_char(tty, 0, tty_insert_flip_char(port, 0,
TTY_NORMAL); TTY_NORMAL);
info->icount.rx++; info->icount.rx++;
} }
} else { } else {
tty_insert_flip_char(tty, 0, TTY_NORMAL); tty_insert_flip_char(port, 0, TTY_NORMAL);
info->icount.rx++; info->icount.rx++;
} }
} else { } else {
@@ -557,7 +557,7 @@ static void cyy_chip_rx(struct cyclades_card *cinfo, int chip,
len = tty_buffer_request_room(port, char_count); len = tty_buffer_request_room(port, char_count);
while (len--) { while (len--) {
data = cyy_readb(info, CyRDSR); data = cyy_readb(info, CyRDSR);
tty_insert_flip_char(tty, data, TTY_NORMAL); tty_insert_flip_char(port, data, TTY_NORMAL);
info->idle_stats.recv_bytes++; info->idle_stats.recv_bytes++;
info->icount.rx++; info->icount.rx++;
#ifdef CY_16Y_HACK #ifdef CY_16Y_HACK
@@ -992,7 +992,7 @@ static void cyz_handle_rx(struct cyclades_port *info, struct tty_struct *tty)
new_rx_get); new_rx_get);
new_rx_get = (new_rx_get + 1) & new_rx_get = (new_rx_get + 1) &
(rx_bufsize - 1); (rx_bufsize - 1);
tty_insert_flip_char(tty, data, TTY_NORMAL); tty_insert_flip_char(port, data, TTY_NORMAL);
info->idle_stats.recv_bytes++; info->idle_stats.recv_bytes++;
info->icount.rx++; info->icount.rx++;
} }
@@ -1117,17 +1117,17 @@ static void cyz_handle_cmd(struct cyclades_card *cinfo)
switch (cmd) { switch (cmd) {
case C_CM_PR_ERROR: case C_CM_PR_ERROR:
tty_insert_flip_char(tty, 0, TTY_PARITY); tty_insert_flip_char(&info->port, 0, TTY_PARITY);
info->icount.rx++; info->icount.rx++;
special_count++; special_count++;
break; break;
case C_CM_FR_ERROR: case C_CM_FR_ERROR:
tty_insert_flip_char(tty, 0, TTY_FRAME); tty_insert_flip_char(&info->port, 0, TTY_FRAME);
info->icount.rx++; info->icount.rx++;
special_count++; special_count++;
break; break;
case C_CM_RXBRK: case C_CM_RXBRK:
tty_insert_flip_char(tty, 0, TTY_BREAK); tty_insert_flip_char(&info->port, 0, TTY_BREAK);
info->icount.rx++; info->icount.rx++;
special_count++; special_count++;
break; break;
+1 -1
View File
@@ -672,7 +672,7 @@ int hvc_poll(struct hvc_struct *hp)
} }
} }
#endif /* CONFIG_MAGIC_SYSRQ */ #endif /* CONFIG_MAGIC_SYSRQ */
tty_insert_flip_char(tty, buf[i], 0); tty_insert_flip_char(&hp->port, buf[i], 0);
} }
read_total += n; read_total += n;

Some files were not shown because too many files have changed in this diff Show More