aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--drivers/serial/serial_core.c87
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 */
1533static int
1534uart_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
1614static struct uart_state *uart_get(struct uart_driver *drv, int line) 1529static 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.