Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

Merge tag 'tty-5.1-rc3' of git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/tty

Pull tty/serial fixes from Greg KH:
"Here are some small tty and serial driver fixes for 5.1-rc3.

Nothing major here, just a number of potential problems fixes for
error handling paths, as well as some other minor bugfixes for
reported issues with 5.1-rc1.

All of these have been in linux-next with no reported issues"

* tag 'tty-5.1-rc3' of git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/tty:
tty: fix NULL pointer issue when tty_port ops is not set
Disable kgdboc failed by echo space to /sys/module/kgdboc/parameters/kgdboc
dt-bindings: serial: Add compatible for Mediatek MT8183
tty/serial: atmel: RS485 HD w/DMA: enable RX after TX is stopped
tty/serial: atmel: Add is_half_duplex helper
serial: sh-sci: Fix setting SCSCR_TIE while transferring data
serial: ar933x_uart: Fix build failure with disabled console
tty: serial: qcom_geni_serial: Initialize baud in qcom_geni_console_setup
sc16is7xx: missing unregister/delete driver on error in sc16is7xx_init()
tty: mxs-auart: fix a potential NULL pointer dereference
tty: atmel_serial: fix a potential NULL pointer dereference
serial: max310x: Fix to avoid potential NULL pointer dereference
serial: mvebu-uart: Fix to avoid a potential NULL pointer dereference

