diff options
author | Peter Hurley <peter@hurleysoftware.com> | 2016-04-09 20:53:25 -0400 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@linuxfoundation.org> | 2016-04-30 12:26:55 -0400 |
commit | d41861ca19c9e96f12a4f1ebbc8255d00909a232 (patch) | |
tree | 4b09c15500d404b0b375469dd673f0bc8fd05f5f /drivers/tty/synclinkmp.c | |
parent | 80f02d5424301bf4df195d09b1a664f394435851 (diff) |
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>
Diffstat (limited to 'drivers/tty/synclinkmp.c')
-rw-r--r-- | drivers/tty/synclinkmp.c | 16 |
1 files changed, 8 insertions, 8 deletions
diff --git a/drivers/tty/synclinkmp.c b/drivers/tty/synclinkmp.c index 17bab5f5b858..6dcfc2089373 100644 --- a/drivers/tty/synclinkmp.c +++ b/drivers/tty/synclinkmp.c | |||
@@ -812,7 +812,7 @@ static void close(struct tty_struct *tty, struct file *filp) | |||
812 | goto cleanup; | 812 | goto cleanup; |
813 | 813 | ||
814 | mutex_lock(&info->port.mutex); | 814 | mutex_lock(&info->port.mutex); |
815 | if (info->port.flags & ASYNC_INITIALIZED) | 815 | if (tty_port_initialized(&info->port)) |
816 | wait_until_sent(tty, info->timeout); | 816 | wait_until_sent(tty, info->timeout); |
817 | 817 | ||
818 | flush_buffer(tty); | 818 | flush_buffer(tty); |
@@ -1061,7 +1061,7 @@ static void wait_until_sent(struct tty_struct *tty, int timeout) | |||
1061 | if (sanity_check(info, tty->name, "wait_until_sent")) | 1061 | if (sanity_check(info, tty->name, "wait_until_sent")) |
1062 | return; | 1062 | return; |
1063 | 1063 | ||
1064 | if (!test_bit(ASYNCB_INITIALIZED, &info->port.flags)) | 1064 | if (!tty_port_initialized(&info->port)) |
1065 | goto exit; | 1065 | goto exit; |
1066 | 1066 | ||
1067 | orig_jiffies = jiffies; | 1067 | orig_jiffies = jiffies; |
@@ -2636,7 +2636,7 @@ static int startup(SLMP_INFO * info) | |||
2636 | if ( debug_level >= DEBUG_LEVEL_INFO ) | 2636 | if ( debug_level >= DEBUG_LEVEL_INFO ) |
2637 | printk("%s(%d):%s tx_releaseup()\n",__FILE__,__LINE__,info->device_name); | 2637 | printk("%s(%d):%s tx_releaseup()\n",__FILE__,__LINE__,info->device_name); |
2638 | 2638 | ||
2639 | if (info->port.flags & ASYNC_INITIALIZED) | 2639 | if (tty_port_initialized(&info->port)) |
2640 | return 0; | 2640 | return 0; |
2641 | 2641 | ||
2642 | if (!info->tx_buf) { | 2642 | if (!info->tx_buf) { |
@@ -2662,7 +2662,7 @@ static int startup(SLMP_INFO * info) | |||
2662 | if (info->port.tty) | 2662 | if (info->port.tty) |
2663 | clear_bit(TTY_IO_ERROR, &info->port.tty->flags); | 2663 | clear_bit(TTY_IO_ERROR, &info->port.tty->flags); |
2664 | 2664 | ||
2665 | info->port.flags |= ASYNC_INITIALIZED; | 2665 | tty_port_set_initialized(&info->port, 1); |
2666 | 2666 | ||
2667 | return 0; | 2667 | return 0; |
2668 | } | 2668 | } |
@@ -2673,7 +2673,7 @@ static void shutdown(SLMP_INFO * info) | |||
2673 | { | 2673 | { |
2674 | unsigned long flags; | 2674 | unsigned long flags; |
2675 | 2675 | ||
2676 | if (!(info->port.flags & ASYNC_INITIALIZED)) | 2676 | if (!tty_port_initialized(&info->port)) |
2677 | return; | 2677 | return; |
2678 | 2678 | ||
2679 | if (debug_level >= DEBUG_LEVEL_INFO) | 2679 | if (debug_level >= DEBUG_LEVEL_INFO) |
@@ -2705,7 +2705,7 @@ static void shutdown(SLMP_INFO * info) | |||
2705 | if (info->port.tty) | 2705 | if (info->port.tty) |
2706 | set_bit(TTY_IO_ERROR, &info->port.tty->flags); | 2706 | set_bit(TTY_IO_ERROR, &info->port.tty->flags); |
2707 | 2707 | ||
2708 | info->port.flags &= ~ASYNC_INITIALIZED; | 2708 | tty_port_set_initialized(&info->port, 0); |
2709 | } | 2709 | } |
2710 | 2710 | ||
2711 | static void program_hw(SLMP_INFO *info) | 2711 | static void program_hw(SLMP_INFO *info) |
@@ -3308,12 +3308,12 @@ static int block_til_ready(struct tty_struct *tty, struct file *filp, | |||
3308 | port->blocked_open++; | 3308 | port->blocked_open++; |
3309 | 3309 | ||
3310 | while (1) { | 3310 | while (1) { |
3311 | if (C_BAUD(tty) && test_bit(ASYNCB_INITIALIZED, &port->flags)) | 3311 | if (C_BAUD(tty) && tty_port_initialized(port)) |
3312 | tty_port_raise_dtr_rts(port); | 3312 | tty_port_raise_dtr_rts(port); |
3313 | 3313 | ||
3314 | set_current_state(TASK_INTERRUPTIBLE); | 3314 | set_current_state(TASK_INTERRUPTIBLE); |
3315 | 3315 | ||
3316 | if (tty_hung_up_p(filp) || !(port->flags & ASYNC_INITIALIZED)){ | 3316 | if (tty_hung_up_p(filp) || !tty_port_initialized(port)) { |
3317 | retval = (port->flags & ASYNC_HUP_NOTIFY) ? | 3317 | retval = (port->flags & ASYNC_HUP_NOTIFY) ? |
3318 | -EAGAIN : -ERESTARTSYS; | 3318 | -EAGAIN : -ERESTARTSYS; |
3319 | break; | 3319 | break; |