tty: Replace ASYNC_INITIALIZED bit and update atomically
Replace ASYNC_INITIALIZED bit in the tty_port::flags field with TTY_PORT_INITIALIZED bit in the tty_port::iflags field. Introduce helpers tty_port_set_initialized() and tty_port_initialized() to abstract atomic bit ops. Note: the transforms for test_and_set_bit() and test_and_clear_bit() are unnecessary as the state transitions are already mutually exclusive; the tty lock prevents concurrent open/close/hangup. Signed-off-by: Peter Hurley <peter@hurleysoftware.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
This commit is contained in:

committed by
Greg Kroah-Hartman

parent
80f02d5424
commit
d41861ca19
@@ -812,7 +812,7 @@ static void close(struct tty_struct *tty, struct file *filp)
|
||||
goto cleanup;
|
||||
|
||||
mutex_lock(&info->port.mutex);
|
||||
if (info->port.flags & ASYNC_INITIALIZED)
|
||||
if (tty_port_initialized(&info->port))
|
||||
wait_until_sent(tty, info->timeout);
|
||||
|
||||
flush_buffer(tty);
|
||||
@@ -1061,7 +1061,7 @@ static void wait_until_sent(struct tty_struct *tty, int timeout)
|
||||
if (sanity_check(info, tty->name, "wait_until_sent"))
|
||||
return;
|
||||
|
||||
if (!test_bit(ASYNCB_INITIALIZED, &info->port.flags))
|
||||
if (!tty_port_initialized(&info->port))
|
||||
goto exit;
|
||||
|
||||
orig_jiffies = jiffies;
|
||||
@@ -2636,7 +2636,7 @@ static int startup(SLMP_INFO * info)
|
||||
if ( debug_level >= DEBUG_LEVEL_INFO )
|
||||
printk("%s(%d):%s tx_releaseup()\n",__FILE__,__LINE__,info->device_name);
|
||||
|
||||
if (info->port.flags & ASYNC_INITIALIZED)
|
||||
if (tty_port_initialized(&info->port))
|
||||
return 0;
|
||||
|
||||
if (!info->tx_buf) {
|
||||
@@ -2662,7 +2662,7 @@ static int startup(SLMP_INFO * info)
|
||||
if (info->port.tty)
|
||||
clear_bit(TTY_IO_ERROR, &info->port.tty->flags);
|
||||
|
||||
info->port.flags |= ASYNC_INITIALIZED;
|
||||
tty_port_set_initialized(&info->port, 1);
|
||||
|
||||
return 0;
|
||||
}
|
||||
@@ -2673,7 +2673,7 @@ static void shutdown(SLMP_INFO * info)
|
||||
{
|
||||
unsigned long flags;
|
||||
|
||||
if (!(info->port.flags & ASYNC_INITIALIZED))
|
||||
if (!tty_port_initialized(&info->port))
|
||||
return;
|
||||
|
||||
if (debug_level >= DEBUG_LEVEL_INFO)
|
||||
@@ -2705,7 +2705,7 @@ static void shutdown(SLMP_INFO * info)
|
||||
if (info->port.tty)
|
||||
set_bit(TTY_IO_ERROR, &info->port.tty->flags);
|
||||
|
||||
info->port.flags &= ~ASYNC_INITIALIZED;
|
||||
tty_port_set_initialized(&info->port, 0);
|
||||
}
|
||||
|
||||
static void program_hw(SLMP_INFO *info)
|
||||
@@ -3308,12 +3308,12 @@ static int block_til_ready(struct tty_struct *tty, struct file *filp,
|
||||
port->blocked_open++;
|
||||
|
||||
while (1) {
|
||||
if (C_BAUD(tty) && test_bit(ASYNCB_INITIALIZED, &port->flags))
|
||||
if (C_BAUD(tty) && tty_port_initialized(port))
|
||||
tty_port_raise_dtr_rts(port);
|
||||
|
||||
set_current_state(TASK_INTERRUPTIBLE);
|
||||
|
||||
if (tty_hung_up_p(filp) || !(port->flags & ASYNC_INITIALIZED)){
|
||||
if (tty_hung_up_p(filp) || !tty_port_initialized(port)) {
|
||||
retval = (port->flags & ASYNC_HUP_NOTIFY) ?
|
||||
-EAGAIN : -ERESTARTSYS;
|
||||
break;
|
||||
|
Reference in New Issue
Block a user