Pull tty/serial driver fixes from Greg KH: "Here are a small number of tty/serial driver fixes to resolve reported issues with 3.14-rc and earlier (in the case of the vt bugfix). Some of these have been tested and reported by a number of people as the tty bugfix was pretty commonly hit on some platforms. All have been in linux-next for a while" * tag 'tty-3.14-rc3' of git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/tty: vt: Fix secure clear screen serial: 8250: Support XR17V35x fraction divisor n_tty: Fix stale echo output serial: sirf: fix kernel panic caused by unpaired spinlock serial: 8250_pci: unbreak last serial ports on NetMos 9865 cards n_tty: Fix poll() when TIME_CHAR and MIN_CHAR == 0 serial: omap: fix rs485 probe on defered pinctrl serial: 8250_dw: fix compilation warning when !CONFIG_PM_SLEEP serial: omap-serial: Move info message to probe function tty: Set correct tty name in 'active' sysfs attribute tty: n_gsm: Fix for modems with brk in modem status control drivers/tty/hvc: don't use module_init in non-modular hyp. console code
Unified · Split
| @@ -3,7 +3,8 @@ Date: Nov 2010 · 2 unmodified lines | ||
| 3 | 3 | Contact: Kay Sievers <kay.sievers@vrfy.org> |
| 4 | 4 | Description: |
| 5 | 5 | Shows the list of currently configured |
| 6 | − console devices, like 'tty1 ttyS0'. | |
| 6 | + tty devices used for the console, | |
| 7 | + like 'tty1 ttyS0'. | |
| 7 | 8 | The last entry in the file is the active |
| 8 | 9 | device connected to /dev/console. |
| 9 | 10 | The file supports poll() to detect virtual |
| @@ -255,13 +255,7 @@ static int __init hvc_opal_init(void) · 254 unmodified lines | ||
| 255 | 255 | /* Register as a vio device to receive callbacks */ |
| 256 | 256 | return platform_driver_register(&hvc_opal_driver); |
| 257 | 257 | } |
| 258 | −module_init(hvc_opal_init); | |
| 259 | − | |
| 260 | −static void __exit hvc_opal_exit(void) | |
| 261 | −{ | |
| 262 | − platform_driver_unregister(&hvc_opal_driver); | |
| 263 | −} | |
| 264 | −module_exit(hvc_opal_exit); | |
| 258 | +device_initcall(hvc_opal_init); | |
| 265 | 259 | |
| 266 | 260 | static void udbg_opal_putc(char c) |
| 267 | 261 | { |
| @@ -102,17 +102,7 @@ static int __init hvc_rtas_init(void) · 101 unmodified lines | ||
| 102 | 102 | |
| 103 | 103 | return 0; |
| 104 | 104 | } |
| 105 | −module_init(hvc_rtas_init); | |
| 106 | − | |
| 107 | −/* This will tear down the tty portion of the driver */ | |
| 108 | −static void __exit hvc_rtas_exit(void) | |
| 109 | −{ | |
| 110 | − /* Really the fun isn't over until the worker thread breaks down and | |
| 111 | − * the tty cleans up */ | |
| 112 | − if (hvc_rtas_dev) | |
| 113 | − hvc_remove(hvc_rtas_dev); | |
| 114 | −} | |
| 115 | −module_exit(hvc_rtas_exit); | |
| 105 | +device_initcall(hvc_rtas_init); | |
| 116 | 106 | |
| 117 | 107 | /* This will happen prior to module init. There is no tty at this time? */ |
| 118 | 108 | static int __init hvc_rtas_console_init(void) |
| @@ -80,14 +80,7 @@ static int __init hvc_udbg_init(void) · 79 unmodified lines | ||
| 80 | 80 | |
| 81 | 81 | return 0; |
| 82 | 82 | } |
| 83 | −module_init(hvc_udbg_init); | |
| 84 | − | |
| 85 | −static void __exit hvc_udbg_exit(void) | |
| 86 | −{ | |
| 87 | − if (hvc_udbg_dev) | |
| 88 | − hvc_remove(hvc_udbg_dev); | |
| 89 | −} | |
| 90 | −module_exit(hvc_udbg_exit); | |
| 83 | +device_initcall(hvc_udbg_init); | |
| 91 | 84 | |
| 92 | 85 | static int __init hvc_udbg_console_init(void) |
| 93 | 86 | { |
| @@ -561,18 +561,7 @@ static int __init xen_hvc_init(void) · 560 unmodified lines | ||
| 561 | 561 | #endif |
| 562 | 562 | return r; |
| 563 | 563 | } |
| 564 | − | |
| 565 | −static void __exit xen_hvc_fini(void) | |
| 566 | −{ | |
| 567 | − struct xencons_info *entry, *next; | |
| 568 | − | |
| 569 | − if (list_empty(&xenconsoles)) | |
| 570 | − return; | |
| 571 | − | |
| 572 | − list_for_each_entry_safe(entry, next, &xenconsoles, list) { | |
| 573 | − xen_console_remove(entry); | |
| 574 | − } | |
| 575 | −} | |
| 564 | +device_initcall(xen_hvc_init); | |
| 576 | 565 | |
| 577 | 566 | static int xen_cons_init(void) |
| 578 | 567 | { |
| @@ -598,10 +587,6 @@ static int xen_cons_init(void) · 19 unmodified lines | ||
| 598 | 587 | hvc_instantiate(HVC_COOKIE, 0, ops); |
| 599 | 588 | return 0; |
| 600 | 589 | } |
| 601 | − | |
| 602 | − | |
| 603 | −module_init(xen_hvc_init); | |
| 604 | −module_exit(xen_hvc_fini); | |
| 605 | 590 | console_initcall(xen_cons_init); |
| 606 | 591 | |
| 607 | 592 | #ifdef CONFIG_EARLY_PRINTK |
| @@ -1090,6 +1090,7 @@ static void gsm_control_modem(struct gsm_mux *gsm, u8 *data, int clen) · 1089 unmodified lines | ||
| 1090 | 1090 | { |
| 1091 | 1091 | unsigned int addr = 0; |
| 1092 | 1092 | unsigned int modem = 0; |
| 1093 | + unsigned int brk = 0; | |
| 1093 | 1094 | struct gsm_dlci *dlci; |
| 1094 | 1095 | int len = clen; |
| 1095 | 1096 | u8 *dp = data; |
| @@ -1116,6 +1117,16 @@ static void gsm_control_modem(struct gsm_mux *gsm, u8 *data, int clen) · 20 unmodified lines | ||
| 1116 | 1117 | if (len == 0) |
| 1117 | 1118 | return; |
| 1118 | 1119 | } |
| 1120 | + len--; | |
| 1121 | + if (len > 0) { | |
| 1122 | + while (gsm_read_ea(&brk, *dp++) == 0) { | |
| 1123 | + len--; | |
| 1124 | + if (len == 0) | |
| 1125 | + return; | |
| 1126 | + } | |
| 1127 | + modem <<= 7; | |
| 1128 | + modem |= (brk & 0x7f); | |
| 1129 | + } | |
| 1119 | 1130 | tty = tty_port_tty_get(&dlci->port); |
| 1120 | 1131 | gsm_process_modem(tty, dlci, modem, clen); |
| 1121 | 1132 | if (tty) { |
| @@ -817,8 +817,7 @@ static void process_echoes(struct tty_struct *tty) · 816 unmodified lines | ||
| 817 | 817 | struct n_tty_data *ldata = tty->disc_data; |
| 818 | 818 | size_t echoed; |
| 819 | 819 | |
| 820 | − if ((!L_ECHO(tty) && !L_ECHONL(tty)) || | |
| 821 | − ldata->echo_mark == ldata->echo_tail) | |
| 820 | + if (ldata->echo_mark == ldata->echo_tail) | |
| 822 | 821 | return; |
| 823 | 822 | |
| 824 | 823 | mutex_lock(&ldata->output_lock); |
| @@ -1244,7 +1243,8 @@ n_tty_receive_signal_char(struct tty_struct *tty, int signal, unsigned char c) · 419 unmodified lines | ||
| 1244 | 1243 | if (L_ECHO(tty)) { |
| 1245 | 1244 | echo_char(c, tty); |
| 1246 | 1245 | commit_echoes(tty); |
| 1247 | − } | |
| 1246 | + } else | |
| 1247 | + process_echoes(tty); | |
| 1248 | 1248 | isig(signal, tty); |
| 1249 | 1249 | return; |
| 1250 | 1250 | } |
| @@ -1274,7 +1274,7 @@ n_tty_receive_char_special(struct tty_struct *tty, unsigned char c) · 23 unmodified lines | ||
| 1274 | 1274 | if (I_IXON(tty)) { |
| 1275 | 1275 | if (c == START_CHAR(tty)) { |
| 1276 | 1276 | start_tty(tty); |
| 1277 | − commit_echoes(tty); | |
| 1277 | + process_echoes(tty); | |
| 1278 | 1278 | return 0; |
| 1279 | 1279 | } |
| 1280 | 1280 | if (c == STOP_CHAR(tty)) { |
| @@ -1820,8 +1820,10 @@ static void n_tty_set_termios(struct tty_struct *tty, struct ktermios *old) · 539 unmodified lines | ||
| 1820 | 1820 | * Fix tty hang when I_IXON(tty) is cleared, but the tty |
| 1821 | 1821 | * been stopped by STOP_CHAR(tty) before it. |
| 1822 | 1822 | */ |
| 1823 | − if (!I_IXON(tty) && old && (old->c_iflag & IXON) && !tty->flow_stopped) | |
| 1823 | + if (!I_IXON(tty) && old && (old->c_iflag & IXON) && !tty->flow_stopped) { | |
| 1824 | 1824 | start_tty(tty); |
| 1825 | + process_echoes(tty); | |
| 1826 | + } | |
| 1825 | 1827 | |
| 1826 | 1828 | /* The termios change make the tty ready for I/O */ |
| 1827 | 1829 | if (waitqueue_active(&tty->write_wait)) |
| @@ -1896,7 +1898,7 @@ err: · 68 unmodified lines | ||
| 1896 | 1898 | static inline int input_available_p(struct tty_struct *tty, int poll) |
| 1897 | 1899 | { |
| 1898 | 1900 | struct n_tty_data *ldata = tty->disc_data; |
| 1899 | − int amt = poll && !TIME_CHAR(tty) ? MIN_CHAR(tty) : 1; | |
| 1901 | + int amt = poll && !TIME_CHAR(tty) && MIN_CHAR(tty) ? MIN_CHAR(tty) : 1; | |
| 1900 | 1902 | |
| 1901 | 1903 | if (ldata->icanon && !L_EXTPROC(tty)) { |
| 1902 | 1904 | if (ldata->canon_head != ldata->read_tail) |
| @@ -2432,6 +2432,24 @@ serial8250_do_set_termios(struct uart_port *port, struct ktermios *termios, · 2431 unmodified lines | ||
| 2432 | 2432 | |
| 2433 | 2433 | serial_dl_write(up, quot); |
| 2434 | 2434 | |
| 2435 | + /* | |
| 2436 | + * XR17V35x UARTs have an extra fractional divisor register (DLD) | |
| 2437 | + * | |
| 2438 | + * We need to recalculate all of the registers, because DLM and DLL | |
| 2439 | + * are already rounded to a whole integer. | |
| 2440 | + * | |
| 2441 | + * When recalculating we use a 32x clock instead of a 16x clock to | |
| 2442 | + * allow 1-bit for rounding in the fractional part. | |
| 2443 | + */ | |
| 2444 | + if (up->port.type == PORT_XR17V35X) { | |
| 2445 | + unsigned int baud_x32 = (port->uartclk * 2) / baud; | |
| 2446 | + u16 quot = baud_x32 / 32; | |
| 2447 | + u8 quot_frac = DIV_ROUND_CLOSEST(baud_x32 % 32, 2); | |
| 2448 | + | |
| 2449 | + serial_dl_write(up, quot); | |
| 2450 | + serial_port_out(port, 0x2, quot_frac & 0xf); | |
| 2451 | + } | |
| 2452 | + | |
| 2435 | 2453 | /* |
| 2436 | 2454 | * LCR DLAB must be set to enable 64-byte FIFO mode. If the FCR |
| 2437 | 2455 | * is written without DLAB set, this mode will be disabled. |
| @@ -391,7 +391,7 @@ static int dw8250_remove(struct platform_device *pdev) · 390 unmodified lines | ||
| 391 | 391 | return 0; |
| 392 | 392 | } |
| 393 | 393 | |
| 394 | −#ifdef CONFIG_PM | |
| 394 | +#ifdef CONFIG_PM_SLEEP | |
| 395 | 395 | static int dw8250_suspend(struct device *dev) |
| 396 | 396 | { |
| 397 | 397 | struct dw8250_data *data = dev_get_drvdata(dev); |
| @@ -409,7 +409,7 @@ static int dw8250_resume(struct device *dev) · 11 unmodified lines | ||
| 409 | 409 | |
| 410 | 410 | return 0; |
| 411 | 411 | } |
| 412 | −#endif /* CONFIG_PM */ | |
| 412 | +#endif /* CONFIG_PM_SLEEP */ | |
| 413 | 413 | |
| 414 | 414 | #ifdef CONFIG_PM_RUNTIME |
| 415 | 415 | static int dw8250_runtime_suspend(struct device *dev) |
| @@ -783,7 +783,8 @@ static int pci_netmos_9900_setup(struct serial_private *priv, · 782 unmodified lines | ||
| 783 | 783 | { |
| 784 | 784 | unsigned int bar; |
| 785 | 785 | |
| 786 | − if ((priv->dev->subsystem_device & 0xff00) == 0x3000) { | |
| 786 | + if ((priv->dev->device != PCI_DEVICE_ID_NETMOS_9865) && | |
| 787 | + (priv->dev->subsystem_device & 0xff00) == 0x3000) { | |
| 787 | 788 | /* netmos apparently orders BARs by datasheet layout, so serial |
| 788 | 789 | * ports get BARs 0 and 3 (or 1 and 4 for memmapped) |
| 789 | 790 | */ |
| @@ -738,9 +738,6 @@ static int serial_omap_startup(struct uart_port *port) · 737 unmodified lines | ||
| 738 | 738 | return retval; |
| 739 | 739 | } |
| 740 | 740 | disable_irq(up->wakeirq); |
| 741 | − } else { | |
| 742 | − dev_info(up->port.dev, "no wakeirq for uart%d\n", | |
| 743 | − up->port.line); | |
| 744 | 741 | } |
| 745 | 742 | |
| 746 | 743 | dev_dbg(up->port.dev, "serial_omap_startup+%d\n", up->port.line); |
| @@ -1604,8 +1601,11 @@ static int serial_omap_probe_rs485(struct uart_omap_port *up, · 857 unmodified lines | ||
| 1604 | 1601 | flags & SER_RS485_RTS_AFTER_SEND); |
| 1605 | 1602 | if (ret < 0) |
| 1606 | 1603 | return ret; |
| 1607 | − } else | |
| 1604 | + } else if (up->rts_gpio == -EPROBE_DEFER) { | |
| 1605 | + return -EPROBE_DEFER; | |
| 1606 | + } else { | |
| 1608 | 1607 | up->rts_gpio = -EINVAL; |
| 1608 | + } | |
| 1609 | 1609 | |
| 1610 | 1610 | if (of_property_read_u32_array(np, "rs485-rts-delay", |
| 1611 | 1611 | rs485_delay, 2) == 0) { |
| @@ -1687,6 +1687,9 @@ static int serial_omap_probe(struct platform_device *pdev) · 75 unmodified lines | ||
| 1687 | 1687 | up->port.iotype = UPIO_MEM; |
| 1688 | 1688 | up->port.irq = uartirq; |
| 1689 | 1689 | up->wakeirq = wakeirq; |
| 1690 | + if (!up->wakeirq) | |
| 1691 | + dev_info(up->port.dev, "no wakeirq for uart%d\n", | |
| 1692 | + up->port.line); | |
| 1690 | 1693 | |
| 1691 | 1694 | up->port.regshift = 2; |
| 1692 | 1695 | up->port.fifosize = 64; |
| @@ -542,8 +542,10 @@ static void sirfsoc_rx_tmo_process_tl(unsigned long param) · 541 unmodified lines | ||
| 542 | 542 | wr_regl(port, ureg->sirfsoc_rx_dma_io_ctrl, |
| 543 | 543 | rd_regl(port, ureg->sirfsoc_rx_dma_io_ctrl) | |
| 544 | 544 | SIRFUART_IO_MODE); |
| 545 | − sirfsoc_uart_pio_rx_chars(port, 4 - sirfport->rx_io_count); | |
| 546 | 545 | spin_unlock_irqrestore(&sirfport->rx_lock, flags); |
| 546 | + spin_lock(&port->lock); | |
| 547 | + sirfsoc_uart_pio_rx_chars(port, 4 - sirfport->rx_io_count); | |
| 548 | + spin_unlock(&port->lock); | |
| 547 | 549 | if (sirfport->rx_io_count == 4) { |
| 548 | 550 | spin_lock_irqsave(&sirfport->rx_lock, flags); |
| 549 | 551 | sirfport->rx_io_count = 0; |
| @@ -1267,16 +1267,17 @@ static void pty_line_name(struct tty_driver *driver, int index, char *p) · 1266 unmodified lines | ||
| 1267 | 1267 | * @p: output buffer of at least 7 bytes |
| 1268 | 1268 | * |
| 1269 | 1269 | * Generate a name from a driver reference and write it to the output |
| 1270 | − * buffer. | |
| 1270 | + * buffer. Return the number of bytes written. | |
| 1271 | 1271 | * |
| 1272 | 1272 | * Locking: None |
| 1273 | 1273 | */ |
| 1274 | −static void tty_line_name(struct tty_driver *driver, int index, char *p) | |
| 1274 | +static ssize_t tty_line_name(struct tty_driver *driver, int index, char *p) | |
| 1275 | 1275 | { |
| 1276 | 1276 | if (driver->flags & TTY_DRIVER_UNNUMBERED_NODE) |
| 1277 | − strcpy(p, driver->name); | |
| 1277 | + return sprintf(p, "%s", driver->name); | |
| 1278 | 1278 | else |
| 1279 | − sprintf(p, "%s%d", driver->name, index + driver->name_base); | |
| 1279 | + return sprintf(p, "%s%d", driver->name, | |
| 1280 | + index + driver->name_base); | |
| 1280 | 1281 | } |
| 1281 | 1282 | |
| 1282 | 1283 | /** |
| @@ -3545,9 +3546,19 @@ static ssize_t show_cons_active(struct device *dev, · 2262 unmodified lines | ||
| 3545 | 3546 | if (i >= ARRAY_SIZE(cs)) |
| 3546 | 3547 | break; |
| 3547 | 3548 | } |
| 3548 | − while (i--) | |
| 3549 | − count += sprintf(buf + count, "%s%d%c", | |
| 3550 | − cs[i]->name, cs[i]->index, i ? ' ':'\n'); | |
| 3549 | + while (i--) { | |
| 3550 | + struct tty_driver *driver; | |
| 3551 | + const char *name = cs[i]->name; | |
| 3552 | + int index = cs[i]->index; | |
| 3553 | + | |
| 3554 | + driver = cs[i]->device(cs[i], &index); | |
| 3555 | + if (driver) { | |
| 3556 | + count += tty_line_name(driver, index, buf + count); | |
| 3557 | + count += sprintf(buf + count, "%c", i ? ' ':'\n'); | |
| 3558 | + } else | |
| 3559 | + count += sprintf(buf + count, "%s%d%c", | |
| 3560 | + name, index, i ? ' ':'\n'); | |
| 3561 | + } | |
| 3551 | 3562 | console_unlock(); |
| 3552 | 3563 | |
| 3553 | 3564 | return count; |
| @@ -1164,6 +1164,8 @@ static void csi_J(struct vc_data *vc, int vpar) · 1163 unmodified lines | ||
| 1164 | 1164 | scr_memsetw(vc->vc_screenbuf, vc->vc_video_erase_char, |
| 1165 | 1165 | vc->vc_screenbuf_size >> 1); |
| 1166 | 1166 | set_origin(vc); |
| 1167 | + if (CON_IS_VISIBLE(vc)) | |
| 1168 | + update_screen(vc); | |
| 1167 | 1169 | /* fall through */ |
| 1168 | 1170 | case 2: /* erase whole display */ |
| 1169 | 1171 | count = vc->vc_cols * vc->vc_rows; |