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/cyclades.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/cyclades.c')
-rw-r--r-- | drivers/tty/cyclades.c | 14 |
1 files changed, 7 insertions, 7 deletions
diff --git a/drivers/tty/cyclades.c b/drivers/tty/cyclades.c index 9d1e19ba25cb..3840d6b421c4 100644 --- a/drivers/tty/cyclades.c +++ b/drivers/tty/cyclades.c | |||
@@ -1279,7 +1279,7 @@ static int cy_startup(struct cyclades_port *info, struct tty_struct *tty) | |||
1279 | 1279 | ||
1280 | spin_lock_irqsave(&card->card_lock, flags); | 1280 | spin_lock_irqsave(&card->card_lock, flags); |
1281 | 1281 | ||
1282 | if (info->port.flags & ASYNC_INITIALIZED) | 1282 | if (tty_port_initialized(&info->port)) |
1283 | goto errout; | 1283 | goto errout; |
1284 | 1284 | ||
1285 | if (!info->type) { | 1285 | if (!info->type) { |
@@ -1364,7 +1364,7 @@ static int cy_startup(struct cyclades_port *info, struct tty_struct *tty) | |||
1364 | /* enable send, recv, modem !!! */ | 1364 | /* enable send, recv, modem !!! */ |
1365 | } | 1365 | } |
1366 | 1366 | ||
1367 | info->port.flags |= ASYNC_INITIALIZED; | 1367 | tty_port_set_initialized(&info->port, 1); |
1368 | 1368 | ||
1369 | clear_bit(TTY_IO_ERROR, &tty->flags); | 1369 | clear_bit(TTY_IO_ERROR, &tty->flags); |
1370 | info->xmit_cnt = info->xmit_head = info->xmit_tail = 0; | 1370 | info->xmit_cnt = info->xmit_head = info->xmit_tail = 0; |
@@ -1424,7 +1424,7 @@ static void cy_shutdown(struct cyclades_port *info, struct tty_struct *tty) | |||
1424 | struct cyclades_card *card; | 1424 | struct cyclades_card *card; |
1425 | unsigned long flags; | 1425 | unsigned long flags; |
1426 | 1426 | ||
1427 | if (!(info->port.flags & ASYNC_INITIALIZED)) | 1427 | if (!tty_port_initialized(&info->port)) |
1428 | return; | 1428 | return; |
1429 | 1429 | ||
1430 | card = info->card; | 1430 | card = info->card; |
@@ -1448,7 +1448,7 @@ static void cy_shutdown(struct cyclades_port *info, struct tty_struct *tty) | |||
1448 | some later date (after testing)!!! */ | 1448 | some later date (after testing)!!! */ |
1449 | 1449 | ||
1450 | set_bit(TTY_IO_ERROR, &tty->flags); | 1450 | set_bit(TTY_IO_ERROR, &tty->flags); |
1451 | info->port.flags &= ~ASYNC_INITIALIZED; | 1451 | tty_port_set_initialized(&info->port, 0); |
1452 | spin_unlock_irqrestore(&card->card_lock, flags); | 1452 | spin_unlock_irqrestore(&card->card_lock, flags); |
1453 | } else { | 1453 | } else { |
1454 | #ifdef CY_DEBUG_OPEN | 1454 | #ifdef CY_DEBUG_OPEN |
@@ -1473,7 +1473,7 @@ static void cy_shutdown(struct cyclades_port *info, struct tty_struct *tty) | |||
1473 | tty_port_lower_dtr_rts(&info->port); | 1473 | tty_port_lower_dtr_rts(&info->port); |
1474 | 1474 | ||
1475 | set_bit(TTY_IO_ERROR, &tty->flags); | 1475 | set_bit(TTY_IO_ERROR, &tty->flags); |
1476 | info->port.flags &= ~ASYNC_INITIALIZED; | 1476 | tty_port_set_initialized(&info->port, 0); |
1477 | 1477 | ||
1478 | spin_unlock_irqrestore(&card->card_lock, flags); | 1478 | spin_unlock_irqrestore(&card->card_lock, flags); |
1479 | } | 1479 | } |
@@ -1711,7 +1711,7 @@ static void cy_do_close(struct tty_port *port) | |||
1711 | /* Stop accepting input */ | 1711 | /* Stop accepting input */ |
1712 | cyy_writeb(info, CyCAR, channel & 0x03); | 1712 | cyy_writeb(info, CyCAR, channel & 0x03); |
1713 | cyy_writeb(info, CySRER, cyy_readb(info, CySRER) & ~CyRxData); | 1713 | cyy_writeb(info, CySRER, cyy_readb(info, CySRER) & ~CyRxData); |
1714 | if (info->port.flags & ASYNC_INITIALIZED) { | 1714 | if (tty_port_initialized(&info->port)) { |
1715 | /* Waiting for on-board buffers to be empty before | 1715 | /* Waiting for on-board buffers to be empty before |
1716 | closing the port */ | 1716 | closing the port */ |
1717 | spin_unlock_irqrestore(&card->card_lock, flags); | 1717 | spin_unlock_irqrestore(&card->card_lock, flags); |
@@ -2334,7 +2334,7 @@ cy_set_serial_info(struct cyclades_port *info, struct tty_struct *tty, | |||
2334 | info->port.closing_wait = new_serial.closing_wait * HZ / 100; | 2334 | info->port.closing_wait = new_serial.closing_wait * HZ / 100; |
2335 | 2335 | ||
2336 | check_and_exit: | 2336 | check_and_exit: |
2337 | if (info->port.flags & ASYNC_INITIALIZED) { | 2337 | if (tty_port_initialized(&info->port)) { |
2338 | cy_set_line_char(info, tty); | 2338 | cy_set_line_char(info, tty); |
2339 | ret = 0; | 2339 | ret = 0; |
2340 | } else { | 2340 | } else { |