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 --- drivers/tty/rocket.c | 25 +++++++++++-------------- 1 file changed, 11 insertions(+), 14 deletions(-) (limited to 'drivers/tty/rocket.c') diff --git a/drivers/tty/rocket.c b/drivers/tty/rocket.c index 5848a767001..8073cc0dff5 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); } /* -- cgit v1.2.3