173
171
retval = uport->ops->startup(uport);
174
172
if (retval == 0) {
173
if (uart_console(uport) && uport->cons->cflag) {
174
tty->termios->c_cflag = uport->cons->cflag;
175
uport->cons->cflag = 0;
178
* Initialise the hardware port settings.
180
uart_change_speed(tty, state, NULL);
177
* Initialise the hardware port settings.
179
uart_change_speed(tty, state, NULL);
182
184
* Setup the RTS and DTR signals once the
183
185
* port is open and ready to respond.
1241
1243
spin_unlock_irqrestore(&state->uart_port->lock, flags);
1245
* No need to wake up processes in open wait, since they
1246
* sample the CLOCAL flag once, and don't recheck it.
1247
* XXX It's not clear whether the current behavior is correct
1248
* or not. Hence, this may change.....
1250
if (!(old_termios->c_cflag & CLOCAL) &&
1251
(tty->termios->c_cflag & CLOCAL))
1252
wake_up_interruptible(&state->uart_port.open_wait);
1466
1456
mutex_unlock(&port->mutex);
1470
* uart_update_termios - update the terminal hw settings
1471
* @tty: tty associated with UART
1472
* @state: UART to update
1474
* Copy across the serial console cflag setting into the termios settings
1475
* for the initial open of the port. This allows continuity between the
1476
* kernel settings, and the settings init adopts when it opens the port
1477
* for the first time.
1479
static void uart_update_termios(struct tty_struct *tty,
1480
struct uart_state *state)
1482
struct uart_port *port = state->uart_port;
1484
if (uart_console(port) && port->cons->cflag) {
1485
tty->termios->c_cflag = port->cons->cflag;
1486
port->cons->cflag = 0;
1490
* If the device failed to grab its irq resources,
1491
* or some other error occurred, don't try to talk
1492
* to the port hardware.
1494
if (!(tty->flags & (1 << TTY_IO_ERROR))) {
1496
* Make termios settings take effect.
1498
uart_change_speed(tty, state, NULL);
1501
* And finally enable the RTS and DTR signals.
1503
if (tty->termios->c_cflag & CBAUD)
1504
uart_set_mctrl(port, TIOCM_DTR | TIOCM_RTS);
1508
1459
static int uart_carrier_raised(struct tty_port *port)
1510
1461
struct uart_state *state = container_of(port, struct uart_state, port);
1524
1475
struct uart_state *state = container_of(port, struct uart_state, port);
1525
1476
struct uart_port *uport = state->uart_port;
1528
1479
uart_set_mctrl(uport, TIOCM_DTR | TIOCM_RTS);
1531
* If this is the first open to succeed,
1532
* adjust things to suit.
1534
if (!test_and_set_bit(ASYNCB_NORMAL_ACTIVE, &port->flags))
1535
uart_update_termios(port->tty, state);
1538
1481
uart_clear_mctrl(uport, TIOCM_DTR | TIOCM_RTS);
1586
1529
pr_debug("uart_open(%d) called\n", line);
1589
* tty->driver->num won't change, so we won't fail here with
1590
* tty->driver_data set to something non-NULL (and therefore
1591
* we won't get caught by uart_close()).
1594
if (line >= tty->driver->num)
1598
1532
* We take the semaphore inside uart_get to guarantee that we won't
1599
1533
* be re-entered while allocating the state structure, or while we
1600
1534
* request any IRQs that the driver may need. This also has the nice
1972
1906
struct tty_port *port = &state->port;
1973
1907
struct device *tty_dev;
1974
1908
struct uart_match match = {uport, drv};
1975
struct tty_struct *tty;
1977
1910
mutex_lock(&port->mutex);
1979
/* Must be inside the mutex lock until we convert to tty_port */
1982
1912
tty_dev = device_find_child(uport->dev, &match, serial_match_port);
1983
1913
if (device_may_wakeup(tty_dev)) {
1984
1914
if (!enable_irq_wake(uport->irq))