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 | |
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>
27 files changed, 157 insertions, 150 deletions
diff --git a/drivers/char/pcmcia/synclink_cs.c b/drivers/char/pcmcia/synclink_cs.c index bf54f4e23b6f..345ca7c7ea74 100644 --- a/drivers/char/pcmcia/synclink_cs.c +++ b/drivers/char/pcmcia/synclink_cs.c | |||
@@ -1272,7 +1272,7 @@ static int startup(MGSLPC_INFO * info, struct tty_struct *tty) | |||
1272 | if (debug_level >= DEBUG_LEVEL_INFO) | 1272 | if (debug_level >= DEBUG_LEVEL_INFO) |
1273 | printk("%s(%d):startup(%s)\n", __FILE__, __LINE__, info->device_name); | 1273 | printk("%s(%d):startup(%s)\n", __FILE__, __LINE__, info->device_name); |
1274 | 1274 | ||
1275 | if (info->port.flags & ASYNC_INITIALIZED) | 1275 | if (tty_port_initialized(&info->port)) |
1276 | return 0; | 1276 | return 0; |
1277 | 1277 | ||
1278 | if (!info->tx_buf) { | 1278 | if (!info->tx_buf) { |
@@ -1311,7 +1311,7 @@ static int startup(MGSLPC_INFO * info, struct tty_struct *tty) | |||
1311 | if (tty) | 1311 | if (tty) |
1312 | clear_bit(TTY_IO_ERROR, &tty->flags); | 1312 | clear_bit(TTY_IO_ERROR, &tty->flags); |
1313 | 1313 | ||
1314 | info->port.flags |= ASYNC_INITIALIZED; | 1314 | tty_port_set_initialized(&info->port, 1); |
1315 | 1315 | ||
1316 | return 0; | 1316 | return 0; |
1317 | } | 1317 | } |
@@ -1322,7 +1322,7 @@ static void shutdown(MGSLPC_INFO * info, struct tty_struct *tty) | |||
1322 | { | 1322 | { |
1323 | unsigned long flags; | 1323 | unsigned long flags; |
1324 | 1324 | ||
1325 | if (!(info->port.flags & ASYNC_INITIALIZED)) | 1325 | if (!tty_port_initialized(&info->port)) |
1326 | return; | 1326 | return; |
1327 | 1327 | ||
1328 | if (debug_level >= DEBUG_LEVEL_INFO) | 1328 | if (debug_level >= DEBUG_LEVEL_INFO) |
@@ -1361,7 +1361,7 @@ static void shutdown(MGSLPC_INFO * info, struct tty_struct *tty) | |||
1361 | if (tty) | 1361 | if (tty) |
1362 | set_bit(TTY_IO_ERROR, &tty->flags); | 1362 | set_bit(TTY_IO_ERROR, &tty->flags); |
1363 | 1363 | ||
1364 | info->port.flags &= ~ASYNC_INITIALIZED; | 1364 | tty_port_set_initialized(&info->port, 0); |
1365 | } | 1365 | } |
1366 | 1366 | ||
1367 | static void mgslpc_program_hw(MGSLPC_INFO *info, struct tty_struct *tty) | 1367 | static void mgslpc_program_hw(MGSLPC_INFO *info, struct tty_struct *tty) |
@@ -2338,7 +2338,7 @@ static void mgslpc_close(struct tty_struct *tty, struct file * filp) | |||
2338 | if (tty_port_close_start(port, tty, filp) == 0) | 2338 | if (tty_port_close_start(port, tty, filp) == 0) |
2339 | goto cleanup; | 2339 | goto cleanup; |
2340 | 2340 | ||
2341 | if (port->flags & ASYNC_INITIALIZED) | 2341 | if (tty_port_initialized(port)) |
2342 | mgslpc_wait_until_sent(tty, info->timeout); | 2342 | mgslpc_wait_until_sent(tty, info->timeout); |
2343 | 2343 | ||
2344 | mgslpc_flush_buffer(tty); | 2344 | mgslpc_flush_buffer(tty); |
@@ -2371,7 +2371,7 @@ static void mgslpc_wait_until_sent(struct tty_struct *tty, int timeout) | |||
2371 | if (mgslpc_paranoia_check(info, tty->name, "mgslpc_wait_until_sent")) | 2371 | if (mgslpc_paranoia_check(info, tty->name, "mgslpc_wait_until_sent")) |
2372 | return; | 2372 | return; |
2373 | 2373 | ||
2374 | if (!(info->port.flags & ASYNC_INITIALIZED)) | 2374 | if (!tty_port_initialized(&info->port)) |
2375 | goto exit; | 2375 | goto exit; |
2376 | 2376 | ||
2377 | orig_jiffies = jiffies; | 2377 | orig_jiffies = jiffies; |
diff --git a/drivers/ipack/devices/ipoctal.c b/drivers/ipack/devices/ipoctal.c index 035d5449227e..75dd15d66df6 100644 --- a/drivers/ipack/devices/ipoctal.c +++ b/drivers/ipack/devices/ipoctal.c | |||
@@ -629,8 +629,7 @@ static void ipoctal_hangup(struct tty_struct *tty) | |||
629 | tty_port_hangup(&channel->tty_port); | 629 | tty_port_hangup(&channel->tty_port); |
630 | 630 | ||
631 | ipoctal_reset_channel(channel); | 631 | ipoctal_reset_channel(channel); |
632 | 632 | tty_port_set_initialized(&channel->tty_port, 0); | |
633 | clear_bit(ASYNCB_INITIALIZED, &channel->tty_port.flags); | ||
634 | wake_up_interruptible(&channel->tty_port.open_wait); | 633 | wake_up_interruptible(&channel->tty_port.open_wait); |
635 | } | 634 | } |
636 | 635 | ||
@@ -642,7 +641,7 @@ static void ipoctal_shutdown(struct tty_struct *tty) | |||
642 | return; | 641 | return; |
643 | 642 | ||
644 | ipoctal_reset_channel(channel); | 643 | ipoctal_reset_channel(channel); |
645 | clear_bit(ASYNCB_INITIALIZED, &channel->tty_port.flags); | 644 | tty_port_set_initialized(&channel->tty_port, 0); |
646 | } | 645 | } |
647 | 646 | ||
648 | static void ipoctal_cleanup(struct tty_struct *tty) | 647 | static void ipoctal_cleanup(struct tty_struct *tty) |
diff --git a/drivers/isdn/i4l/isdn_tty.c b/drivers/isdn/i4l/isdn_tty.c index 023a350a8cd8..63eaa0a9f8a1 100644 --- a/drivers/isdn/i4l/isdn_tty.c +++ b/drivers/isdn/i4l/isdn_tty.c | |||
@@ -1049,7 +1049,7 @@ isdn_tty_change_speed(modem_info *info) | |||
1049 | static int | 1049 | static int |
1050 | isdn_tty_startup(modem_info *info) | 1050 | isdn_tty_startup(modem_info *info) |
1051 | { | 1051 | { |
1052 | if (info->port.flags & ASYNC_INITIALIZED) | 1052 | if (tty_port_initialized(&info->port)) |
1053 | return 0; | 1053 | return 0; |
1054 | isdn_lock_drivers(); | 1054 | isdn_lock_drivers(); |
1055 | #ifdef ISDN_DEBUG_MODEM_OPEN | 1055 | #ifdef ISDN_DEBUG_MODEM_OPEN |
@@ -1066,7 +1066,7 @@ isdn_tty_startup(modem_info *info) | |||
1066 | */ | 1066 | */ |
1067 | isdn_tty_change_speed(info); | 1067 | isdn_tty_change_speed(info); |
1068 | 1068 | ||
1069 | info->port.flags |= ASYNC_INITIALIZED; | 1069 | tty_port_set_initialized(&info->port, 1); |
1070 | info->msr |= (UART_MSR_DSR | UART_MSR_CTS); | 1070 | info->msr |= (UART_MSR_DSR | UART_MSR_CTS); |
1071 | info->send_outstanding = 0; | 1071 | info->send_outstanding = 0; |
1072 | return 0; | 1072 | return 0; |
@@ -1079,7 +1079,7 @@ isdn_tty_startup(modem_info *info) | |||
1079 | static void | 1079 | static void |
1080 | isdn_tty_shutdown(modem_info *info) | 1080 | isdn_tty_shutdown(modem_info *info) |
1081 | { | 1081 | { |
1082 | if (!(info->port.flags & ASYNC_INITIALIZED)) | 1082 | if (!tty_port_initialized(&info->port)) |
1083 | return; | 1083 | return; |
1084 | #ifdef ISDN_DEBUG_MODEM_OPEN | 1084 | #ifdef ISDN_DEBUG_MODEM_OPEN |
1085 | printk(KERN_DEBUG "Shutting down isdnmodem port %d ....\n", info->line); | 1085 | printk(KERN_DEBUG "Shutting down isdnmodem port %d ....\n", info->line); |
@@ -1099,7 +1099,7 @@ isdn_tty_shutdown(modem_info *info) | |||
1099 | if (info->port.tty) | 1099 | if (info->port.tty) |
1100 | set_bit(TTY_IO_ERROR, &info->port.tty->flags); | 1100 | set_bit(TTY_IO_ERROR, &info->port.tty->flags); |
1101 | 1101 | ||
1102 | info->port.flags &= ~ASYNC_INITIALIZED; | 1102 | tty_port_set_initialized(&info->port, 0); |
1103 | } | 1103 | } |
1104 | 1104 | ||
1105 | /* isdn_tty_write() is the main send-routine. It is called from the upper | 1105 | /* isdn_tty_write() is the main send-routine. It is called from the upper |
@@ -1577,7 +1577,7 @@ isdn_tty_close(struct tty_struct *tty, struct file *filp) | |||
1577 | * interrupt driver to stop checking the data ready bit in the | 1577 | * interrupt driver to stop checking the data ready bit in the |
1578 | * line status register. | 1578 | * line status register. |
1579 | */ | 1579 | */ |
1580 | if (port->flags & ASYNC_INITIALIZED) { | 1580 | if (tty_port_initialized(port)) { |
1581 | tty_wait_until_sent(tty, 3000); /* 30 seconds timeout */ | 1581 | tty_wait_until_sent(tty, 3000); /* 30 seconds timeout */ |
1582 | /* | 1582 | /* |
1583 | * Before we drop DTR, make sure the UART transmitter | 1583 | * Before we drop DTR, make sure the UART transmitter |
diff --git a/drivers/s390/char/con3215.c b/drivers/s390/char/con3215.c index 114fe2845270..931d10e86837 100644 --- a/drivers/s390/char/con3215.c +++ b/drivers/s390/char/con3215.c | |||
@@ -311,8 +311,7 @@ static void raw3215_timeout(unsigned long __data) | |||
311 | */ | 311 | */ |
312 | static inline void raw3215_try_io(struct raw3215_info *raw) | 312 | static inline void raw3215_try_io(struct raw3215_info *raw) |
313 | { | 313 | { |
314 | if (!(raw->port.flags & ASYNC_INITIALIZED) || | 314 | if (!tty_port_initialized(&raw->port) || tty_port_suspended(&raw->port)) |
315 | tty_port_suspended(&raw->port)) | ||
316 | return; | 315 | return; |
317 | if (raw->queued_read != NULL) | 316 | if (raw->queued_read != NULL) |
318 | raw3215_start_io(raw); | 317 | raw3215_start_io(raw); |
@@ -616,10 +615,10 @@ static int raw3215_startup(struct raw3215_info *raw) | |||
616 | { | 615 | { |
617 | unsigned long flags; | 616 | unsigned long flags; |
618 | 617 | ||
619 | if (raw->port.flags & ASYNC_INITIALIZED) | 618 | if (tty_port_initialized(&raw->port)) |
620 | return 0; | 619 | return 0; |
621 | raw->line_pos = 0; | 620 | raw->line_pos = 0; |
622 | raw->port.flags |= ASYNC_INITIALIZED; | 621 | tty_port_set_initialized(&raw->port, 1); |
623 | spin_lock_irqsave(get_ccwdev_lock(raw->cdev), flags); | 622 | spin_lock_irqsave(get_ccwdev_lock(raw->cdev), flags); |
624 | raw3215_try_io(raw); | 623 | raw3215_try_io(raw); |
625 | spin_unlock_irqrestore(get_ccwdev_lock(raw->cdev), flags); | 624 | spin_unlock_irqrestore(get_ccwdev_lock(raw->cdev), flags); |
@@ -635,8 +634,7 @@ static void raw3215_shutdown(struct raw3215_info *raw) | |||
635 | DECLARE_WAITQUEUE(wait, current); | 634 | DECLARE_WAITQUEUE(wait, current); |
636 | unsigned long flags; | 635 | unsigned long flags; |
637 | 636 | ||
638 | if (!(raw->port.flags & ASYNC_INITIALIZED) || | 637 | if (!tty_port_initialized(&raw->port) || (raw->flags & RAW3215_FIXED)) |
639 | (raw->flags & RAW3215_FIXED)) | ||
640 | return; | 638 | return; |
641 | /* Wait for outstanding requests, then free irq */ | 639 | /* Wait for outstanding requests, then free irq */ |
642 | spin_lock_irqsave(get_ccwdev_lock(raw->cdev), flags); | 640 | spin_lock_irqsave(get_ccwdev_lock(raw->cdev), flags); |
@@ -650,7 +648,7 @@ static void raw3215_shutdown(struct raw3215_info *raw) | |||
650 | spin_lock_irqsave(get_ccwdev_lock(raw->cdev), flags); | 648 | spin_lock_irqsave(get_ccwdev_lock(raw->cdev), flags); |
651 | remove_wait_queue(&raw->empty_wait, &wait); | 649 | remove_wait_queue(&raw->empty_wait, &wait); |
652 | set_current_state(TASK_RUNNING); | 650 | set_current_state(TASK_RUNNING); |
653 | raw->port.flags &= ~ASYNC_INITIALIZED; | 651 | tty_port_set_initialized(&raw->port, 1); |
654 | } | 652 | } |
655 | spin_unlock_irqrestore(get_ccwdev_lock(raw->cdev), flags); | 653 | spin_unlock_irqrestore(get_ccwdev_lock(raw->cdev), flags); |
656 | } | 654 | } |
diff --git a/drivers/tty/amiserial.c b/drivers/tty/amiserial.c index b4ab97d56351..208f573495dc 100644 --- a/drivers/tty/amiserial.c +++ b/drivers/tty/amiserial.c | |||
@@ -525,7 +525,7 @@ static int startup(struct tty_struct *tty, struct serial_state *info) | |||
525 | 525 | ||
526 | local_irq_save(flags); | 526 | local_irq_save(flags); |
527 | 527 | ||
528 | if (port->flags & ASYNC_INITIALIZED) { | 528 | if (tty_port_initialized(port)) { |
529 | free_page(page); | 529 | free_page(page); |
530 | goto errout; | 530 | goto errout; |
531 | } | 531 | } |
@@ -586,7 +586,7 @@ static int startup(struct tty_struct *tty, struct serial_state *info) | |||
586 | */ | 586 | */ |
587 | change_speed(tty, info, NULL); | 587 | change_speed(tty, info, NULL); |
588 | 588 | ||
589 | port->flags |= ASYNC_INITIALIZED; | 589 | tty_port_set_initialized(port, 1); |
590 | local_irq_restore(flags); | 590 | local_irq_restore(flags); |
591 | return 0; | 591 | return 0; |
592 | 592 | ||
@@ -604,7 +604,7 @@ static void shutdown(struct tty_struct *tty, struct serial_state *info) | |||
604 | unsigned long flags; | 604 | unsigned long flags; |
605 | struct serial_state *state; | 605 | struct serial_state *state; |
606 | 606 | ||
607 | if (!(info->tport.flags & ASYNC_INITIALIZED)) | 607 | if (!tty_port_initialized(&info->tport)) |
608 | return; | 608 | return; |
609 | 609 | ||
610 | state = info; | 610 | state = info; |
@@ -645,7 +645,7 @@ static void shutdown(struct tty_struct *tty, struct serial_state *info) | |||
645 | 645 | ||
646 | set_bit(TTY_IO_ERROR, &tty->flags); | 646 | set_bit(TTY_IO_ERROR, &tty->flags); |
647 | 647 | ||
648 | info->tport.flags &= ~ASYNC_INITIALIZED; | 648 | tty_port_set_initialized(&info->tport, 0); |
649 | local_irq_restore(flags); | 649 | local_irq_restore(flags); |
650 | } | 650 | } |
651 | 651 | ||
@@ -1084,7 +1084,7 @@ static int set_serial_info(struct tty_struct *tty, struct serial_state *state, | |||
1084 | port->low_latency = (port->flags & ASYNC_LOW_LATENCY) ? 1 : 0; | 1084 | port->low_latency = (port->flags & ASYNC_LOW_LATENCY) ? 1 : 0; |
1085 | 1085 | ||
1086 | check_and_exit: | 1086 | check_and_exit: |
1087 | if (port->flags & ASYNC_INITIALIZED) { | 1087 | if (tty_port_initialized(port)) { |
1088 | if (change_spd) { | 1088 | if (change_spd) { |
1089 | if ((port->flags & ASYNC_SPD_MASK) == ASYNC_SPD_HI) | 1089 | if ((port->flags & ASYNC_SPD_MASK) == ASYNC_SPD_HI) |
1090 | tty->alt_speed = 57600; | 1090 | tty->alt_speed = 57600; |
@@ -1390,7 +1390,7 @@ static void rs_close(struct tty_struct *tty, struct file * filp) | |||
1390 | * line status register. | 1390 | * line status register. |
1391 | */ | 1391 | */ |
1392 | state->read_status_mask &= ~UART_LSR_DR; | 1392 | state->read_status_mask &= ~UART_LSR_DR; |
1393 | if (port->flags & ASYNC_INITIALIZED) { | 1393 | if (tty_port_initialized(port)) { |
1394 | /* disable receive interrupts */ | 1394 | /* disable receive interrupts */ |
1395 | custom.intena = IF_RBF; | 1395 | custom.intena = IF_RBF; |
1396 | mb(); | 1396 | mb(); |
@@ -1538,7 +1538,7 @@ static inline void line_info(struct seq_file *m, int line, | |||
1538 | 1538 | ||
1539 | local_irq_save(flags); | 1539 | local_irq_save(flags); |
1540 | status = ciab.pra; | 1540 | status = ciab.pra; |
1541 | control = (state->tport.flags & ASYNC_INITIALIZED) ? state->MCR : status; | 1541 | control = tty_port_initialized(&state->tport) ? state->MCR : status; |
1542 | local_irq_restore(flags); | 1542 | local_irq_restore(flags); |
1543 | 1543 | ||
1544 | stat_buf[0] = 0; | 1544 | stat_buf[0] = 0; |
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 { |
diff --git a/drivers/tty/isicom.c b/drivers/tty/isicom.c index 0b2bae1b2d55..b70187b46d9d 100644 --- a/drivers/tty/isicom.c +++ b/drivers/tty/isicom.c | |||
@@ -438,8 +438,8 @@ static void isicom_tx(unsigned long _data) | |||
438 | 438 | ||
439 | for (; count > 0; count--, port++) { | 439 | for (; count > 0; count--, port++) { |
440 | /* port not active or tx disabled to force flow control */ | 440 | /* port not active or tx disabled to force flow control */ |
441 | if (!(port->port.flags & ASYNC_INITIALIZED) || | 441 | if (!tty_port_initialized(&port->port) || |
442 | !(port->status & ISI_TXOK)) | 442 | !(port->status & ISI_TXOK)) |
443 | continue; | 443 | continue; |
444 | 444 | ||
445 | txcount = min_t(short, TX_SIZE, port->xmit_cnt); | 445 | txcount = min_t(short, TX_SIZE, port->xmit_cnt); |
@@ -553,7 +553,7 @@ static irqreturn_t isicom_interrupt(int irq, void *dev_id) | |||
553 | return IRQ_HANDLED; | 553 | return IRQ_HANDLED; |
554 | } | 554 | } |
555 | port = card->ports + channel; | 555 | port = card->ports + channel; |
556 | if (!(port->port.flags & ASYNC_INITIALIZED)) { | 556 | if (!tty_port_initialized(&port->port)) { |
557 | outw(0x0000, base+0x04); /* enable interrupts */ | 557 | outw(0x0000, base+0x04); /* enable interrupts */ |
558 | spin_unlock(&card->card_lock); | 558 | spin_unlock(&card->card_lock); |
559 | return IRQ_HANDLED; | 559 | return IRQ_HANDLED; |
diff --git a/drivers/tty/moxa.c b/drivers/tty/moxa.c index ce521d3f58cb..60d37b225589 100644 --- a/drivers/tty/moxa.c +++ b/drivers/tty/moxa.c | |||
@@ -912,7 +912,7 @@ static void moxa_board_deinit(struct moxa_board_conf *brd) | |||
912 | 912 | ||
913 | /* pci hot-un-plug support */ | 913 | /* pci hot-un-plug support */ |
914 | for (a = 0; a < brd->numPorts; a++) | 914 | for (a = 0; a < brd->numPorts; a++) |
915 | if (brd->ports[a].port.flags & ASYNC_INITIALIZED) | 915 | if (tty_port_initialized(&brd->ports[a].port)) |
916 | tty_port_tty_hangup(&brd->ports[a].port, false); | 916 | tty_port_tty_hangup(&brd->ports[a].port, false); |
917 | 917 | ||
918 | for (a = 0; a < MAX_PORTS_PER_BOARD; a++) | 918 | for (a = 0; a < MAX_PORTS_PER_BOARD; a++) |
@@ -921,7 +921,7 @@ static void moxa_board_deinit(struct moxa_board_conf *brd) | |||
921 | while (1) { | 921 | while (1) { |
922 | opened = 0; | 922 | opened = 0; |
923 | for (a = 0; a < brd->numPorts; a++) | 923 | for (a = 0; a < brd->numPorts; a++) |
924 | if (brd->ports[a].port.flags & ASYNC_INITIALIZED) | 924 | if (tty_port_initialized(&brd->ports[a].port)) |
925 | opened++; | 925 | opened++; |
926 | mutex_unlock(&moxa_openlock); | 926 | mutex_unlock(&moxa_openlock); |
927 | if (!opened) | 927 | if (!opened) |
@@ -1192,13 +1192,13 @@ static int moxa_open(struct tty_struct *tty, struct file *filp) | |||
1192 | tty->driver_data = ch; | 1192 | tty->driver_data = ch; |
1193 | tty_port_tty_set(&ch->port, tty); | 1193 | tty_port_tty_set(&ch->port, tty); |
1194 | mutex_lock(&ch->port.mutex); | 1194 | mutex_lock(&ch->port.mutex); |
1195 | if (!(ch->port.flags & ASYNC_INITIALIZED)) { | 1195 | if (!tty_port_initialized(&ch->port)) { |
1196 | ch->statusflags = 0; | 1196 | ch->statusflags = 0; |
1197 | moxa_set_tty_param(tty, &tty->termios); | 1197 | moxa_set_tty_param(tty, &tty->termios); |
1198 | MoxaPortLineCtrl(ch, 1, 1); | 1198 | MoxaPortLineCtrl(ch, 1, 1); |
1199 | MoxaPortEnable(ch); | 1199 | MoxaPortEnable(ch); |
1200 | MoxaSetFifo(ch, ch->type == PORT_16550A); | 1200 | MoxaSetFifo(ch, ch->type == PORT_16550A); |
1201 | ch->port.flags |= ASYNC_INITIALIZED; | 1201 | tty_port_set_initialized(&ch->port, 1); |
1202 | } | 1202 | } |
1203 | mutex_unlock(&ch->port.mutex); | 1203 | mutex_unlock(&ch->port.mutex); |
1204 | mutex_unlock(&moxa_openlock); | 1204 | mutex_unlock(&moxa_openlock); |
@@ -1379,7 +1379,7 @@ static int moxa_poll_port(struct moxa_port *p, unsigned int handle, | |||
1379 | { | 1379 | { |
1380 | struct tty_struct *tty = tty_port_tty_get(&p->port); | 1380 | struct tty_struct *tty = tty_port_tty_get(&p->port); |
1381 | void __iomem *ofsAddr; | 1381 | void __iomem *ofsAddr; |
1382 | unsigned int inited = p->port.flags & ASYNC_INITIALIZED; | 1382 | unsigned int inited = tty_port_initialized(&p->port); |
1383 | u16 intr; | 1383 | u16 intr; |
1384 | 1384 | ||
1385 | if (tty) { | 1385 | if (tty) { |
diff --git a/drivers/tty/mxser.c b/drivers/tty/mxser.c index ab618ef3d171..7e8c27bf1ac8 100644 --- a/drivers/tty/mxser.c +++ b/drivers/tty/mxser.c | |||
@@ -1081,12 +1081,10 @@ static void mxser_close(struct tty_struct *tty, struct file *filp) | |||
1081 | mutex_lock(&port->mutex); | 1081 | mutex_lock(&port->mutex); |
1082 | mxser_close_port(port); | 1082 | mxser_close_port(port); |
1083 | mxser_flush_buffer(tty); | 1083 | mxser_flush_buffer(tty); |
1084 | if (test_bit(ASYNCB_INITIALIZED, &port->flags)) { | 1084 | if (tty_port_initialized(port) && C_HUPCL(tty)) |
1085 | if (C_HUPCL(tty)) | 1085 | tty_port_lower_dtr_rts(port); |
1086 | tty_port_lower_dtr_rts(port); | ||
1087 | } | ||
1088 | mxser_shutdown_port(port); | 1086 | mxser_shutdown_port(port); |
1089 | clear_bit(ASYNCB_INITIALIZED, &port->flags); | 1087 | tty_port_set_initialized(port, 0); |
1090 | mutex_unlock(&port->mutex); | 1088 | mutex_unlock(&port->mutex); |
1091 | info->closing = 0; | 1089 | info->closing = 0; |
1092 | /* Right now the tty_port set is done outside of the close_end helper | 1090 | /* Right now the tty_port set is done outside of the close_end helper |
@@ -1282,7 +1280,7 @@ static int mxser_set_serial_info(struct tty_struct *tty, | |||
1282 | 1280 | ||
1283 | process_txrx_fifo(info); | 1281 | process_txrx_fifo(info); |
1284 | 1282 | ||
1285 | if (test_bit(ASYNCB_INITIALIZED, &port->flags)) { | 1283 | if (tty_port_initialized(port)) { |
1286 | if (flags != (port->flags & ASYNC_SPD_MASK)) { | 1284 | if (flags != (port->flags & ASYNC_SPD_MASK)) { |
1287 | spin_lock_irqsave(&info->slock, sl_flags); | 1285 | spin_lock_irqsave(&info->slock, sl_flags); |
1288 | mxser_change_speed(tty, NULL); | 1286 | mxser_change_speed(tty, NULL); |
@@ -1291,7 +1289,7 @@ static int mxser_set_serial_info(struct tty_struct *tty, | |||
1291 | } else { | 1289 | } else { |
1292 | retval = mxser_activate(port, tty); | 1290 | retval = mxser_activate(port, tty); |
1293 | if (retval == 0) | 1291 | if (retval == 0) |
1294 | set_bit(ASYNCB_INITIALIZED, &port->flags); | 1292 | tty_port_set_initialized(port, 1); |
1295 | } | 1293 | } |
1296 | return retval; | 1294 | return retval; |
1297 | } | 1295 | } |
@@ -2251,7 +2249,7 @@ static irqreturn_t mxser_interrupt(int irq, void *dev_id) | |||
2251 | iir &= MOXA_MUST_IIR_MASK; | 2249 | iir &= MOXA_MUST_IIR_MASK; |
2252 | tty = tty_port_tty_get(&port->port); | 2250 | tty = tty_port_tty_get(&port->port); |
2253 | if (!tty || port->closing || | 2251 | if (!tty || port->closing || |
2254 | !(port->port.flags & ASYNC_INITIALIZED)) { | 2252 | !tty_port_initialized(&port->port)) { |
2255 | status = inb(port->ioaddr + UART_LSR); | 2253 | status = inb(port->ioaddr + UART_LSR); |
2256 | outb(0x27, port->ioaddr + UART_FCR); | 2254 | outb(0x27, port->ioaddr + UART_FCR); |
2257 | inb(port->ioaddr + UART_MSR); | 2255 | inb(port->ioaddr + UART_MSR); |
diff --git a/drivers/tty/n_gsm.c b/drivers/tty/n_gsm.c index 365dfd8bc42b..9f7a7bbff57d 100644 --- a/drivers/tty/n_gsm.c +++ b/drivers/tty/n_gsm.c | |||
@@ -2949,7 +2949,7 @@ static int gsmtty_open(struct tty_struct *tty, struct file *filp) | |||
2949 | dlci->modem_rx = 0; | 2949 | dlci->modem_rx = 0; |
2950 | /* We could in theory open and close before we wait - eg if we get | 2950 | /* We could in theory open and close before we wait - eg if we get |
2951 | a DM straight back. This is ok as that will have caused a hangup */ | 2951 | a DM straight back. This is ok as that will have caused a hangup */ |
2952 | set_bit(ASYNCB_INITIALIZED, &port->flags); | 2952 | tty_port_set_initialized(port, 1); |
2953 | /* Start sending off SABM messages */ | 2953 | /* Start sending off SABM messages */ |
2954 | gsm_dlci_begin_open(dlci); | 2954 | gsm_dlci_begin_open(dlci); |
2955 | /* And wait for virtual carrier */ | 2955 | /* And wait for virtual carrier */ |
@@ -2972,10 +2972,8 @@ static void gsmtty_close(struct tty_struct *tty, struct file *filp) | |||
2972 | if (tty_port_close_start(&dlci->port, tty, filp) == 0) | 2972 | if (tty_port_close_start(&dlci->port, tty, filp) == 0) |
2973 | return; | 2973 | return; |
2974 | gsm_dlci_begin_close(dlci); | 2974 | gsm_dlci_begin_close(dlci); |
2975 | if (test_bit(ASYNCB_INITIALIZED, &dlci->port.flags)) { | 2975 | if (tty_port_initialized(&dlci->port) && C_HUPCL(tty)) |
2976 | if (C_HUPCL(tty)) | 2976 | tty_port_lower_dtr_rts(&dlci->port); |
2977 | tty_port_lower_dtr_rts(&dlci->port); | ||
2978 | } | ||
2979 | tty_port_close_end(&dlci->port, tty); | 2977 | tty_port_close_end(&dlci->port, tty); |
2980 | tty_port_tty_set(&dlci->port, NULL); | 2978 | tty_port_tty_set(&dlci->port, NULL); |
2981 | return; | 2979 | return; |
diff --git a/drivers/tty/rocket.c b/drivers/tty/rocket.c index eb8311b20782..7f3b1db88061 100644 --- a/drivers/tty/rocket.c +++ b/drivers/tty/rocket.c | |||
@@ -495,7 +495,7 @@ static void rp_handle_port(struct r_port *info) | |||
495 | if (!info) | 495 | if (!info) |
496 | return; | 496 | return; |
497 | 497 | ||
498 | if ((info->port.flags & ASYNC_INITIALIZED) == 0) { | 498 | if (!tty_port_initialized(&info->port)) { |
499 | printk(KERN_WARNING "rp: WARNING: rp_handle_port called with " | 499 | printk(KERN_WARNING "rp: WARNING: rp_handle_port called with " |
500 | "info->flags & NOT_INIT\n"); | 500 | "info->flags & NOT_INIT\n"); |
501 | return; | 501 | return; |
@@ -920,7 +920,7 @@ static int rp_open(struct tty_struct *tty, struct file *filp) | |||
920 | /* | 920 | /* |
921 | * Info->count is now 1; so it's safe to sleep now. | 921 | * Info->count is now 1; so it's safe to sleep now. |
922 | */ | 922 | */ |
923 | if (!test_bit(ASYNCB_INITIALIZED, &port->flags)) { | 923 | if (!tty_port_initialized(port)) { |
924 | cp = &info->channel; | 924 | cp = &info->channel; |
925 | sSetRxTrigger(cp, TRIG_1); | 925 | sSetRxTrigger(cp, TRIG_1); |
926 | if (sGetChanStatus(cp) & CD_ACT) | 926 | if (sGetChanStatus(cp) & CD_ACT) |
@@ -944,7 +944,7 @@ static int rp_open(struct tty_struct *tty, struct file *filp) | |||
944 | sEnRxFIFO(cp); | 944 | sEnRxFIFO(cp); |
945 | sEnTransmit(cp); | 945 | sEnTransmit(cp); |
946 | 946 | ||
947 | set_bit(ASYNCB_INITIALIZED, &info->port.flags); | 947 | tty_port_set_initialized(&info->port, 1); |
948 | 948 | ||
949 | /* | 949 | /* |
950 | * Set up the tty->alt_speed kludge | 950 | * Set up the tty->alt_speed kludge |
@@ -1042,9 +1042,9 @@ static void rp_close(struct tty_struct *tty, struct file *filp) | |||
1042 | } | 1042 | } |
1043 | } | 1043 | } |
1044 | spin_lock_irq(&port->lock); | 1044 | spin_lock_irq(&port->lock); |
1045 | port->flags &= ~ASYNC_INITIALIZED; | ||
1046 | tty->closing = 0; | 1045 | tty->closing = 0; |
1047 | spin_unlock_irq(&port->lock); | 1046 | spin_unlock_irq(&port->lock); |
1047 | tty_port_set_initialized(port, 0); | ||
1048 | tty_port_set_active(port, 0); | 1048 | tty_port_set_active(port, 0); |
1049 | mutex_unlock(&port->mutex); | 1049 | mutex_unlock(&port->mutex); |
1050 | tty_port_tty_set(port, NULL); | 1050 | tty_port_tty_set(port, NULL); |
@@ -1513,7 +1513,7 @@ static void rp_hangup(struct tty_struct *tty) | |||
1513 | sDisCTSFlowCtl(cp); | 1513 | sDisCTSFlowCtl(cp); |
1514 | sDisTxSoftFlowCtl(cp); | 1514 | sDisTxSoftFlowCtl(cp); |
1515 | sClrTxXOFF(cp); | 1515 | sClrTxXOFF(cp); |
1516 | clear_bit(ASYNCB_INITIALIZED, &info->port.flags); | 1516 | tty_port_set_initialized(&info->port, 0); |
1517 | 1517 | ||
1518 | wake_up_interruptible(&info->port.open_wait); | 1518 | wake_up_interruptible(&info->port.open_wait); |
1519 | } | 1519 | } |
diff --git a/drivers/tty/serial/crisv10.c b/drivers/tty/serial/crisv10.c index 92c8c628e00e..315c84979b18 100644 --- a/drivers/tty/serial/crisv10.c +++ b/drivers/tty/serial/crisv10.c | |||
@@ -2599,7 +2599,7 @@ startup(struct e100_serial * info) | |||
2599 | 2599 | ||
2600 | /* if it was already initialized, skip this */ | 2600 | /* if it was already initialized, skip this */ |
2601 | 2601 | ||
2602 | if (info->port.flags & ASYNC_INITIALIZED) { | 2602 | if (tty_port_initialized(&info->port)) { |
2603 | local_irq_restore(flags); | 2603 | local_irq_restore(flags); |
2604 | free_page(xmit_page); | 2604 | free_page(xmit_page); |
2605 | return 0; | 2605 | return 0; |
@@ -2703,7 +2703,7 @@ startup(struct e100_serial * info) | |||
2703 | e100_rts(info, 1); | 2703 | e100_rts(info, 1); |
2704 | e100_dtr(info, 1); | 2704 | e100_dtr(info, 1); |
2705 | 2705 | ||
2706 | info->port.flags |= ASYNC_INITIALIZED; | 2706 | tty_port_set_initialized(&info->port, 1); |
2707 | 2707 | ||
2708 | local_irq_restore(flags); | 2708 | local_irq_restore(flags); |
2709 | return 0; | 2709 | return 0; |
@@ -2745,7 +2745,7 @@ shutdown(struct e100_serial * info) | |||
2745 | info->tr_running = 0; | 2745 | info->tr_running = 0; |
2746 | } | 2746 | } |
2747 | 2747 | ||
2748 | if (!(info->port.flags & ASYNC_INITIALIZED)) | 2748 | if (!tty_port_initialized(&info->port)) |
2749 | return; | 2749 | return; |
2750 | 2750 | ||
2751 | #ifdef SERIAL_DEBUG_OPEN | 2751 | #ifdef SERIAL_DEBUG_OPEN |
@@ -2776,7 +2776,7 @@ shutdown(struct e100_serial * info) | |||
2776 | if (info->port.tty) | 2776 | if (info->port.tty) |
2777 | set_bit(TTY_IO_ERROR, &info->port.tty->flags); | 2777 | set_bit(TTY_IO_ERROR, &info->port.tty->flags); |
2778 | 2778 | ||
2779 | info->port.flags &= ~ASYNC_INITIALIZED; | 2779 | tty_port_set_initialized(&info->port, 0); |
2780 | local_irq_restore(flags); | 2780 | local_irq_restore(flags); |
2781 | } | 2781 | } |
2782 | 2782 | ||
@@ -3273,9 +3273,9 @@ set_serial_info(struct e100_serial *info, | |||
3273 | info->port.low_latency = (info->port.flags & ASYNC_LOW_LATENCY) ? 1 : 0; | 3273 | info->port.low_latency = (info->port.flags & ASYNC_LOW_LATENCY) ? 1 : 0; |
3274 | 3274 | ||
3275 | check_and_exit: | 3275 | check_and_exit: |
3276 | if (info->port.flags & ASYNC_INITIALIZED) { | 3276 | if (tty_port_initialized(&info->port)) |
3277 | change_speed(info); | 3277 | change_speed(info); |
3278 | } else | 3278 | else |
3279 | retval = startup(info); | 3279 | retval = startup(info); |
3280 | return retval; | 3280 | return retval; |
3281 | } | 3281 | } |
@@ -3628,7 +3628,7 @@ rs_close(struct tty_struct *tty, struct file * filp) | |||
3628 | e100_disable_rx(info); | 3628 | e100_disable_rx(info); |
3629 | e100_disable_rx_irq(info); | 3629 | e100_disable_rx_irq(info); |
3630 | 3630 | ||
3631 | if (info->port.flags & ASYNC_INITIALIZED) { | 3631 | if (tty_port_initialized(&info->port)) { |
3632 | /* | 3632 | /* |
3633 | * Before we drop DTR, make sure the UART transmitter | 3633 | * Before we drop DTR, make sure the UART transmitter |
3634 | * has completely drained; this is especially | 3634 | * has completely drained; this is especially |
@@ -3787,8 +3787,7 @@ block_til_ready(struct tty_struct *tty, struct file * filp, | |||
3787 | e100_dtr(info, 1); | 3787 | e100_dtr(info, 1); |
3788 | local_irq_restore(flags); | 3788 | local_irq_restore(flags); |
3789 | set_current_state(TASK_INTERRUPTIBLE); | 3789 | set_current_state(TASK_INTERRUPTIBLE); |
3790 | if (tty_hung_up_p(filp) || | 3790 | if (tty_hung_up_p(filp) || !tty_port_initialized(&info->port)) { |
3791 | !(info->port.flags & ASYNC_INITIALIZED)) { | ||
3792 | #ifdef SERIAL_DO_RESTART | 3791 | #ifdef SERIAL_DO_RESTART |
3793 | if (info->port.flags & ASYNC_HUP_NOTIFY) | 3792 | if (info->port.flags & ASYNC_HUP_NOTIFY) |
3794 | retval = -EAGAIN; | 3793 | retval = -EAGAIN; |
diff --git a/drivers/tty/serial/serial_core.c b/drivers/tty/serial/serial_core.c index 933606777f45..0c48051db172 100644 --- a/drivers/tty/serial/serial_core.c +++ b/drivers/tty/serial/serial_core.c | |||
@@ -196,7 +196,7 @@ static int uart_startup(struct tty_struct *tty, struct uart_state *state, | |||
196 | struct tty_port *port = &state->port; | 196 | struct tty_port *port = &state->port; |
197 | int retval; | 197 | int retval; |
198 | 198 | ||
199 | if (port->flags & ASYNC_INITIALIZED) | 199 | if (tty_port_initialized(port)) |
200 | return 0; | 200 | return 0; |
201 | 201 | ||
202 | /* | 202 | /* |
@@ -207,7 +207,7 @@ static int uart_startup(struct tty_struct *tty, struct uart_state *state, | |||
207 | 207 | ||
208 | retval = uart_port_startup(tty, state, init_hw); | 208 | retval = uart_port_startup(tty, state, init_hw); |
209 | if (!retval) { | 209 | if (!retval) { |
210 | set_bit(ASYNCB_INITIALIZED, &port->flags); | 210 | tty_port_set_initialized(port, 1); |
211 | clear_bit(TTY_IO_ERROR, &tty->flags); | 211 | clear_bit(TTY_IO_ERROR, &tty->flags); |
212 | } else if (retval > 0) | 212 | } else if (retval > 0) |
213 | retval = 0; | 213 | retval = 0; |
@@ -231,7 +231,9 @@ static void uart_shutdown(struct tty_struct *tty, struct uart_state *state) | |||
231 | if (tty) | 231 | if (tty) |
232 | set_bit(TTY_IO_ERROR, &tty->flags); | 232 | set_bit(TTY_IO_ERROR, &tty->flags); |
233 | 233 | ||
234 | if (test_and_clear_bit(ASYNCB_INITIALIZED, &port->flags)) { | 234 | if (tty_port_initialized(port)) { |
235 | tty_port_set_initialized(port, 0); | ||
236 | |||
235 | /* | 237 | /* |
236 | * Turn off DTR and RTS early. | 238 | * Turn off DTR and RTS early. |
237 | */ | 239 | */ |
@@ -886,7 +888,7 @@ static int uart_set_info(struct tty_struct *tty, struct tty_port *port, | |||
886 | retval = 0; | 888 | retval = 0; |
887 | if (uport->type == PORT_UNKNOWN) | 889 | if (uport->type == PORT_UNKNOWN) |
888 | goto exit; | 890 | goto exit; |
889 | if (port->flags & ASYNC_INITIALIZED) { | 891 | if (tty_port_initialized(port)) { |
890 | if (((old_flags ^ uport->flags) & UPF_SPD_MASK) || | 892 | if (((old_flags ^ uport->flags) & UPF_SPD_MASK) || |
891 | old_custom_divisor != uport->custom_divisor) { | 893 | old_custom_divisor != uport->custom_divisor) { |
892 | /* | 894 | /* |
@@ -1390,7 +1392,7 @@ static void uart_close(struct tty_struct *tty, struct file *filp) | |||
1390 | * At this point, we stop accepting input. To do this, we | 1392 | * At this point, we stop accepting input. To do this, we |
1391 | * disable the receive line status interrupts. | 1393 | * disable the receive line status interrupts. |
1392 | */ | 1394 | */ |
1393 | if (port->flags & ASYNC_INITIALIZED) { | 1395 | if (tty_port_initialized(port)) { |
1394 | spin_lock_irq(&uport->lock); | 1396 | spin_lock_irq(&uport->lock); |
1395 | uport->ops->stop_rx(uport); | 1397 | uport->ops->stop_rx(uport); |
1396 | spin_unlock_irq(&uport->lock); | 1398 | spin_unlock_irq(&uport->lock); |
@@ -2003,12 +2005,12 @@ int uart_suspend_port(struct uart_driver *drv, struct uart_port *uport) | |||
2003 | 2005 | ||
2004 | uport->suspended = 1; | 2006 | uport->suspended = 1; |
2005 | 2007 | ||
2006 | if (port->flags & ASYNC_INITIALIZED) { | 2008 | if (tty_port_initialized(port)) { |
2007 | const struct uart_ops *ops = uport->ops; | 2009 | const struct uart_ops *ops = uport->ops; |
2008 | int tries; | 2010 | int tries; |
2009 | 2011 | ||
2010 | tty_port_set_suspended(port, 1); | 2012 | tty_port_set_suspended(port, 1); |
2011 | clear_bit(ASYNCB_INITIALIZED, &port->flags); | 2013 | tty_port_set_initialized(port, 0); |
2012 | 2014 | ||
2013 | spin_lock_irq(&uport->lock); | 2015 | spin_lock_irq(&uport->lock); |
2014 | ops->stop_tx(uport); | 2016 | ops->stop_tx(uport); |
@@ -2107,7 +2109,7 @@ int uart_resume_port(struct uart_driver *drv, struct uart_port *uport) | |||
2107 | ops->set_mctrl(uport, uport->mctrl); | 2109 | ops->set_mctrl(uport, uport->mctrl); |
2108 | ops->start_tx(uport); | 2110 | ops->start_tx(uport); |
2109 | spin_unlock_irq(&uport->lock); | 2111 | spin_unlock_irq(&uport->lock); |
2110 | set_bit(ASYNCB_INITIALIZED, &port->flags); | 2112 | tty_port_set_initialized(port, 1); |
2111 | } else { | 2113 | } else { |
2112 | /* | 2114 | /* |
2113 | * Failed to resume - maybe hardware went away? | 2115 | * Failed to resume - maybe hardware went away? |
@@ -2248,10 +2250,10 @@ static int uart_poll_init(struct tty_driver *driver, int line, char *options) | |||
2248 | ret = 0; | 2250 | ret = 0; |
2249 | mutex_lock(&tport->mutex); | 2251 | mutex_lock(&tport->mutex); |
2250 | /* | 2252 | /* |
2251 | * We don't set ASYNCB_INITIALIZED as we only initialized the | 2253 | * We don't set initialized as we only initialized the hw, |
2252 | * hw, e.g. state->xmit is still uninitialized. | 2254 | * e.g. state->xmit is still uninitialized. |
2253 | */ | 2255 | */ |
2254 | if (!test_bit(ASYNCB_INITIALIZED, &tport->flags)) | 2256 | if (!tty_port_initialized(tport)) |
2255 | ret = port->ops->poll_init(port); | 2257 | ret = port->ops->poll_init(port); |
2256 | mutex_unlock(&tport->mutex); | 2258 | mutex_unlock(&tport->mutex); |
2257 | if (ret) | 2259 | if (ret) |
diff --git a/drivers/tty/synclink.c b/drivers/tty/synclink.c index b67b54a800bb..bc4bc1ff775e 100644 --- a/drivers/tty/synclink.c +++ b/drivers/tty/synclink.c | |||
@@ -1749,13 +1749,13 @@ static irqreturn_t mgsl_interrupt(int dummy, void *dev_id) | |||
1749 | static int startup(struct mgsl_struct * info) | 1749 | static int startup(struct mgsl_struct * info) |
1750 | { | 1750 | { |
1751 | int retval = 0; | 1751 | int retval = 0; |
1752 | 1752 | ||
1753 | if ( debug_level >= DEBUG_LEVEL_INFO ) | 1753 | if ( debug_level >= DEBUG_LEVEL_INFO ) |
1754 | printk("%s(%d):mgsl_startup(%s)\n",__FILE__,__LINE__,info->device_name); | 1754 | printk("%s(%d):mgsl_startup(%s)\n",__FILE__,__LINE__,info->device_name); |
1755 | 1755 | ||
1756 | if (info->port.flags & ASYNC_INITIALIZED) | 1756 | if (tty_port_initialized(&info->port)) |
1757 | return 0; | 1757 | return 0; |
1758 | 1758 | ||
1759 | if (!info->xmit_buf) { | 1759 | if (!info->xmit_buf) { |
1760 | /* allocate a page of memory for a transmit buffer */ | 1760 | /* allocate a page of memory for a transmit buffer */ |
1761 | info->xmit_buf = (unsigned char *)get_zeroed_page(GFP_KERNEL); | 1761 | info->xmit_buf = (unsigned char *)get_zeroed_page(GFP_KERNEL); |
@@ -1788,14 +1788,13 @@ static int startup(struct mgsl_struct * info) | |||
1788 | 1788 | ||
1789 | /* program hardware for current parameters */ | 1789 | /* program hardware for current parameters */ |
1790 | mgsl_change_params(info); | 1790 | mgsl_change_params(info); |
1791 | 1791 | ||
1792 | if (info->port.tty) | 1792 | if (info->port.tty) |
1793 | clear_bit(TTY_IO_ERROR, &info->port.tty->flags); | 1793 | clear_bit(TTY_IO_ERROR, &info->port.tty->flags); |
1794 | 1794 | ||
1795 | info->port.flags |= ASYNC_INITIALIZED; | 1795 | tty_port_set_initialized(&info->port, 1); |
1796 | 1796 | ||
1797 | return 0; | 1797 | return 0; |
1798 | |||
1799 | } /* end of startup() */ | 1798 | } /* end of startup() */ |
1800 | 1799 | ||
1801 | /* shutdown() | 1800 | /* shutdown() |
@@ -1808,8 +1807,8 @@ static int startup(struct mgsl_struct * info) | |||
1808 | static void shutdown(struct mgsl_struct * info) | 1807 | static void shutdown(struct mgsl_struct * info) |
1809 | { | 1808 | { |
1810 | unsigned long flags; | 1809 | unsigned long flags; |
1811 | 1810 | ||
1812 | if (!(info->port.flags & ASYNC_INITIALIZED)) | 1811 | if (!tty_port_initialized(&info->port)) |
1813 | return; | 1812 | return; |
1814 | 1813 | ||
1815 | if (debug_level >= DEBUG_LEVEL_INFO) | 1814 | if (debug_level >= DEBUG_LEVEL_INFO) |
@@ -1853,13 +1852,12 @@ static void shutdown(struct mgsl_struct * info) | |||
1853 | 1852 | ||
1854 | spin_unlock_irqrestore(&info->irq_spinlock,flags); | 1853 | spin_unlock_irqrestore(&info->irq_spinlock,flags); |
1855 | 1854 | ||
1856 | mgsl_release_resources(info); | 1855 | mgsl_release_resources(info); |
1857 | 1856 | ||
1858 | if (info->port.tty) | 1857 | if (info->port.tty) |
1859 | set_bit(TTY_IO_ERROR, &info->port.tty->flags); | 1858 | set_bit(TTY_IO_ERROR, &info->port.tty->flags); |
1860 | 1859 | ||
1861 | info->port.flags &= ~ASYNC_INITIALIZED; | 1860 | tty_port_set_initialized(&info->port, 0); |
1862 | |||
1863 | } /* end of shutdown() */ | 1861 | } /* end of shutdown() */ |
1864 | 1862 | ||
1865 | static void mgsl_program_hw(struct mgsl_struct *info) | 1863 | static void mgsl_program_hw(struct mgsl_struct *info) |
@@ -3084,7 +3082,7 @@ static void mgsl_close(struct tty_struct *tty, struct file * filp) | |||
3084 | goto cleanup; | 3082 | goto cleanup; |
3085 | 3083 | ||
3086 | mutex_lock(&info->port.mutex); | 3084 | mutex_lock(&info->port.mutex); |
3087 | if (info->port.flags & ASYNC_INITIALIZED) | 3085 | if (tty_port_initialized(&info->port)) |
3088 | mgsl_wait_until_sent(tty, info->timeout); | 3086 | mgsl_wait_until_sent(tty, info->timeout); |
3089 | mgsl_flush_buffer(tty); | 3087 | mgsl_flush_buffer(tty); |
3090 | tty_ldisc_flush(tty); | 3088 | tty_ldisc_flush(tty); |
@@ -3122,15 +3120,15 @@ static void mgsl_wait_until_sent(struct tty_struct *tty, int timeout) | |||
3122 | if (debug_level >= DEBUG_LEVEL_INFO) | 3120 | if (debug_level >= DEBUG_LEVEL_INFO) |
3123 | printk("%s(%d):mgsl_wait_until_sent(%s) entry\n", | 3121 | printk("%s(%d):mgsl_wait_until_sent(%s) entry\n", |
3124 | __FILE__,__LINE__, info->device_name ); | 3122 | __FILE__,__LINE__, info->device_name ); |
3125 | 3123 | ||
3126 | if (mgsl_paranoia_check(info, tty->name, "mgsl_wait_until_sent")) | 3124 | if (mgsl_paranoia_check(info, tty->name, "mgsl_wait_until_sent")) |
3127 | return; | 3125 | return; |
3128 | 3126 | ||
3129 | if (!(info->port.flags & ASYNC_INITIALIZED)) | 3127 | if (!tty_port_initialized(&info->port)) |
3130 | goto exit; | 3128 | goto exit; |
3131 | 3129 | ||
3132 | orig_jiffies = jiffies; | 3130 | orig_jiffies = jiffies; |
3133 | 3131 | ||
3134 | /* Set check interval to 1/5 of estimated time to | 3132 | /* Set check interval to 1/5 of estimated time to |
3135 | * send a character, and make it at least 1. The check | 3133 | * send a character, and make it at least 1. The check |
3136 | * interval should also be less than the timeout. | 3134 | * interval should also be less than the timeout. |
@@ -3290,14 +3288,14 @@ static int block_til_ready(struct tty_struct *tty, struct file * filp, | |||
3290 | port->count--; | 3288 | port->count--; |
3291 | spin_unlock_irqrestore(&info->irq_spinlock, flags); | 3289 | spin_unlock_irqrestore(&info->irq_spinlock, flags); |
3292 | port->blocked_open++; | 3290 | port->blocked_open++; |
3293 | 3291 | ||
3294 | while (1) { | 3292 | while (1) { |
3295 | if (C_BAUD(tty) && test_bit(ASYNCB_INITIALIZED, &port->flags)) | 3293 | if (C_BAUD(tty) && tty_port_initialized(port)) |
3296 | tty_port_raise_dtr_rts(port); | 3294 | tty_port_raise_dtr_rts(port); |
3297 | 3295 | ||
3298 | set_current_state(TASK_INTERRUPTIBLE); | 3296 | set_current_state(TASK_INTERRUPTIBLE); |
3299 | 3297 | ||
3300 | if (tty_hung_up_p(filp) || !(port->flags & ASYNC_INITIALIZED)){ | 3298 | if (tty_hung_up_p(filp) || !tty_port_initialized(port)) { |
3301 | retval = (port->flags & ASYNC_HUP_NOTIFY) ? | 3299 | retval = (port->flags & ASYNC_HUP_NOTIFY) ? |
3302 | -EAGAIN : -ERESTARTSYS; | 3300 | -EAGAIN : -ERESTARTSYS; |
3303 | break; | 3301 | break; |
diff --git a/drivers/tty/synclink_gt.c b/drivers/tty/synclink_gt.c index 333652a8896a..82c98b820335 100644 --- a/drivers/tty/synclink_gt.c +++ b/drivers/tty/synclink_gt.c | |||
@@ -726,7 +726,7 @@ static void close(struct tty_struct *tty, struct file *filp) | |||
726 | goto cleanup; | 726 | goto cleanup; |
727 | 727 | ||
728 | mutex_lock(&info->port.mutex); | 728 | mutex_lock(&info->port.mutex); |
729 | if (info->port.flags & ASYNC_INITIALIZED) | 729 | if (tty_port_initialized(&info->port)) |
730 | wait_until_sent(tty, info->timeout); | 730 | wait_until_sent(tty, info->timeout); |
731 | flush_buffer(tty); | 731 | flush_buffer(tty); |
732 | tty_ldisc_flush(tty); | 732 | tty_ldisc_flush(tty); |
@@ -893,7 +893,7 @@ static void wait_until_sent(struct tty_struct *tty, int timeout) | |||
893 | if (sanity_check(info, tty->name, "wait_until_sent")) | 893 | if (sanity_check(info, tty->name, "wait_until_sent")) |
894 | return; | 894 | return; |
895 | DBGINFO(("%s wait_until_sent entry\n", info->device_name)); | 895 | DBGINFO(("%s wait_until_sent entry\n", info->device_name)); |
896 | if (!(info->port.flags & ASYNC_INITIALIZED)) | 896 | if (!tty_port_initialized(&info->port)) |
897 | goto exit; | 897 | goto exit; |
898 | 898 | ||
899 | orig_jiffies = jiffies; | 899 | orig_jiffies = jiffies; |
@@ -2421,7 +2421,7 @@ static int startup(struct slgt_info *info) | |||
2421 | { | 2421 | { |
2422 | DBGINFO(("%s startup\n", info->device_name)); | 2422 | DBGINFO(("%s startup\n", info->device_name)); |
2423 | 2423 | ||
2424 | if (info->port.flags & ASYNC_INITIALIZED) | 2424 | if (tty_port_initialized(&info->port)) |
2425 | return 0; | 2425 | return 0; |
2426 | 2426 | ||
2427 | if (!info->tx_buf) { | 2427 | if (!info->tx_buf) { |
@@ -2442,7 +2442,7 @@ static int startup(struct slgt_info *info) | |||
2442 | if (info->port.tty) | 2442 | if (info->port.tty) |
2443 | clear_bit(TTY_IO_ERROR, &info->port.tty->flags); | 2443 | clear_bit(TTY_IO_ERROR, &info->port.tty->flags); |
2444 | 2444 | ||
2445 | info->port.flags |= ASYNC_INITIALIZED; | 2445 | tty_port_set_initialized(&info->port, 1); |
2446 | 2446 | ||
2447 | return 0; | 2447 | return 0; |
2448 | } | 2448 | } |
@@ -2454,7 +2454,7 @@ static void shutdown(struct slgt_info *info) | |||
2454 | { | 2454 | { |
2455 | unsigned long flags; | 2455 | unsigned long flags; |
2456 | 2456 | ||
2457 | if (!(info->port.flags & ASYNC_INITIALIZED)) | 2457 | if (!tty_port_initialized(&info->port)) |
2458 | return; | 2458 | return; |
2459 | 2459 | ||
2460 | DBGINFO(("%s shutdown\n", info->device_name)); | 2460 | DBGINFO(("%s shutdown\n", info->device_name)); |
@@ -2489,7 +2489,7 @@ static void shutdown(struct slgt_info *info) | |||
2489 | if (info->port.tty) | 2489 | if (info->port.tty) |
2490 | set_bit(TTY_IO_ERROR, &info->port.tty->flags); | 2490 | set_bit(TTY_IO_ERROR, &info->port.tty->flags); |
2491 | 2491 | ||
2492 | info->port.flags &= ~ASYNC_INITIALIZED; | 2492 | tty_port_set_initialized(&info->port, 0); |
2493 | } | 2493 | } |
2494 | 2494 | ||
2495 | static void program_hw(struct slgt_info *info) | 2495 | static void program_hw(struct slgt_info *info) |
@@ -3287,12 +3287,12 @@ static int block_til_ready(struct tty_struct *tty, struct file *filp, | |||
3287 | port->blocked_open++; | 3287 | port->blocked_open++; |
3288 | 3288 | ||
3289 | while (1) { | 3289 | while (1) { |
3290 | if (C_BAUD(tty) && test_bit(ASYNCB_INITIALIZED, &port->flags)) | 3290 | if (C_BAUD(tty) && tty_port_initialized(port)) |
3291 | tty_port_raise_dtr_rts(port); | 3291 | tty_port_raise_dtr_rts(port); |
3292 | 3292 | ||
3293 | set_current_state(TASK_INTERRUPTIBLE); | 3293 | set_current_state(TASK_INTERRUPTIBLE); |
3294 | 3294 | ||
3295 | if (tty_hung_up_p(filp) || !(port->flags & ASYNC_INITIALIZED)){ | 3295 | if (tty_hung_up_p(filp) || !tty_port_initialized(port)) { |
3296 | retval = (port->flags & ASYNC_HUP_NOTIFY) ? | 3296 | retval = (port->flags & ASYNC_HUP_NOTIFY) ? |
3297 | -EAGAIN : -ERESTARTSYS; | 3297 | -EAGAIN : -ERESTARTSYS; |
3298 | break; | 3298 | break; |
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; |
diff --git a/drivers/tty/tty_port.c b/drivers/tty/tty_port.c index 130c8cf520cb..c3f9d93ba227 100644 --- a/drivers/tty/tty_port.c +++ b/drivers/tty/tty_port.c | |||
@@ -204,7 +204,8 @@ static void tty_port_shutdown(struct tty_port *port, struct tty_struct *tty) | |||
204 | if (port->console) | 204 | if (port->console) |
205 | goto out; | 205 | goto out; |
206 | 206 | ||
207 | if (test_and_clear_bit(ASYNCB_INITIALIZED, &port->flags)) { | 207 | if (tty_port_initialized(port)) { |
208 | tty_port_set_initialized(port, 0); | ||
208 | /* | 209 | /* |
209 | * Drop DTR/RTS if HUPCL is set. This causes any attached | 210 | * Drop DTR/RTS if HUPCL is set. This causes any attached |
210 | * modem to hang up the line. | 211 | * modem to hang up the line. |
@@ -393,13 +394,13 @@ int tty_port_block_til_ready(struct tty_port *port, | |||
393 | 394 | ||
394 | while (1) { | 395 | while (1) { |
395 | /* Indicate we are open */ | 396 | /* Indicate we are open */ |
396 | if (C_BAUD(tty) && test_bit(ASYNCB_INITIALIZED, &port->flags)) | 397 | if (C_BAUD(tty) && tty_port_initialized(port)) |
397 | tty_port_raise_dtr_rts(port); | 398 | tty_port_raise_dtr_rts(port); |
398 | 399 | ||
399 | prepare_to_wait(&port->open_wait, &wait, TASK_INTERRUPTIBLE); | 400 | prepare_to_wait(&port->open_wait, &wait, TASK_INTERRUPTIBLE); |
400 | /* Check for a hangup or uninitialised port. | 401 | /* Check for a hangup or uninitialised port. |
401 | Return accordingly */ | 402 | Return accordingly */ |
402 | if (tty_hung_up_p(filp) || !(port->flags & ASYNC_INITIALIZED)) { | 403 | if (tty_hung_up_p(filp) || !tty_port_initialized(port)) { |
403 | if (port->flags & ASYNC_HUP_NOTIFY) | 404 | if (port->flags & ASYNC_HUP_NOTIFY) |
404 | retval = -EAGAIN; | 405 | retval = -EAGAIN; |
405 | else | 406 | else |
@@ -480,7 +481,7 @@ int tty_port_close_start(struct tty_port *port, | |||
480 | 481 | ||
481 | tty->closing = 1; | 482 | tty->closing = 1; |
482 | 483 | ||
483 | if (test_bit(ASYNCB_INITIALIZED, &port->flags)) { | 484 | if (tty_port_initialized(port)) { |
484 | /* Don't block on a stalled port, just pull the chain */ | 485 | /* Don't block on a stalled port, just pull the chain */ |
485 | if (tty->flow_stopped) | 486 | if (tty->flow_stopped) |
486 | tty_driver_flush_buffer(tty); | 487 | tty_driver_flush_buffer(tty); |
@@ -578,7 +579,7 @@ int tty_port_open(struct tty_port *port, struct tty_struct *tty, | |||
578 | 579 | ||
579 | mutex_lock(&port->mutex); | 580 | mutex_lock(&port->mutex); |
580 | 581 | ||
581 | if (!test_bit(ASYNCB_INITIALIZED, &port->flags)) { | 582 | if (!tty_port_initialized(port)) { |
582 | clear_bit(TTY_IO_ERROR, &tty->flags); | 583 | clear_bit(TTY_IO_ERROR, &tty->flags); |
583 | if (port->ops->activate) { | 584 | if (port->ops->activate) { |
584 | int retval = port->ops->activate(port, tty); | 585 | int retval = port->ops->activate(port, tty); |
@@ -587,7 +588,7 @@ int tty_port_open(struct tty_port *port, struct tty_struct *tty, | |||
587 | return retval; | 588 | return retval; |
588 | } | 589 | } |
589 | } | 590 | } |
590 | set_bit(ASYNCB_INITIALIZED, &port->flags); | 591 | tty_port_set_initialized(port, 1); |
591 | } | 592 | } |
592 | mutex_unlock(&port->mutex); | 593 | mutex_unlock(&port->mutex); |
593 | return tty_port_block_til_ready(port, tty, filp); | 594 | return tty_port_block_til_ready(port, tty, filp); |
diff --git a/drivers/usb/class/cdc-acm.c b/drivers/usb/class/cdc-acm.c index a6c4a1b895bd..94a14f5dc4d4 100644 --- a/drivers/usb/class/cdc-acm.c +++ b/drivers/usb/class/cdc-acm.c | |||
@@ -1680,7 +1680,7 @@ static int acm_resume(struct usb_interface *intf) | |||
1680 | if (--acm->susp_count) | 1680 | if (--acm->susp_count) |
1681 | goto out; | 1681 | goto out; |
1682 | 1682 | ||
1683 | if (test_bit(ASYNCB_INITIALIZED, &acm->port.flags)) { | 1683 | if (tty_port_initialized(&acm->port)) { |
1684 | rv = usb_submit_urb(acm->ctrlurb, GFP_ATOMIC); | 1684 | rv = usb_submit_urb(acm->ctrlurb, GFP_ATOMIC); |
1685 | 1685 | ||
1686 | for (;;) { | 1686 | for (;;) { |
@@ -1710,7 +1710,7 @@ static int acm_reset_resume(struct usb_interface *intf) | |||
1710 | { | 1710 | { |
1711 | struct acm *acm = usb_get_intfdata(intf); | 1711 | struct acm *acm = usb_get_intfdata(intf); |
1712 | 1712 | ||
1713 | if (test_bit(ASYNCB_INITIALIZED, &acm->port.flags)) | 1713 | if (tty_port_initialized(&acm->port)) |
1714 | tty_port_tty_hangup(&acm->port, false); | 1714 | tty_port_tty_hangup(&acm->port, false); |
1715 | 1715 | ||
1716 | return acm_resume(intf); | 1716 | return acm_resume(intf); |
diff --git a/drivers/usb/serial/console.c b/drivers/usb/serial/console.c index a66b01bb1fa1..8967715fe6fc 100644 --- a/drivers/usb/serial/console.c +++ b/drivers/usb/serial/console.c | |||
@@ -127,7 +127,7 @@ static int usb_console_setup(struct console *co, char *options) | |||
127 | info->port = port; | 127 | info->port = port; |
128 | 128 | ||
129 | ++port->port.count; | 129 | ++port->port.count; |
130 | if (!test_bit(ASYNCB_INITIALIZED, &port->port.flags)) { | 130 | if (!tty_port_initialized(&port->port)) { |
131 | if (serial->type->set_termios) { | 131 | if (serial->type->set_termios) { |
132 | /* | 132 | /* |
133 | * allocate a fake tty so the driver can initialize | 133 | * allocate a fake tty so the driver can initialize |
@@ -168,7 +168,7 @@ static int usb_console_setup(struct console *co, char *options) | |||
168 | tty_port_tty_set(&port->port, NULL); | 168 | tty_port_tty_set(&port->port, NULL); |
169 | tty_kref_put(tty); | 169 | tty_kref_put(tty); |
170 | } | 170 | } |
171 | set_bit(ASYNCB_INITIALIZED, &port->port.flags); | 171 | tty_port_set_initialized(&port->port, 1); |
172 | } | 172 | } |
173 | /* Now that any required fake tty operations are completed restore | 173 | /* Now that any required fake tty operations are completed restore |
174 | * the tty port count */ | 174 | * the tty port count */ |
diff --git a/drivers/usb/serial/generic.c b/drivers/usb/serial/generic.c index 54e170dd3dad..ae8c0365abd6 100644 --- a/drivers/usb/serial/generic.c +++ b/drivers/usb/serial/generic.c | |||
@@ -473,7 +473,7 @@ static bool usb_serial_generic_msr_changed(struct tty_struct *tty, | |||
473 | * Use tty-port initialised flag to detect all hangups including the | 473 | * Use tty-port initialised flag to detect all hangups including the |
474 | * one generated at USB-device disconnect. | 474 | * one generated at USB-device disconnect. |
475 | */ | 475 | */ |
476 | if (!test_bit(ASYNCB_INITIALIZED, &port->port.flags)) | 476 | if (!tty_port_initialized(&port->port)) |
477 | return true; | 477 | return true; |
478 | 478 | ||
479 | spin_lock_irqsave(&port->lock, flags); | 479 | spin_lock_irqsave(&port->lock, flags); |
@@ -503,7 +503,7 @@ int usb_serial_generic_tiocmiwait(struct tty_struct *tty, unsigned long arg) | |||
503 | 503 | ||
504 | ret = wait_event_interruptible(port->port.delta_msr_wait, | 504 | ret = wait_event_interruptible(port->port.delta_msr_wait, |
505 | usb_serial_generic_msr_changed(tty, arg, &cnow)); | 505 | usb_serial_generic_msr_changed(tty, arg, &cnow)); |
506 | if (!ret && !test_bit(ASYNCB_INITIALIZED, &port->port.flags)) | 506 | if (!ret && !tty_port_initialized(&port->port)) |
507 | ret = -EIO; | 507 | ret = -EIO; |
508 | 508 | ||
509 | return ret; | 509 | return ret; |
@@ -606,7 +606,7 @@ int usb_serial_generic_resume(struct usb_serial *serial) | |||
606 | 606 | ||
607 | for (i = 0; i < serial->num_ports; i++) { | 607 | for (i = 0; i < serial->num_ports; i++) { |
608 | port = serial->port[i]; | 608 | port = serial->port[i]; |
609 | if (!test_bit(ASYNCB_INITIALIZED, &port->port.flags)) | 609 | if (!tty_port_initialized(&port->port)) |
610 | continue; | 610 | continue; |
611 | 611 | ||
612 | if (port->bulk_in_size) { | 612 | if (port->bulk_in_size) { |
diff --git a/drivers/usb/serial/mxuport.c b/drivers/usb/serial/mxuport.c index 31a8b47f1ac6..3722d6c1ba77 100644 --- a/drivers/usb/serial/mxuport.c +++ b/drivers/usb/serial/mxuport.c | |||
@@ -503,7 +503,7 @@ static void mxuport_process_read_urb_demux_data(struct urb *urb) | |||
503 | return; | 503 | return; |
504 | } | 504 | } |
505 | 505 | ||
506 | if (test_bit(ASYNCB_INITIALIZED, &demux_port->port.flags)) { | 506 | if (tty_port_initialized(&demux_port->port)) { |
507 | ch = data + HEADER_SIZE; | 507 | ch = data + HEADER_SIZE; |
508 | mxuport_process_read_urb_data(demux_port, ch, rcv_len); | 508 | mxuport_process_read_urb_data(demux_port, ch, rcv_len); |
509 | } else { | 509 | } else { |
@@ -544,7 +544,7 @@ static void mxuport_process_read_urb_demux_event(struct urb *urb) | |||
544 | } | 544 | } |
545 | 545 | ||
546 | demux_port = serial->port[rcv_port]; | 546 | demux_port = serial->port[rcv_port]; |
547 | if (test_bit(ASYNCB_INITIALIZED, &demux_port->port.flags)) { | 547 | if (tty_port_initialized(&demux_port->port)) { |
548 | ch = data + HEADER_SIZE; | 548 | ch = data + HEADER_SIZE; |
549 | rcv_event = get_unaligned_be16(data + 2); | 549 | rcv_event = get_unaligned_be16(data + 2); |
550 | mxuport_process_read_urb_event(demux_port, ch, | 550 | mxuport_process_read_urb_event(demux_port, ch, |
@@ -1339,7 +1339,7 @@ static int mxuport_resume(struct usb_serial *serial) | |||
1339 | 1339 | ||
1340 | for (i = 0; i < serial->num_ports; i++) { | 1340 | for (i = 0; i < serial->num_ports; i++) { |
1341 | port = serial->port[i]; | 1341 | port = serial->port[i]; |
1342 | if (!test_bit(ASYNCB_INITIALIZED, &port->port.flags)) | 1342 | if (!tty_port_initialized(&port->port)) |
1343 | continue; | 1343 | continue; |
1344 | 1344 | ||
1345 | r = usb_serial_generic_write_start(port, GFP_NOIO); | 1345 | r = usb_serial_generic_write_start(port, GFP_NOIO); |
diff --git a/drivers/usb/serial/sierra.c b/drivers/usb/serial/sierra.c index 07d1ecd564f7..e1994e264cc0 100644 --- a/drivers/usb/serial/sierra.c +++ b/drivers/usb/serial/sierra.c | |||
@@ -776,7 +776,7 @@ static void sierra_close(struct usb_serial_port *port) | |||
776 | 776 | ||
777 | /* | 777 | /* |
778 | * Need to take susp_lock to make sure port is not already being | 778 | * Need to take susp_lock to make sure port is not already being |
779 | * resumed, but no need to hold it due to ASYNC_INITIALIZED. | 779 | * resumed, but no need to hold it due to initialized |
780 | */ | 780 | */ |
781 | spin_lock_irq(&intfdata->susp_lock); | 781 | spin_lock_irq(&intfdata->susp_lock); |
782 | if (--intfdata->open_ports == 0) | 782 | if (--intfdata->open_ports == 0) |
@@ -1039,7 +1039,7 @@ static int sierra_resume(struct usb_serial *serial) | |||
1039 | for (i = 0; i < serial->num_ports; i++) { | 1039 | for (i = 0; i < serial->num_ports; i++) { |
1040 | port = serial->port[i]; | 1040 | port = serial->port[i]; |
1041 | 1041 | ||
1042 | if (!test_bit(ASYNCB_INITIALIZED, &port->port.flags)) | 1042 | if (!tty_port_initialized(&port->port)) |
1043 | continue; | 1043 | continue; |
1044 | 1044 | ||
1045 | err = sierra_submit_delayed_urbs(port); | 1045 | err = sierra_submit_delayed_urbs(port); |
diff --git a/drivers/usb/serial/usb-serial.c b/drivers/usb/serial/usb-serial.c index 46f1f13b41f1..3f253aec0c16 100644 --- a/drivers/usb/serial/usb-serial.c +++ b/drivers/usb/serial/usb-serial.c | |||
@@ -254,7 +254,7 @@ static int serial_open(struct tty_struct *tty, struct file *filp) | |||
254 | * | 254 | * |
255 | * Shut down a USB serial port. Serialized against activate by the | 255 | * Shut down a USB serial port. Serialized against activate by the |
256 | * tport mutex and kept to matching open/close pairs | 256 | * tport mutex and kept to matching open/close pairs |
257 | * of calls by the ASYNCB_INITIALIZED flag. | 257 | * of calls by the initialized flag. |
258 | * | 258 | * |
259 | * Not called if tty is console. | 259 | * Not called if tty is console. |
260 | */ | 260 | */ |
diff --git a/drivers/usb/serial/usb_wwan.c b/drivers/usb/serial/usb_wwan.c index be9cb61b4d19..3dfdfc81254b 100644 --- a/drivers/usb/serial/usb_wwan.c +++ b/drivers/usb/serial/usb_wwan.c | |||
@@ -464,7 +464,7 @@ void usb_wwan_close(struct usb_serial_port *port) | |||
464 | 464 | ||
465 | /* | 465 | /* |
466 | * Need to take susp_lock to make sure port is not already being | 466 | * Need to take susp_lock to make sure port is not already being |
467 | * resumed, but no need to hold it due to ASYNC_INITIALIZED. | 467 | * resumed, but no need to hold it due to initialized |
468 | */ | 468 | */ |
469 | spin_lock_irq(&intfdata->susp_lock); | 469 | spin_lock_irq(&intfdata->susp_lock); |
470 | if (--intfdata->open_ports == 0) | 470 | if (--intfdata->open_ports == 0) |
@@ -682,7 +682,7 @@ int usb_wwan_resume(struct usb_serial *serial) | |||
682 | for (i = 0; i < serial->num_ports; i++) { | 682 | for (i = 0; i < serial->num_ports; i++) { |
683 | port = serial->port[i]; | 683 | port = serial->port[i]; |
684 | 684 | ||
685 | if (!test_bit(ASYNCB_INITIALIZED, &port->port.flags)) | 685 | if (!tty_port_initialized(&port->port)) |
686 | continue; | 686 | continue; |
687 | 687 | ||
688 | portdata = usb_get_serial_port_data(port); | 688 | portdata = usb_get_serial_port_data(port); |
diff --git a/include/linux/tty.h b/include/linux/tty.h index 7ac5add66c00..bf1bcdb01df0 100644 --- a/include/linux/tty.h +++ b/include/linux/tty.h | |||
@@ -610,6 +610,19 @@ static inline void tty_port_set_suspended(struct tty_port *port, bool val) | |||
610 | clear_bit(TTY_PORT_SUSPENDED, &port->iflags); | 610 | clear_bit(TTY_PORT_SUSPENDED, &port->iflags); |
611 | } | 611 | } |
612 | 612 | ||
613 | static inline bool tty_port_initialized(struct tty_port *port) | ||
614 | { | ||
615 | return test_bit(TTY_PORT_INITIALIZED, &port->iflags); | ||
616 | } | ||
617 | |||
618 | static inline void tty_port_set_initialized(struct tty_port *port, bool val) | ||
619 | { | ||
620 | if (val) | ||
621 | set_bit(TTY_PORT_INITIALIZED, &port->iflags); | ||
622 | else | ||
623 | clear_bit(TTY_PORT_INITIALIZED, &port->iflags); | ||
624 | } | ||
625 | |||
613 | extern struct tty_struct *tty_port_tty_get(struct tty_port *port); | 626 | extern struct tty_struct *tty_port_tty_get(struct tty_port *port); |
614 | extern void tty_port_tty_set(struct tty_port *port, struct tty_struct *tty); | 627 | extern void tty_port_tty_set(struct tty_port *port, struct tty_struct *tty); |
615 | extern int tty_port_carrier_raised(struct tty_port *port); | 628 | extern int tty_port_carrier_raised(struct tty_port *port); |
diff --git a/net/irda/ircomm/ircomm_tty.c b/net/irda/ircomm/ircomm_tty.c index 5b7ce599c709..873c4b707d6a 100644 --- a/net/irda/ircomm/ircomm_tty.c +++ b/net/irda/ircomm/ircomm_tty.c | |||
@@ -220,10 +220,11 @@ static int ircomm_tty_startup(struct ircomm_tty_cb *self) | |||
220 | IRDA_ASSERT(self->magic == IRCOMM_TTY_MAGIC, return -1;); | 220 | IRDA_ASSERT(self->magic == IRCOMM_TTY_MAGIC, return -1;); |
221 | 221 | ||
222 | /* Check if already open */ | 222 | /* Check if already open */ |
223 | if (test_and_set_bit(ASYNCB_INITIALIZED, &self->port.flags)) { | 223 | if (tty_port_initialized(&self->port)) { |
224 | pr_debug("%s(), already open so break out!\n", __func__); | 224 | pr_debug("%s(), already open so break out!\n", __func__); |
225 | return 0; | 225 | return 0; |
226 | } | 226 | } |
227 | tty_port_set_initialized(&self->port, 1); | ||
227 | 228 | ||
228 | /* Register with IrCOMM */ | 229 | /* Register with IrCOMM */ |
229 | irda_notify_init(¬ify); | 230 | irda_notify_init(¬ify); |
@@ -257,7 +258,7 @@ static int ircomm_tty_startup(struct ircomm_tty_cb *self) | |||
257 | 258 | ||
258 | return 0; | 259 | return 0; |
259 | err: | 260 | err: |
260 | clear_bit(ASYNCB_INITIALIZED, &self->port.flags); | 261 | tty_port_set_initialized(&self->port, 0); |
261 | return ret; | 262 | return ret; |
262 | } | 263 | } |
263 | 264 | ||
@@ -318,13 +319,12 @@ static int ircomm_tty_block_til_ready(struct ircomm_tty_cb *self, | |||
318 | spin_unlock_irqrestore(&port->lock, flags); | 319 | spin_unlock_irqrestore(&port->lock, flags); |
319 | 320 | ||
320 | while (1) { | 321 | while (1) { |
321 | if (C_BAUD(tty) && test_bit(ASYNCB_INITIALIZED, &port->flags)) | 322 | if (C_BAUD(tty) && tty_port_initialized(port)) |
322 | tty_port_raise_dtr_rts(port); | 323 | tty_port_raise_dtr_rts(port); |
323 | 324 | ||
324 | set_current_state(TASK_INTERRUPTIBLE); | 325 | set_current_state(TASK_INTERRUPTIBLE); |
325 | 326 | ||
326 | if (tty_hung_up_p(filp) || | 327 | if (tty_hung_up_p(filp) || !tty_port_initialized(port)) { |
327 | !test_bit(ASYNCB_INITIALIZED, &port->flags)) { | ||
328 | retval = (port->flags & ASYNC_HUP_NOTIFY) ? | 328 | retval = (port->flags & ASYNC_HUP_NOTIFY) ? |
329 | -EAGAIN : -ERESTARTSYS; | 329 | -EAGAIN : -ERESTARTSYS; |
330 | break; | 330 | break; |
@@ -876,8 +876,9 @@ static void ircomm_tty_shutdown(struct ircomm_tty_cb *self) | |||
876 | IRDA_ASSERT(self != NULL, return;); | 876 | IRDA_ASSERT(self != NULL, return;); |
877 | IRDA_ASSERT(self->magic == IRCOMM_TTY_MAGIC, return;); | 877 | IRDA_ASSERT(self->magic == IRCOMM_TTY_MAGIC, return;); |
878 | 878 | ||
879 | if (!test_and_clear_bit(ASYNCB_INITIALIZED, &self->port.flags)) | 879 | if (!tty_port_initialized(&self->port)) |
880 | return; | 880 | return; |
881 | tty_port_set_initialized(&self->port, 0); | ||
881 | 882 | ||
882 | ircomm_tty_detach_cable(self); | 883 | ircomm_tty_detach_cable(self); |
883 | 884 | ||
@@ -1259,7 +1260,7 @@ static void ircomm_tty_line_info(struct ircomm_tty_cb *self, struct seq_file *m) | |||
1259 | seq_printf(m, "%cASYNC_CHECK_CD", sep); | 1260 | seq_printf(m, "%cASYNC_CHECK_CD", sep); |
1260 | sep = '|'; | 1261 | sep = '|'; |
1261 | } | 1262 | } |
1262 | if (self->port.flags & ASYNC_INITIALIZED) { | 1263 | if (tty_port_initialized(&self->port)) { |
1263 | seq_printf(m, "%cASYNC_INITIALIZED", sep); | 1264 | seq_printf(m, "%cASYNC_INITIALIZED", sep); |
1264 | sep = '|'; | 1265 | sep = '|'; |
1265 | } | 1266 | } |
diff --git a/net/irda/ircomm/ircomm_tty_ioctl.c b/net/irda/ircomm/ircomm_tty_ioctl.c index e24724db36a2..d4fdf8f7b471 100644 --- a/net/irda/ircomm/ircomm_tty_ioctl.c +++ b/net/irda/ircomm/ircomm_tty_ioctl.c | |||
@@ -324,7 +324,7 @@ static int ircomm_tty_set_serial_info(struct ircomm_tty_cb *self, | |||
324 | 324 | ||
325 | check_and_exit: | 325 | check_and_exit: |
326 | 326 | ||
327 | if (self->flags & ASYNC_INITIALIZED) { | 327 | if (tty_port_initialized(self)) { |
328 | if (((old_state.flags & ASYNC_SPD_MASK) != | 328 | if (((old_state.flags & ASYNC_SPD_MASK) != |
329 | (self->flags & ASYNC_SPD_MASK)) || | 329 | (self->flags & ASYNC_SPD_MASK)) || |
330 | (old_driver.custom_divisor != driver->custom_divisor)) { | 330 | (old_driver.custom_divisor != driver->custom_divisor)) { |