~ubuntu-branches/ubuntu/trusty/linux-linaro-omap/trusty

« back to all changes in this revision

Viewing changes to drivers/tty/serial/serial_core.c

  • Committer: Package Import Robot
  • Author(s): John Rigby, John Rigby
  • Date: 2011-09-26 10:44:23 UTC
  • Revision ID: package-import@ubuntu.com-20110926104423-57i0gl3v99b3lkfg
Tags: 3.0.0-1007.9
[ John Rigby ]

Enable crypto modules and remove crypto-modules from
exclude-module files
LP: #826021

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
/*
2
 
 *  linux/drivers/char/core.c
3
 
 *
4
2
 *  Driver core for serial ports
5
3
 *
6
4
 *  Based on drivers/char/serial.c, by Linus Torvalds, Theodore Ts'o.
172
170
 
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;
 
176
                }
 
177
                /*
 
178
                 * Initialise the hardware port settings.
 
179
                 */
 
180
                uart_change_speed(tty, state, NULL);
 
181
 
175
182
                if (init_hw) {
176
183
                        /*
177
 
                         * Initialise the hardware port settings.
178
 
                         */
179
 
                        uart_change_speed(tty, state, NULL);
180
 
 
181
 
                        /*
182
184
                         * Setup the RTS and DTR signals once the
183
185
                         * port is open and ready to respond.
184
186
                         */
1240
1242
                }
1241
1243
                spin_unlock_irqrestore(&state->uart_port->lock, flags);
1242
1244
        }
1243
 
#if 0
1244
 
        /*
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.....
1249
 
         */
1250
 
        if (!(old_termios->c_cflag & CLOCAL) &&
1251
 
            (tty->termios->c_cflag & CLOCAL))
1252
 
                wake_up_interruptible(&state->uart_port.open_wait);
1253
 
#endif
1254
1245
}
1255
1246
 
1256
1247
/*
1423
1414
                if (time_after(jiffies, expire))
1424
1415
                        break;
1425
1416
        }
1426
 
        set_current_state(TASK_RUNNING); /* might not be needed */
1427
1417
}
1428
1418
 
1429
1419
static void uart_wait_until_sent(struct tty_struct *tty, int timeout)
1466
1456
        mutex_unlock(&port->mutex);
1467
1457
}
1468
1458
 
1469
 
/**
1470
 
 *      uart_update_termios     -       update the terminal hw settings
1471
 
 *      @tty: tty associated with UART
1472
 
 *      @state: UART to update
1473
 
 *
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.
1478
 
 */
1479
 
static void uart_update_termios(struct tty_struct *tty,
1480
 
                                                struct uart_state *state)
1481
 
{
1482
 
        struct uart_port *port = state->uart_port;
1483
 
 
1484
 
        if (uart_console(port) && port->cons->cflag) {
1485
 
                tty->termios->c_cflag = port->cons->cflag;
1486
 
                port->cons->cflag = 0;
1487
 
        }
1488
 
 
1489
 
        /*
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.
1493
 
         */
1494
 
        if (!(tty->flags & (1 << TTY_IO_ERROR))) {
1495
 
                /*
1496
 
                 * Make termios settings take effect.
1497
 
                 */
1498
 
                uart_change_speed(tty, state, NULL);
1499
 
 
1500
 
                /*
1501
 
                 * And finally enable the RTS and DTR signals.
1502
 
                 */
1503
 
                if (tty->termios->c_cflag & CBAUD)
1504
 
                        uart_set_mctrl(port, TIOCM_DTR | TIOCM_RTS);
1505
 
        }
1506
 
}
1507
 
 
1508
1459
static int uart_carrier_raised(struct tty_port *port)
1509
1460
{
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;
1526
1477
 
1527
 
        if (onoff) {
 
1478
        if (onoff)
1528
1479
                uart_set_mctrl(uport, TIOCM_DTR | TIOCM_RTS);
1529
 
 
1530
 
                /*
1531
 
                 * If this is the first open to succeed,
1532
 
                 * adjust things to suit.
1533
 
                 */
1534
 
                if (!test_and_set_bit(ASYNCB_NORMAL_ACTIVE, &port->flags))
1535
 
                        uart_update_termios(port->tty, state);
1536
 
        }
1537
1480
        else
1538
1481
                uart_clear_mctrl(uport, TIOCM_DTR | TIOCM_RTS);
1539
1482
}
1586
1529
        pr_debug("uart_open(%d) called\n", line);
1587
1530
 
1588
1531
        /*
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()).
1592
 
         */
1593
 
        retval = -ENODEV;
1594
 
        if (line >= tty->driver->num)
1595
 
                goto fail;
1596
 
 
1597
 
        /*
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;
1976
1909
 
1977
1910
        mutex_lock(&port->mutex);
1978
1911
 
1979
 
        /* Must be inside the mutex lock until we convert to tty_port */
1980
 
        tty = port->tty;
1981
 
 
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))