aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@linux-foundation.org>2017-07-22 12:00:24 -0400
committerLinus Torvalds <torvalds@linux-foundation.org>2017-07-22 12:00:24 -0400
commitae75d1aefe04c30de9b344abc69939cf7b537ac6 (patch)
treec4309b781624ae92cc17e043ed1c1b93215231db
parentdedaff2f6d0dd1e88022da6aaa3dbc97f7b5cf8b (diff)
parentc6325179238f1d4683edbec53d8322575d76d7e2 (diff)
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
-rw-r--r--Documentation/devicetree/bindings/serial/fsl-imx-uart.txt2
-rw-r--r--arch/alpha/include/uapi/asm/ioctls.h2
-rw-r--r--arch/mips/include/uapi/asm/ioctls.h2
-rw-r--r--arch/parisc/include/uapi/asm/ioctls.h2
-rw-r--r--arch/powerpc/include/uapi/asm/ioctls.h2
-rw-r--r--arch/sh/include/uapi/asm/ioctls.h2
-rw-r--r--arch/sparc/include/uapi/asm/ioctls.h2
-rw-r--r--arch/xtensa/include/uapi/asm/ioctls.h2
-rw-r--r--drivers/tty/pty.c85
-rw-r--r--drivers/tty/serial/fsl_lpuart.c24
-rw-r--r--drivers/tty/serial/imx.c27
-rw-r--r--drivers/tty/serial/sh-sci.c12
-rw-r--r--drivers/tty/serial/st-asc.c1
-rw-r--r--include/uapi/asm-generic/ioctls.h2
14 files changed, 83 insertions, 84 deletions
diff --git a/Documentation/devicetree/bindings/serial/fsl-imx-uart.txt b/Documentation/devicetree/bindings/serial/fsl-imx-uart.txt
index e6b572409cf5..574c3a2c77d5 100644
--- a/Documentation/devicetree/bindings/serial/fsl-imx-uart.txt
+++ b/Documentation/devicetree/bindings/serial/fsl-imx-uart.txt
@@ -9,7 +9,6 @@ Optional properties:
9- fsl,irda-mode : Indicate the uart supports irda mode 9- fsl,irda-mode : Indicate the uart supports irda mode
10- fsl,dte-mode : Indicate the uart works in DTE mode. The uart works 10- fsl,dte-mode : Indicate the uart works in DTE mode. The uart works
11 in DCE mode by default. 11 in DCE mode by default.
12- fsl,dma-size : Indicate the size of the DMA buffer and its periods
13 12
14Please check Documentation/devicetree/bindings/serial/serial.txt 13Please check Documentation/devicetree/bindings/serial/serial.txt
15for the complete list of generic properties. 14for the complete list of generic properties.
@@ -29,5 +28,4 @@ uart1: serial@73fbc000 {
29 interrupts = <31>; 28 interrupts = <31>;
30 uart-has-rtscts; 29 uart-has-rtscts;
31 fsl,dte-mode; 30 fsl,dte-mode;
32 fsl,dma-size = <1024 4>;
33}; 31};
diff --git a/arch/alpha/include/uapi/asm/ioctls.h b/arch/alpha/include/uapi/asm/ioctls.h
index ff67b8373bf7..1cd7dc7d4870 100644
--- a/arch/alpha/include/uapi/asm/ioctls.h
+++ b/arch/alpha/include/uapi/asm/ioctls.h
@@ -100,7 +100,7 @@
100#define TIOCGPKT _IOR('T', 0x38, int) /* Get packet mode state */ 100#define TIOCGPKT _IOR('T', 0x38, int) /* Get packet mode state */
101#define TIOCGPTLCK _IOR('T', 0x39, int) /* Get Pty lock state */ 101#define TIOCGPTLCK _IOR('T', 0x39, int) /* Get Pty lock state */
102#define TIOCGEXCL _IOR('T', 0x40, int) /* Get exclusive mode state */ 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#define TIOCSERCONFIG 0x5453 105#define TIOCSERCONFIG 0x5453
106#define TIOCSERGWILD 0x5454 106#define TIOCSERGWILD 0x5454
diff --git a/arch/mips/include/uapi/asm/ioctls.h b/arch/mips/include/uapi/asm/ioctls.h
index 68e19b689a00..1609cb0907ac 100644
--- a/arch/mips/include/uapi/asm/ioctls.h
+++ b/arch/mips/include/uapi/asm/ioctls.h
@@ -91,7 +91,7 @@
91#define TIOCGPKT _IOR('T', 0x38, int) /* Get packet mode state */ 91#define TIOCGPKT _IOR('T', 0x38, int) /* Get packet mode state */
92#define TIOCGPTLCK _IOR('T', 0x39, int) /* Get Pty lock state */ 92#define TIOCGPTLCK _IOR('T', 0x39, int) /* Get Pty lock state */
93#define TIOCGEXCL _IOR('T', 0x40, int) /* Get exclusive mode state */ 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/* I hope the range from 0x5480 on is free ... */ 96/* I hope the range from 0x5480 on is free ... */
97#define TIOCSCTTY 0x5480 /* become controlling tty */ 97#define TIOCSCTTY 0x5480 /* become controlling tty */
diff --git a/arch/parisc/include/uapi/asm/ioctls.h b/arch/parisc/include/uapi/asm/ioctls.h
index 674c68a5bbd0..d0e3321403be 100644
--- a/arch/parisc/include/uapi/asm/ioctls.h
+++ b/arch/parisc/include/uapi/asm/ioctls.h
@@ -60,7 +60,7 @@
60#define TIOCGPKT _IOR('T', 0x38, int) /* Get packet mode state */ 60#define TIOCGPKT _IOR('T', 0x38, int) /* Get packet mode state */
61#define TIOCGPTLCK _IOR('T', 0x39, int) /* Get Pty lock state */ 61#define TIOCGPTLCK _IOR('T', 0x39, int) /* Get Pty lock state */
62#define TIOCGEXCL _IOR('T', 0x40, int) /* Get exclusive mode state */ 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#define FIONCLEX 0x5450 /* these numbers need to be adjusted. */ 65#define FIONCLEX 0x5450 /* these numbers need to be adjusted. */
66#define FIOCLEX 0x5451 66#define FIOCLEX 0x5451
diff --git a/arch/powerpc/include/uapi/asm/ioctls.h b/arch/powerpc/include/uapi/asm/ioctls.h
index bfd609a3e928..e3b10469f787 100644
--- a/arch/powerpc/include/uapi/asm/ioctls.h
+++ b/arch/powerpc/include/uapi/asm/ioctls.h
@@ -100,7 +100,7 @@
100#define TIOCGPKT _IOR('T', 0x38, int) /* Get packet mode state */ 100#define TIOCGPKT _IOR('T', 0x38, int) /* Get packet mode state */
101#define TIOCGPTLCK _IOR('T', 0x39, int) /* Get Pty lock state */ 101#define TIOCGPTLCK _IOR('T', 0x39, int) /* Get Pty lock state */
102#define TIOCGEXCL _IOR('T', 0x40, int) /* Get exclusive mode state */ 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#define TIOCSERCONFIG 0x5453 105#define TIOCSERCONFIG 0x5453
106#define TIOCSERGWILD 0x5454 106#define TIOCSERGWILD 0x5454
diff --git a/arch/sh/include/uapi/asm/ioctls.h b/arch/sh/include/uapi/asm/ioctls.h
index eec7901e9e65..787bac9f67da 100644
--- a/arch/sh/include/uapi/asm/ioctls.h
+++ b/arch/sh/include/uapi/asm/ioctls.h
@@ -93,7 +93,7 @@
93#define TIOCGPKT _IOR('T', 0x38, int) /* Get packet mode state */ 93#define TIOCGPKT _IOR('T', 0x38, int) /* Get packet mode state */
94#define TIOCGPTLCK _IOR('T', 0x39, int) /* Get Pty lock state */ 94#define TIOCGPTLCK _IOR('T', 0x39, int) /* Get Pty lock state */
95#define TIOCGEXCL _IOR('T', 0x40, int) /* Get exclusive mode state */ 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#define TIOCSERCONFIG _IO('T', 83) /* 0x5453 */ 98#define TIOCSERCONFIG _IO('T', 83) /* 0x5453 */
99#define TIOCSERGWILD _IOR('T', 84, int) /* 0x5454 */ 99#define TIOCSERGWILD _IOR('T', 84, int) /* 0x5454 */
diff --git a/arch/sparc/include/uapi/asm/ioctls.h b/arch/sparc/include/uapi/asm/ioctls.h
index 6d27398632ea..f5df72b93bb2 100644
--- a/arch/sparc/include/uapi/asm/ioctls.h
+++ b/arch/sparc/include/uapi/asm/ioctls.h
@@ -88,7 +88,7 @@
88#define TIOCGPTN _IOR('t', 134, unsigned int) /* Get Pty Number */ 88#define TIOCGPTN _IOR('t', 134, unsigned int) /* Get Pty Number */
89#define TIOCSPTLCK _IOW('t', 135, int) /* Lock/unlock PTY */ 89#define TIOCSPTLCK _IOW('t', 135, int) /* Lock/unlock PTY */
90#define TIOCSIG _IOW('t', 136, int) /* Generate signal on Pty slave */ 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/* Little f */ 93/* Little f */
94#define FIOCLEX _IO('f', 1) 94#define FIOCLEX _IO('f', 1)
diff --git a/arch/xtensa/include/uapi/asm/ioctls.h b/arch/xtensa/include/uapi/asm/ioctls.h
index 98b004e24e85..47d82c09be7b 100644
--- a/arch/xtensa/include/uapi/asm/ioctls.h
+++ b/arch/xtensa/include/uapi/asm/ioctls.h
@@ -105,7 +105,7 @@
105#define TIOCGPKT _IOR('T', 0x38, int) /* Get packet mode state */ 105#define TIOCGPKT _IOR('T', 0x38, int) /* Get packet mode state */
106#define TIOCGPTLCK _IOR('T', 0x39, int) /* Get Pty lock state */ 106#define TIOCGPTLCK _IOR('T', 0x39, int) /* Get Pty lock state */
107#define TIOCGEXCL _IOR('T', 0x40, int) /* Get exclusive mode state */ 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#define TIOCSERCONFIG _IO('T', 83) 110#define TIOCSERCONFIG _IO('T', 83)
111#define TIOCSERGWILD _IOR('T', 84, int) 111#define TIOCSERGWILD _IOR('T', 84, int)
diff --git a/drivers/tty/pty.c b/drivers/tty/pty.c
index d1399aac05a1..284749fb0f6b 100644
--- a/drivers/tty/pty.c
+++ b/drivers/tty/pty.c
@@ -448,48 +448,6 @@ err:
448 return retval; 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 */
459static 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
466static 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
487err_put:
488 put_unused_fd(fd);
489err:
490 return retval;
491}
492
493static void pty_cleanup(struct tty_struct *tty) 451static void pty_cleanup(struct tty_struct *tty)
494{ 452{
495 tty_port_put(tty->port); 453 tty_port_put(tty->port);
@@ -646,9 +604,50 @@ static inline void legacy_pty_init(void) { }
646 604
647/* Unix98 devices */ 605/* Unix98 devices */
648#ifdef CONFIG_UNIX98_PTYS 606#ifdef CONFIG_UNIX98_PTYS
649
650static struct cdev ptmx_cdev; 607static struct cdev ptmx_cdev;
651 608
609/**
610 * pty_open_peer - open the peer of a pty
611 * @tty: the peer of the pty being opened
612 *
613 * Open the cached dentry in tty->link, providing a safe way for userspace
614 * to get the slave end of a pty (where they have the master fd and cannot
615 * access or trust the mount namespace /dev/pts was mounted inside).
616 */
617static struct file *pty_open_peer(struct tty_struct *tty, int flags)
618{
619 if (tty->driver->subtype != PTY_TYPE_MASTER)
620 return ERR_PTR(-EIO);
621 return dentry_open(tty->link->driver_data, flags, current_cred());
622}
623
624static int pty_get_peer(struct tty_struct *tty, int flags)
625{
626 int fd = -1;
627 struct file *filp = NULL;
628 int retval = -EINVAL;
629
630 fd = get_unused_fd_flags(0);
631 if (fd < 0) {
632 retval = fd;
633 goto err;
634 }
635
636 filp = pty_open_peer(tty, flags);
637 if (IS_ERR(filp)) {
638 retval = PTR_ERR(filp);
639 goto err_put;
640 }
641
642 fd_install(fd, filp);
643 return fd;
644
645err_put:
646 put_unused_fd(fd);
647err:
648 return retval;
649}
650
652static int pty_unix98_ioctl(struct tty_struct *tty, 651static int pty_unix98_ioctl(struct tty_struct *tty,
653 unsigned int cmd, unsigned long arg) 652 unsigned int cmd, unsigned long arg)
654{ 653{
diff --git a/drivers/tty/serial/fsl_lpuart.c b/drivers/tty/serial/fsl_lpuart.c
index 343de8c384b0..898dcb091a27 100644
--- a/drivers/tty/serial/fsl_lpuart.c
+++ b/drivers/tty/serial/fsl_lpuart.c
@@ -619,6 +619,12 @@ static unsigned int lpuart32_tx_empty(struct uart_port *port)
619 TIOCSER_TEMT : 0; 619 TIOCSER_TEMT : 0;
620} 620}
621 621
622static bool lpuart_is_32(struct lpuart_port *sport)
623{
624 return sport->port.iotype == UPIO_MEM32 ||
625 sport->port.iotype == UPIO_MEM32BE;
626}
627
622static irqreturn_t lpuart_txint(int irq, void *dev_id) 628static irqreturn_t lpuart_txint(int irq, void *dev_id)
623{ 629{
624 struct lpuart_port *sport = dev_id; 630 struct lpuart_port *sport = dev_id;
@@ -627,7 +633,7 @@ static irqreturn_t lpuart_txint(int irq, void *dev_id)
627 633
628 spin_lock_irqsave(&sport->port.lock, flags); 634 spin_lock_irqsave(&sport->port.lock, flags);
629 if (sport->port.x_char) { 635 if (sport->port.x_char) {
630 if (sport->port.iotype & (UPIO_MEM32 | UPIO_MEM32BE)) 636 if (lpuart_is_32(sport))
631 lpuart32_write(&sport->port, sport->port.x_char, UARTDATA); 637 lpuart32_write(&sport->port, sport->port.x_char, UARTDATA);
632 else 638 else
633 writeb(sport->port.x_char, sport->port.membase + UARTDR); 639 writeb(sport->port.x_char, sport->port.membase + UARTDR);
@@ -635,14 +641,14 @@ static irqreturn_t lpuart_txint(int irq, void *dev_id)
635 } 641 }
636 642
637 if (uart_circ_empty(xmit) || uart_tx_stopped(&sport->port)) { 643 if (uart_circ_empty(xmit) || uart_tx_stopped(&sport->port)) {
638 if (sport->port.iotype & (UPIO_MEM32 | UPIO_MEM32BE)) 644 if (lpuart_is_32(sport))
639 lpuart32_stop_tx(&sport->port); 645 lpuart32_stop_tx(&sport->port);
640 else 646 else
641 lpuart_stop_tx(&sport->port); 647 lpuart_stop_tx(&sport->port);
642 goto out; 648 goto out;
643 } 649 }
644 650
645 if (sport->port.iotype & (UPIO_MEM32 | UPIO_MEM32BE)) 651 if (lpuart_is_32(sport))
646 lpuart32_transmit_buffer(sport); 652 lpuart32_transmit_buffer(sport);
647 else 653 else
648 lpuart_transmit_buffer(sport); 654 lpuart_transmit_buffer(sport);
@@ -1978,12 +1984,12 @@ static int __init lpuart_console_setup(struct console *co, char *options)
1978 if (options) 1984 if (options)
1979 uart_parse_options(options, &baud, &parity, &bits, &flow); 1985 uart_parse_options(options, &baud, &parity, &bits, &flow);
1980 else 1986 else
1981 if (sport->port.iotype & (UPIO_MEM32 | UPIO_MEM32BE)) 1987 if (lpuart_is_32(sport))
1982 lpuart32_console_get_options(sport, &baud, &parity, &bits); 1988 lpuart32_console_get_options(sport, &baud, &parity, &bits);
1983 else 1989 else
1984 lpuart_console_get_options(sport, &baud, &parity, &bits); 1990 lpuart_console_get_options(sport, &baud, &parity, &bits);
1985 1991
1986 if (sport->port.iotype & (UPIO_MEM32 | UPIO_MEM32BE)) 1992 if (lpuart_is_32(sport))
1987 lpuart32_setup_watermark(sport); 1993 lpuart32_setup_watermark(sport);
1988 else 1994 else
1989 lpuart_setup_watermark(sport); 1995 lpuart_setup_watermark(sport);
@@ -2118,7 +2124,7 @@ static int lpuart_probe(struct platform_device *pdev)
2118 } 2124 }
2119 sport->port.irq = ret; 2125 sport->port.irq = ret;
2120 sport->port.iotype = sdata->iotype; 2126 sport->port.iotype = sdata->iotype;
2121 if (sport->port.iotype & (UPIO_MEM32 | UPIO_MEM32BE)) 2127 if (lpuart_is_32(sport))
2122 sport->port.ops = &lpuart32_pops; 2128 sport->port.ops = &lpuart32_pops;
2123 else 2129 else
2124 sport->port.ops = &lpuart_pops; 2130 sport->port.ops = &lpuart_pops;
@@ -2145,7 +2151,7 @@ static int lpuart_probe(struct platform_device *pdev)
2145 2151
2146 platform_set_drvdata(pdev, &sport->port); 2152 platform_set_drvdata(pdev, &sport->port);
2147 2153
2148 if (sport->port.iotype & (UPIO_MEM32 | UPIO_MEM32BE)) 2154 if (lpuart_is_32(sport))
2149 lpuart_reg.cons = LPUART32_CONSOLE; 2155 lpuart_reg.cons = LPUART32_CONSOLE;
2150 else 2156 else
2151 lpuart_reg.cons = LPUART_CONSOLE; 2157 lpuart_reg.cons = LPUART_CONSOLE;
@@ -2198,7 +2204,7 @@ static int lpuart_suspend(struct device *dev)
2198 struct lpuart_port *sport = dev_get_drvdata(dev); 2204 struct lpuart_port *sport = dev_get_drvdata(dev);
2199 unsigned long temp; 2205 unsigned long temp;
2200 2206
2201 if (sport->port.iotype & (UPIO_MEM32 | UPIO_MEM32BE)) { 2207 if (lpuart_is_32(sport)) {
2202 /* disable Rx/Tx and interrupts */ 2208 /* disable Rx/Tx and interrupts */
2203 temp = lpuart32_read(&sport->port, UARTCTRL); 2209 temp = lpuart32_read(&sport->port, UARTCTRL);
2204 temp &= ~(UARTCTRL_TE | UARTCTRL_TIE | UARTCTRL_TCIE); 2210 temp &= ~(UARTCTRL_TE | UARTCTRL_TIE | UARTCTRL_TCIE);
@@ -2249,7 +2255,7 @@ static int lpuart_resume(struct device *dev)
2249 if (sport->port.suspended && !sport->port.irq_wake) 2255 if (sport->port.suspended && !sport->port.irq_wake)
2250 clk_prepare_enable(sport->clk); 2256 clk_prepare_enable(sport->clk);
2251 2257
2252 if (sport->port.iotype & (UPIO_MEM32 | UPIO_MEM32BE)) { 2258 if (lpuart_is_32(sport)) {
2253 lpuart32_setup_watermark(sport); 2259 lpuart32_setup_watermark(sport);
2254 temp = lpuart32_read(&sport->port, UARTCTRL); 2260 temp = lpuart32_read(&sport->port, UARTCTRL);
2255 temp |= (UARTCTRL_RIE | UARTCTRL_TIE | UARTCTRL_RE | 2261 temp |= (UARTCTRL_RIE | UARTCTRL_TIE | UARTCTRL_RE |
diff --git a/drivers/tty/serial/imx.c b/drivers/tty/serial/imx.c
index 9e3162bf3bd1..80934e7bd67f 100644
--- a/drivers/tty/serial/imx.c
+++ b/drivers/tty/serial/imx.c
@@ -186,11 +186,6 @@
186 186
187#define UART_NR 8 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/* i.MX21 type uart runs on all i.mx except i.MX1 and i.MX6q */ 189/* i.MX21 type uart runs on all i.mx except i.MX1 and i.MX6q */
195enum imx_uart_type { 190enum imx_uart_type {
196 IMX1_UART, 191 IMX1_UART,
@@ -226,7 +221,6 @@ struct imx_port {
226 struct dma_chan *dma_chan_rx, *dma_chan_tx; 221 struct dma_chan *dma_chan_rx, *dma_chan_tx;
227 struct scatterlist rx_sgl, tx_sgl[2]; 222 struct scatterlist rx_sgl, tx_sgl[2];
228 void *rx_buf; 223 void *rx_buf;
229 unsigned int rx_buf_size;
230 struct circ_buf rx_ring; 224 struct circ_buf rx_ring;
231 unsigned int rx_periods; 225 unsigned int rx_periods;
232 dma_cookie_t rx_cookie; 226 dma_cookie_t rx_cookie;
@@ -464,7 +458,7 @@ static inline void imx_transmit_buffer(struct imx_port *sport)
464 } 458 }
465 } 459 }
466 460
467 while (!uart_circ_empty(xmit) && 461 while (!uart_circ_empty(xmit) && !sport->dma_is_txing &&
468 !(readl(sport->port.membase + uts_reg(sport)) & UTS_TXFULL)) { 462 !(readl(sport->port.membase + uts_reg(sport)) & UTS_TXFULL)) {
469 /* send xmit->buf[xmit->tail] 463 /* send xmit->buf[xmit->tail]
470 * out the port here */ 464 * out the port here */
@@ -967,6 +961,8 @@ static void imx_timeout(unsigned long data)
967 } 961 }
968} 962}
969 963
964#define RX_BUF_SIZE (PAGE_SIZE)
965
970/* 966/*
971 * There are two kinds of RX DMA interrupts(such as in the MX6Q): 967 * There are two kinds of RX DMA interrupts(such as in the MX6Q):
972 * [1] the RX DMA buffer is full. 968 * [1] the RX DMA buffer is full.
@@ -1049,6 +1045,9 @@ static void dma_rx_callback(void *data)
1049 } 1045 }
1050} 1046}
1051 1047
1048/* RX DMA buffer periods */
1049#define RX_DMA_PERIODS 4
1050
1052static int start_rx_dma(struct imx_port *sport) 1051static int start_rx_dma(struct imx_port *sport)
1053{ 1052{
1054 struct scatterlist *sgl = &sport->rx_sgl; 1053 struct scatterlist *sgl = &sport->rx_sgl;
@@ -1059,8 +1058,9 @@ static int start_rx_dma(struct imx_port *sport)
1059 1058
1060 sport->rx_ring.head = 0; 1059 sport->rx_ring.head = 0;
1061 sport->rx_ring.tail = 0; 1060 sport->rx_ring.tail = 0;
1061 sport->rx_periods = RX_DMA_PERIODS;
1062 1062
1063 sg_init_one(sgl, sport->rx_buf, sport->rx_buf_size); 1063 sg_init_one(sgl, sport->rx_buf, RX_BUF_SIZE);
1064 ret = dma_map_sg(dev, sgl, 1, DMA_FROM_DEVICE); 1064 ret = dma_map_sg(dev, sgl, 1, DMA_FROM_DEVICE);
1065 if (ret == 0) { 1065 if (ret == 0) {
1066 dev_err(dev, "DMA mapping error for RX.\n"); 1066 dev_err(dev, "DMA mapping error for RX.\n");
@@ -1171,7 +1171,7 @@ static int imx_uart_dma_init(struct imx_port *sport)
1171 goto err; 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 if (!sport->rx_buf) { 1175 if (!sport->rx_buf) {
1176 ret = -ENOMEM; 1176 ret = -ENOMEM;
1177 goto err; 1177 goto err;
@@ -2036,7 +2036,6 @@ static int serial_imx_probe_dt(struct imx_port *sport,
2036{ 2036{
2037 struct device_node *np = pdev->dev.of_node; 2037 struct device_node *np = pdev->dev.of_node;
2038 int ret; 2038 int ret;
2039 u32 dma_buf_size[2];
2040 2039
2041 sport->devdata = of_device_get_match_data(&pdev->dev); 2040 sport->devdata = of_device_get_match_data(&pdev->dev);
2042 if (!sport->devdata) 2041 if (!sport->devdata)
@@ -2060,14 +2059,6 @@ static int serial_imx_probe_dt(struct imx_port *sport,
2060 if (of_get_property(np, "rts-gpios", NULL)) 2059 if (of_get_property(np, "rts-gpios", NULL))
2061 sport->have_rtsgpio = 1; 2060 sport->have_rtsgpio = 1;
2062 2061
2063 if (!of_property_read_u32_array(np, "fsl,dma-size", dma_buf_size, 2)) {
2064 sport->rx_buf_size = dma_buf_size[0] * dma_buf_size[1];
2065 sport->rx_periods = dma_buf_size[1];
2066 } else {
2067 sport->rx_buf_size = RX_BUF_SIZE;
2068 sport->rx_periods = RX_DMA_PERIODS;
2069 }
2070
2071 return 0; 2062 return 0;
2072} 2063}
2073#else 2064#else
diff --git a/drivers/tty/serial/sh-sci.c b/drivers/tty/serial/sh-sci.c
index da5ddfc14778..e08b16b070c0 100644
--- a/drivers/tty/serial/sh-sci.c
+++ b/drivers/tty/serial/sh-sci.c
@@ -1085,10 +1085,12 @@ static ssize_t rx_trigger_store(struct device *dev,
1085{ 1085{
1086 struct uart_port *port = dev_get_drvdata(dev); 1086 struct uart_port *port = dev_get_drvdata(dev);
1087 struct sci_port *sci = to_sci_port(port); 1087 struct sci_port *sci = to_sci_port(port);
1088 int ret;
1088 long r; 1089 long r;
1089 1090
1090 if (kstrtol(buf, 0, &r) == -EINVAL) 1091 ret = kstrtol(buf, 0, &r);
1091 return -EINVAL; 1092 if (ret)
1093 return ret;
1092 1094
1093 sci->rx_trigger = scif_set_rtrg(port, r); 1095 sci->rx_trigger = scif_set_rtrg(port, r);
1094 if (port->type == PORT_SCIFA || port->type == PORT_SCIFB) 1096 if (port->type == PORT_SCIFA || port->type == PORT_SCIFB)
@@ -1116,10 +1118,12 @@ static ssize_t rx_fifo_timeout_store(struct device *dev,
1116{ 1118{
1117 struct uart_port *port = dev_get_drvdata(dev); 1119 struct uart_port *port = dev_get_drvdata(dev);
1118 struct sci_port *sci = to_sci_port(port); 1120 struct sci_port *sci = to_sci_port(port);
1121 int ret;
1119 long r; 1122 long r;
1120 1123
1121 if (kstrtol(buf, 0, &r) == -EINVAL) 1124 ret = kstrtol(buf, 0, &r);
1122 return -EINVAL; 1125 if (ret)
1126 return ret;
1123 sci->rx_fifo_timeout = r; 1127 sci->rx_fifo_timeout = r;
1124 scif_set_rtrg(port, 1); 1128 scif_set_rtrg(port, 1);
1125 if (r > 0) 1129 if (r > 0)
diff --git a/drivers/tty/serial/st-asc.c b/drivers/tty/serial/st-asc.c
index f5335be344f6..6b0ca65027d0 100644
--- a/drivers/tty/serial/st-asc.c
+++ b/drivers/tty/serial/st-asc.c
@@ -758,6 +758,7 @@ static int asc_init_port(struct asc_port *ascport,
758 if (IS_ERR(ascport->pinctrl)) { 758 if (IS_ERR(ascport->pinctrl)) {
759 ret = PTR_ERR(ascport->pinctrl); 759 ret = PTR_ERR(ascport->pinctrl);
760 dev_err(&pdev->dev, "Failed to get Pinctrl: %d\n", ret); 760 dev_err(&pdev->dev, "Failed to get Pinctrl: %d\n", ret);
761 return ret;
761 } 762 }
762 763
763 ascport->states[DEFAULT] = 764 ascport->states[DEFAULT] =
diff --git a/include/uapi/asm-generic/ioctls.h b/include/uapi/asm-generic/ioctls.h
index 06d5f7ddf84e..14baf9f23a14 100644
--- a/include/uapi/asm-generic/ioctls.h
+++ b/include/uapi/asm-generic/ioctls.h
@@ -77,7 +77,7 @@
77#define TIOCGPKT _IOR('T', 0x38, int) /* Get packet mode state */ 77#define TIOCGPKT _IOR('T', 0x38, int) /* Get packet mode state */
78#define TIOCGPTLCK _IOR('T', 0x39, int) /* Get Pty lock state */ 78#define TIOCGPTLCK _IOR('T', 0x39, int) /* Get Pty lock state */
79#define TIOCGEXCL _IOR('T', 0x40, int) /* Get exclusive mode state */ 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#define FIONCLEX 0x5450 82#define FIONCLEX 0x5450
83#define FIOCLEX 0x5451 83#define FIOCLEX 0x5451