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-4.13-rc2' 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 4.13-rc2. Nothing
huge at all, a revert of a patch that turned out to break things, a
fix up for a new tty ioctl we added in 4.13-rc1 to get the uapi
definition correct, and a few minor serial driver fixes for reported
issues.

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

* tag 'tty-4.13-rc2' of git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/tty:
tty: Fix TIOCGPTPEER ioctl definition
tty: hide unused pty_get_peer function
tty: serial: lpuart: Fix the logic for detecting the 32-bit type UART
serial: imx: Prevent TX buffer PIO write when a DMA has been started
Revert "serial: imx-serial - move DMA buffer configuration to DT"
serial: sh-sci: Uninitialized variables in sysfs files
serial: st-asc: Potential error pointer dereference

+83 -84
-2
Documentation/devicetree/bindings/serial/fsl-imx-uart.txt
··· 9 9 - fsl,irda-mode : Indicate the uart supports irda mode 10 10 - fsl,dte-mode : Indicate the uart works in DTE mode. The uart works 11 11 in DCE mode by default. 12 - - fsl,dma-size : Indicate the size of the DMA buffer and its periods 13 12 14 13 Please check Documentation/devicetree/bindings/serial/serial.txt 15 14 for the complete list of generic properties. ··· 28 29 interrupts = <31>; 29 30 uart-has-rtscts; 30 31 fsl,dte-mode; 31 - fsl,dma-size = <1024 4>; 32 32 };
+1 -1
arch/alpha/include/uapi/asm/ioctls.h
··· 100 100 #define TIOCGPKT _IOR('T', 0x38, int) /* Get packet mode state */ 101 101 #define TIOCGPTLCK _IOR('T', 0x39, int) /* Get Pty lock state */ 102 102 #define TIOCGEXCL _IOR('T', 0x40, int) /* Get exclusive mode state */ 103 - #define TIOCGPTPEER _IOR('T', 0x41, int) /* Safely open the slave */ 103 + #define TIOCGPTPEER _IO('T', 0x41) /* Safely open the slave */ 104 104 105 105 #define TIOCSERCONFIG 0x5453 106 106 #define TIOCSERGWILD 0x5454
+1 -1
arch/mips/include/uapi/asm/ioctls.h
··· 91 91 #define TIOCGPKT _IOR('T', 0x38, int) /* Get packet mode state */ 92 92 #define TIOCGPTLCK _IOR('T', 0x39, int) /* Get Pty lock state */ 93 93 #define TIOCGEXCL _IOR('T', 0x40, int) /* Get exclusive mode state */ 94 - #define TIOCGPTPEER _IOR('T', 0x41, int) /* Safely open the slave */ 94 + #define TIOCGPTPEER _IO('T', 0x41) /* Safely open the slave */ 95 95 96 96 /* I hope the range from 0x5480 on is free ... */ 97 97 #define TIOCSCTTY 0x5480 /* become controlling tty */
+1 -1
arch/parisc/include/uapi/asm/ioctls.h
··· 60 60 #define TIOCGPKT _IOR('T', 0x38, int) /* Get packet mode state */ 61 61 #define TIOCGPTLCK _IOR('T', 0x39, int) /* Get Pty lock state */ 62 62 #define TIOCGEXCL _IOR('T', 0x40, int) /* Get exclusive mode state */ 63 - #define TIOCGPTPEER _IOR('T', 0x41, int) /* Safely open the slave */ 63 + #define TIOCGPTPEER _IO('T', 0x41) /* Safely open the slave */ 64 64 65 65 #define FIONCLEX 0x5450 /* these numbers need to be adjusted. */ 66 66 #define FIOCLEX 0x5451
+1 -1
arch/powerpc/include/uapi/asm/ioctls.h
··· 100 100 #define TIOCGPKT _IOR('T', 0x38, int) /* Get packet mode state */ 101 101 #define TIOCGPTLCK _IOR('T', 0x39, int) /* Get Pty lock state */ 102 102 #define TIOCGEXCL _IOR('T', 0x40, int) /* Get exclusive mode state */ 103 - #define TIOCGPTPEER _IOR('T', 0x41, int) /* Safely open the slave */ 103 + #define TIOCGPTPEER _IO('T', 0x41) /* Safely open the slave */ 104 104 105 105 #define TIOCSERCONFIG 0x5453 106 106 #define TIOCSERGWILD 0x5454
+1 -1
arch/sh/include/uapi/asm/ioctls.h
··· 93 93 #define TIOCGPKT _IOR('T', 0x38, int) /* Get packet mode state */ 94 94 #define TIOCGPTLCK _IOR('T', 0x39, int) /* Get Pty lock state */ 95 95 #define TIOCGEXCL _IOR('T', 0x40, int) /* Get exclusive mode state */ 96 - #define TIOCGPTPEER _IOR('T', 0x41, int) /* Safely open the slave */ 96 + #define TIOCGPTPEER _IO('T', 0x41) /* Safely open the slave */ 97 97 98 98 #define TIOCSERCONFIG _IO('T', 83) /* 0x5453 */ 99 99 #define TIOCSERGWILD _IOR('T', 84, int) /* 0x5454 */
+1 -1
arch/sparc/include/uapi/asm/ioctls.h
··· 88 88 #define TIOCGPTN _IOR('t', 134, unsigned int) /* Get Pty Number */ 89 89 #define TIOCSPTLCK _IOW('t', 135, int) /* Lock/unlock PTY */ 90 90 #define TIOCSIG _IOW('t', 136, int) /* Generate signal on Pty slave */ 91 - #define TIOCGPTPEER _IOR('t', 137, int) /* Safely open the slave */ 91 + #define TIOCGPTPEER _IO('t', 137) /* Safely open the slave */ 92 92 93 93 /* Little f */ 94 94 #define FIOCLEX _IO('f', 1)
+1 -1
arch/xtensa/include/uapi/asm/ioctls.h
··· 105 105 #define TIOCGPKT _IOR('T', 0x38, int) /* Get packet mode state */ 106 106 #define TIOCGPTLCK _IOR('T', 0x39, int) /* Get Pty lock state */ 107 107 #define TIOCGEXCL _IOR('T', 0x40, int) /* Get exclusive mode state */ 108 - #define TIOCGPTPEER _IOR('T', 0x41, int) /* Safely open the slave */ 108 + #define TIOCGPTPEER _IO('T', 0x41) /* Safely open the slave */ 109 109 110 110 #define TIOCSERCONFIG _IO('T', 83) 111 111 #define TIOCSERGWILD _IOR('T', 84, int)
+42 -43
drivers/tty/pty.c
··· 448 448 return retval; 449 449 } 450 450 451 - /** 452 - * pty_open_peer - open the peer of a pty 453 - * @tty: the peer of the pty being opened 454 - * 455 - * Open the cached dentry in tty->link, providing a safe way for userspace 456 - * to get the slave end of a pty (where they have the master fd and cannot 457 - * access or trust the mount namespace /dev/pts was mounted inside). 458 - */ 459 - static struct file *pty_open_peer(struct tty_struct *tty, int flags) 460 - { 461 - if (tty->driver->subtype != PTY_TYPE_MASTER) 462 - return ERR_PTR(-EIO); 463 - return dentry_open(tty->link->driver_data, flags, current_cred()); 464 - } 465 - 466 - static int pty_get_peer(struct tty_struct *tty, int flags) 467 - { 468 - int fd = -1; 469 - struct file *filp = NULL; 470 - int retval = -EINVAL; 471 - 472 - fd = get_unused_fd_flags(0); 473 - if (fd < 0) { 474 - retval = fd; 475 - goto err; 476 - } 477 - 478 - filp = pty_open_peer(tty, flags); 479 - if (IS_ERR(filp)) { 480 - retval = PTR_ERR(filp); 481 - goto err_put; 482 - } 483 - 484 - fd_install(fd, filp); 485 - return fd; 486 - 487 - err_put: 488 - put_unused_fd(fd); 489 - err: 490 - return retval; 491 - } 492 - 493 451 static void pty_cleanup(struct tty_struct *tty) 494 452 { 495 453 tty_port_put(tty->port); ··· 604 646 605 647 /* Unix98 devices */ 606 648 #ifdef CONFIG_UNIX98_PTYS 607 - 608 649 static struct cdev ptmx_cdev; 650 + 651 + /** 652 + * pty_open_peer - open the peer of a pty 653 + * @tty: the peer of the pty being opened 654 + * 655 + * Open the cached dentry in tty->link, providing a safe way for userspace 656 + * to get the slave end of a pty (where they have the master fd and cannot 657 + * access or trust the mount namespace /dev/pts was mounted inside). 658 + */ 659 + static struct file *pty_open_peer(struct tty_struct *tty, int flags) 660 + { 661 + if (tty->driver->subtype != PTY_TYPE_MASTER) 662 + return ERR_PTR(-EIO); 663 + return dentry_open(tty->link->driver_data, flags, current_cred()); 664 + } 665 + 666 + static int pty_get_peer(struct tty_struct *tty, int flags) 667 + { 668 + int fd = -1; 669 + struct file *filp = NULL; 670 + int retval = -EINVAL; 671 + 672 + fd = get_unused_fd_flags(0); 673 + if (fd < 0) { 674 + retval = fd; 675 + goto err; 676 + } 677 + 678 + filp = pty_open_peer(tty, flags); 679 + if (IS_ERR(filp)) { 680 + retval = PTR_ERR(filp); 681 + goto err_put; 682 + } 683 + 684 + fd_install(fd, filp); 685 + return fd; 686 + 687 + err_put: 688 + put_unused_fd(fd); 689 + err: 690 + return retval; 691 + } 609 692 610 693 static int pty_unix98_ioctl(struct tty_struct *tty, 611 694 unsigned int cmd, unsigned long arg)
+15 -9
drivers/tty/serial/fsl_lpuart.c
··· 619 619 TIOCSER_TEMT : 0; 620 620 } 621 621 622 + static bool lpuart_is_32(struct lpuart_port *sport) 623 + { 624 + return sport->port.iotype == UPIO_MEM32 || 625 + sport->port.iotype == UPIO_MEM32BE; 626 + } 627 + 622 628 static irqreturn_t lpuart_txint(int irq, void *dev_id) 623 629 { 624 630 struct lpuart_port *sport = dev_id; ··· 633 627 634 628 spin_lock_irqsave(&sport->port.lock, flags); 635 629 if (sport->port.x_char) { 636 - if (sport->port.iotype & (UPIO_MEM32 | UPIO_MEM32BE)) 630 + if (lpuart_is_32(sport)) 637 631 lpuart32_write(&sport->port, sport->port.x_char, UARTDATA); 638 632 else 639 633 writeb(sport->port.x_char, sport->port.membase + UARTDR); ··· 641 635 } 642 636 643 637 if (uart_circ_empty(xmit) || uart_tx_stopped(&sport->port)) { 644 - if (sport->port.iotype & (UPIO_MEM32 | UPIO_MEM32BE)) 638 + if (lpuart_is_32(sport)) 645 639 lpuart32_stop_tx(&sport->port); 646 640 else 647 641 lpuart_stop_tx(&sport->port); 648 642 goto out; 649 643 } 650 644 651 - if (sport->port.iotype & (UPIO_MEM32 | UPIO_MEM32BE)) 645 + if (lpuart_is_32(sport)) 652 646 lpuart32_transmit_buffer(sport); 653 647 else 654 648 lpuart_transmit_buffer(sport); ··· 1984 1978 if (options) 1985 1979 uart_parse_options(options, &baud, &parity, &bits, &flow); 1986 1980 else 1987 - if (sport->port.iotype & (UPIO_MEM32 | UPIO_MEM32BE)) 1981 + if (lpuart_is_32(sport)) 1988 1982 lpuart32_console_get_options(sport, &baud, &parity, &bits); 1989 1983 else 1990 1984 lpuart_console_get_options(sport, &baud, &parity, &bits); 1991 1985 1992 - if (sport->port.iotype & (UPIO_MEM32 | UPIO_MEM32BE)) 1986 + if (lpuart_is_32(sport)) 1993 1987 lpuart32_setup_watermark(sport); 1994 1988 else 1995 1989 lpuart_setup_watermark(sport); ··· 2124 2118 } 2125 2119 sport->port.irq = ret; 2126 2120 sport->port.iotype = sdata->iotype; 2127 - if (sport->port.iotype & (UPIO_MEM32 | UPIO_MEM32BE)) 2121 + if (lpuart_is_32(sport)) 2128 2122 sport->port.ops = &lpuart32_pops; 2129 2123 else 2130 2124 sport->port.ops = &lpuart_pops; ··· 2151 2145 2152 2146 platform_set_drvdata(pdev, &sport->port); 2153 2147 2154 - if (sport->port.iotype & (UPIO_MEM32 | UPIO_MEM32BE)) 2148 + if (lpuart_is_32(sport)) 2155 2149 lpuart_reg.cons = LPUART32_CONSOLE; 2156 2150 else 2157 2151 lpuart_reg.cons = LPUART_CONSOLE; ··· 2204 2198 struct lpuart_port *sport = dev_get_drvdata(dev); 2205 2199 unsigned long temp; 2206 2200 2207 - if (sport->port.iotype & (UPIO_MEM32 | UPIO_MEM32BE)) { 2201 + if (lpuart_is_32(sport)) { 2208 2202 /* disable Rx/Tx and interrupts */ 2209 2203 temp = lpuart32_read(&sport->port, UARTCTRL); 2210 2204 temp &= ~(UARTCTRL_TE | UARTCTRL_TIE | UARTCTRL_TCIE); ··· 2255 2249 if (sport->port.suspended && !sport->port.irq_wake) 2256 2250 clk_prepare_enable(sport->clk); 2257 2251 2258 - if (sport->port.iotype & (UPIO_MEM32 | UPIO_MEM32BE)) { 2252 + if (lpuart_is_32(sport)) { 2259 2253 lpuart32_setup_watermark(sport); 2260 2254 temp = lpuart32_read(&sport->port, UARTCTRL); 2261 2255 temp |= (UARTCTRL_RIE | UARTCTRL_TIE | UARTCTRL_RE |
+9 -18
drivers/tty/serial/imx.c
··· 186 186 187 187 #define UART_NR 8 188 188 189 - /* RX DMA buffer periods */ 190 - #define RX_DMA_PERIODS 4 191 - #define RX_BUF_SIZE (PAGE_SIZE) 192 - 193 - 194 189 /* i.MX21 type uart runs on all i.mx except i.MX1 and i.MX6q */ 195 190 enum imx_uart_type { 196 191 IMX1_UART, ··· 221 226 struct dma_chan *dma_chan_rx, *dma_chan_tx; 222 227 struct scatterlist rx_sgl, tx_sgl[2]; 223 228 void *rx_buf; 224 - unsigned int rx_buf_size; 225 229 struct circ_buf rx_ring; 226 230 unsigned int rx_periods; 227 231 dma_cookie_t rx_cookie; ··· 458 464 } 459 465 } 460 466 461 - while (!uart_circ_empty(xmit) && 467 + while (!uart_circ_empty(xmit) && !sport->dma_is_txing && 462 468 !(readl(sport->port.membase + uts_reg(sport)) & UTS_TXFULL)) { 463 469 /* send xmit->buf[xmit->tail] 464 470 * out the port here */ ··· 961 967 } 962 968 } 963 969 970 + #define RX_BUF_SIZE (PAGE_SIZE) 971 + 964 972 /* 965 973 * There are two kinds of RX DMA interrupts(such as in the MX6Q): 966 974 * [1] the RX DMA buffer is full. ··· 1045 1049 } 1046 1050 } 1047 1051 1052 + /* RX DMA buffer periods */ 1053 + #define RX_DMA_PERIODS 4 1054 + 1048 1055 static int start_rx_dma(struct imx_port *sport) 1049 1056 { 1050 1057 struct scatterlist *sgl = &sport->rx_sgl; ··· 1058 1059 1059 1060 sport->rx_ring.head = 0; 1060 1061 sport->rx_ring.tail = 0; 1062 + sport->rx_periods = RX_DMA_PERIODS; 1061 1063 1062 - sg_init_one(sgl, sport->rx_buf, sport->rx_buf_size); 1064 + sg_init_one(sgl, sport->rx_buf, RX_BUF_SIZE); 1063 1065 ret = dma_map_sg(dev, sgl, 1, DMA_FROM_DEVICE); 1064 1066 if (ret == 0) { 1065 1067 dev_err(dev, "DMA mapping error for RX.\n"); ··· 1171 1171 goto err; 1172 1172 } 1173 1173 1174 - sport->rx_buf = kzalloc(sport->rx_buf_size, GFP_KERNEL); 1174 + sport->rx_buf = kzalloc(PAGE_SIZE, GFP_KERNEL); 1175 1175 if (!sport->rx_buf) { 1176 1176 ret = -ENOMEM; 1177 1177 goto err; ··· 2036 2036 { 2037 2037 struct device_node *np = pdev->dev.of_node; 2038 2038 int ret; 2039 - u32 dma_buf_size[2]; 2040 2039 2041 2040 sport->devdata = of_device_get_match_data(&pdev->dev); 2042 2041 if (!sport->devdata) ··· 2058 2059 2059 2060 if (of_get_property(np, "rts-gpios", NULL)) 2060 2061 sport->have_rtsgpio = 1; 2061 - 2062 - if (!of_property_read_u32_array(np, "fsl,dma-size", dma_buf_size, 2)) { 2063 - sport->rx_buf_size = dma_buf_size[0] * dma_buf_size[1]; 2064 - sport->rx_periods = dma_buf_size[1]; 2065 - } else { 2066 - sport->rx_buf_size = RX_BUF_SIZE; 2067 - sport->rx_periods = RX_DMA_PERIODS; 2068 - } 2069 2062 2070 2063 return 0; 2071 2064 }
+8 -4
drivers/tty/serial/sh-sci.c
··· 1085 1085 { 1086 1086 struct uart_port *port = dev_get_drvdata(dev); 1087 1087 struct sci_port *sci = to_sci_port(port); 1088 + int ret; 1088 1089 long r; 1089 1090 1090 - if (kstrtol(buf, 0, &r) == -EINVAL) 1091 - return -EINVAL; 1091 + ret = kstrtol(buf, 0, &r); 1092 + if (ret) 1093 + return ret; 1092 1094 1093 1095 sci->rx_trigger = scif_set_rtrg(port, r); 1094 1096 if (port->type == PORT_SCIFA || port->type == PORT_SCIFB) ··· 1118 1116 { 1119 1117 struct uart_port *port = dev_get_drvdata(dev); 1120 1118 struct sci_port *sci = to_sci_port(port); 1119 + int ret; 1121 1120 long r; 1122 1121 1123 - if (kstrtol(buf, 0, &r) == -EINVAL) 1124 - return -EINVAL; 1122 + ret = kstrtol(buf, 0, &r); 1123 + if (ret) 1124 + return ret; 1125 1125 sci->rx_fifo_timeout = r; 1126 1126 scif_set_rtrg(port, 1); 1127 1127 if (r > 0)
+1
drivers/tty/serial/st-asc.c
··· 758 758 if (IS_ERR(ascport->pinctrl)) { 759 759 ret = PTR_ERR(ascport->pinctrl); 760 760 dev_err(&pdev->dev, "Failed to get Pinctrl: %d\n", ret); 761 + return ret; 761 762 } 762 763 763 764 ascport->states[DEFAULT] =
+1 -1
include/uapi/asm-generic/ioctls.h
··· 77 77 #define TIOCGPKT _IOR('T', 0x38, int) /* Get packet mode state */ 78 78 #define TIOCGPTLCK _IOR('T', 0x39, int) /* Get Pty lock state */ 79 79 #define TIOCGEXCL _IOR('T', 0x40, int) /* Get exclusive mode state */ 80 - #define TIOCGPTPEER _IOR('T', 0x41, int) /* Safely open the slave */ 80 + #define TIOCGPTPEER _IO('T', 0x41) /* Safely open the slave */ 81 81 82 82 #define FIONCLEX 0x5450 83 83 #define FIOCLEX 0x5451