From 807c8d81f4ec441241cafa3034c58df721fee869 Mon Sep 17 00:00:00 2001 From: Peter Hurley Date: Sat, 9 Apr 2016 17:53:22 -0700 Subject: tty: Replace ASYNC_NORMAL_ACTIVE bit and update atomically Replace ASYNC_NORMAL_ACTIVE bit in the tty_port::flags field with TTY_PORT_ACTIVE bit in the tty_port::iflags field. Introduce helpers tty_port_set_active() and tty_port_active() to abstract atomic bit ops. Extract state changes from port lock sections, as this usage is broken and confused; the state transitions are protected by the tty lock (which mutually excludes parallel open/close/hangup), and no user tests the active state while holding the port lock. Signed-off-by: Peter Hurley Signed-off-by: Greg Kroah-Hartman --- drivers/isdn/i4l/isdn_tty.c | 20 +++++++++----------- 1 file changed, 9 insertions(+), 11 deletions(-) (limited to 'drivers/isdn/i4l') diff --git a/drivers/isdn/i4l/isdn_tty.c b/drivers/isdn/i4l/isdn_tty.c index f1edc0814120..d8468f3529a7 100644 --- a/drivers/isdn/i4l/isdn_tty.c +++ b/drivers/isdn/i4l/isdn_tty.c @@ -1622,7 +1622,7 @@ isdn_tty_hangup(struct tty_struct *tty) return; isdn_tty_shutdown(info); port->count = 0; - port->flags &= ~ASYNC_NORMAL_ACTIVE; + tty_port_set_active(port, 0); port->tty = NULL; wake_up_interruptible(&port->open_wait); } @@ -1979,7 +1979,7 @@ isdn_tty_find_icall(int di, int ch, setup_parm *setup) #endif if ( #ifndef FIX_FILE_TRANSFER - (info->port.flags & ASYNC_NORMAL_ACTIVE) && + tty_port_active(&info->port) && #endif (info->isdn_driver == -1) && (info->isdn_channel == -1) && @@ -2018,8 +2018,6 @@ isdn_tty_find_icall(int di, int ch, setup_parm *setup) return (wret == 2) ? 3 : 0; } -#define TTY_IS_ACTIVE(info) (info->port.flags & ASYNC_NORMAL_ACTIVE) - int isdn_tty_stat_callback(int i, isdn_ctrl *c) { @@ -2077,7 +2075,7 @@ isdn_tty_stat_callback(int i, isdn_ctrl *c) #ifdef ISDN_TTY_STAT_DEBUG printk(KERN_DEBUG "tty_STAT_DCONN ttyI%d\n", info->line); #endif - if (TTY_IS_ACTIVE(info)) { + if (tty_port_active(&info->port)) { if (info->dialing == 1) { info->dialing = 2; return 1; @@ -2088,7 +2086,7 @@ isdn_tty_stat_callback(int i, isdn_ctrl *c) #ifdef ISDN_TTY_STAT_DEBUG printk(KERN_DEBUG "tty_STAT_DHUP ttyI%d\n", info->line); #endif - if (TTY_IS_ACTIVE(info)) { + if (tty_port_active(&info->port)) { if (info->dialing == 1) isdn_tty_modem_result(RESULT_BUSY, info); if (info->dialing > 1) @@ -2118,7 +2116,7 @@ isdn_tty_stat_callback(int i, isdn_ctrl *c) * waiting for it and * set DCD-bit of its modem-status. */ - if (TTY_IS_ACTIVE(info) || + if (tty_port_active(&info->port) || (info->port.blocked_open && (info->emu.mdmreg[REG_DCD] & BIT_DCD))) { info->msr |= UART_MSR_DCD; @@ -2145,7 +2143,7 @@ isdn_tty_stat_callback(int i, isdn_ctrl *c) #ifdef ISDN_TTY_STAT_DEBUG printk(KERN_DEBUG "tty_STAT_BHUP ttyI%d\n", info->line); #endif - if (TTY_IS_ACTIVE(info)) { + if (tty_port_active(&info->port)) { #ifdef ISDN_DEBUG_MODEM_HUP printk(KERN_DEBUG "Mhup in ISDN_STAT_BHUP\n"); #endif @@ -2157,7 +2155,7 @@ isdn_tty_stat_callback(int i, isdn_ctrl *c) #ifdef ISDN_TTY_STAT_DEBUG printk(KERN_DEBUG "tty_STAT_NODCH ttyI%d\n", info->line); #endif - if (TTY_IS_ACTIVE(info)) { + if (tty_port_active(&info->port)) { if (info->dialing) { info->dialing = 0; info->last_l2 = -1; @@ -2183,14 +2181,14 @@ isdn_tty_stat_callback(int i, isdn_ctrl *c) return 1; #ifdef CONFIG_ISDN_TTY_FAX case ISDN_STAT_FAXIND: - if (TTY_IS_ACTIVE(info)) { + if (tty_port_active(&info->port)) { isdn_tty_fax_command(info, c); } break; #endif #ifdef CONFIG_ISDN_AUDIO case ISDN_STAT_AUDIO: - if (TTY_IS_ACTIVE(info)) { + if (tty_port_active(&info->port)) { switch (c->parm.num[0]) { case ISDN_AUDIO_DTMF: if (info->vonline) { -- cgit