diff options
author | Alan Cox <alan@linux.intel.com> | 2010-06-01 16:53:00 -0400 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@suse.de> | 2010-08-10 16:47:42 -0400 |
commit | 74c2107759dc6efaa1b9127014be58a742a1e7ac (patch) | |
tree | 0e453f7768ede123c108b3104a098375bec6a0b4 /drivers/serial | |
parent | 24fcc7c8cd0fcabcf37d455abe3501b3196fcf64 (diff) |
serial: Use block_til_ready helper
Our code now rather closely resembles the helper, so switch to it.
Signed-off-by: Alan Cox <alan@linux.intel.com>
Cc: Arnd Bergmann <arnd@arndb.de>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
Diffstat (limited to 'drivers/serial')
-rw-r--r-- | drivers/serial/serial_core.c | 87 |
1 files changed, 1 insertions, 86 deletions
diff --git a/drivers/serial/serial_core.c b/drivers/serial/serial_core.c index 0603e0d46d33..a55751a12c38 100644 --- a/drivers/serial/serial_core.c +++ b/drivers/serial/serial_core.c | |||
@@ -1526,91 +1526,6 @@ static void uart_dtr_rts(struct tty_port *port, int onoff) | |||
1526 | uart_clear_mctrl(uport, TIOCM_DTR | TIOCM_RTS); | 1526 | uart_clear_mctrl(uport, TIOCM_DTR | TIOCM_RTS); |
1527 | } | 1527 | } |
1528 | 1528 | ||
1529 | /* | ||
1530 | * Block the open until the port is ready. We must be called with | ||
1531 | * the per-port semaphore held. | ||
1532 | */ | ||
1533 | static int | ||
1534 | uart_block_til_ready(struct file *filp, struct uart_state *state) | ||
1535 | { | ||
1536 | DECLARE_WAITQUEUE(wait, current); | ||
1537 | struct tty_port *port = &state->port; | ||
1538 | unsigned long flags; | ||
1539 | |||
1540 | spin_lock_irqsave(&port->lock, flags); | ||
1541 | if (!tty_hung_up_p(filp)) | ||
1542 | port->count--; | ||
1543 | port->blocked_open++; | ||
1544 | spin_unlock_irqrestore(&port->lock, flags); | ||
1545 | |||
1546 | add_wait_queue(&port->open_wait, &wait); | ||
1547 | while (1) { | ||
1548 | set_current_state(TASK_INTERRUPTIBLE); | ||
1549 | |||
1550 | /* | ||
1551 | * If we have been hung up, tell userspace/restart open. | ||
1552 | */ | ||
1553 | if (tty_hung_up_p(filp) || port->tty == NULL) | ||
1554 | break; | ||
1555 | |||
1556 | /* | ||
1557 | * If the port has been closed, tell userspace/restart open. | ||
1558 | */ | ||
1559 | if (!(port->flags & ASYNC_INITIALIZED)) | ||
1560 | break; | ||
1561 | |||
1562 | /* | ||
1563 | * If non-blocking mode is set, or CLOCAL mode is set, | ||
1564 | * we don't want to wait for the modem status lines to | ||
1565 | * indicate that the port is ready. | ||
1566 | * | ||
1567 | * Also, if the port is not enabled/configured, we want | ||
1568 | * to allow the open to succeed here. Note that we will | ||
1569 | * have set TTY_IO_ERROR for a non-existant port. | ||
1570 | */ | ||
1571 | if ((filp->f_flags & O_NONBLOCK) || | ||
1572 | (port->tty->termios->c_cflag & CLOCAL) || | ||
1573 | (port->tty->flags & (1 << TTY_IO_ERROR))) | ||
1574 | break; | ||
1575 | |||
1576 | /* | ||
1577 | * Set DTR to allow modem to know we're waiting. Do | ||
1578 | * not set RTS here - we want to make sure we catch | ||
1579 | * the data from the modem. | ||
1580 | */ | ||
1581 | if (port->tty->termios->c_cflag & CBAUD) | ||
1582 | tty_port_raise_dtr_rts(port); | ||
1583 | |||
1584 | /* | ||
1585 | * and wait for the carrier to indicate that the | ||
1586 | * modem is ready for us. | ||
1587 | */ | ||
1588 | if (tty_port_carrier_raised(port)) | ||
1589 | break; | ||
1590 | |||
1591 | schedule(); | ||
1592 | |||
1593 | if (signal_pending(current)) | ||
1594 | break; | ||
1595 | } | ||
1596 | set_current_state(TASK_RUNNING); | ||
1597 | remove_wait_queue(&port->open_wait, &wait); | ||
1598 | |||
1599 | spin_lock_irqsave(&port->lock, flags); | ||
1600 | if (!tty_hung_up_p(filp)) | ||
1601 | port->count++; | ||
1602 | port->blocked_open--; | ||
1603 | spin_unlock_irqrestore(&port->lock, flags); | ||
1604 | |||
1605 | if (signal_pending(current)) | ||
1606 | return -ERESTARTSYS; | ||
1607 | |||
1608 | if (!port->tty || tty_hung_up_p(filp)) | ||
1609 | return -EAGAIN; | ||
1610 | |||
1611 | return 0; | ||
1612 | } | ||
1613 | |||
1614 | static struct uart_state *uart_get(struct uart_driver *drv, int line) | 1529 | static struct uart_state *uart_get(struct uart_driver *drv, int line) |
1615 | { | 1530 | { |
1616 | struct uart_state *state; | 1531 | struct uart_state *state; |
@@ -1719,7 +1634,7 @@ static int uart_open(struct tty_struct *tty, struct file *filp) | |||
1719 | */ | 1634 | */ |
1720 | mutex_unlock(&port->mutex); | 1635 | mutex_unlock(&port->mutex); |
1721 | if (retval == 0) | 1636 | if (retval == 0) |
1722 | retval = uart_block_til_ready(filp, state); | 1637 | retval = tty_port_block_til_ready(port, tty, filp); |
1723 | 1638 | ||
1724 | /* | 1639 | /* |
1725 | * If this is the first open to succeed, adjust things to suit. | 1640 | * If this is the first open to succeed, adjust things to suit. |