From 2e124b4a390ca85325fae75764bef92f0547fa25 Mon Sep 17 00:00:00 2001 From: Jiri Slaby Date: Thu, 3 Jan 2013 15:53:06 +0100 Subject: TTY: switch tty_flip_buffer_push Now, we start converting tty buffer functions to actually use tty_port. This will allow us to get rid of the need of tty in many call sites. Only tty_port will needed and hence no more tty_port_tty_get in those paths. Now, the one where most of tty_port_tty_get gets removed: tty_flip_buffer_push. IOW we also closed all the races in drivers not using tty_port_tty_get at all yet. Also we move tty_flip_buffer_push declaration from include/linux/tty.h to include/linux/tty_flip.h to all others while we are changing it anyway. Signed-off-by: Jiri Slaby Signed-off-by: Greg Kroah-Hartman --- arch/ia64/hp/sim/simserial.c | 18 ++------- arch/mn10300/kernel/mn10300-serial.c | 7 ++-- arch/parisc/kernel/pdc_cons.c | 8 +--- arch/um/drivers/chan.h | 3 +- arch/um/drivers/chan_kern.c | 14 +++---- arch/um/drivers/line.c | 7 ++-- arch/xtensa/platforms/iss/console.c | 9 ++--- drivers/char/pcmcia/synclink_cs.c | 14 ++----- drivers/ipack/devices/ipoctal.c | 14 ++----- drivers/isdn/gigaset/interface.c | 10 +---- drivers/isdn/i4l/isdn_tty.c | 39 ++++++++----------- drivers/mmc/card/sdio_uart.c | 14 ++----- drivers/net/usb/hso.c | 31 ++++++++------- drivers/s390/char/con3215.c | 4 +- drivers/s390/char/sclp_tty.c | 4 +- drivers/s390/char/sclp_vt220.c | 8 +--- drivers/staging/ccg/u_serial.c | 11 ++---- drivers/staging/dgrp/dgrp_net_ops.c | 4 +- drivers/staging/fwserial/fwserial.c | 41 ++++++++------------ drivers/staging/serqt_usb2/serqt_usb2.c | 9 ++--- drivers/tty/amiserial.c | 5 +-- drivers/tty/bfin_jtag_comm.c | 22 +++++------ drivers/tty/ehv_bytechan.c | 9 +---- drivers/tty/hvc/hvc_console.c | 2 +- drivers/tty/hvc/hvcs.c | 2 +- drivers/tty/hvc/hvsi.c | 6 +-- drivers/tty/ipwireless/tty.c | 8 +--- drivers/tty/isicom.c | 4 +- drivers/tty/mxser.c | 2 +- drivers/tty/n_gsm.c | 58 ++++++++++++++--------------- drivers/tty/nozomi.c | 14 +++---- drivers/tty/pty.c | 2 +- drivers/tty/rocket.c | 25 ++++++------- drivers/tty/serial/21285.c | 3 +- drivers/tty/serial/8250/8250.c | 3 +- drivers/tty/serial/altera_jtaguart.c | 2 +- drivers/tty/serial/altera_uart.c | 2 +- drivers/tty/serial/amba-pl010.c | 3 +- drivers/tty/serial/amba-pl011.c | 7 +--- drivers/tty/serial/apbuart.c | 3 +- drivers/tty/serial/ar933x_uart.c | 7 +--- drivers/tty/serial/arc_uart.c | 8 +--- drivers/tty/serial/atmel_serial.c | 5 +-- drivers/tty/serial/bcm63xx_uart.c | 4 +- drivers/tty/serial/bfin_sport_uart.c | 4 +- drivers/tty/serial/bfin_uart.c | 10 ++--- drivers/tty/serial/clps711x.c | 8 +--- drivers/tty/serial/cpm_uart/cpm_uart_core.c | 3 +- drivers/tty/serial/crisv10.c | 17 +-------- drivers/tty/serial/dz.c | 4 +- drivers/tty/serial/efm32-uart.c | 8 +--- drivers/tty/serial/icom.c | 3 +- drivers/tty/serial/ifx6x60.c | 6 +-- drivers/tty/serial/imx.c | 3 +- drivers/tty/serial/ioc3_serial.c | 6 +-- drivers/tty/serial/ioc4_serial.c | 6 +-- drivers/tty/serial/jsm/jsm_tty.c | 2 +- drivers/tty/serial/kgdb_nmi.c | 10 +---- drivers/tty/serial/lantiq.c | 15 +++----- drivers/tty/serial/lpc32xx_hs.c | 16 +------- drivers/tty/serial/m32r_sio.c | 3 +- drivers/tty/serial/max3100.c | 8 ++-- drivers/tty/serial/max310x.c | 8 +--- drivers/tty/serial/mcf.c | 2 +- drivers/tty/serial/mfd.c | 12 +----- drivers/tty/serial/mpc52xx_uart.c | 3 +- drivers/tty/serial/mpsc.c | 5 +-- drivers/tty/serial/mrst_max3110.c | 11 +----- drivers/tty/serial/msm_serial.c | 6 +-- drivers/tty/serial/msm_serial_hs.c | 3 +- drivers/tty/serial/msm_smd_tty.c | 2 +- drivers/tty/serial/mux.c | 6 +-- drivers/tty/serial/mxs-auart.c | 6 +-- drivers/tty/serial/netx-serial.c | 4 +- drivers/tty/serial/nwpserial.c | 3 +- drivers/tty/serial/omap-serial.c | 3 +- drivers/tty/serial/pch_uart.c | 19 +--------- drivers/tty/serial/pmac_zilog.c | 30 +++++++-------- drivers/tty/serial/pnx8xxx_uart.c | 3 +- drivers/tty/serial/pxa.c | 3 +- drivers/tty/serial/sa1100.c | 3 +- drivers/tty/serial/samsung.c | 3 +- drivers/tty/serial/sb1250-duart.c | 2 +- drivers/tty/serial/sc26xx.c | 27 ++++++-------- drivers/tty/serial/sccnxp.c | 8 +--- drivers/tty/serial/serial_ks8695.c | 3 +- drivers/tty/serial/serial_txx9.c | 3 +- drivers/tty/serial/sh-sci.c | 18 +++------ drivers/tty/serial/sirfsoc_uart.c | 8 +--- drivers/tty/serial/sn_console.c | 12 ++---- drivers/tty/serial/sunhv.c | 16 ++++---- drivers/tty/serial/sunsab.c | 20 ++++------ drivers/tty/serial/sunsu.c | 13 ++----- drivers/tty/serial/sunzilog.c | 28 ++++++-------- drivers/tty/serial/timbuart.c | 2 +- drivers/tty/serial/uartlite.c | 2 +- drivers/tty/serial/ucc_uart.c | 3 +- drivers/tty/serial/vr41xx_siu.c | 4 +- drivers/tty/serial/vt8500_serial.c | 12 +----- drivers/tty/serial/xilinx_uartps.c | 14 ++----- drivers/tty/serial/zs.c | 2 +- drivers/tty/synclink.c | 5 +-- drivers/tty/synclink_gt.c | 5 +-- drivers/tty/synclinkmp.c | 4 +- drivers/tty/tty_buffer.c | 8 ++-- drivers/usb/class/cdc-acm.c | 10 +---- drivers/usb/gadget/u_serial.c | 4 +- drivers/usb/serial/aircable.c | 8 +--- drivers/usb/serial/ark3116.c | 8 +--- drivers/usb/serial/belkin_sa.c | 8 +--- drivers/usb/serial/cyberjack.c | 9 +---- drivers/usb/serial/cypress_m8.c | 4 +- drivers/usb/serial/digi_acceleport.c | 8 +--- drivers/usb/serial/f81232.c | 8 +--- drivers/usb/serial/ftdi_sio.c | 8 +--- drivers/usb/serial/garmin_gps.c | 7 +--- drivers/usb/serial/generic.c | 8 +--- drivers/usb/serial/io_edgeport.c | 35 +++++++---------- drivers/usb/serial/io_ti.c | 27 +++++--------- drivers/usb/serial/ir-usb.c | 7 +--- drivers/usb/serial/iuu_phoenix.c | 7 +--- drivers/usb/serial/keyspan.c | 31 ++++----------- drivers/usb/serial/keyspan_pda.c | 7 +--- drivers/usb/serial/kl5kusb105.c | 8 +--- drivers/usb/serial/kobil_sct.c | 7 +--- drivers/usb/serial/mct_u232.c | 11 ++---- drivers/usb/serial/metro-usb.c | 7 +--- drivers/usb/serial/mos7720.c | 7 +--- drivers/usb/serial/mos7840.c | 9 +---- drivers/usb/serial/navman.c | 7 +--- drivers/usb/serial/omninet.c | 11 ++---- drivers/usb/serial/opticon.c | 9 +---- drivers/usb/serial/oti6858.c | 7 +--- drivers/usb/serial/pl2303.c | 8 +--- drivers/usb/serial/quatech2.c | 19 +--------- drivers/usb/serial/safe_serial.c | 13 ++----- drivers/usb/serial/sierra.c | 17 +++------ drivers/usb/serial/spcp8x5.c | 18 ++++----- drivers/usb/serial/ssu100.c | 23 ++---------- drivers/usb/serial/symbolserial.c | 10 +---- drivers/usb/serial/ti_usb_3410_5052.c | 39 ++++++++----------- drivers/usb/serial/usb_wwan.c | 17 +++------ include/linux/tty.h | 1 - include/linux/tty_flip.h | 1 + net/bluetooth/rfcomm/tty.c | 16 +++----- net/irda/ircomm/ircomm_tty.c | 4 +- 146 files changed, 446 insertions(+), 988 deletions(-) diff --git a/arch/ia64/hp/sim/simserial.c b/arch/ia64/hp/sim/simserial.c index 942022a5bc86..da2f319fb71d 100644 --- a/arch/ia64/hp/sim/simserial.c +++ b/arch/ia64/hp/sim/simserial.c @@ -53,9 +53,8 @@ struct tty_driver *hp_simserial_driver; static struct console *console; -static void receive_chars(struct tty_struct *tty) +static void receive_chars(struct tty_port *port) { - struct tty_port *port = tty->port; unsigned char ch; static unsigned char seen_esc = 0; @@ -85,7 +84,7 @@ static void receive_chars(struct tty_struct *tty) if (tty_insert_flip_char(port, ch, TTY_NORMAL) == 0) break; } - tty_flip_buffer_push(tty); + tty_flip_buffer_push(port); } /* @@ -94,18 +93,9 @@ static void receive_chars(struct tty_struct *tty) static irqreturn_t rs_interrupt_single(int irq, void *dev_id) { struct serial_state *info = dev_id; - struct tty_struct *tty = tty_port_tty_get(&info->port); - if (!tty) { - printk(KERN_INFO "%s: tty=0 problem\n", __func__); - return IRQ_NONE; - } - /* - * pretty simple in our case, because we only get interrupts - * on inbound traffic - */ - receive_chars(tty); - tty_kref_put(tty); + receive_chars(&info->port); + return IRQ_HANDLED; } diff --git a/arch/mn10300/kernel/mn10300-serial.c b/arch/mn10300/kernel/mn10300-serial.c index ae61bd692b4b..1dd20dbfd098 100644 --- a/arch/mn10300/kernel/mn10300-serial.c +++ b/arch/mn10300/kernel/mn10300-serial.c @@ -525,7 +525,6 @@ static void mn10300_serial_receive_interrupt(struct mn10300_serial_port *port) { struct uart_icount *icount = &port->uart.icount; struct tty_port *port = &port->uart.state->port; - struct tty_struct *tty = port->tty; unsigned ix; int count; u8 st, ch, push, status, overrun; @@ -538,7 +537,7 @@ static void mn10300_serial_receive_interrupt(struct mn10300_serial_port *port) count = tty_buffer_request_room(port, count); if (count == 0) { if (!port->low_latency) - tty_flip_buffer_push(tty); + tty_flip_buffer_push(port); return; } @@ -547,7 +546,7 @@ try_again: ix = ACCESS_ONCE(port->rx_outp); if (CIRC_CNT(port->rx_inp, ix, MNSC_BUFFER_SIZE) == 0) { if (push && !port->low_latency) - tty_flip_buffer_push(tty); + tty_flip_buffer_push(port); return; } @@ -679,7 +678,7 @@ insert: count--; if (count <= 0) { if (!port->low_latency) - tty_flip_buffer_push(tty); + tty_flip_buffer_push(port); return; } diff --git a/arch/parisc/kernel/pdc_cons.c b/arch/parisc/kernel/pdc_cons.c index 4d92a379eb21..d5cae55195ec 100644 --- a/arch/parisc/kernel/pdc_cons.c +++ b/arch/parisc/kernel/pdc_cons.c @@ -138,10 +138,6 @@ static const struct tty_operations pdc_console_tty_ops = { static void pdc_console_poll(unsigned long unused) { int data, count = 0; - struct tty_struct *tty = tty_port_tty_get(&tty_port); - - if (!tty) - return; while (1) { data = pdc_console_poll_key(NULL); @@ -152,9 +148,7 @@ static void pdc_console_poll(unsigned long unused) } if (count) - tty_flip_buffer_push(tty); - - tty_kref_put(tty); + tty_flip_buffer_push(&tty_port); if (pdc_cons.flags & CON_ENABLED) mod_timer(&pdc_console_timer, jiffies + PDC_CONS_POLL_DELAY); diff --git a/arch/um/drivers/chan.h b/arch/um/drivers/chan.h index 02b5a76e98d9..78f1b8999964 100644 --- a/arch/um/drivers/chan.h +++ b/arch/um/drivers/chan.h @@ -27,8 +27,7 @@ struct chan { void *data; }; -extern void chan_interrupt(struct line *line, - struct tty_struct *tty, int irq); +extern void chan_interrupt(struct line *line, int irq); extern int parse_chan_pair(char *str, struct line *line, int device, const struct chan_opts *opts, char **error_out); extern int write_chan(struct chan *chan, const char *buf, int len, diff --git a/arch/um/drivers/chan_kern.c b/arch/um/drivers/chan_kern.c index 795bd8102205..15c553c239a1 100644 --- a/arch/um/drivers/chan_kern.c +++ b/arch/um/drivers/chan_kern.c @@ -131,11 +131,9 @@ void chan_enable_winch(struct chan *chan, struct tty_struct *tty) static void line_timer_cb(struct work_struct *work) { struct line *line = container_of(work, struct line, task.work); - struct tty_struct *tty = tty_port_tty_get(&line->port); if (!line->throttled) - chan_interrupt(line, tty, line->driver->read_irq); - tty_kref_put(tty); + chan_interrupt(line, line->driver->read_irq); } int enable_chan(struct line *line) @@ -546,7 +544,7 @@ int parse_chan_pair(char *str, struct line *line, int device, return 0; } -void chan_interrupt(struct line *line, struct tty_struct *tty, int irq) +void chan_interrupt(struct line *line, int irq) { struct tty_port *port = &line->port; struct chan *chan = line->chan_in; @@ -570,8 +568,11 @@ void chan_interrupt(struct line *line, struct tty_struct *tty, int irq) reactivate_fd(chan->fd, irq); if (err == -EIO) { if (chan->primary) { - if (tty != NULL) + struct tty_struct *tty = tty_port_tty_get(&line->port); + if (tty != NULL) { tty_hangup(tty); + tty_kref_put(tty); + } if (line->chan_out != chan) close_one_chan(line->chan_out, 1); } @@ -580,6 +581,5 @@ void chan_interrupt(struct line *line, struct tty_struct *tty, int irq) return; } out: - if (tty) - tty_flip_buffer_push(tty); + tty_flip_buffer_push(port); } diff --git a/arch/um/drivers/line.c b/arch/um/drivers/line.c index 9ffc28bd4b7a..f1b38571f94e 100644 --- a/arch/um/drivers/line.c +++ b/arch/um/drivers/line.c @@ -19,11 +19,10 @@ static irqreturn_t line_interrupt(int irq, void *data) { struct chan *chan = data; struct line *line = chan->line; - struct tty_struct *tty = tty_port_tty_get(&line->port); if (line) - chan_interrupt(line, tty, irq); - tty_kref_put(tty); + chan_interrupt(line, irq); + return IRQ_HANDLED; } @@ -234,7 +233,7 @@ void line_unthrottle(struct tty_struct *tty) struct line *line = tty->driver_data; line->throttled = 0; - chan_interrupt(line, tty, line->driver->read_irq); + chan_interrupt(line, line->driver->read_irq); /* * Maybe there is enough stuff pending that calling the interrupt diff --git a/arch/xtensa/platforms/iss/console.c b/arch/xtensa/platforms/iss/console.c index 62447d63890c..da9866f7fecf 100644 --- a/arch/xtensa/platforms/iss/console.c +++ b/arch/xtensa/platforms/iss/console.c @@ -58,7 +58,8 @@ static int rs_open(struct tty_struct *tty, struct file * filp) tty->port = &serial_port; spin_lock(&timer_lock); if (tty->count == 1) { - setup_timer(&serial_timer, rs_poll, (unsigned long)tty); + setup_timer(&serial_timer, rs_poll, + (unsigned long)&serial_port); mod_timer(&serial_timer, jiffies + SERIAL_TIMER_VALUE); } spin_unlock(&timer_lock); @@ -97,9 +98,7 @@ static int rs_write(struct tty_struct * tty, static void rs_poll(unsigned long priv) { - struct tty_struct* tty = (struct tty_struct*) priv; - struct tty_port *port = tty->port; - + struct tty_port *port = (struct tty_port *)priv; struct timeval tv = { .tv_sec = 0, .tv_usec = 0 }; int i = 0; unsigned char c; @@ -113,7 +112,7 @@ static void rs_poll(unsigned long priv) } if (i) - tty_flip_buffer_push(tty); + tty_flip_buffer_push(port); mod_timer(&serial_timer, jiffies + SERIAL_TIMER_VALUE); diff --git a/drivers/char/pcmcia/synclink_cs.c b/drivers/char/pcmcia/synclink_cs.c index 92dc7327c7aa..f334aec65fc7 100644 --- a/drivers/char/pcmcia/synclink_cs.c +++ b/drivers/char/pcmcia/synclink_cs.c @@ -886,7 +886,7 @@ static void rx_ready_hdlc(MGSLPC_INFO *info, int eom) issue_command(info, CHA, CMD_RXFIFO); } -static void rx_ready_async(MGSLPC_INFO *info, int tcd, struct tty_struct *tty) +static void rx_ready_async(MGSLPC_INFO *info, int tcd) { struct tty_port *port = &info->port; unsigned char data, status, flag; @@ -894,14 +894,6 @@ static void rx_ready_async(MGSLPC_INFO *info, int tcd, struct tty_struct *tty) int work = 0; struct mgsl_icount *icount = &info->icount; - if (!tty) { - /* tty is not available anymore */ - issue_command(info, CHA, CMD_RXRESET); - if (debug_level >= DEBUG_LEVEL_ISR) - printk("%s(%d):rx_ready_async(tty=NULL)\n",__FILE__,__LINE__); - return; - } - if (tcd) { /* early termination, get FIFO count from RBCL register */ fifo_count = (unsigned char)(read_reg(info, CHA+RBCL) & 0x1f); @@ -958,7 +950,7 @@ static void rx_ready_async(MGSLPC_INFO *info, int tcd, struct tty_struct *tty) } if (work) - tty_flip_buffer_push(tty); + tty_flip_buffer_push(port); } @@ -1218,7 +1210,7 @@ static irqreturn_t mgslpc_isr(int dummy, void *dev_id) if (info->params.mode == MGSL_MODE_HDLC) rx_ready_hdlc(info, isr & IRQ_RXEOM); else - rx_ready_async(info, isr & IRQ_RXEOM, tty); + rx_ready_async(info, isr & IRQ_RXEOM); } /* transmit IRQs */ diff --git a/drivers/ipack/devices/ipoctal.c b/drivers/ipack/devices/ipoctal.c index 8e0ed663ba9b..ab20a0851dd2 100644 --- a/drivers/ipack/devices/ipoctal.c +++ b/drivers/ipack/devices/ipoctal.c @@ -133,8 +133,7 @@ static int ipoctal_get_icount(struct tty_struct *tty, return 0; } -static void ipoctal_irq_rx(struct ipoctal_channel *channel, - struct tty_struct *tty, u8 sr) +static void ipoctal_irq_rx(struct ipoctal_channel *channel, u8 sr) { struct tty_port *port = &channel->tty_port; unsigned char value; @@ -176,7 +175,7 @@ static void ipoctal_irq_rx(struct ipoctal_channel *channel, sr = ioread8(&channel->regs->r.sr); } while (isr & channel->isr_rx_rdy_mask); - tty_flip_buffer_push(tty); + tty_flip_buffer_push(port); } static void ipoctal_irq_tx(struct ipoctal_channel *channel) @@ -209,15 +208,11 @@ static void ipoctal_irq_tx(struct ipoctal_channel *channel) static void ipoctal_irq_channel(struct ipoctal_channel *channel) { u8 isr, sr; - struct tty_struct *tty; /* If there is no client, skip the check */ if (!atomic_read(&channel->open)) return; - tty = tty_port_tty_get(&channel->tty_port); - if (!tty) - return; /* The HW is organized in pair of channels. See which register we need * to read from */ isr = ioread8(&channel->block_regs->r.isr); @@ -236,14 +231,13 @@ static void ipoctal_irq_channel(struct ipoctal_channel *channel) /* RX data */ if ((isr & channel->isr_rx_rdy_mask) && (sr & SR_RX_READY)) - ipoctal_irq_rx(channel, tty, sr); + ipoctal_irq_rx(channel, sr); /* TX of each character */ if ((isr & channel->isr_tx_rdy_mask) && (sr & SR_TX_READY)) ipoctal_irq_tx(channel); - tty_flip_buffer_push(tty); - tty_kref_put(tty); + tty_flip_buffer_push(&channel->tty_port); } static irqreturn_t ipoctal_irq_handler(void *arg) diff --git a/drivers/isdn/gigaset/interface.c b/drivers/isdn/gigaset/interface.c index 6dcecd40a819..0fbf4f215d86 100644 --- a/drivers/isdn/gigaset/interface.c +++ b/drivers/isdn/gigaset/interface.c @@ -562,16 +562,8 @@ void gigaset_if_free(struct cardstate *cs) void gigaset_if_receive(struct cardstate *cs, unsigned char *buffer, size_t len) { - struct tty_struct *tty = tty_port_tty_get(&cs->port); - - if (tty == NULL) { - gig_dbg(DEBUG_IF, "receive on closed device"); - return; - } - tty_insert_flip_string(&cs->port, buffer, len); - tty_flip_buffer_push(tty); - tty_kref_put(tty); + tty_flip_buffer_push(&cs->port); } EXPORT_SYMBOL_GPL(gigaset_if_receive); diff --git a/drivers/isdn/i4l/isdn_tty.c b/drivers/isdn/i4l/isdn_tty.c index 9bb9986659e4..d8a7d8323414 100644 --- a/drivers/isdn/i4l/isdn_tty.c +++ b/drivers/isdn/i4l/isdn_tty.c @@ -63,16 +63,11 @@ isdn_tty_try_read(modem_info *info, struct sk_buff *skb) struct tty_port *port = &info->port; int c; int len; - struct tty_struct *tty; char last; if (!info->online) return 0; - tty = port->tty; - if (!tty) - return 0; - if (!(info->mcr & UART_MCR_RTS)) return 0; @@ -110,7 +105,7 @@ isdn_tty_try_read(modem_info *info, struct sk_buff *skb) tty_insert_flip_char(port, last, 0xFF); else tty_insert_flip_char(port, last, TTY_NORMAL); - tty_flip_buffer_push(tty); + tty_flip_buffer_push(port); kfree_skb(skb); return 1; @@ -127,7 +122,6 @@ isdn_tty_readmodem(void) int midx; int i; int r; - struct tty_struct *tty; modem_info *info; for (i = 0; i < ISDN_MAX_CHANNELS; i++) { @@ -145,20 +139,21 @@ isdn_tty_readmodem(void) if ((info->vonline & 1) && (info->emu.vpar[1])) isdn_audio_eval_silence(info); #endif - tty = info->port.tty; - if (tty) { - if (info->mcr & UART_MCR_RTS) { - /* CISCO AsyncPPP Hack */ - if (!(info->emu.mdmreg[REG_CPPP] & BIT_CPPP)) - r = isdn_readbchan_tty(info->isdn_driver, info->isdn_channel, &info->port, 0); - else - r = isdn_readbchan_tty(info->isdn_driver, info->isdn_channel, &info->port, 1); - if (r) - tty_flip_buffer_push(tty); - } else - r = 1; + if (info->mcr & UART_MCR_RTS) { + /* CISCO AsyncPPP Hack */ + if (!(info->emu.mdmreg[REG_CPPP] & BIT_CPPP)) + r = isdn_readbchan_tty(info->isdn_driver, + info->isdn_channel, + &info->port, 0); + else + r = isdn_readbchan_tty(info->isdn_driver, + info->isdn_channel, + &info->port, 1); + if (r) + tty_flip_buffer_push(&info->port); } else r = 1; + if (r) { info->rcvsched = 0; resched = 1; @@ -2230,7 +2225,6 @@ isdn_tty_stat_callback(int i, isdn_ctrl *c) void isdn_tty_at_cout(char *msg, modem_info *info) { - struct tty_struct *tty; struct tty_port *port = &info->port; atemu *m = &info->emu; char *p; @@ -2248,8 +2242,7 @@ isdn_tty_at_cout(char *msg, modem_info *info) l = strlen(msg); spin_lock_irqsave(&info->readlock, flags); - tty = port->tty; - if ((port->flags & ASYNC_CLOSING) || (!tty)) { + if (port->flags & ASYNC_CLOSING) { spin_unlock_irqrestore(&info->readlock, flags); return; } @@ -2301,7 +2294,7 @@ isdn_tty_at_cout(char *msg, modem_info *info) } else { spin_unlock_irqrestore(&info->readlock, flags); - tty_flip_buffer_push(tty); + tty_flip_buffer_push(port); } } diff --git a/drivers/mmc/card/sdio_uart.c b/drivers/mmc/card/sdio_uart.c index 894078be0b96..c931dfe6a59c 100644 --- a/drivers/mmc/card/sdio_uart.c +++ b/drivers/mmc/card/sdio_uart.c @@ -381,7 +381,6 @@ static void sdio_uart_stop_rx(struct sdio_uart_port *port) static void sdio_uart_receive_chars(struct sdio_uart_port *port, unsigned int *status) { - struct tty_struct *tty = tty_port_tty_get(&port->port); unsigned int ch, flag; int max_count = 256; @@ -418,24 +417,19 @@ static void sdio_uart_receive_chars(struct sdio_uart_port *port, } if ((*status & port->ignore_status_mask & ~UART_LSR_OE) == 0) - if (tty) - tty_insert_flip_char(&port->port, ch, flag); + tty_insert_flip_char(&port->port, ch, flag); /* * Overrun is special. Since it's reported immediately, * it doesn't affect the current character. */ if (*status & ~port->ignore_status_mask & UART_LSR_OE) - if (tty) - tty_insert_flip_char(&port->port, 0, - TTY_OVERRUN); + tty_insert_flip_char(&port->port, 0, TTY_OVERRUN); *status = sdio_in(port, UART_LSR); } while ((*status & UART_LSR_DR) && (max_count-- > 0)); - if (tty) { - tty_flip_buffer_push(tty); - tty_kref_put(tty); - } + + tty_flip_buffer_push(&port->port); } static void sdio_uart_transmit_chars(struct sdio_uart_port *port) diff --git a/drivers/net/usb/hso.c b/drivers/net/usb/hso.c index d235ca07548f..f902a14da88c 100644 --- a/drivers/net/usb/hso.c +++ b/drivers/net/usb/hso.c @@ -2035,24 +2035,23 @@ static int put_rxbuf_data(struct urb *urb, struct hso_serial *serial) tty = tty_port_tty_get(&serial->port); /* Push data to tty */ - if (tty) { - write_length_remaining = urb->actual_length - - serial->curr_rx_urb_offset; - D1("data to push to tty"); - while (write_length_remaining) { - if (test_bit(TTY_THROTTLED, &tty->flags)) { - tty_kref_put(tty); - return -1; - } - curr_write_len = tty_insert_flip_string(&serial->port, - urb->transfer_buffer + serial->curr_rx_urb_offset, - write_length_remaining); - serial->curr_rx_urb_offset += curr_write_len; - write_length_remaining -= curr_write_len; - tty_flip_buffer_push(tty); + write_length_remaining = urb->actual_length - + serial->curr_rx_urb_offset; + D1("data to push to tty"); + while (write_length_remaining) { + if (tty && test_bit(TTY_THROTTLED, &tty->flags)) { + tty_kref_put(tty); + return -1; } - tty_kref_put(tty); + curr_write_len = tty_insert_flip_string(&serial->port, + urb->transfer_buffer + serial->curr_rx_urb_offset, + write_length_remaining); + serial->curr_rx_urb_offset += curr_write_len; + write_length_remaining -= curr_write_len; + tty_flip_buffer_push(&serial->port); } + tty_kref_put(tty); + if (write_length_remaining == 0) { serial->curr_rx_urb_offset = 0; serial->rx_urb_filled[hso_urb_to_index(serial, urb)] = 0; diff --git a/drivers/s390/char/con3215.c b/drivers/s390/char/con3215.c index 41b75c5ae0d5..2f58e9fde156 100644 --- a/drivers/s390/char/con3215.c +++ b/drivers/s390/char/con3215.c @@ -413,7 +413,7 @@ static void raw3215_irq(struct ccw_device *cdev, unsigned long intparm, case CTRLCHAR_CTRL: tty_insert_flip_char(&raw->port, cchar, TTY_NORMAL); - tty_flip_buffer_push(tty); + tty_flip_buffer_push(&raw->port); break; case CTRLCHAR_NONE: @@ -427,7 +427,7 @@ static void raw3215_irq(struct ccw_device *cdev, unsigned long intparm, count -= 2; tty_insert_flip_string(&raw->port, raw->inbuf, count); - tty_flip_buffer_push(tty); + tty_flip_buffer_push(&raw->port); break; } } else if (req->type == RAW3215_WRITE) { diff --git a/drivers/s390/char/sclp_tty.c b/drivers/s390/char/sclp_tty.c index 19b7c516c07d..14b4cb8abcc8 100644 --- a/drivers/s390/char/sclp_tty.c +++ b/drivers/s390/char/sclp_tty.c @@ -343,7 +343,7 @@ sclp_tty_input(unsigned char* buf, unsigned int count) break; case CTRLCHAR_CTRL: tty_insert_flip_char(&sclp_port, cchar, TTY_NORMAL); - tty_flip_buffer_push(tty); + tty_flip_buffer_push(&sclp_port); break; case CTRLCHAR_NONE: /* send (normal) input to line discipline */ @@ -355,7 +355,7 @@ sclp_tty_input(unsigned char* buf, unsigned int count) tty_insert_flip_char(&sclp_port, '\n', TTY_NORMAL); } else tty_insert_flip_string(&sclp_port, buf, count - 2); - tty_flip_buffer_push(tty); + tty_flip_buffer_push(&sclp_port); break; } tty_kref_put(tty); diff --git a/drivers/s390/char/sclp_vt220.c b/drivers/s390/char/sclp_vt220.c index 0eca99b98712..6c92f62623be 100644 --- a/drivers/s390/char/sclp_vt220.c +++ b/drivers/s390/char/sclp_vt220.c @@ -461,14 +461,9 @@ sclp_vt220_write(struct tty_struct *tty, const unsigned char *buf, int count) static void sclp_vt220_receiver_fn(struct evbuf_header *evbuf) { - struct tty_struct *tty = tty_port_tty_get(&sclp_vt220_port); char *buffer; unsigned int count; - /* Ignore input if device is not open */ - if (tty == NULL) - return; - buffer = (char *) ((addr_t) evbuf + sizeof(struct evbuf_header)); count = evbuf->length - sizeof(struct evbuf_header); @@ -481,10 +476,9 @@ sclp_vt220_receiver_fn(struct evbuf_header *evbuf) buffer++; count--; tty_insert_flip_string(&sclp_vt220_port, buffer, count); - tty_flip_buffer_push(tty); + tty_flip_buffer_push(&sclp_vt220_port); break; } - tty_kref_put(tty); } /* diff --git a/drivers/staging/ccg/u_serial.c b/drivers/staging/ccg/u_serial.c index 7df2c02d1137..b10947ae0ac5 100644 --- a/drivers/staging/ccg/u_serial.c +++ b/drivers/staging/ccg/u_serial.c @@ -491,12 +491,8 @@ static void gs_rx_push(unsigned long _port) req = list_first_entry(queue, struct usb_request, list); - /* discard data if tty was closed */ - if (!tty) - goto recycle; - /* leave data queued if tty was rx throttled */ - if (test_bit(TTY_THROTTLED, &tty->flags)) + if (tty && test_bit(TTY_THROTTLED, &tty->flags)) break; switch (req->status) { @@ -542,7 +538,6 @@ static void gs_rx_push(unsigned long _port) } port->n_read = 0; } -recycle: list_move(&req->list, &port->read_pool); port->read_started--; } @@ -550,8 +545,8 @@ recycle: /* Push from tty to ldisc; without low_latency set this is handled by * a workqueue, so we won't get callbacks and can hold port_lock */ - if (tty && do_push) - tty_flip_buffer_push(tty); + if (do_push) + tty_flip_buffer_push(&port->port); /* We want our data queue to become empty ASAP, keeping data diff --git a/drivers/staging/dgrp/dgrp_net_ops.c b/drivers/staging/dgrp/dgrp_net_ops.c index e618a667d84c..4c7abfabf197 100644 --- a/drivers/staging/dgrp/dgrp_net_ops.c +++ b/drivers/staging/dgrp/dgrp_net_ops.c @@ -234,7 +234,7 @@ static void dgrp_input(struct ch_struct *ch) tty_insert_flip_string_flags(&ch->port, myflipbuf, myflipflagbuf, len); - tty_flip_buffer_push(tty); + tty_flip_buffer_push(&ch->port); ch->ch_rxcount += len; } @@ -2958,7 +2958,7 @@ check_query: tty_buffer_request_room(&ch->port, 1); tty_insert_flip_char(&ch->port, 0, TTY_BREAK); - tty_flip_buffer_push(ch->ch_tun.un_tty); + tty_flip_buffer_push(&ch->port); } diff --git a/drivers/staging/fwserial/fwserial.c b/drivers/staging/fwserial/fwserial.c index a2a0c43dec1c..b403393c49c3 100644 --- a/drivers/staging/fwserial/fwserial.c +++ b/drivers/staging/fwserial/fwserial.c @@ -489,16 +489,11 @@ static void fwtty_do_hangup(struct work_struct *work) static void fwtty_emit_breaks(struct work_struct *work) { struct fwtty_port *port = to_port(to_delayed_work(work), emit_breaks); - struct tty_struct *tty; static const char buf[16]; unsigned long now = jiffies; unsigned long elapsed = now - port->break_last; int n, t, c, brk = 0; - tty = tty_port_tty_get(&port->port); - if (!tty) - return; - /* generate breaks at the line rate (but at least 1) */ n = (elapsed * port->cps) / HZ + 1; port->break_last = now; @@ -514,9 +509,7 @@ static void fwtty_emit_breaks(struct work_struct *work) if (c < t) break; } - tty_flip_buffer_push(tty); - - tty_kref_put(tty); + tty_flip_buffer_push(&port->port); if (port->mstatus & (UART_LSR_BI << 24)) schedule_delayed_work(&port->emit_breaks, FREQ_BREAKS); @@ -530,10 +523,6 @@ static void fwtty_pushrx(struct work_struct *work) struct buffered_rx *buf, *next; int n, c = 0; - tty = tty_port_tty_get(&port->port); - if (!tty) - return; - spin_lock_bh(&port->lock); list_for_each_entry_safe(buf, next, &port->buf_list, list) { n = tty_insert_flip_string_fixed_flag(&port->port, buf->data, @@ -545,7 +534,11 @@ static void fwtty_pushrx(struct work_struct *work) memmove(buf->data, buf->data + n, buf->n - n); buf->n -= n; } - __fwtty_throttle(port, tty); + tty = tty_port_tty_get(&port->port); + if (tty) { + __fwtty_throttle(port, tty); + tty_kref_put(tty); + } break; } else { list_del(&buf->list); @@ -553,13 +546,11 @@ static void fwtty_pushrx(struct work_struct *work) } } if (c > 0) - tty_flip_buffer_push(tty); + tty_flip_buffer_push(&port->port); if (list_empty(&port->buf_list)) clear_bit(BUFFERING_RX, &port->flags); spin_unlock_bh(&port->lock); - - tty_kref_put(tty); } static int fwtty_buffer_rx(struct fwtty_port *port, unsigned char *d, size_t n) @@ -594,10 +585,6 @@ static int fwtty_rx(struct fwtty_port *port, unsigned char *data, size_t len) unsigned lsr; int err = 0; - tty = tty_port_tty_get(&port->port); - if (!tty) - return -ENOENT; - fwtty_dbg(port, "%d", n); profile_size_distrib(port->stats.reads, n); @@ -634,16 +621,20 @@ static int fwtty_rx(struct fwtty_port *port, unsigned char *data, size_t len) c = tty_insert_flip_string_fixed_flag(&port->port, data, TTY_NORMAL, n); if (c > 0) - tty_flip_buffer_push(tty); + tty_flip_buffer_push(&port->port); n -= c; if (n) { /* start buffering and throttling */ n -= fwtty_buffer_rx(port, &data[c], n); - spin_lock_bh(&port->lock); - __fwtty_throttle(port, tty); - spin_unlock_bh(&port->lock); + tty = tty_port_tty_get(&port->port); + if (tty) { + spin_lock_bh(&port->lock); + __fwtty_throttle(port, tty); + spin_unlock_bh(&port->lock); + tty_kref_put(tty); + } } } else n -= fwtty_buffer_rx(port, data, n); @@ -654,8 +645,6 @@ static int fwtty_rx(struct fwtty_port *port, unsigned char *data, size_t len) } out: - tty_kref_put(tty); - port->icount.rx += len; port->stats.lost += n; return err; diff --git a/drivers/staging/serqt_usb2/serqt_usb2.c b/drivers/staging/serqt_usb2/serqt_usb2.c index 14965662d09c..df29a3de29f2 100644 --- a/drivers/staging/serqt_usb2/serqt_usb2.c +++ b/drivers/staging/serqt_usb2/serqt_usb2.c @@ -290,8 +290,7 @@ static void qt_interrupt_callback(struct urb *urb) /* FIXME */ } -static void qt_status_change_check(struct tty_struct *tty, - struct urb *urb, +static void qt_status_change_check(struct urb *urb, struct quatech_port *qt_port, struct usb_serial_port *port) { @@ -348,7 +347,7 @@ static void qt_status_change_check(struct tty_struct *tty, tty_insert_flip_char(&port->port, data[i], TTY_NORMAL); } - tty_flip_buffer_push(tty); + tty_flip_buffer_push(&port->port); } static void qt_read_bulk_callback(struct urb *urb) @@ -411,7 +410,7 @@ static void qt_read_bulk_callback(struct urb *urb) } if (urb->actual_length) - qt_status_change_check(tty, urb, qt_port, port); + qt_status_change_check(urb, qt_port, port); /* Continue trying to always read */ usb_fill_bulk_urb(port->read_urb, serial->dev, @@ -427,7 +426,7 @@ static void qt_read_bulk_callback(struct urb *urb) __func__, result); else { if (urb->actual_length) { - tty_flip_buffer_push(tty); + tty_flip_buffer_push(&port->port); tty_schedule_flip(tty); } } diff --git a/drivers/tty/amiserial.c b/drivers/tty/amiserial.c index 2d1357acbc23..4c7d70172193 100644 --- a/drivers/tty/amiserial.c +++ b/drivers/tty/amiserial.c @@ -251,7 +251,6 @@ static void receive_chars(struct serial_state *info) { int status; int serdatr; - struct tty_struct *tty = info->tport.tty; unsigned char ch, flag; struct async_icount *icount; int oe = 0; @@ -314,7 +313,7 @@ static void receive_chars(struct serial_state *info) #endif flag = TTY_BREAK; if (info->tport.flags & ASYNC_SAK) - do_SAK(tty); + do_SAK(info->tport.tty); } else if (status & UART_LSR_PE) flag = TTY_PARITY; else if (status & UART_LSR_FE) @@ -331,7 +330,7 @@ static void receive_chars(struct serial_state *info) tty_insert_flip_char(&info->tport, ch, flag); if (oe == 1) tty_insert_flip_char(&info->tport, 0, TTY_OVERRUN); - tty_flip_buffer_push(tty); + tty_flip_buffer_push(&info->tport); out: return; } diff --git a/drivers/tty/bfin_jtag_comm.c b/drivers/tty/bfin_jtag_comm.c index 143c38579cb5..a93a424873fa 100644 --- a/drivers/tty/bfin_jtag_comm.c +++ b/drivers/tty/bfin_jtag_comm.c @@ -95,18 +95,16 @@ bfin_jc_emudat_manager(void *arg) /* if incoming data is ready, eat it */ if (bfin_read_DBGSTAT() & EMUDIF) { - if (tty != NULL) { - uint32_t emudat = bfin_read_emudat(); - if (inbound_len == 0) { - pr_debug("incoming length: 0x%08x\n", emudat); - inbound_len = emudat; - } else { - size_t num_chars = (4 <= inbound_len ? 4 : inbound_len); - pr_debug(" incoming data: 0x%08x (pushing %zu)\n", emudat, num_chars); - inbound_len -= num_chars; - tty_insert_flip_string(&port, (unsigned char *)&emudat, num_chars); - tty_flip_buffer_push(tty); - } + uint32_t emudat = bfin_read_emudat(); + if (inbound_len == 0) { + pr_debug("incoming length: 0x%08x\n", emudat); + inbound_len = emudat; + } else { + size_t num_chars = (4 <= inbound_len ? 4 : inbound_len); + pr_debug(" incoming data: 0x%08x (pushing %zu)\n", emudat, num_chars); + inbound_len -= num_chars; + tty_insert_flip_string(&port, (unsigned char *)&emudat, num_chars); + tty_flip_buffer_push(&port); } } diff --git a/drivers/tty/ehv_bytechan.c b/drivers/tty/ehv_bytechan.c index 5164f9a57017..ed92622b8949 100644 --- a/drivers/tty/ehv_bytechan.c +++ b/drivers/tty/ehv_bytechan.c @@ -371,16 +371,11 @@ console_initcall(ehv_bc_console_init); static irqreturn_t ehv_bc_tty_rx_isr(int irq, void *data) { struct ehv_bc_data *bc = data; - struct tty_struct *ttys = tty_port_tty_get(&bc->port); unsigned int rx_count, tx_count, len; int count; char buffer[EV_BYTE_CHANNEL_MAX_BYTES]; int ret; - /* ttys could be NULL during a hangup */ - if (!ttys) - return IRQ_HANDLED; - /* Find out how much data needs to be read, and then ask the TTY layer * if it can handle that much. We want to ensure that every byte we * read from the byte channel will be accepted by the TTY layer. @@ -422,9 +417,7 @@ static irqreturn_t ehv_bc_tty_rx_isr(int irq, void *data) } /* Tell the tty layer that we're done. */ - tty_flip_buffer_push(ttys); - - tty_kref_put(ttys); + tty_flip_buffer_push(&bc->port); return IRQ_HANDLED; } diff --git a/drivers/tty/hvc/hvc_console.c b/drivers/tty/hvc/hvc_console.c index 8c2fe3a0e091..eb255e807c06 100644 --- a/drivers/tty/hvc/hvc_console.c +++ b/drivers/tty/hvc/hvc_console.c @@ -691,7 +691,7 @@ int hvc_poll(struct hvc_struct *hp) a minimum for performance. */ timeout = MIN_TIMEOUT; - tty_flip_buffer_push(tty); + tty_flip_buffer_push(&hp->port); } tty_kref_put(tty); diff --git a/drivers/tty/hvc/hvcs.c b/drivers/tty/hvc/hvcs.c index 7bfc0a924b2f..1956593ee89d 100644 --- a/drivers/tty/hvc/hvcs.c +++ b/drivers/tty/hvc/hvcs.c @@ -623,7 +623,7 @@ static int hvcs_io(struct hvcs_struct *hvcsd) spin_unlock_irqrestore(&hvcsd->lock, flags); /* This is synch because tty->low_latency == 1 */ if(got) - tty_flip_buffer_push(tty); + tty_flip_buffer_push(&hvcsd->port); if (!got) { /* Do this _after_ the flip_buffer_push */ diff --git a/drivers/tty/hvc/hvsi.c b/drivers/tty/hvc/hvsi.c index 1f528b8ebf5f..dc591290120b 100644 --- a/drivers/tty/hvc/hvsi.c +++ b/drivers/tty/hvc/hvsi.c @@ -465,7 +465,7 @@ static int hvsi_load_chunk(struct hvsi_struct *hp, struct tty_struct *tty, compact_inbuf(hp, packet); if (flip) - tty_flip_buffer_push(tty); + tty_flip_buffer_push(&hp->port); return 1; } @@ -511,7 +511,7 @@ static irqreturn_t hvsi_interrupt(int irq, void *arg) /* we weren't hung up and we weren't throttled, so we can * deliver the rest now */ hvsi_send_overflow(hp); - tty_flip_buffer_push(tty); + tty_flip_buffer_push(&hp->port); } spin_unlock_irqrestore(&hp->lock, flags); @@ -998,7 +998,7 @@ static void hvsi_unthrottle(struct tty_struct *tty) spin_lock_irqsave(&hp->lock, flags); if (hp->n_throttle) { hvsi_send_overflow(hp); - tty_flip_buffer_push(tty); + tty_flip_buffer_push(&hp->port); } spin_unlock_irqrestore(&hp->lock, flags); diff --git a/drivers/tty/ipwireless/tty.c b/drivers/tty/ipwireless/tty.c index c43da7445432..8fd72ff9436e 100644 --- a/drivers/tty/ipwireless/tty.c +++ b/drivers/tty/ipwireless/tty.c @@ -160,15 +160,9 @@ static void ipw_close(struct tty_struct *linux_tty, struct file *filp) void ipwireless_tty_received(struct ipw_tty *tty, unsigned char *data, unsigned int length) { - struct tty_struct *linux_tty; int work = 0; mutex_lock(&tty->ipw_tty_mutex); - linux_tty = tty->port.tty; - if (linux_tty == NULL) { - mutex_unlock(&tty->ipw_tty_mutex); - return; - } if (!tty->port.count) { mutex_unlock(&tty->ipw_tty_mutex); @@ -187,7 +181,7 @@ void ipwireless_tty_received(struct ipw_tty *tty, unsigned char *data, * This may sleep if ->low_latency is set */ if (work) - tty_flip_buffer_push(linux_tty); + tty_flip_buffer_push(&tty->port); } static void ipw_write_packet_sent_callback(void *callback_data, diff --git a/drivers/tty/isicom.c b/drivers/tty/isicom.c index c70144f55fc0..858291ca889c 100644 --- a/drivers/tty/isicom.c +++ b/drivers/tty/isicom.c @@ -637,7 +637,7 @@ static irqreturn_t isicom_interrupt(int irq, void *dev_id) tty_insert_flip_char(&port->port, 0, TTY_BREAK); if (port->port.flags & ASYNC_SAK) do_SAK(tty); - tty_flip_buffer_push(tty); + tty_flip_buffer_push(&port->port); break; case 2: /* Statistics */ @@ -671,7 +671,7 @@ static irqreturn_t isicom_interrupt(int irq, void *dev_id) byte_count -= 2; } } - tty_flip_buffer_push(tty); + tty_flip_buffer_push(&port->port); } outw(0x0000, base+0x04); /* enable interrupts */ spin_unlock(&card->card_lock); diff --git a/drivers/tty/mxser.c b/drivers/tty/mxser.c index e9cdfdfe06e9..ad34a202a34d 100644 --- a/drivers/tty/mxser.c +++ b/drivers/tty/mxser.c @@ -2145,7 +2145,7 @@ end_intr: * recursive locking. */ spin_unlock(&port->slock); - tty_flip_buffer_push(tty); + tty_flip_buffer_push(&port->port); spin_lock(&port->slock); } diff --git a/drivers/tty/n_gsm.c b/drivers/tty/n_gsm.c index 4a3342d21c8f..d84dcfeadce3 100644 --- a/drivers/tty/n_gsm.c +++ b/drivers/tty/n_gsm.c @@ -1141,7 +1141,6 @@ static void gsm_control_modem(struct gsm_mux *gsm, u8 *data, int clen) static void gsm_control_rls(struct gsm_mux *gsm, u8 *data, int clen) { struct tty_port *port; - struct tty_struct *tty; unsigned int addr = 0 ; u8 bits; int len = clen; @@ -1174,12 +1173,8 @@ static void gsm_control_rls(struct gsm_mux *gsm, u8 *data, int clen) if (bits & 8) tty_insert_flip_char(port, 0, TTY_FRAME); - /* See if we have an uplink tty */ - tty = tty_port_tty_get(port); - if (tty) { - tty_flip_buffer_push(tty); - tty_kref_put(tty); - } + tty_flip_buffer_push(port); + gsm_control_reply(gsm, CMD_RLS, data, clen); } @@ -1552,36 +1547,37 @@ static void gsm_dlci_data(struct gsm_dlci *dlci, u8 *data, int clen) { /* krefs .. */ struct tty_port *port = &dlci->port; - struct tty_struct *tty = tty_port_tty_get(port); + struct tty_struct *tty; unsigned int modem = 0; int len = clen; if (debug & 16) - pr_debug("%d bytes for tty %p\n", len, tty); - if (tty) { - switch (dlci->adaption) { - /* Unsupported types */ - /* Packetised interruptible data */ - case 4: - break; - /* Packetised uininterruptible voice/data */ - case 3: - break; - /* Asynchronous serial with line state in each frame */ - case 2: - while (gsm_read_ea(&modem, *data++) == 0) { - len--; - if (len == 0) - return; - } + pr_debug("%d bytes for tty\n", len); + switch (dlci->adaption) { + /* Unsupported types */ + /* Packetised interruptible data */ + case 4: + break; + /* Packetised uininterruptible voice/data */ + case 3: + break; + /* Asynchronous serial with line state in each frame */ + case 2: + while (gsm_read_ea(&modem, *data++) == 0) { + len--; + if (len == 0) + return; + } + tty = tty_port_tty_get(port); + if (tty) { gsm_process_modem(tty, dlci, modem, clen); - /* Line state will go via DLCI 0 controls only */ - case 1: - default: - tty_insert_flip_string(port, data, len); - tty_flip_buffer_push(tty); + tty_kref_put(tty); } - tty_kref_put(tty); + /* Line state will go via DLCI 0 controls only */ + case 1: + default: + tty_insert_flip_string(port, data, len); + tty_flip_buffer_push(port); } } diff --git a/drivers/tty/nozomi.c b/drivers/tty/nozomi.c index 941fe8060ea5..afdd7732d925 100644 --- a/drivers/tty/nozomi.c +++ b/drivers/tty/nozomi.c @@ -1272,15 +1272,11 @@ static irqreturn_t interrupt_handler(int irq, void *dev_id) exit_handler: spin_unlock(&dc->spin_mutex); - for (a = 0; a < NOZOMI_MAX_PORTS; a++) { - struct tty_struct *tty; - if (test_and_clear_bit(a, &dc->flip)) { - tty = tty_port_tty_get(&dc->port[a].port); - if (tty) - tty_flip_buffer_push(tty); - tty_kref_put(tty); - } - } + + for (a = 0; a < NOZOMI_MAX_PORTS; a++) + if (test_and_clear_bit(a, &dc->flip)) + tty_flip_buffer_push(&dc->port[a].port); + return IRQ_HANDLED; none: spin_unlock(&dc->spin_mutex); diff --git a/drivers/tty/pty.c b/drivers/tty/pty.c index 3c285d398f38..32d027c303aa 100644 --- a/drivers/tty/pty.c +++ b/drivers/tty/pty.c @@ -123,7 +123,7 @@ static int pty_write(struct tty_struct *tty, const unsigned char *buf, int c) c = tty_insert_flip_string(to->port, buf, c); /* And shovel */ if (c) { - tty_flip_buffer_push(to); + tty_flip_buffer_push(to->port); tty_wakeup(tty); } } diff --git a/drivers/tty/rocket.c b/drivers/tty/rocket.c index 5848a767001a..8073cc0dff59 100644 --- a/drivers/tty/rocket.c +++ b/drivers/tty/rocket.c @@ -315,9 +315,8 @@ static inline int rocket_paranoia_check(struct r_port *info, * that receive data is present on a serial port. Pulls data from FIFO, moves it into the * tty layer. */ -static void rp_do_receive(struct r_port *info, - struct tty_struct *tty, - CHANNEL_t * cp, unsigned int ChanStatus) +static void rp_do_receive(struct r_port *info, CHANNEL_t *cp, + unsigned int ChanStatus) { unsigned int CharNStat; int ToRecv, wRecv, space; @@ -416,7 +415,7 @@ static void rp_do_receive(struct r_port *info, cbuf[ToRecv - 1] = sInB(sGetTxRxDataIO(cp)); } /* Push the data up to the tty layer */ - tty_flip_buffer_push(tty); + tty_flip_buffer_push(&info->port); } /* @@ -495,7 +494,6 @@ static void rp_do_transmit(struct r_port *info) static void rp_handle_port(struct r_port *info) { CHANNEL_t *cp; - struct tty_struct *tty; unsigned int IntMask, ChanStatus; if (!info) @@ -506,12 +504,7 @@ static void rp_handle_port(struct r_port *info) "info->flags & NOT_INIT\n"); return; } - tty = tty_port_tty_get(&info->port); - if (!tty) { - printk(KERN_WARNING "rp: WARNING: rp_handle_port called with " - "tty==NULL\n"); - return; - } + cp = &info->channel; IntMask = sGetChanIntID(cp) & info->intmask; @@ -520,7 +513,7 @@ static void rp_handle_port(struct r_port *info) #endif ChanStatus = sGetChanStatus(cp); if (IntMask & RXF_TRIG) { /* Rx FIFO trigger level */ - rp_do_receive(info, tty, cp, ChanStatus); + rp_do_receive(info, cp, ChanStatus); } if (IntMask & DELTA_CD) { /* CD change */ #if (defined(ROCKET_DEBUG_OPEN) || defined(ROCKET_DEBUG_INTR) || defined(ROCKET_DEBUG_HANGUP)) @@ -528,10 +521,15 @@ static void rp_handle_port(struct r_port *info) (ChanStatus & CD_ACT) ? "on" : "off"); #endif if (!(ChanStatus & CD_ACT) && info->cd_status) { + struct tty_struct *tty; #ifdef ROCKET_DEBUG_HANGUP printk(KERN_INFO "CD drop, calling hangup.\n"); #endif - tty_hangup(tty); + tty = tty_port_tty_get(&info->port); + if (tty) { + tty_hangup(tty); + tty_kref_put(tty); + } } info->cd_status = (ChanStatus & CD_ACT) ? 1 : 0; wake_up_interruptible(&info->port.open_wait); @@ -544,7 +542,6 @@ static void rp_handle_port(struct r_port *info) printk(KERN_INFO "DSR change...\n"); } #endif - tty_kref_put(tty); } /* diff --git a/drivers/tty/serial/21285.c b/drivers/tty/serial/21285.c index a44345a2dbb4..c7e8b60b6177 100644 --- a/drivers/tty/serial/21285.c +++ b/drivers/tty/serial/21285.c @@ -85,7 +85,6 @@ static void serial21285_enable_ms(struct uart_port *port) static irqreturn_t serial21285_rx_chars(int irq, void *dev_id) { struct uart_port *port = dev_id; - struct tty_struct *tty = port->state->port.tty; unsigned int status, ch, flag, rxs, max_count = 256; status = *CSR_UARTFLG; @@ -115,7 +114,7 @@ static irqreturn_t serial21285_rx_chars(int irq, void *dev_id) status = *CSR_UARTFLG; } - tty_flip_buffer_push(tty); + tty_flip_buffer_push(&port->state->port); return IRQ_HANDLED; } diff --git a/drivers/tty/serial/8250/8250.c b/drivers/tty/serial/8250/8250.c index 5fb6577b94dc..0d771ec16750 100644 --- a/drivers/tty/serial/8250/8250.c +++ b/drivers/tty/serial/8250/8250.c @@ -1323,7 +1323,6 @@ unsigned char serial8250_rx_chars(struct uart_8250_port *up, unsigned char lsr) { struct uart_port *port = &up->port; - struct tty_struct *tty = port->state->port.tty; unsigned char ch; int max_count = 256; char flag; @@ -1388,7 +1387,7 @@ ignore_char: lsr = serial_in(up, UART_LSR); } while ((lsr & (UART_LSR_DR | UART_LSR_BI)) && (max_count-- > 0)); spin_unlock(&port->lock); - tty_flip_buffer_push(tty); + tty_flip_buffer_push(&port->state->port); spin_lock(&port->lock); return lsr; } diff --git a/drivers/tty/serial/altera_jtaguart.c b/drivers/tty/serial/altera_jtaguart.c index 872f14ae43d2..84b90fd48063 100644 --- a/drivers/tty/serial/altera_jtaguart.c +++ b/drivers/tty/serial/altera_jtaguart.c @@ -139,7 +139,7 @@ static void altera_jtaguart_rx_chars(struct altera_jtaguart *pp) uart_insert_char(port, 0, 0, ch, flag); } - tty_flip_buffer_push(port->state->port.tty); + tty_flip_buffer_push(&port->state->port); } static void altera_jtaguart_tx_chars(struct altera_jtaguart *pp) diff --git a/drivers/tty/serial/altera_uart.c b/drivers/tty/serial/altera_uart.c index 684a0808e1c7..e133c8814bb5 100644 --- a/drivers/tty/serial/altera_uart.c +++ b/drivers/tty/serial/altera_uart.c @@ -231,7 +231,7 @@ static void altera_uart_rx_chars(struct altera_uart *pp) flag); } - tty_flip_buffer_push(port->state->port.tty); + tty_flip_buffer_push(&port->state->port); } static void altera_uart_tx_chars(struct altera_uart *pp) diff --git a/drivers/tty/serial/amba-pl010.c b/drivers/tty/serial/amba-pl010.c index 22317dd16474..c36840519527 100644 --- a/drivers/tty/serial/amba-pl010.c +++ b/drivers/tty/serial/amba-pl010.c @@ -116,7 +116,6 @@ static void pl010_enable_ms(struct uart_port *port) static void pl010_rx_chars(struct uart_amba_port *uap) { - struct tty_struct *tty = uap->port.state->port.tty; unsigned int status, ch, flag, rsr, max_count = 256; status = readb(uap->port.membase + UART01x_FR); @@ -165,7 +164,7 @@ static void pl010_rx_chars(struct uart_amba_port *uap) status = readb(uap->port.membase + UART01x_FR); } spin_unlock(&uap->port.lock); - tty_flip_buffer_push(tty); + tty_flip_buffer_push(&uap->port.state->port); spin_lock(&uap->port.lock); } diff --git a/drivers/tty/serial/amba-pl011.c b/drivers/tty/serial/amba-pl011.c index e1257d17f5f0..3ea5408fcbeb 100644 --- a/drivers/tty/serial/amba-pl011.c +++ b/drivers/tty/serial/amba-pl011.c @@ -699,7 +699,6 @@ static void pl011_dma_rx_chars(struct uart_amba_port *uap, bool readfifo) { struct tty_port *port = &uap->port.state->port; - struct tty_struct *tty = port->tty; struct pl011_sgbuf *sgbuf = use_buf_b ? &uap->dmarx.sgbuf_b : &uap->dmarx.sgbuf_a; struct device *dev = uap->dmarx.chan->device->dev; @@ -754,7 +753,7 @@ static void pl011_dma_rx_chars(struct uart_amba_port *uap, dev_vdbg(uap->port.dev, "Took %d chars from DMA buffer and %d chars from the FIFO\n", dma_count, fifotaken); - tty_flip_buffer_push(tty); + tty_flip_buffer_push(port); spin_lock(&uap->port.lock); } @@ -1076,12 +1075,10 @@ static void pl011_enable_ms(struct uart_port *port) static void pl011_rx_chars(struct uart_amba_port *uap) { - struct tty_struct *tty = uap->port.state->port.tty; - pl011_fifo_to_tty(uap); spin_unlock(&uap->port.lock); - tty_flip_buffer_push(tty); + tty_flip_buffer_push(&uap->port.state->port); /* * If we were temporarily out of DMA mode for a while, * attempt to switch back to DMA mode again. diff --git a/drivers/tty/serial/apbuart.c b/drivers/tty/serial/apbuart.c index 59ae2b53e765..6331464d9101 100644 --- a/drivers/tty/serial/apbuart.c +++ b/drivers/tty/serial/apbuart.c @@ -78,7 +78,6 @@ static void apbuart_enable_ms(struct uart_port *port) static void apbuart_rx_chars(struct uart_port *port) { - struct tty_struct *tty = port->state->port.tty; unsigned int status, ch, rsr, flag; unsigned int max_chars = port->fifosize; @@ -126,7 +125,7 @@ static void apbuart_rx_chars(struct uart_port *port) status = UART_GET_STATUS(port); } - tty_flip_buffer_push(tty); + tty_flip_buffer_push(&port->state->port); } static void apbuart_tx_chars(struct uart_port *port) diff --git a/drivers/tty/serial/ar933x_uart.c b/drivers/tty/serial/ar933x_uart.c index 6ca5dd615f9e..27f20c57abed 100644 --- a/drivers/tty/serial/ar933x_uart.c +++ b/drivers/tty/serial/ar933x_uart.c @@ -298,10 +298,8 @@ static void ar933x_uart_set_termios(struct uart_port *port, static void ar933x_uart_rx_chars(struct ar933x_uart_port *up) { struct tty_port *port = &up->port.state->port; - struct tty_struct *tty; int max_count = 256; - tty = tty_port_tty_get(port); do { unsigned int rdata; unsigned char ch; @@ -324,10 +322,7 @@ static void ar933x_uart_rx_chars(struct ar933x_uart_port *up) tty_insert_flip_char(port, ch, TTY_NORMAL); } while (max_count-- > 0); - if (tty) { - tty_flip_buffer_push(tty); - tty_kref_put(tty); - } + tty_flip_buffer_push(port); } static void ar933x_uart_tx_chars(struct ar933x_uart_port *up) diff --git a/drivers/tty/serial/arc_uart.c b/drivers/tty/serial/arc_uart.c index b46860104312..da734222e537 100644 --- a/drivers/tty/serial/arc_uart.c +++ b/drivers/tty/serial/arc_uart.c @@ -211,12 +211,8 @@ static void arc_serial_start_tx(struct uart_port *port) static void arc_serial_rx_chars(struct arc_uart_port *uart) { - struct tty_struct *tty = tty_port_tty_get(&uart->port.state->port); unsigned int status, ch, flg = 0; - if (!tty) - return; - /* * UART has 4 deep RX-FIFO. Driver's recongnition of this fact * is very subtle. Here's how ... @@ -252,10 +248,8 @@ static void arc_serial_rx_chars(struct arc_uart_port *uart) uart_insert_char(&uart->port, status, RXOERR, ch, flg); done: - tty_flip_buffer_push(tty); + tty_flip_buffer_push(&uart->port.state->port); } - - tty_kref_put(tty); } /* diff --git a/drivers/tty/serial/atmel_serial.c b/drivers/tty/serial/atmel_serial.c index 929567038c5a..d4a7c241b751 100644 --- a/drivers/tty/serial/atmel_serial.c +++ b/drivers/tty/serial/atmel_serial.c @@ -774,7 +774,7 @@ static void atmel_rx_from_ring(struct uart_port *port) * uart_start(), which takes the lock. */ spin_unlock(&port->lock); - tty_flip_buffer_push(port->state->port.tty); + tty_flip_buffer_push(&port->state->port); spin_lock(&port->lock); } @@ -782,7 +782,6 @@ static void atmel_rx_from_dma(struct uart_port *port) { struct atmel_uart_port *atmel_port = to_atmel_uart_port(port); struct tty_port *tport = &port->state->port; - struct tty_struct *tty = tport->tty; struct atmel_dma_buffer *pdc; int rx_idx = atmel_port->pdc_rx_idx; unsigned int head; @@ -850,7 +849,7 @@ static void atmel_rx_from_dma(struct uart_port *port) * uart_start(), which takes the lock. */ spin_unlock(&port->lock); - tty_flip_buffer_push(tty); + tty_flip_buffer_push(tport); spin_lock(&port->lock); UART_PUT_IER(port, ATMEL_US_ENDRX | ATMEL_US_TIMEOUT); diff --git a/drivers/tty/serial/bcm63xx_uart.c b/drivers/tty/serial/bcm63xx_uart.c index de30b1909728..719594e5fc21 100644 --- a/drivers/tty/serial/bcm63xx_uart.c +++ b/drivers/tty/serial/bcm63xx_uart.c @@ -236,14 +236,12 @@ static const char *bcm_uart_type(struct uart_port *port) static void bcm_uart_do_rx(struct uart_port *port) { struct tty_port *port = &port->state->port; - struct tty_struct *tty; unsigned int max_count; /* limit number of char read in interrupt, should not be * higher than fifo size anyway since we're much faster than * serial port */ max_count = 32; - tty = port->tty; do { unsigned int iestat, c, cstat; char flag; @@ -305,7 +303,7 @@ static void bcm_uart_do_rx(struct uart_port *port) } while (--max_count); - tty_flip_buffer_push(tty); + tty_flip_buffer_push(port); } /* diff --git a/drivers/tty/serial/bfin_sport_uart.c b/drivers/tty/serial/bfin_sport_uart.c index e4d3ac2e8992..487c173b0f72 100644 --- a/drivers/tty/serial/bfin_sport_uart.c +++ b/drivers/tty/serial/bfin_sport_uart.c @@ -150,7 +150,6 @@ static irqreturn_t sport_uart_rx_irq(int irq, void *dev_id) { struct sport_uart_port *up = dev_id; struct tty_port *port = &up->port.state->port; - struct tty_struct *tty = tport->tty; unsigned int ch; spin_lock(&up->port.lock); @@ -162,7 +161,8 @@ static irqreturn_t sport_uart_rx_irq(int irq, void *dev_id) if (!uart_handle_sysrq_char(&up->port, ch)) tty_insert_flip_char(port, ch, TTY_NORMAL); } - tty_flip_buffer_push(tty); + /* XXX this won't deadlock with lowlat? */ + tty_flip_buffer_push(port); spin_unlock(&up->port.lock); diff --git a/drivers/tty/serial/bfin_uart.c b/drivers/tty/serial/bfin_uart.c index 2e2b2c1cb722..12dceda9db33 100644 --- a/drivers/tty/serial/bfin_uart.c +++ b/drivers/tty/serial/bfin_uart.c @@ -223,7 +223,6 @@ static void bfin_serial_enable_ms(struct uart_port *port) #ifdef CONFIG_SERIAL_BFIN_PIO static void bfin_serial_rx_chars(struct bfin_serial_port *uart) { - struct tty_struct *tty = NULL; unsigned int status, ch, flg; static struct timeval anomaly_start = { .tv_sec = 0 }; @@ -242,11 +241,9 @@ static void bfin_serial_rx_chars(struct bfin_serial_port *uart) return; } - if (!uart->port.state || !uart->port.state->port.tty) + if (!uart->port.state) return; #endif - tty = uart->port.state->port.tty; - if (ANOMALY_05000363) { /* The BF533 (and BF561) family of processors have a nice anomaly * where they continuously generate characters for a "single" break. @@ -325,7 +322,7 @@ static void bfin_serial_rx_chars(struct bfin_serial_port *uart) uart_insert_char(&uart->port, status, OE, ch, flg); ignore_char: - tty_flip_buffer_push(tty); + tty_flip_buffer_push(&uart->port.state->port); } static void bfin_serial_tx_chars(struct bfin_serial_port *uart) @@ -426,7 +423,6 @@ static void bfin_serial_dma_tx_chars(struct bfin_serial_port *uart) static void bfin_serial_dma_rx_chars(struct bfin_serial_port *uart) { - struct tty_struct *tty = uart->port.state->port.tty; int i, flg, status; status = UART_GET_LSR(uart); @@ -471,7 +467,7 @@ static void bfin_serial_dma_rx_chars(struct bfin_serial_port *uart) } dma_ignore_char: - tty_flip_buffer_push(tty); + tty_flip_buffer_push(&uart->port.state->port); } void bfin_serial_rx_dma_timeout(struct bfin_serial_port *uart) diff --git a/drivers/tty/serial/clps711x.c b/drivers/tty/serial/clps711x.c index 3fd2526d121e..bfb17968c8db 100644 --- a/drivers/tty/serial/clps711x.c +++ b/drivers/tty/serial/clps711x.c @@ -85,12 +85,8 @@ static void uart_clps711x_enable_ms(struct uart_port *port) static irqreturn_t uart_clps711x_int_rx(int irq, void *dev_id) { struct uart_port *port = dev_id; - struct tty_struct *tty = tty_port_tty_get(&port->state->port); unsigned int status, ch, flg; - if (!tty) - return IRQ_HANDLED; - for (;;) { status = clps_readl(SYSFLG(port)); if (status & SYSFLG_URXFE) @@ -130,9 +126,7 @@ static irqreturn_t uart_clps711x_int_rx(int irq, void *dev_id) uart_insert_char(port, status, UARTDR_OVERR, ch, flg); } - tty_flip_buffer_push(tty); - - tty_kref_put(tty); + tty_flip_buffer_push(&port->state->port); return IRQ_HANDLED; } diff --git a/drivers/tty/serial/cpm_uart/cpm_uart_core.c b/drivers/tty/serial/cpm_uart/cpm_uart_core.c index 0bb24378a3c0..97f4e1858649 100644 --- a/drivers/tty/serial/cpm_uart/cpm_uart_core.c +++ b/drivers/tty/serial/cpm_uart/cpm_uart_core.c @@ -246,7 +246,6 @@ static void cpm_uart_int_rx(struct uart_port *port) unsigned char ch; u8 *cp; struct tty_port *tport = &port->state->port; - struct tty_struct *tty = tport->tty; struct uart_cpm_port *pinfo = (struct uart_cpm_port *)port; cbd_t __iomem *bdp; u16 status; @@ -323,7 +322,7 @@ static void cpm_uart_int_rx(struct uart_port *port) pinfo->rx_cur = bdp; /* activate BH processing */ - tty_flip_buffer_push(tty); + tty_flip_buffer_push(tport); return; diff --git a/drivers/tty/serial/crisv10.c b/drivers/tty/serial/crisv10.c index 52449adc09ac..45acf103433e 100644 --- a/drivers/tty/serial/crisv10.c +++ b/drivers/tty/serial/crisv10.c @@ -2104,17 +2104,10 @@ static int force_eop_if_needed(struct e100_serial *info) static void flush_to_flip_buffer(struct e100_serial *info) { - struct tty_struct *tty; struct etrax_recv_buffer *buffer; unsigned long flags; local_irq_save(flags); - tty = info->port.tty; - - if (!tty) { - local_irq_restore(flags); - return; - } while ((buffer = info->first_recv_buffer) != NULL) { unsigned int count = buffer->length; @@ -2138,7 +2131,7 @@ static void flush_to_flip_buffer(struct e100_serial *info) local_irq_restore(flags); /* This includes a check for low-latency */ - tty_flip_buffer_push(tty); + tty_flip_buffer_push(&info->port); } static void check_flush_timeout(struct e100_serial *info) @@ -2274,12 +2267,6 @@ static struct e100_serial * handle_ser_rx_interrupt_no_dma(struct e100_serial *info) { unsigned long data_read; - struct tty_struct *tty = info->port.tty; - - if (!tty) { - printk("!NO TTY!\n"); - return info; - } /* Read data and status at the same time */ data_read = *((unsigned long *)&info->ioport[REG_DATA_STATUS32]); @@ -2382,7 +2369,7 @@ more_data: goto more_data; } - tty_flip_buffer_push(info->port.tty); + tty_flip_buffer_push(&info->port); return info; } diff --git a/drivers/tty/serial/dz.c b/drivers/tty/serial/dz.c index 6491b8644a7f..2f2b2e538a54 100644 --- a/drivers/tty/serial/dz.c +++ b/drivers/tty/serial/dz.c @@ -187,7 +187,6 @@ static inline void dz_receive_chars(struct dz_mux *mux) { struct uart_port *uport; struct dz_port *dport = &mux->dport[0]; - struct tty_struct *tty = NULL; struct uart_icount *icount; int lines_rx[DZ_NB_PORT] = { [0 ... DZ_NB_PORT - 1] = 0 }; unsigned char ch, flag; @@ -197,7 +196,6 @@ static inline void dz_receive_chars(struct dz_mux *mux) while ((status = dz_in(dport, DZ_RBUF)) & DZ_DVAL) { dport = &mux->dport[LINE(status)]; uport = &dport->port; - tty = uport->state->port.tty; /* point to the proper dev */ ch = UCHAR(status); /* grab the char */ flag = TTY_NORMAL; @@ -249,7 +247,7 @@ static inline void dz_receive_chars(struct dz_mux *mux) } for (i = 0; i < DZ_NB_PORT; i++) if (lines_rx[i]) - tty_flip_buffer_push(mux->dport[i].port.state->port.tty); + tty_flip_buffer_push(&mux->dport[i].port.state->port); } /* diff --git a/drivers/tty/serial/efm32-uart.c b/drivers/tty/serial/efm32-uart.c index bdf67b0cb8b6..de14bd7dce10 100644 --- a/drivers/tty/serial/efm32-uart.c +++ b/drivers/tty/serial/efm32-uart.c @@ -249,12 +249,9 @@ static irqreturn_t efm32_uart_rxirq(int irq, void *data) int handled = IRQ_NONE; struct uart_port *port = &efm_port->port; struct tty_port *tport = &port->state->port; - struct tty_struct *tty; spin_lock(&port->lock); - tty = tty_kref_get(tport->tty); - if (irqflag & UARTn_IF_RXDATAV) { efm32_uart_write32(efm_port, UARTn_IF_RXDATAV, UARTn_IFC); efm32_uart_rx_chars(efm_port); @@ -270,10 +267,7 @@ static irqreturn_t efm32_uart_rxirq(int irq, void *data) handled = IRQ_HANDLED; } - if (tty) { - tty_flip_buffer_push(tty); - tty_kref_put(tty); - } + tty_flip_buffer_push(tport); spin_unlock(&port->lock); diff --git a/drivers/tty/serial/icom.c b/drivers/tty/serial/icom.c index 54903ee5e5ab..bc9e6b017b05 100644 --- a/drivers/tty/serial/icom.c +++ b/drivers/tty/serial/icom.c @@ -735,7 +735,6 @@ static void recv_interrupt(u16 port_int_reg, struct icom_port *icom_port) { short int count, rcv_buff; struct tty_port *port = &icom_port->uart_port.state->port; - struct tty_struct *tty = port->tty; unsigned short int status; struct uart_icount *icount; unsigned long offset; @@ -835,7 +834,7 @@ ignore_char: status = cpu_to_le16(icom_port->statStg->rcv[rcv_buff].flags); } icom_port->next_rcv = rcv_buff; - tty_flip_buffer_push(tty); + tty_flip_buffer_push(port); } static void process_interrupt(u16 port_int_reg, diff --git a/drivers/tty/serial/ifx6x60.c b/drivers/tty/serial/ifx6x60.c index 4bc6e47890b4..6a6668bbb330 100644 --- a/drivers/tty/serial/ifx6x60.c +++ b/drivers/tty/serial/ifx6x60.c @@ -669,12 +669,8 @@ static const struct tty_operations ifx_spi_serial_ops = { static void ifx_spi_insert_flip_string(struct ifx_spi_device *ifx_dev, unsigned char *chars, size_t size) { - struct tty_struct *tty = tty_port_tty_get(&ifx_dev->tty_port); - if (!tty) - return; tty_insert_flip_string(&ifx