+75 -51
+1
Documentation/devicetree/bindings/serial/mtk-uart.txt
··· 16 16 * "mediatek,mt8127-uart" for MT8127 compatible UARTS 17 17 * "mediatek,mt8135-uart" for MT8135 compatible UARTS 18 18 * "mediatek,mt8173-uart" for MT8173 compatible UARTS 19 + * "mediatek,mt8183-uart", "mediatek,mt6577-uart" for MT8183 compatible UARTS 19 20 * "mediatek,mt6577-uart" for MT6577 and all of the above 20 21 21 22 - reg: The base address of the UART register bank.
+8 -16
drivers/tty/serial/ar933x_uart.c
··· 49 49 struct clk *clk; 50 50 }; 51 51 52 - static inline bool ar933x_uart_console_enabled(void) 53 - { 54 - return IS_ENABLED(CONFIG_SERIAL_AR933X_CONSOLE); 55 - } 56 - 57 52 static inline unsigned int ar933x_uart_read(struct ar933x_uart_port *up, 58 53 int offset) 59 54 { ··· 503 508 .verify_port = ar933x_uart_verify_port, 504 509 }; 505 510 511 + #ifdef CONFIG_SERIAL_AR933X_CONSOLE 506 512 static struct ar933x_uart_port * 507 513 ar933x_console_ports[CONFIG_SERIAL_AR933X_NR_UARTS]; 508 514 ··· 600 604 .index = -1, 601 605 .data = &ar933x_uart_driver, 602 606 }; 603 - 604 - static void ar933x_uart_add_console_port(struct ar933x_uart_port *up) 605 - { 606 - if (!ar933x_uart_console_enabled()) 607 - return; 608 - 609 - ar933x_console_ports[up->port.line] = up; 610 - } 607 + #endif /* CONFIG_SERIAL_AR933X_CONSOLE */ 611 608 612 609 static struct uart_driver ar933x_uart_driver = { 613 610 .owner = THIS_MODULE, ··· 689 700 baud = ar933x_uart_get_baud(port->uartclk, 0, AR933X_UART_MAX_STEP); 690 701 up->max_baud = min_t(unsigned int, baud, AR933X_UART_MAX_BAUD); 691 702 692 - ar933x_uart_add_console_port(up); 703 + #ifdef CONFIG_SERIAL_AR933X_CONSOLE 704 + ar933x_console_ports[up->port.line] = up; 705 + #endif 693 706 694 707 ret = uart_add_one_port(&ar933x_uart_driver, &up->port); 695 708 if (ret) ··· 740 749 { 741 750 int ret; 742 751 743 - if (ar933x_uart_console_enabled()) 744 - ar933x_uart_driver.cons = &ar933x_uart_console; 752 + #ifdef CONFIG_SERIAL_AR933X_CONSOLE 753 + ar933x_uart_driver.cons = &ar933x_uart_console; 754 + #endif 745 755 746 756 ret = uart_register_driver(&ar933x_uart_driver); 747 757 if (ret)
+37 -15
drivers/tty/serial/atmel_serial.c
··· 166 166 unsigned int pending_status; 167 167 spinlock_t lock_suspended; 168 168 169 + bool hd_start_rx; /* can start RX during half-duplex operation */ 170 + 169 171 /* ISO7816 */ 170 172 unsigned int fidi_min; 171 173 unsigned int fidi_max; ··· 231 229 static inline void atmel_uart_write_char(struct uart_port *port, u8 value) 232 230 { 233 231 __raw_writeb(value, port->membase + ATMEL_US_THR); 232 + } 233 + 234 + static inline int atmel_uart_is_half_duplex(struct uart_port *port) 235 + { 236 + return ((port->rs485.flags & SER_RS485_ENABLED) && 237 + !(port->rs485.flags & SER_RS485_RX_DURING_TX)) || 238 + (port->iso7816.flags & SER_ISO7816_ENABLED); 234 239 } 235 240 236 241 #ifdef CONFIG_SERIAL_ATMEL_PDC ··· 617 608 /* Disable interrupts */ 618 609 atmel_uart_writel(port, ATMEL_US_IDR, atmel_port->tx_done_mask); 619 610 620 - if (((port->rs485.flags & SER_RS485_ENABLED) && 621 - !(port->rs485.flags & SER_RS485_RX_DURING_TX)) || 622 - port->iso7816.flags & SER_ISO7816_ENABLED) 611 + if (atmel_uart_is_half_duplex(port)) 623 612 atmel_start_rx(port); 613 + 624 614 } 625 615 626 616 /* ··· 636 628 return; 637 629 638 630 if (atmel_use_pdc_tx(port) || atmel_use_dma_tx(port)) 639 - if (((port->rs485.flags & SER_RS485_ENABLED) && 640 - !(port->rs485.flags & SER_RS485_RX_DURING_TX)) || 641 - port->iso7816.flags & SER_ISO7816_ENABLED) 631 + if (atmel_uart_is_half_duplex(port)) 642 632 atmel_stop_rx(port); 643 633 644 634 if (atmel_use_pdc_tx(port)) ··· 934 928 */ 935 929 if (!uart_circ_empty(xmit)) 936 930 atmel_tasklet_schedule(atmel_port, &atmel_port->tasklet_tx); 937 - else if (((port->rs485.flags & SER_RS485_ENABLED) && 938 - !(port->rs485.flags & SER_RS485_RX_DURING_TX)) || 939 - port->iso7816.flags & SER_ISO7816_ENABLED) { 940 - /* DMA done, stop TX, start RX for RS485 */ 941 - atmel_start_rx(port); 931 + else if (atmel_uart_is_half_duplex(port)) { 932 + /* 933 + * DMA done, re-enable TXEMPTY and signal that we can stop 934 + * TX and start RX for RS485 935 + */ 936 + atmel_port->hd_start_rx = true; 937 + atmel_uart_writel(port, ATMEL_US_IER, 938 + atmel_port->tx_done_mask); 942 939 } 943 940 944 941 spin_unlock_irqrestore(&port->lock, flags); ··· 1297 1288 sg_dma_len(&atmel_port->sg_rx)/2, 1298 1289 DMA_DEV_TO_MEM, 1299 1290 DMA_PREP_INTERRUPT); 1291 + if (!desc) { 1292 + dev_err(port->dev, "Preparing DMA cyclic failed\n"); 1293 + goto chan_err; 1294 + } 1300 1295 desc->callback = atmel_complete_rx_dma; 1301 1296 desc->callback_param = port; 1302 1297 atmel_port->desc_rx = desc; ··· 1389 1376 struct atmel_uart_port *atmel_port = to_atmel_uart_port(port); 1390 1377 1391 1378 if (pending & atmel_port->tx_done_mask) { 1392 - /* Either PDC or interrupt transmission */ 1393 1379 atmel_uart_writel(port, ATMEL_US_IDR, 1394 1380 atmel_port->tx_done_mask); 1381 + 1382 + /* Start RX if flag was set and FIFO is empty */ 1383 + if (atmel_port->hd_start_rx) { 1384 + if (!(atmel_uart_readl(port, ATMEL_US_CSR) 1385 + & ATMEL_US_TXEMPTY)) 1386 + dev_warn(port->dev, "Should start RX, but TX fifo is not empty\n"); 1387 + 1388 + atmel_port->hd_start_rx = false; 1389 + atmel_start_rx(port); 1390 + return; 1391 + } 1392 + 1395 1393 atmel_tasklet_schedule(atmel_port, &atmel_port->tasklet_tx); 1396 1394 } 1397 1395 } ··· 1532 1508 atmel_uart_writel(port, ATMEL_US_IER, 1533 1509 atmel_port->tx_done_mask); 1534 1510 } else { 1535 - if (((port->rs485.flags & SER_RS485_ENABLED) && 1536 - !(port->rs485.flags & SER_RS485_RX_DURING_TX)) || 1537 - port->iso7816.flags & SER_ISO7816_ENABLED) { 1511 + if (atmel_uart_is_half_duplex(port)) { 1538 1512 /* DMA done, stop TX, start RX for RS485 */ 1539 1513 atmel_start_rx(port); 1540 1514 }
+3 -1
drivers/tty/serial/kgdboc.c
··· 148 148 char *cptr = config; 149 149 struct console *cons; 150 150 151 - if (!strlen(config) || isspace(config[0])) 151 + if (!strlen(config) || isspace(config[0])) { 152 + err = 0; 152 153 goto noconfig; 154 + } 153 155 154 156 kgdboc_io_ops.is_console = 0; 155 157 kgdb_tty_driver = NULL;
+2
drivers/tty/serial/max310x.c
··· 1415 1415 if (spi->dev.of_node) { 1416 1416 const struct of_device_id *of_id = 1417 1417 of_match_device(max310x_dt_ids, &spi->dev); 1418 + if (!of_id) 1419 + return -ENODEV; 1418 1420 1419 1421 devtype = (struct max310x_devtype *)of_id->data; 1420 1422 } else {
+3
drivers/tty/serial/mvebu-uart.c
··· 810 810 return -EINVAL; 811 811 } 812 812 813 + if (!match) 814 + return -ENODEV; 815 + 813 816 /* Assume that all UART ports have a DT alias or none has */ 814 817 id = of_alias_get_id(pdev->dev.of_node, "serial"); 815 818 if (!pdev->dev.of_node || id < 0)
+4
drivers/tty/serial/mxs-auart.c
··· 1686 1686 1687 1687 s->port.mapbase = r->start; 1688 1688 s->port.membase = ioremap(r->start, resource_size(r)); 1689 + if (!s->port.membase) { 1690 + ret = -ENOMEM; 1691 + goto out_disable_clks; 1692 + } 1689 1693 s->port.ops = &mxs_auart_ops; 1690 1694 s->port.iotype = UPIO_MEM; 1691 1695 s->port.fifosize = MXS_AUART_FIFO_SIZE;
+1 -1
drivers/tty/serial/qcom_geni_serial.c
··· 1050 1050 { 1051 1051 struct uart_port *uport; 1052 1052 struct qcom_geni_serial_port *port; 1053 - int baud; 1053 + int baud = 9600; 1054 1054 int bits = 8; 1055 1055 int parity = 'n'; 1056 1056 int flow = 'n';
+10 -2
drivers/tty/serial/sc16is7xx.c
··· 1507 1507 ret = i2c_add_driver(&sc16is7xx_i2c_uart_driver); 1508 1508 if (ret < 0) { 1509 1509 pr_err("failed to init sc16is7xx i2c --> %d\n", ret); 1510 - return ret; 1510 + goto err_i2c; 1511 1511 } 1512 1512 #endif 1513 1513 ··· 1515 1515 ret = spi_register_driver(&sc16is7xx_spi_uart_driver); 1516 1516 if (ret < 0) { 1517 1517 pr_err("failed to init sc16is7xx spi --> %d\n", ret); 1518 - return ret; 1518 + goto err_spi; 1519 1519 } 1520 1520 #endif 1521 + return ret; 1522 + 1523 + err_spi: 1524 + #ifdef CONFIG_SERIAL_SC16IS7XX_I2C 1525 + i2c_del_driver(&sc16is7xx_i2c_uart_driver); 1526 + #endif 1527 + err_i2c: 1528 + uart_unregister_driver(&sc16is7xx_uart); 1521 1529 return ret; 1522 1530 } 1523 1531 module_init(sc16is7xx_init);
+1 -11
drivers/tty/serial/sh-sci.c
··· 838 838 839 839 if (uart_circ_chars_pending(xmit) < WAKEUP_CHARS) 840 840 uart_write_wakeup(port); 841 - if (uart_circ_empty(xmit)) { 841 + if (uart_circ_empty(xmit)) 842 842 sci_stop_tx(port); 843 - } else { 844 - ctrl = serial_port_in(port, SCSCR); 845 843 846 - if (port->type != PORT_SCI) { 847 - serial_port_in(port, SCxSR); /* Dummy read */ 848 - sci_clear_SCxSR(port, SCxSR_TDxE_CLEAR(port)); 849 - } 850 - 851 - ctrl |= SCSCR_TIE; 852 - serial_port_out(port, SCSCR, ctrl); 853 - } 854 844 } 855 845 856 846 /* On SH3, SCIF may read end-of-break as a space->mark char */
+5 -5
drivers/tty/tty_port.c
··· 325 325 if (tty && C_HUPCL(tty)) 326 326 tty_port_lower_dtr_rts(port); 327 327 328 - if (port->ops->shutdown) 328 + if (port->ops && port->ops->shutdown) 329 329 port->ops->shutdown(port); 330 330 } 331 331 out: ··· 398 398 */ 399 399 int tty_port_carrier_raised(struct tty_port *port) 400 400 { 401 - if (port->ops->carrier_raised == NULL) 401 + if (!port->ops || !port->ops->carrier_raised) 402 402 return 1; 403 403 return port->ops->carrier_raised(port); 404 404 } ··· 414 414 */ 415 415 void tty_port_raise_dtr_rts(struct tty_port *port) 416 416 { 417 - if (port->ops->dtr_rts) 417 + if (port->ops && port->ops->dtr_rts) 418 418 port->ops->dtr_rts(port, 1); 419 419 } 420 420 EXPORT_SYMBOL(tty_port_raise_dtr_rts); ··· 429 429 */ 430 430 void tty_port_lower_dtr_rts(struct tty_port *port) 431 431 { 432 - if (port->ops->dtr_rts) 432 + if (port->ops && port->ops->dtr_rts) 433 433 port->ops->dtr_rts(port, 0); 434 434 } 435 435 EXPORT_SYMBOL(tty_port_lower_dtr_rts); ··· 684 684 685 685 if (!tty_port_initialized(port)) { 686 686 clear_bit(TTY_IO_ERROR, &tty->flags); 687 - if (port->ops->activate) { 687 + if (port->ops && port->ops->activate) { 688 688 int retval = port->ops->activate(port, tty); 689 689 if (retval) { 690 690 mutex_unlock(&port->mutex);