History

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

Pull tty / serial updates from Greg KH: "Here is the big set of tty/serial driver updates for 6.4-rc1. Nothing major, just lots of tiny, constant, forward development. This includes: - obligatory n_gsm updates and feature additions - 8250_em driver updates - sh-sci driver updates - dts cleanups and updates - general cleanups and improvements by Ilpo and Jiri - other small serial driver core fixes and driver updates All of these have been in linux-next for a while with no reported problems" * tag 'tty-6.4-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/tty: (87 commits) n_gsm: Use array_index_nospec() with index that comes from userspace tty: vt: drop checks for undefined VT_SINGLE_DRIVER tty: vt: distribute EXPORT_SYMBOL() tty: vt: simplify some cases in tioclinux() tty: vt: reformat tioclinux() tty: serial: sh-sci: Fix end of transmission on SCI tty: serial: sh-sci: Add support for tx end interrupt handling tty: serial: sh-sci: Fix TE setting on SCI IP tty: serial: sh-sci: Add RZ/G2L SCIFA DMA rx support tty: serial: sh-sci: Add RZ/G2L SCIFA DMA tx support serial: max310x: fix IO data corruption in batched operations serial: core: Disable uart_start() on uart_remove_one_port() serial: 8250: Reinit port->pm on port specific driver unbind serial: 8250: Add missing wakeup event reporting tty: serial: fsl_lpuart: use UARTMODIR register bits for lpuart32 platform tty: serial: fsl_lpuart: adjust buffer length to the intended size serial: fix TIOCSRS485 locking serial: make SiFive serial drivers depend on ARCH_ symbols tty: synclink_gt: don't allocate and pass dummy flags tty: serial: simplify qcom_geni_serial_send_chunk_fifo() ...

Linus Torvalds committed 3 years ago

Commit b39667a2 parents 4010e62 2b3174c57 files · +949 −476Browse files

Unified · Split

57 files
  1. Documentation/admin-guide/serial-console.rst +33 −3
  2. Documentation/devicetree/bindings/serial/amlogic,meson-uart.yaml +11 −2
  3. Documentation/devicetree/bindings/serial/fsl-imx-uart.yaml +27 −0
  4. Documentation/devicetree/bindings/serial/fsl-lpuart.yaml +3 −0
  5. Documentation/devicetree/bindings/serial/qcom,serial-geni-qcom.yaml +2 −2
  6. Documentation/devicetree/bindings/serial/renesas,em-uart.yaml +2 −2
  7. Documentation/devicetree/bindings/serial/renesas,hscif.yaml +2 −2
  8. Documentation/devicetree/bindings/serial/renesas,sci.yaml +2 −2
  9. Documentation/devicetree/bindings/serial/renesas,scif.yaml +2 −2
  10. Documentation/devicetree/bindings/serial/renesas,scifa.yaml +2 −2
  11. Documentation/devicetree/bindings/serial/renesas,scifb.yaml +2 −2
  12. Documentation/devicetree/bindings/serial/serial.yaml +2 −2
  13. Documentation/devicetree/bindings/serial/snps-dw-apb-uart.yaml +2 −2
  14. Documentation/devicetree/bindings/serial/sprd-uart.yaml +2 −2
  15. Documentation/devicetree/bindings/serial/sunplus,sp7021-uart.yaml +2 −2
  16. Documentation/driver-api/tty/n_gsm.rst +20 −0
  17. arch/arm64/boot/dts/amlogic/meson-g12-common.dtsi +10 −5
  18. drivers/char/pcmcia/synclink_cs.c +3 −3
  19. drivers/mmc/core/sdio_uart.c +5 −5
  20. drivers/tty/Kconfig +1 −1
  21. drivers/tty/amiserial.c +3 −3
  22. drivers/tty/mxser.c +3 −3
  23. drivers/tty/n_gsm.c +222 −9
  24. drivers/tty/n_tty.c +21 −22
  25. drivers/tty/serial/8250/8250.h +12 −0
  26. drivers/tty/serial/8250/8250_bcm7271.c +12 −6
  27. drivers/tty/serial/8250/8250_core.c +1 −0
  28. drivers/tty/serial/8250/8250_em.c +90 −23
  29. drivers/tty/serial/8250/8250_port.c +8 −3
  30. drivers/tty/serial/Kconfig +2 −9
  31. drivers/tty/serial/bcm63xx_uart.c +38 −0
  32. drivers/tty/serial/cpm_uart/cpm_uart_core.c +2 −3
  33. drivers/tty/serial/fsl_lpuart.c +5 −5
  34. drivers/tty/serial/imx.c +12 −36
  35. drivers/tty/serial/max310x.c +15 −2
  36. drivers/tty/serial/meson_uart.c +6 −2
  37. drivers/tty/serial/mxs-auart.c +2 −2
  38. drivers/tty/serial/qcom_geni_serial.c +5 −6
  39. drivers/tty/serial/sb1250-duart.c +1 −1
  40. drivers/tty/serial/serial_core.c +64 −61
  41. drivers/tty/serial/sh-sci.c +90 −25
  42. drivers/tty/serial/sh-sci.h +3 −0
  43. drivers/tty/serial/sprd_serial.c +1 −1
  44. drivers/tty/serial/stm32-usart.c +3 −3
  45. drivers/tty/serial/stm32-usart.h +0 −1
  46. drivers/tty/serial/sunzilog.c +2 −2
  47. drivers/tty/serial/ucc_uart.c +3 −4
  48. drivers/tty/synclink_gt.c +8 −16
  49. drivers/tty/tty.h +2 −0
  50. drivers/tty/tty_io.c +3 −21
  51. drivers/tty/tty_ioctl.c +38 −16
  52. drivers/tty/tty_ldisc.c +1 −2
  53. drivers/tty/vt/vt.c +92 −113
  54. include/linux/serial_8250.h +20 −25
  55. include/linux/serial_core.h +7 −8
  56. include/linux/tty.h +1 −1
  57. include/uapi/linux/gsmmux.h +16 −1
Documentation/admin-guide/serial-console.rst+33−3
@@ -33,8 +33,11 @@ The format of this option is:: · 32 unmodified lines
3333 9600n8. The maximum baudrate is 115200.
3434
3535 You can specify multiple console= options on the kernel command line.
36−Output will appear on all of them. The last device will be used when
37−you open ``/dev/console``. So, for example::
36+
37+The behavior is well defined when each device type is mentioned only once.
38+In this case, the output will appear on all requested consoles. And
39+the last device will be used when you open ``/dev/console``.
40+So, for example::
3841
3942 console=ttyS1,9600 console=tty0
4043
@@ -42,7 +45,34 @@ defines that opening ``/dev/console`` will get you the current foreground · 1 unmodified line
4245 virtual console, and kernel messages will appear on both the VGA
4346 console and the 2nd serial port (ttyS1 or COM2) at 9600 baud.
4447
45−Note that you can only define one console per device type (serial, video).
48+The behavior is more complicated when the same device type is defined more
49+times. In this case, there are the following two rules:
50+
51+1. The output will appear only on the first device of each defined type.
52+
53+2. ``/dev/console`` will be associated with the first registered device.
54+ Where the registration order depends on how kernel initializes various
55+ subsystems.
56+
57+ This rule is used also when the last console= parameter is not used
58+ for other reasons. For example, because of a typo or because
59+ the hardware is not available.
60+
61+The result might be surprising. For example, the following two command
62+lines have the same result:
63+
64+ console=ttyS1,9600 console=tty0 console=tty1
65+ console=tty0 console=ttyS1,9600 console=tty1
66+
67+The kernel messages are printed only on ``tty0`` and ``ttyS1``. And
68+``/dev/console`` gets associated with ``tty0``. It is because kernel
69+tries to register graphical consoles before serial ones. It does it
70+because of the default behavior when no console device is specified,
71+see below.
72+
73+Note that the last ``console=tty1`` parameter still makes a difference.
74+The kernel command line is used also by systemd. It would use the last
75+defined ``tty1`` as the login console.
4676
4777 If no console device is specified, the first device found capable of
4878 acting as a system console will be used. At this time, the system
Documentation/devicetree/bindings/serial/amlogic,meson-uart.yaml+11−2
@@ -2,8 +2,8 @@ · 1 unmodified line
22 # Copyright 2019 BayLibre, SAS
33 %YAML 1.2
44 ---
5−$id: "http://devicetree.org/schemas/serial/amlogic,meson-uart.yaml#"
6−$schema: "http://devicetree.org/meta-schemas/core.yaml#"
5+$id: http://devicetree.org/schemas/serial/amlogic,meson-uart.yaml#
6+$schema: http://devicetree.org/meta-schemas/core.yaml#
77
88 title: Amlogic Meson SoC UART Serial Interface
99
@@ -34,6 +34,11 @@ properties: · 24 unmodified lines
3434 - amlogic,meson-gx-uart
3535 - amlogic,meson-s4-uart
3636 - const: amlogic,meson-ao-uart
37+ - description: Always-on power domain UART controller on G12A SoCs
38+ items:
39+ - const: amlogic,meson-g12a-uart
40+ - const: amlogic,meson-gx-uart
41+ - const: amlogic,meson-ao-uart
3742 - description: Everything-Else power domain UART controller
3843 enum:
3944 - amlogic,meson6-uart
@@ -41,6 +46,10 @@ properties: · 1 unmodified line
4146 - amlogic,meson8b-uart
4247 - amlogic,meson-gx-uart
4348 - amlogic,meson-s4-uart
49+ - description: Everything-Else power domain UART controller on G12A SoCs
50+ items:
51+ - const: amlogic,meson-g12a-uart
52+ - const: amlogic,meson-gx-uart
4453
4554 reg:
4655 maxItems: 1
Documentation/devicetree/bindings/serial/fsl-imx-uart.yaml+27−0
@@ -49,6 +49,24 @@ properties: · 48 unmodified lines
4949 reg:
5050 maxItems: 1
5151
52+ clocks:
53+ maxItems: 2
54+
55+ clock-names:
56+ items:
57+ - const: ipg
58+ - const: per
59+
60+ dmas:
61+ items:
62+ - description: DMA controller phandle and request line for RX
63+ - description: DMA controller phandle and request line for TX
64+
65+ dma-names:
66+ items:
67+ - const: rx
68+ - const: tx
69+
5270 interrupts:
5371 maxItems: 1
5472
@@ -86,12 +104,16 @@ properties: · 31 unmodified lines
86104 required:
87105 - compatible
88106 - reg
107+ - clocks
108+ - clock-names
89109 - interrupts
90110
91111 unevaluatedProperties: false
92112
93113 examples:
94114 - |
115+ #include <dt-bindings/clock/imx5-clock.h>
116+
95117 aliases {
96118 serial0 = &uart1;
97119 };
@@ -100,6 +122,11 @@ examples: · 2 unmodified lines
100122 compatible = "fsl,imx51-uart", "fsl,imx21-uart";
101123 reg = <0x73fbc000 0x4000>;
102124 interrupts = <31>;
125+ clocks = <&clks IMX5_CLK_UART1_IPG_GATE>,
126+ <&clks IMX5_CLK_UART1_PER_GATE>;
127+ clock-names = "ipg", "per";
128+ dmas = <&sdma 18 4 1>, <&sdma 19 4 2>;
129+ dma-names = "rx", "tx";
103130 uart-has-rtscts;
104131 fsl,dte-mode;
105132 };
Documentation/devicetree/bindings/serial/fsl-lpuart.yaml+3−0
@@ -65,6 +65,9 @@ properties: · 64 unmodified lines
6565 - const: rx
6666 - const: tx
6767
68+ power-domains:
69+ maxItems: 1
70+
6871 required:
6972 - compatible
7073 - reg
Documentation/devicetree/bindings/serial/qcom,serial-geni-qcom.yaml+2−2
@@ -1,8 +1,8 @@
11 # SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause)
22 %YAML 1.2
33 ---
4−$id: "http://devicetree.org/schemas/serial/qcom,serial-geni-qcom.yaml#"
5−$schema: "http://devicetree.org/meta-schemas/core.yaml#"
4+$id: http://devicetree.org/schemas/serial/qcom,serial-geni-qcom.yaml#
5+$schema: http://devicetree.org/meta-schemas/core.yaml#
66
77 title: Qualcomm Geni based QUP UART interface
88
Documentation/devicetree/bindings/serial/renesas,em-uart.yaml+2−2
@@ -1,8 +1,8 @@
11 # SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause)
22 %YAML 1.2
33 ---
4−$id: "http://devicetree.org/schemas/serial/renesas,em-uart.yaml#"
5−$schema: "http://devicetree.org/meta-schemas/core.yaml#"
4+$id: http://devicetree.org/schemas/serial/renesas,em-uart.yaml#
5+$schema: http://devicetree.org/meta-schemas/core.yaml#
66
77 title: Renesas EMMA Mobile UART Interface
88
Documentation/devicetree/bindings/serial/renesas,hscif.yaml+2−2
@@ -1,8 +1,8 @@
11 # SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause)
22 %YAML 1.2
33 ---
4−$id: "http://devicetree.org/schemas/serial/renesas,hscif.yaml#"
5−$schema: "http://devicetree.org/meta-schemas/core.yaml#"
4+$id: http://devicetree.org/schemas/serial/renesas,hscif.yaml#
5+$schema: http://devicetree.org/meta-schemas/core.yaml#
66
77 title: Renesas High Speed Serial Communication Interface with FIFO (HSCIF)
88
Documentation/devicetree/bindings/serial/renesas,sci.yaml+2−2
@@ -1,8 +1,8 @@
11 # SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause)
22 %YAML 1.2
33 ---
4−$id: "http://devicetree.org/schemas/serial/renesas,sci.yaml#"
5−$schema: "http://devicetree.org/meta-schemas/core.yaml#"
4+$id: http://devicetree.org/schemas/serial/renesas,sci.yaml#
5+$schema: http://devicetree.org/meta-schemas/core.yaml#
66
77 title: Renesas Serial Communication Interface
88
Documentation/devicetree/bindings/serial/renesas,scif.yaml+2−2
@@ -1,8 +1,8 @@
11 # SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause)
22 %YAML 1.2
33 ---
4−$id: "http://devicetree.org/schemas/serial/renesas,scif.yaml#"
5−$schema: "http://devicetree.org/meta-schemas/core.yaml#"
4+$id: http://devicetree.org/schemas/serial/renesas,scif.yaml#
5+$schema: http://devicetree.org/meta-schemas/core.yaml#
66
77 title: Renesas Serial Communication Interface with FIFO (SCIF)
88
Documentation/devicetree/bindings/serial/renesas,scifa.yaml+2−2
@@ -1,8 +1,8 @@
11 # SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause)
22 %YAML 1.2
33 ---
4−$id: "http://devicetree.org/schemas/serial/renesas,scifa.yaml#"
5−$schema: "http://devicetree.org/meta-schemas/core.yaml#"
4+$id: http://devicetree.org/schemas/serial/renesas,scifa.yaml#
5+$schema: http://devicetree.org/meta-schemas/core.yaml#
66
77 title: Renesas Serial Communications Interface with FIFO A (SCIFA)
88
Documentation/devicetree/bindings/serial/renesas,scifb.yaml+2−2
@@ -1,8 +1,8 @@
11 # SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause)
22 %YAML 1.2
33 ---
4−$id: "http://devicetree.org/schemas/serial/renesas,scifb.yaml#"
5−$schema: "http://devicetree.org/meta-schemas/core.yaml#"
4+$id: http://devicetree.org/schemas/serial/renesas,scifb.yaml#
5+$schema: http://devicetree.org/meta-schemas/core.yaml#
66
77 title: Renesas Serial Communications Interface with FIFO B (SCIFB)
88
Documentation/devicetree/bindings/serial/serial.yaml+2−2
@@ -1,8 +1,8 @@
11 # SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause)
22 %YAML 1.2
33 ---
4−$id: "http://devicetree.org/schemas/serial/serial.yaml#"
5−$schema: "http://devicetree.org/meta-schemas/core.yaml#"
4+$id: http://devicetree.org/schemas/serial/serial.yaml#
5+$schema: http://devicetree.org/meta-schemas/core.yaml#
66
77 title: Serial Interface Generic
88
Documentation/devicetree/bindings/serial/snps-dw-apb-uart.yaml+2−2
@@ -68,12 +68,12 @@ properties: · 67 unmodified lines
6868 - const: apb_pclk
6969
7070 dmas:
71− minItems: 2
71+ maxItems: 2
7272
7373 dma-names:
7474 items:
75− - const: rx
7675 - const: tx
76+ - const: rx
7777
7878 snps,uart-16550-compatible:
7979 description: reflects the value of UART_16550_COMPATIBLE configuration
Documentation/devicetree/bindings/serial/sprd-uart.yaml+2−2
@@ -2,8 +2,8 @@ · 1 unmodified line
22 # Copyright 2019 Unisoc Inc.
33 %YAML 1.2
44 ---
5−$id: "http://devicetree.org/schemas/serial/sprd-uart.yaml#"
6−$schema: "http://devicetree.org/meta-schemas/core.yaml#"
5+$id: http://devicetree.org/schemas/serial/sprd-uart.yaml#
6+$schema: http://devicetree.org/meta-schemas/core.yaml#
77
88 title: Spreadtrum serial UART
99
Documentation/devicetree/bindings/serial/sunplus,sp7021-uart.yaml+2−2
@@ -2,8 +2,8 @@ · 1 unmodified line
22 # Copyright (C) Sunplus Co., Ltd. 2021
33 %YAML 1.2
44 ---
5−$id: "http://devicetree.org/schemas/serial/sunplus,sp7021-uart.yaml#"
6−$schema: "http://devicetree.org/meta-schemas/core.yaml#"
5+$id: http://devicetree.org/schemas/serial/sunplus,sp7021-uart.yaml#
6+$schema: http://devicetree.org/meta-schemas/core.yaml#
77
88 title: Sunplus SoC SP7021 UART Controller
99
Documentation/driver-api/tty/n_gsm.rst+20−0
@@ -29,6 +29,8 @@ Config Initiator · 28 unmodified lines
2929
3030 #. Configure the mux using ``GSMIOC_GETCONF``/``GSMIOC_SETCONF`` ioctl.
3131
32+#. Configure DLCs using ``GSMIOC_GETCONF_DLCI``/``GSMIOC_SETCONF_DLCI`` ioctl for non-defaults.
33+
3234 #. Obtain base gsmtty number for the used serial port.
3335
3436 Major parts of the initialization program
@@ -45,6 +47,7 @@ Config Initiator · 10 unmodified lines
4547 int ldisc = N_GSM0710;
4648 struct gsm_config c;
4749 struct gsm_config_ext ce;
50+ struct gsm_dlci_config dc;
4851 struct termios configuration;
4952 uint32_t first;
5053
@@ -81,6 +84,13 @@ Config Initiator · 30 unmodified lines
8184 c.mtu = 127;
8285 /* set the new configuration */
8386 ioctl(fd, GSMIOC_SETCONF, &c);
87+ /* get DLC 1 configuration */
88+ dc.channel = 1;
89+ ioctl(fd, GSMIOC_GETCONF_DLCI, &dc);
90+ /* the first user channel gets a higher priority */
91+ dc.priority = 1;
92+ /* set the new DLC 1 specific configuration */
93+ ioctl(fd, GSMIOC_SETCONF_DLCI, &dc);
8494 /* get first gsmtty device node */
8595 ioctl(fd, GSMIOC_GETFIRST, &first);
8696 printf("first muxed line: /dev/gsmtty%i\n", first);
@@ -120,6 +130,8 @@ Config Requester · 33 unmodified lines
120130
121131 #. Configure the mux using ``GSMIOC_GETCONF``/``GSMIOC_SETCONF`` ioctl.
122132
133+#. Configure DLCs using ``GSMIOC_GETCONF_DLCI``/``GSMIOC_SETCONF_DLCI`` ioctl for non-defaults.
134+
123135 #. Obtain base gsmtty number for the used serial port::
124136
125137 #include <stdio.h>
@@ -132,6 +144,7 @@ Config Requester · 6 unmodified lines
132144 int ldisc = N_GSM0710;
133145 struct gsm_config c;
134146 struct gsm_config_ext ce;
147+ struct gsm_dlci_config dc;
135148 struct termios configuration;
136149 uint32_t first;
137150
@@ -161,6 +174,13 @@ Config Requester · 23 unmodified lines
161174 c.mtu = 127;
162175 /* set the new configuration */
163176 ioctl(fd, GSMIOC_SETCONF, &c);
177+ /* get DLC 1 configuration */
178+ dc.channel = 1;
179+ ioctl(fd, GSMIOC_GETCONF_DLCI, &dc);
180+ /* the first user channel gets a higher priority */
181+ dc.priority = 1;
182+ /* set the new DLC 1 specific configuration */
183+ ioctl(fd, GSMIOC_SETCONF_DLCI, &dc);
164184 /* get first gsmtty device node */
165185 ioctl(fd, GSMIOC_GETFIRST, &first);
166186 printf("first muxed line: /dev/gsmtty%i\n", first);
arch/arm64/boot/dts/amlogic/meson-g12-common.dtsi+10−5
@@ -2045,7 +2045,8 @@ · 2044 unmodified lines
20452045 };
20462046
20472047 uart_AO: serial@3000 {
2048− compatible = "amlogic,meson-gx-uart",
2048+ compatible = "amlogic,meson-g12a-uart",
2049+ "amlogic,meson-gx-uart",
20492050 "amlogic,meson-ao-uart";
20502051 reg = <0x0 0x3000 0x0 0x18>;
20512052 interrupts = <GIC_SPI 193 IRQ_TYPE_EDGE_RISING>;
@@ -2055,7 +2056,8 @@ · 3 unmodified lines
20552056 };
20562057
20572058 uart_AO_B: serial@4000 {
2058− compatible = "amlogic,meson-gx-uart",
2059+ compatible = "amlogic,meson-g12a-uart",
2060+ "amlogic,meson-gx-uart",
20592061 "amlogic,meson-ao-uart";
20602062 reg = <0x0 0x4000 0x0 0x18>;
20612063 interrupts = <GIC_SPI 197 IRQ_TYPE_EDGE_RISING>;
@@ -2292,7 +2294,8 @@ · 230 unmodified lines
22922294 };
22932295
22942296 uart_C: serial@22000 {
2295− compatible = "amlogic,meson-gx-uart";
2297+ compatible = "amlogic,meson-g12a-uart",
2298+ "amlogic,meson-gx-uart";
22962299 reg = <0x0 0x22000 0x0 0x18>;
22972300 interrupts = <GIC_SPI 93 IRQ_TYPE_EDGE_RISING>;
22982301 clocks = <&xtal>, <&clkc CLKID_UART2>, <&xtal>;
@@ -2301,7 +2304,8 @@ · 2 unmodified lines
23012304 };
23022305
23032306 uart_B: serial@23000 {
2304− compatible = "amlogic,meson-gx-uart";
2307+ compatible = "amlogic,meson-g12a-uart",
2308+ "amlogic,meson-gx-uart";
23052309 reg = <0x0 0x23000 0x0 0x18>;
23062310 interrupts = <GIC_SPI 75 IRQ_TYPE_EDGE_RISING>;
23072311 clocks = <&xtal>, <&clkc CLKID_UART1>, <&xtal>;
@@ -2310,7 +2314,8 @@ · 2 unmodified lines
23102314 };
23112315
23122316 uart_A: serial@24000 {
2313− compatible = "amlogic,meson-gx-uart";
2317+ compatible = "amlogic,meson-g12a-uart",
2318+ "amlogic,meson-gx-uart";
23142319 reg = <0x0 0x24000 0x0 0x18>;
23152320 interrupts = <GIC_SPI 26 IRQ_TYPE_EDGE_RISING>;
23162321 clocks = <&xtal>, <&clkc CLKID_UART0>, <&xtal>;
drivers/char/pcmcia/synclink_cs.c+3−3
@@ -1060,7 +1060,7 @@ static void cts_change(MGSLPC_INFO *info, struct tty_struct *tty) · 1059 unmodified lines
10601060 if (info->serial_signals & SerialSignal_CTS) {
10611061 if (debug_level >= DEBUG_LEVEL_ISR)
10621062 printk("CTS tx start...");
1063− tty->hw_stopped = 0;
1063+ tty->hw_stopped = false;
10641064 tx_start(info, tty);
10651065 info->pending_bh |= BH_TRANSMIT;
10661066 return;
@@ -1069,7 +1069,7 @@ static void cts_change(MGSLPC_INFO *info, struct tty_struct *tty) · 2 unmodified lines
10691069 if (!(info->serial_signals & SerialSignal_CTS)) {
10701070 if (debug_level >= DEBUG_LEVEL_ISR)
10711071 printk("CTS tx stop...");
1072− tty->hw_stopped = 1;
1072+ tty->hw_stopped = true;
10731073 tx_stop(info);
10741074 }
10751075 }
@@ -2312,7 +2312,7 @@ static void mgslpc_set_termios(struct tty_struct *tty, · 1236 unmodified lines
23122312
23132313 /* Handle turning off CRTSCTS */
23142314 if (old_termios->c_cflag & CRTSCTS && !C_CRTSCTS(tty)) {
2315− tty->hw_stopped = 0;
2315+ tty->hw_stopped = false;
23162316 tx_release(tty);
23172317 }
23182318 }
drivers/mmc/core/sdio_uart.c+5−5
@@ -478,13 +478,13 @@ static void sdio_uart_check_modem_status(struct sdio_uart_port *port) · 477 unmodified lines
478478 int cts = (status & UART_MSR_CTS);
479479 if (tty->hw_stopped) {
480480 if (cts) {
481− tty->hw_stopped = 0;
481+ tty->hw_stopped = false;
482482 sdio_uart_start_tx(port);
483483 tty_wakeup(tty);
484484 }
485485 } else {
486486 if (!cts) {
487− tty->hw_stopped = 1;
487+ tty->hw_stopped = true;
488488 sdio_uart_stop_tx(port);
489489 }
490490 }
@@ -633,7 +633,7 @@ static int sdio_uart_activate(struct tty_port *tport, struct tty_struct *tty) · 142 unmodified lines
633633
634634 if (C_CRTSCTS(tty))
635635 if (!(sdio_uart_get_mctrl(port) & TIOCM_CTS))
636− tty->hw_stopped = 1;
636+ tty->hw_stopped = true;
637637
638638 clear_bit(TTY_IO_ERROR, &tty->flags);
639639
@@ -882,14 +882,14 @@ static void sdio_uart_set_termios(struct tty_struct *tty, · 242 unmodified lines
882882
883883 /* Handle turning off CRTSCTS */
884884 if ((old_termios->c_cflag & CRTSCTS) && !(cflag & CRTSCTS)) {
885− tty->hw_stopped = 0;
885+ tty->hw_stopped = false;
886886 sdio_uart_start_tx(port);
887887 }
888888
889889 /* Handle turning on CRTSCTS */
890890 if (!(old_termios->c_cflag & CRTSCTS) && (cflag & CRTSCTS)) {
891891 if (!(sdio_uart_get_mctrl(port) & TIOCM_CTS)) {
892− tty->hw_stopped = 1;
892+ tty->hw_stopped = true;
893893 sdio_uart_stop_tx(port);
894894 }
895895 }
drivers/tty/Kconfig+1−1
@@ -160,7 +160,7 @@ config LEGACY_TIOCSTI · 159 unmodified lines
160160 a dangerous legacy operation, and can be disabled on most
161161 systems.
162162
163− Say 'Y here only if you have confirmed that your system's
163+ Say Y here only if you have confirmed that your system's
164164 userspace depends on this functionality to continue operating
165165 normally.
166166
drivers/tty/amiserial.c+3−3
@@ -347,7 +347,7 @@ static void check_modem_status(struct serial_state *info) · 346 unmodified lines
347347 #if (defined(SERIAL_DEBUG_INTR) || defined(SERIAL_DEBUG_FLOW))
348348 printk("CTS tx start...");
349349 #endif
350− port->tty->hw_stopped = 0;
350+ port->tty->hw_stopped = false;
351351 info->IER |= UART_IER_THRI;
352352 amiga_custom.intena = IF_SETCLR | IF_TBE;
353353 mb();
@@ -362,7 +362,7 @@ static void check_modem_status(struct serial_state *info) · 8 unmodified lines
362362 #if (defined(SERIAL_DEBUG_INTR) || defined(SERIAL_DEBUG_FLOW))
363363 printk("CTS tx stop...");
364364 #endif
365− port->tty->hw_stopped = 1;
365+ port->tty->hw_stopped = true;
366366 info->IER &= ~UART_IER_THRI;
367367 /* disable Tx interrupt and remove any pending interrupts */
368368 amiga_custom.intena = IF_TBE;
@@ -1197,7 +1197,7 @@ static void rs_set_termios(struct tty_struct *tty, const struct ktermios *old_te · 828 unmodified lines
11971197
11981198 /* Handle turning off CRTSCTS */
11991199 if ((old_termios->c_cflag & CRTSCTS) && !C_CRTSCTS(tty)) {
1200− tty->hw_stopped = 0;
1200+ tty->hw_stopped = false;
12011201 rs_start(tty);
12021202 }
12031203
drivers/tty/mxser.c+3−3
@@ -553,7 +553,7 @@ static void mxser_handle_cts(struct tty_struct *tty, struct mxser_port *info, · 552 unmodified lines
553553
554554 if (tty->hw_stopped) {
555555 if (cts) {
556− tty->hw_stopped = 0;
556+ tty->hw_stopped = false;
557557
558558 if (!mxser_16550A_or_MUST(info))
559559 __mxser_start_tx(info);
@@ -563,7 +563,7 @@ static void mxser_handle_cts(struct tty_struct *tty, struct mxser_port *info, · 3 unmodified lines
563563 } else if (cts)
564564 return;
565565
566− tty->hw_stopped = 1;
566+ tty->hw_stopped = true;
567567 if (!mxser_16550A_or_MUST(info))
568568 __mxser_stop_tx(info);
569569 }
@@ -1361,7 +1361,7 @@ static void mxser_set_termios(struct tty_struct *tty, · 791 unmodified lines
13611361 spin_unlock_irqrestore(&info->slock, flags);
13621362
13631363 if ((old_termios->c_cflag & CRTSCTS) && !C_CRTSCTS(tty)) {
1364− tty->hw_stopped = 0;
1364+ tty->hw_stopped = false;
13651365 mxser_start(tty);
13661366 }
13671367
drivers/tty/n_gsm.c+222−9
@@ -42,6 +42,7 @@ · 41 unmodified lines
4242 #include <linux/ctype.h>
4343 #include <linux/mm.h>
4444 #include <linux/math.h>
45+#include <linux/nospec.h>
4546 #include <linux/string.h>
4647 #include <linux/slab.h>
4748 #include <linux/poll.h>
@@ -128,6 +129,7 @@ struct gsm_msg { · 80 unmodified lines
128129
129130 enum gsm_dlci_state {
130131 DLCI_CLOSED,
132+ DLCI_WAITING_CONFIG, /* Waiting for DLCI configuration from user */
131133 DLCI_CONFIGURE, /* Sending PN (for adaption > 1) */
132134 DLCI_OPENING, /* Sending SABM not seen UA */
133135 DLCI_OPEN, /* SABM/UA complete */
@@ -330,6 +332,7 @@ struct gsm_mux { · 196 unmodified lines
330332 unsigned int t3; /* Power wake-up timer in seconds. */
331333 int n2; /* Retry count */
332334 u8 k; /* Window size */
335+ bool wait_config; /* Wait for configuration by ioctl before DLCI open */
333336 u32 keep_alive; /* Control channel keep-alive in 10ms */
334337
335338 /* Statistics (not currently exposed) */
@@ -451,6 +454,7 @@ static int gsm_modem_update(struct gsm_dlci *dlci, u8 brk); · 115 unmodified lines
451454 static struct gsm_msg *gsm_data_alloc(struct gsm_mux *gsm, u8 addr, int len,
452455 u8 ctrl);
453456 static int gsm_send_packet(struct gsm_mux *gsm, struct gsm_msg *msg);
457+static struct gsm_dlci *gsm_dlci_alloc(struct gsm_mux *gsm, int addr);
454458 static void gsmld_write_trigger(struct gsm_mux *gsm);
455459 static void gsmld_write_task(struct work_struct *work);
456460
@@ -2280,6 +2284,7 @@ static void gsm_dlci_begin_open(struct gsm_dlci *dlci) · 1823 unmodified lines
22802284
22812285 switch (dlci->state) {
22822286 case DLCI_CLOSED:
2287+ case DLCI_WAITING_CONFIG:
22832288 case DLCI_CLOSING:
22842289 dlci->retries = gsm->n2;
22852290 if (!need_pn) {
@@ -2311,6 +2316,7 @@ static void gsm_dlci_set_opening(struct gsm_dlci *dlci) · 25 unmodified lines
23112316 {
23122317 switch (dlci->state) {
23132318 case DLCI_CLOSED:
2319+ case DLCI_WAITING_CONFIG:
23142320 case DLCI_CLOSING:
23152321 dlci->state = DLCI_OPENING;
23162322 break;
@@ -2319,6 +2325,24 @@ static void gsm_dlci_set_opening(struct gsm_dlci *dlci) · 2 unmodified lines
23192325 }
23202326 }
23212327
2328+/**
2329+ * gsm_dlci_set_wait_config - wait for channel configuration
2330+ * @dlci: DLCI to configure
2331+ *
2332+ * Wait for a DLCI configuration from the application.
2333+ */
2334+static void gsm_dlci_set_wait_config(struct gsm_dlci *dlci)
2335+{
2336+ switch (dlci->state) {
2337+ case DLCI_CLOSED:
2338+ case DLCI_CLOSING:
2339+ dlci->state = DLCI_WAITING_CONFIG;
2340+ break;
2341+ default:
2342+ break;
2343+ }
2344+}
2345+
23222346 /**
23232347 * gsm_dlci_begin_close - start channel open procedure
23242348 * @dlci: DLCI to open
@@ -2453,6 +2477,128 @@ static void gsm_kick_timer(struct timer_list *t) · 128 unmodified lines
24532477 pr_info("%s TX queue stalled\n", __func__);
24542478 }
24552479
2480+/**
2481+ * gsm_dlci_copy_config_values - copy DLCI configuration
2482+ * @dlci: source DLCI
2483+ * @dc: configuration structure to fill
2484+ */
2485+static void gsm_dlci_copy_config_values(struct gsm_dlci *dlci, struct gsm_dlci_config *dc)
2486+{
2487+ memset(dc, 0, sizeof(*dc));
2488+ dc->channel = (u32)dlci->addr;
2489+ dc->adaption = (u32)dlci->adaption;
2490+ dc->mtu = (u32)dlci->mtu;
2491+ dc->priority = (u32)dlci->prio;
2492+ if (dlci->ftype == UIH)
2493+ dc->i = 1;
2494+ else
2495+ dc->i = 2;
2496+ dc->k = (u32)dlci->k;
2497+}
2498+
2499+/**
2500+ * gsm_dlci_config - configure DLCI from configuration
2501+ * @dlci: DLCI to configure
2502+ * @dc: DLCI configuration
2503+ * @open: open DLCI after configuration?
2504+ */
2505+static int gsm_dlci_config(struct gsm_dlci *dlci, struct gsm_dlci_config *dc, int open)
2506+{
2507+ struct gsm_mux *gsm;
2508+ bool need_restart = false;
2509+ bool need_open = false;
2510+ unsigned int i;
2511+
2512+ /*
2513+ * Check that userspace doesn't put stuff in here to prevent breakages
2514+ * in the future.
2515+ */
2516+ for (i = 0; i < ARRAY_SIZE(dc->reserved); i++)
2517+ if (dc->reserved[i])
2518+ return -EINVAL;
2519+
2520+ if (!dlci)
2521+ return -EINVAL;
2522+ gsm = dlci->gsm;
2523+
2524+ /* Stuff we don't support yet - I frame transport */
2525+ if (dc->adaption != 1 && dc->adaption != 2)
2526+ return -EOPNOTSUPP;
2527+ if (dc->mtu > MAX_MTU || dc->mtu < MIN_MTU || dc->mtu > gsm->mru)
2528+ return -EINVAL;
2529+ if (dc->priority >= 64)
2530+ return -EINVAL;
2531+ if (dc->i == 0 || dc->i > 2) /* UIH and UI only */
2532+ return -EINVAL;
2533+ if (dc->k > 7)
2534+ return -EINVAL;
2535+
2536+ /*
2537+ * See what is needed for reconfiguration
2538+ */
2539+ /* Framing fields */
2540+ if (dc->adaption != dlci->adaption)
2541+ need_restart = true;
2542+ if (dc->mtu != dlci->mtu)
2543+ need_restart = true;
2544+ if (dc->i != dlci->ftype)
2545+ need_restart = true;
2546+ /* Requires care */
2547+ if (dc->priority != dlci->prio)
2548+ need_restart = true;
2549+
2550+ if ((open && gsm->wait_config) || need_restart)
2551+ need_open = true;
2552+ if (dlci->state == DLCI_WAITING_CONFIG) {
2553+ need_restart = false;
2554+ need_open = true;
2555+ }
2556+
2557+ /*
2558+ * Close down what is needed, restart and initiate the new
2559+ * configuration.
2560+ */
2561+ if (need_restart) {
2562+ gsm_dlci_begin_close(dlci);
2563+ wait_event_interruptible(gsm->event, dlci->state == DLCI_CLOSED);
2564+ if (signal_pending(current))
2565+ return -EINTR;
2566+ }
2567+ /*
2568+ * Setup the new configuration values
2569+ */
2570+ dlci->adaption = (int)dc->adaption;
2571+
2572+ if (dc->mtu)
2573+ dlci->mtu = (unsigned int)dc->mtu;
2574+ else
2575+ dlci->mtu = gsm->mtu;
2576+
2577+ if (dc->priority)
2578+ dlci->prio = (u8)dc->priority;
2579+ else
2580+ dlci->prio = roundup(dlci->addr + 1, 8) - 1;
2581+
2582+ if (dc->i == 1)
2583+ dlci->ftype = UIH;
2584+ else if (dc->i == 2)
2585+ dlci->ftype = UI;
2586+
2587+ if (dc->k)
2588+ dlci->k = (u8)dc->k;
2589+ else
2590+ dlci->k = gsm->k;
2591+
2592+ if (need_open) {
2593+ if (gsm->initiator)
2594+ gsm_dlci_begin_open(dlci);
2595+ else
2596+ gsm_dlci_set_opening(dlci);
2597+ }
2598+
2599+ return 0;
2600+}
2601+
24562602 /*
24572603 * Allocate/Free DLCI channels
24582604 */
@@ -3078,6 +3224,7 @@ static struct gsm_mux *gsm_alloc_mux(void) · 619 unmodified lines
30783224 gsm->mru = 64; /* Default to encoding 1 so these should be 64 */
30793225 gsm->mtu = 64;
30803226 gsm->dead = true; /* Avoid early tty opens */
3227+ gsm->wait_config = false; /* Disabled */
30813228 gsm->keep_alive = 0; /* Disabled */
30823229
30833230 /* Store the instance to the mux array or abort if no space is
@@ -3130,8 +3277,8 @@ static int gsm_config(struct gsm_mux *gsm, struct gsm_config *c) · 46 unmodified lines
31303277 int need_close = 0;
31313278 int need_restart = 0;
31323279
3133− /* Stuff we don't support yet - UI or I frame transport, windowing */
3134− if ((c->adaption != 1 && c->adaption != 2) || c->k)
3280+ /* Stuff we don't support yet - UI or I frame transport */
3281+ if (c->adaption != 1 && c->adaption != 2)
31353282 return -EOPNOTSUPP;
31363283 /* Check the MRU/MTU range looks sane */
31373284 if (c->mru < MIN_MTU || c->mtu < MIN_MTU)
@@ -3218,6 +3365,7 @@ static void gsm_copy_config_ext_values(struct gsm_mux *gsm, · 80 unmodified lines
32183365 struct gsm_config_ext *ce)
32193366 {
32203367 memset(ce, 0, sizeof(*ce));
3368+ ce->wait_config = gsm->wait_config ? 1 : 0;
32213369 ce->keep_alive = gsm->keep_alive;
32223370 }
32233371
@@ -3233,7 +3381,12 @@ static int gsm_config_ext(struct gsm_mux *gsm, struct gsm_config_ext *ce) · 9 unmodified lines
32333381 if (ce->reserved[i])
32343382 return -EINVAL;
32353383
3384+ /*
3385+ * Setup the new configuration values
3386+ */
3387+ gsm->wait_config = ce->wait_config ? true : false;
32363388 gsm->keep_alive = ce->keep_alive;
3389+
32373390 return 0;
32383391 }
32393392
@@ -3433,9 +3586,16 @@ static int gsmld_open(struct tty_struct *tty) · 193 unmodified lines
34333586 tty->receive_room = 65536;
34343587
34353588 /* Attach the initial passive connection */
3436− gsm->encoding = GSM_ADV_OPT;
34373589 gsmld_attach_gsm(tty, gsm);
34383590
3591+ /* The mux will not be activated yet, we wait for correct
3592+ * configuration first.
3593+ */
3594+ if (gsm->encoding == GSM_BASIC_OPT)
3595+ gsm->receive = gsm0_receive;
3596+ else
3597+ gsm->receive = gsm1_receive;
3598+
34393599 return 0;
34403600 }
34413601
@@ -3556,8 +3716,10 @@ static int gsmld_ioctl(struct tty_struct *tty, unsigned int cmd, · 114 unmodified lines
35563716 {
35573717 struct gsm_config c;
35583718 struct gsm_config_ext ce;
3719+ struct gsm_dlci_config dc;
35593720 struct gsm_mux *gsm = tty->disc_data;
3560− unsigned int base;
3721+ unsigned int base, addr;
3722+ struct gsm_dlci *dlci;
35613723
35623724 switch (cmd) {
35633725 case GSMIOC_GETCONF:
@@ -3581,6 +3743,35 @@ static int gsmld_ioctl(struct tty_struct *tty, unsigned int cmd, · 17 unmodified lines
35813743 if (copy_from_user(&ce, (void __user *)arg, sizeof(ce)))
35823744 return -EFAULT;
35833745 return gsm_config_ext(gsm, &ce);
3746+ case GSMIOC_GETCONF_DLCI:
3747+ if (copy_from_user(&dc, (void __user *)arg, sizeof(dc)))
3748+ return -EFAULT;
3749+ if (dc.channel == 0 || dc.channel >= NUM_DLCI)
3750+ return -EINVAL;
3751+ addr = array_index_nospec(dc.channel, NUM_DLCI);
3752+ dlci = gsm->dlci[addr];
3753+ if (!dlci) {
3754+ dlci = gsm_dlci_alloc(gsm, addr);
3755+ if (!dlci)
3756+ return -ENOMEM;
3757+ }
3758+ gsm_dlci_copy_config_values(dlci, &dc);
3759+ if (copy_to_user((void __user *)arg, &dc, sizeof(dc)))
3760+ return -EFAULT;
3761+ return 0;
3762+ case GSMIOC_SETCONF_DLCI:
3763+ if (copy_from_user(&dc, (void __user *)arg, sizeof(dc)))
3764+ return -EFAULT;
3765+ if (dc.channel == 0 || dc.channel >= NUM_DLCI)
3766+ return -EINVAL;
3767+ addr = array_index_nospec(dc.channel, NUM_DLCI);
3768+ dlci = gsm->dlci[addr];
3769+ if (!dlci) {
3770+ dlci = gsm_dlci_alloc(gsm, addr);
3771+ if (!dlci)
3772+ return -ENOMEM;
3773+ }
3774+ return gsm_dlci_config(dlci, &dc, 0);
35843775 default:
35853776 return n_tty_ioctl_helper(tty, cmd, arg);
35863777 }
@@ -4008,7 +4199,6 @@ static int gsmtty_open(struct tty_struct *tty, struct file *filp) · 421 unmodified lines
40084199 {
40094200 struct gsm_dlci *dlci = tty->driver_data;
40104201 struct tty_port *port = &dlci->port;
4011− struct gsm_mux *gsm = dlci->gsm;
40124202
40134203 port->count++;
40144204 tty_port_tty_set(port, tty);
@@ -4018,10 +4208,15 @@ static int gsmtty_open(struct tty_struct *tty, struct file *filp) · 3 unmodified lines
40184208 a DM straight back. This is ok as that will have caused a hangup */
40194209 tty_port_set_initialized(port, true);
40204210 /* Start sending off SABM messages */
4021− if (gsm->initiator)
4022− gsm_dlci_begin_open(dlci);
4023− else
4024− gsm_dlci_set_opening(dlci);
4211+ if (!dlci->gsm->wait_config) {
4212+ /* Start sending off SABM messages */
4213+ if (dlci->gsm->initiator)
4214+ gsm_dlci_begin_open(dlci);
4215+ else
4216+ gsm_dlci_set_opening(dlci);
4217+ } else {
4218+ gsm_dlci_set_wait_config(dlci);
4219+ }
40254220 /* And wait for virtual carrier */
40264221 return tty_port_block_til_ready(port, tty, filp);
40274222 }
@@ -4142,6 +4337,7 @@ static int gsmtty_ioctl(struct tty_struct *tty, · 114 unmodified lines
41424337 {
41434338 struct gsm_dlci *dlci = tty->driver_data;
41444339 struct gsm_netconfig nc;
4340+ struct gsm_dlci_config dc;
41454341 int index;
41464342
41474343 if (dlci->state == DLCI_CLOSED)
@@ -4165,6 +4361,23 @@ static int gsmtty_ioctl(struct tty_struct *tty, · 17 unmodified lines
41654361 gsm_destroy_network(dlci);
41664362 mutex_unlock(&dlci->mutex);
41674363 return 0;
4364+ case GSMIOC_GETCONF_DLCI:
4365+ if (copy_from_user(&dc, (void __user *)arg, sizeof(dc)))
4366+ return -EFAULT;
4367+ if (dc.channel != dlci->addr)
4368+ return -EPERM;
4369+ gsm_dlci_copy_config_values(dlci, &dc);
4370+ if (copy_to_user((void __user *)arg, &dc, sizeof(dc)))
4371+ return -EFAULT;
4372+ return 0;
4373+ case GSMIOC_SETCONF_DLCI:
4374+ if (copy_from_user(&dc, (void __user *)arg, sizeof(dc)))
4375+ return -EFAULT;
4376+ if (dc.channel >= NUM_DLCI)
4377+ return -EINVAL;
4378+ if (dc.channel != 0 && dc.channel != dlci->addr)
4379+ return -EPERM;
4380+ return gsm_dlci_config(dlci, &dc, 1);
41684381 case TIOCMIWAIT:
41694382 return gsm_wait_modem_change(dlci, (u32)arg);
41704383 default:
drivers/tty/n_tty.c+21−22
@@ -28,27 +28,26 @@ · 27 unmodified lines
2828 * EAGAIN
2929 */
3030
31−#include <linux/types.h>
32−#include <linux/major.h>
31+#include <linux/bitmap.h>
32+#include <linux/bitops.h>
33+#include <linux/ctype.h>
3334 #include <linux/errno.h>
34−#include <linux/signal.h>
35+#include <linux/export.h>
3536 #include <linux/fcntl.h>
37+#include <linux/file.h>
38+#include <linux/jiffies.h>
39+#include <linux/math.h>
40+#include <linux/poll.h>
41+#include <linux/ratelimit.h>
3642 #include <linux/sched.h>
37−#include <linux/interrupt.h>
38−#include <linux/tty.h>
39−#include <linux/timer.h>
40−#include <linux/ctype.h>
41−#include <linux/mm.h>
42−#include <linux/string.h>
43+#include <linux/signal.h>
4344 #include <linux/slab.h>
44−#include <linux/poll.h>
45−#include <linux/bitops.h>
46−#include <linux/audit.h>
47−#include <linux/file.h>
45+#include <linux/string.h>
46+#include <linux/tty.h>
47+#include <linux/types.h>
4848 #include <linux/uaccess.h>
49−#include <linux/module.h>
50−#include <linux/ratelimit.h>
5149 #include <linux/vmalloc.h>
50+
5251 #include "tty.h"
5352
5453 /*
@@ -625,7 +624,7 @@ static size_t __process_echoes(struct tty_struct *tty) · 570 unmodified lines
625624 c = echo_buf(ldata, tail);
626625 if (c == ECHO_OP_START) {
627626 unsigned char op;
628− int no_space_left = 0;
627+ bool space_left = true;
629628
630629 /*
631630 * Since add_echo_byte() is called without holding
@@ -664,7 +663,7 @@ static size_t __process_echoes(struct tty_struct *tty) · 32 unmodified lines
664663 num_bs = 8 - (num_chars & 7);
665664
666665 if (num_bs > space) {
667− no_space_left = 1;
666+ space_left = false;
668667 break;
669668 }
670669 space -= num_bs;
@@ -690,7 +689,7 @@ static size_t __process_echoes(struct tty_struct *tty) · 19 unmodified lines
690689 case ECHO_OP_START:
691690 /* This is an escaped echo op start code */
692691 if (!space) {
693− no_space_left = 1;
692+ space_left = false;
694693 break;
695694 }
696695 tty_put_char(tty, ECHO_OP_START);
@@ -710,7 +709,7 @@ static size_t __process_echoes(struct tty_struct *tty) · 13 unmodified lines
710709 *
711710 */
712711 if (space < 2) {
713− no_space_left = 1;
712+ space_left = false;
714713 break;
715714 }
716715 tty_put_char(tty, '^');
@@ -720,7 +719,7 @@ static size_t __process_echoes(struct tty_struct *tty) · 3 unmodified lines
720719 tail += 2;
721720 }
722721
723− if (no_space_left)
722+ if (!space_left)
724723 break;
725724 } else {
726725 if (O_OPOST(tty)) {
@@ -1177,7 +1176,7 @@ static void n_tty_receive_overrun(struct tty_struct *tty) · 450 unmodified lines
11771176
11781177 ldata->num_overrun++;
11791178 if (time_after(jiffies, ldata->overrun_time + HZ) ||
1180− time_after(ldata->overrun_time, jiffies)) {
1179+ time_after(ldata->overrun_time, jiffies)) {
11811180 tty_warn(tty, "%d input overrun(s)\n", ldata->num_overrun);
11821181 ldata->overrun_time = jiffies;
11831182 ldata->num_overrun = 0;
@@ -1691,7 +1690,7 @@ n_tty_receive_buf_common(struct tty_struct *tty, const unsigned char *cp, · 507 unmodified lines
16911690
16921691 room = N_TTY_BUF_SIZE - (ldata->read_head - tail);
16931692 if (I_PARMRK(tty))
1694− room = (room + 2) / 3;
1693+ room = DIV_ROUND_UP(room, 3);
16951694 room--;
16961695 if (room <= 0) {
16971696 overflow = ldata->icanon && ldata->canon_head == tail;
drivers/tty/serial/8250/8250.h+12−0
@@ -365,6 +365,13 @@ static inline void serial8250_do_prepare_rx_dma(struct uart_8250_port *p) · 364 unmodified lines
365365 if (dma->prepare_rx_dma)
366366 dma->prepare_rx_dma(p);
367367 }
368+
369+static inline bool serial8250_tx_dma_running(struct uart_8250_port *p)
370+{
371+ struct uart_8250_dma *dma = p->dma;
372+
373+ return dma && dma->tx_running;
374+}
368375 #else
369376 static inline int serial8250_tx_dma(struct uart_8250_port *p)
370377 {
@@ -380,6 +387,11 @@ static inline int serial8250_request_dma(struct uart_8250_port *p) · 9 unmodified lines
380387 return -1;
381388 }
382389 static inline void serial8250_release_dma(struct uart_8250_port *p) { }
390+
391+static inline bool serial8250_tx_dma_running(struct uart_8250_port *p)
392+{
393+ return false;
394+}
383395 #endif
384396
385397 static inline int ns16550a_goto_highspeed(struct uart_8250_port *up)
drivers/tty/serial/8250/8250_bcm7271.c+12−6
@@ -1014,14 +1014,16 @@ static int brcmuart_probe(struct platform_device *pdev) · 1013 unmodified lines
10141014 /* See if a Baud clock has been specified */
10151015 baud_mux_clk = of_clk_get_by_name(np, "sw_baud");
10161016 if (IS_ERR(baud_mux_clk)) {
1017− if (PTR_ERR(baud_mux_clk) == -EPROBE_DEFER)
1018− return -EPROBE_DEFER;
1017+ if (PTR_ERR(baud_mux_clk) == -EPROBE_DEFER) {
1018+ ret = -EPROBE_DEFER;
1019+ goto release_dma;
1020+ }
10191021 dev_dbg(dev, "BAUD MUX clock not specified\n");
10201022 } else {
10211023 dev_dbg(dev, "BAUD MUX clock found\n");
10221024 ret = clk_prepare_enable(baud_mux_clk);
10231025 if (ret)
1024− return ret;
1026+ goto release_dma;
10251027 priv->baud_mux_clk = baud_mux_clk;
10261028 init_real_clk_rates(dev, priv);
10271029 clk_rate = priv->default_mux_rate;
@@ -1029,7 +1031,8 @@ static int brcmuart_probe(struct platform_device *pdev) · 1 unmodified line
10291031
10301032 if (clk_rate == 0) {
10311033 dev_err(dev, "clock-frequency or clk not defined\n");
1032− return -EINVAL;
1034+ ret = -EINVAL;
1035+ goto release_dma;
10331036 }
10341037
10351038 dev_dbg(dev, "DMA is %senabled\n", priv->dma_enabled ? "" : "not ");
@@ -1116,7 +1119,9 @@ err1: · 80 unmodified lines
11161119 serial8250_unregister_port(priv->line);
11171120 err:
11181121 brcmuart_free_bufs(dev, priv);
1119− brcmuart_arbitration(priv, 0);
1122+release_dma:
1123+ if (priv->dma_enabled)
1124+ brcmuart_arbitration(priv, 0);
11201125 return ret;
11211126 }
11221127
@@ -1128,7 +1133,8 @@ static int brcmuart_remove(struct platform_device *pdev) · 5 unmodified lines
11281133 hrtimer_cancel(&priv->hrt);
11291134 serial8250_unregister_port(priv->line);
11301135 brcmuart_free_bufs(&pdev->dev, priv);
1131− brcmuart_arbitration(priv, 0);
1136+ if (priv->dma_enabled)
1137+ brcmuart_arbitration(priv, 0);
11321138 return 0;
11331139 }
11341140
drivers/tty/serial/8250/8250_core.c+1−0
@@ -1158,6 +1158,7 @@ void serial8250_unregister_port(int line) · 1157 unmodified lines
11581158 uart->port.type = PORT_UNKNOWN;
11591159 uart->port.dev = &serial8250_isa_devs->dev;
11601160 uart->capabilities = 0;
1161+ serial8250_init_port(uart);
11611162 serial8250_apply_quirks(uart);
11621163 uart_add_one_port(&serial8250_reg, &uart->port);
11631164 } else {
drivers/tty/serial/8250/8250_em.c+90−23
@@ -13,36 +13,49 @@ · 12 unmodified lines
1313 #include <linux/serial_reg.h>
1414 #include <linux/platform_device.h>
1515 #include <linux/clk.h>
16−#include <linux/slab.h>
1716
1817 #include "8250.h"
1918
2019 #define UART_DLL_EM 9
2120 #define UART_DLM_EM 10
21+#define UART_HCR0_EM 11
22+
23+/*
24+ * A high value for UART_FCR_EM avoids overlapping with existing UART_*
25+ * register defines. UART_FCR_EM_HW is the real HW register offset.
26+ */
27+#define UART_FCR_EM 0x10003
28+#define UART_FCR_EM_HW 3
29+
30+#define UART_HCR0_EM_SW_RESET BIT(7) /* SW Reset */
2231
2332 struct serial8250_em_priv {
24− struct clk *sclk;
2533 int line;
2634 };
2735
28−static void serial8250_em_serial_out(struct uart_port *p, int offset, int value)
36+static void serial8250_em_serial_out_helper(struct uart_port *p, int offset,
37+ int value)
2938 {
3039 switch (offset) {
3140 case UART_TX: /* TX @ 0x00 */
3241 writeb(value, p->membase);
3342 break;
34− case UART_FCR: /* FCR @ 0x0c (+1) */
3543 case UART_LCR: /* LCR @ 0x10 (+1) */
3644 case UART_MCR: /* MCR @ 0x14 (+1) */
3745 case UART_SCR: /* SCR @ 0x20 (+1) */
3846 writel(value, p->membase + ((offset + 1) << 2));
3947 break;
48+ case UART_FCR_EM:
49+ writel(value, p->membase + (UART_FCR_EM_HW << 2));
50+ break;
4051 case UART_IER: /* IER @ 0x04 */
4152 value &= 0x0f; /* only 4 valid bits - not Xscale */
4253 fallthrough;
4354 case UART_DLL_EM: /* DLL @ 0x24 (+9) */
4455 case UART_DLM_EM: /* DLM @ 0x28 (+9) */
56+ case UART_HCR0_EM: /* HCR0 @ 0x2c */
4557 writel(value, p->membase + (offset << 2));
58+ break;
4659 }
4760 }
4861
@@ -51,20 +64,81 @@ static unsigned int serial8250_em_serial_in(struct uart_port *p, int offset) · 2 unmodified lines
5164 switch (offset) {
5265 case UART_RX: /* RX @ 0x00 */
5366 return readb(p->membase);
67+ case UART_LCR: /* LCR @ 0x10 (+1) */
5468 case UART_MCR: /* MCR @ 0x14 (+1) */
5569 case UART_LSR: /* LSR @ 0x18 (+1) */
5670 case UART_MSR: /* MSR @ 0x1c (+1) */
5771 case UART_SCR: /* SCR @ 0x20 (+1) */
5872 return readl(p->membase + ((offset + 1) << 2));
73+ case UART_FCR_EM:
74+ return readl(p->membase + (UART_FCR_EM_HW << 2));
5975 case UART_IER: /* IER @ 0x04 */
6076 case UART_IIR: /* IIR @ 0x08 */
6177 case UART_DLL_EM: /* DLL @ 0x24 (+9) */
6278 case UART_DLM_EM: /* DLM @ 0x28 (+9) */
79+ case UART_HCR0_EM: /* HCR0 @ 0x2c */
6380 return readl(p->membase + (offset << 2));
6481 }
6582 return 0;
6683 }
6784
85+static void serial8250_em_reg_update(struct uart_port *p, int off, int value)
86+{
87+ unsigned int ier, fcr, lcr, mcr, hcr0;
88+
89+ ier = serial8250_em_serial_in(p, UART_IER);
90+ fcr = serial8250_em_serial_in(p, UART_FCR_EM);
91+ lcr = serial8250_em_serial_in(p, UART_LCR);
92+ mcr = serial8250_em_serial_in(p, UART_MCR);
93+ hcr0 = serial8250_em_serial_in(p, UART_HCR0_EM);
94+
95+ serial8250_em_serial_out_helper(p, UART_FCR_EM, fcr |
96+ UART_FCR_CLEAR_RCVR |
97+ UART_FCR_CLEAR_XMIT);
98+ serial8250_em_serial_out_helper(p, UART_HCR0_EM, hcr0 |
99+ UART_HCR0_EM_SW_RESET);
100+ serial8250_em_serial_out_helper(p, UART_HCR0_EM, hcr0 &
101+ ~UART_HCR0_EM_SW_RESET);
102+
103+ switch (off) {
104+ case UART_FCR_EM:
105+ fcr = value;
106+ break;
107+ case UART_LCR:
108+ lcr = value;
109+ break;
110+ case UART_MCR:
111+ mcr = value;
112+ break;
113+ }
114+
115+ serial8250_em_serial_out_helper(p, UART_IER, ier);
116+ serial8250_em_serial_out_helper(p, UART_FCR_EM, fcr);
117+ serial8250_em_serial_out_helper(p, UART_MCR, mcr);
118+ serial8250_em_serial_out_helper(p, UART_LCR, lcr);
119+ serial8250_em_serial_out_helper(p, UART_HCR0_EM, hcr0);
120+}
121+
122+static void serial8250_em_serial_out(struct uart_port *p, int offset, int value)
123+{
124+ switch (offset) {
125+ case UART_TX:
126+ case UART_SCR:
127+ case UART_IER:
128+ case UART_DLL_EM:
129+ case UART_DLM_EM:
130+ serial8250_em_serial_out_helper(p, offset, value);
131+ break;
132+ case UART_FCR:
133+ serial8250_em_reg_update(p, UART_FCR_EM, value);
134+ break;
135+ case UART_LCR:
136+ case UART_MCR:
137+ serial8250_em_reg_update(p, offset, value);
138+ break;
139+ }
140+}
141+
68142 static int serial8250_em_serial_dl_read(struct uart_8250_port *up)
69143 {
70144 return serial_in(up, UART_DLL_EM) | serial_in(up, UART_DLM_EM) << 8;
@@ -79,8 +153,10 @@ static void serial8250_em_serial_dl_write(struct uart_8250_port *up, int value) · 8 unmodified lines
79153 static int serial8250_em_probe(struct platform_device *pdev)
80154 {
81155 struct serial8250_em_priv *priv;
156+ struct device *dev = &pdev->dev;
82157 struct uart_8250_port up;
83158 struct resource *regs;
159+ struct clk *sclk;
84160 int irq, ret;
85161
86162 irq = platform_get_irq(pdev, 0);
@@ -88,31 +164,26 @@ static int serial8250_em_probe(struct platform_device *pdev) · 1 unmodified line
88164 return irq;
89165
90166 regs = platform_get_resource(pdev, IORESOURCE_MEM, 0);
91− if (!regs) {
92− dev_err(&pdev->dev, "missing registers\n");
93− return -EINVAL;
94− }
167+ if (!regs)
168+ return dev_err_probe(dev, -EINVAL, "missing registers\n");
95169
96− priv = devm_kzalloc(&pdev->dev, sizeof(*priv), GFP_KERNEL);
170+ priv = devm_kzalloc(dev, sizeof(*priv), GFP_KERNEL);
97171 if (!priv)
98172 return -ENOMEM;
99173
100− priv->sclk = devm_clk_get(&pdev->dev, "sclk");
101− if (IS_ERR(priv->sclk)) {
102− dev_err(&pdev->dev, "unable to get clock\n");
103− return PTR_ERR(priv->sclk);
104− }
174+ sclk = devm_clk_get_enabled(dev, "sclk");
175+ if (IS_ERR(sclk))
176+ return dev_err_probe(dev, PTR_ERR(sclk), "unable to get clock\n");
105177
106178 memset(&up, 0, sizeof(up));
107179 up.port.mapbase = regs->start;
108180 up.port.irq = irq;
109181 up.port.type = PORT_16750;
110182 up.port.flags = UPF_FIXED_PORT | UPF_IOREMAP | UPF_FIXED_TYPE;
111− up.port.dev = &pdev->dev;
183+ up.port.dev = dev;
112184 up.port.private_data = priv;
113185
114− clk_prepare_enable(priv->sclk);
115− up.port.uartclk = clk_get_rate(priv->sclk);
186+ up.port.uartclk = clk_get_rate(sclk);
116187
117188 up.port.iotype = UPIO_MEM32;
118189 up.port.serial_in = serial8250_em_serial_in;
@@ -121,11 +192,8 @@ static int serial8250_em_probe(struct platform_device *pdev) · 2 unmodified lines
121192 up.dl_write = serial8250_em_serial_dl_write;
122193
123194 ret = serial8250_register_8250_port(&up);
124− if (ret < 0) {
125− dev_err(&pdev->dev, "unable to register 8250 port\n");
126− clk_disable_unprepare(priv->sclk);
127− return ret;
128− }
195+ if (ret < 0)
196+ return dev_err_probe(dev, ret, "unable to register 8250 port\n");
129197
130198 priv->line = ret;
131199 platform_set_drvdata(pdev, priv);
@@ -137,7 +205,6 @@ static int serial8250_em_remove(struct platform_device *pdev) · 5 unmodified lines
137205 struct serial8250_em_priv *priv = platform_get_drvdata(pdev);
138206
139207 serial8250_unregister_port(priv->line);
140− clk_disable_unprepare(priv->sclk);
141208 return 0;
142209 }
143210
drivers/tty/serial/8250/8250_port.c+8−3
@@ -15,6 +15,7 @@ · 14 unmodified lines
1515 #include <linux/moduleparam.h>
1616 #include <linux/ioport.h>
1717 #include <linux/init.h>
18+#include <linux/irq.h>
1819 #include <linux/console.h>
1920 #include <linux/gpio/consumer.h>
2021 #include <linux/sysrq.h>
@@ -1932,6 +1933,7 @@ static bool handle_rx_dma(struct uart_8250_port *up, unsigned int iir) · 1911 unmodified lines
19321933 int serial8250_handle_irq(struct uart_port *port, unsigned int iir)
19331934 {
19341935 struct uart_8250_port *up = up_to_u8250p(port);
1936+ struct tty_port *tport = &port->state->port;
19351937 bool skip_rx = false;
19361938 unsigned long flags;
19371939 u16 status;
@@ -1957,6 +1959,8 @@ int serial8250_handle_irq(struct uart_port *port, unsigned int iir) · 19 unmodified lines
19571959 skip_rx = true;
19581960
19591961 if (status & (UART_LSR_DR | UART_LSR_BI) && !skip_rx) {
1962+ if (irqd_is_wakeup_set(irq_get_irq_data(port->irq)))
1963+ pm_wakeup_event(tport->tty->dev, 0);
19601964 if (!up->dma || handle_rx_dma(up, iir))
19611965 status = serial8250_rx_chars(up, status);
19621966 }
@@ -2016,18 +2020,19 @@ static int serial8250_tx_threshold_handle_irq(struct uart_port *port) · 53 unmodified lines
20162020 static unsigned int serial8250_tx_empty(struct uart_port *port)
20172021 {
20182022 struct uart_8250_port *up = up_to_u8250p(port);
2023+ unsigned int result = 0;
20192024 unsigned long flags;
2020− u16 lsr;
20212025
20222026 serial8250_rpm_get(up);
20232027
20242028 spin_lock_irqsave(&port->lock, flags);
2025− lsr = serial_lsr_in(up);
2029+ if (!serial8250_tx_dma_running(up) && uart_lsr_tx_empty(serial_lsr_in(up)))
2030+ result = TIOCSER_TEMT;
20262031 spin_unlock_irqrestore(&port->lock, flags);
20272032
20282033 serial8250_rpm_put(up);
20292034
2030− return uart_lsr_tx_empty(lsr) ? TIOCSER_TEMT : 0;
2035+ return result;
20312036 }
20322037
20332038 unsigned int serial8250_do_get_mctrl(struct uart_port *port)
drivers/tty/serial/Kconfig+2−9
@@ -248,13 +248,6 @@ config SERIAL_SAMSUNG · 247 unmodified lines
248248
249249 Choose Y/M here only if you build for such SoC.
250250
251−config SERIAL_SAMSUNG_UARTS_4
252− bool
253− depends on SERIAL_SAMSUNG
254− default y
255− help
256− Internal node for the common case of 4 Samsung compatible UARTs
257−
258251 config SERIAL_SAMSUNG_UARTS
259252 int
260253 depends on SERIAL_SAMSUNG
@@ -958,7 +951,7 @@ config SERIAL_OMAP_CONSOLE · 697 unmodified lines
958951 config SERIAL_SIFIVE
959952 tristate "SiFive UART support"
960953 depends on OF
961− default SOC_SIFIVE || SOC_CANAAN
954+ default ARCH_SIFIVE || ARCH_CANAAN
962955 select SERIAL_CORE
963956 help
964957 Select this option if you are building a kernel for a device that
@@ -968,7 +961,7 @@ config SERIAL_SIFIVE · 3 unmodified lines
968961 config SERIAL_SIFIVE_CONSOLE
969962 bool "Console on SiFive UART"
970963 depends on SERIAL_SIFIVE=y
971− default SOC_SIFIVE || SOC_CANAAN
964+ default ARCH_SIFIVE || ARCH_CANAAN
972965 select SERIAL_CORE_CONSOLE
973966 select SERIAL_EARLYCON
974967 help
drivers/tty/serial/bcm63xx_uart.c+38−0
@@ -596,6 +596,40 @@ static int bcm_uart_verify_port(struct uart_port *port, · 595 unmodified lines
596596 return 0;
597597 }
598598
599+#ifdef CONFIG_CONSOLE_POLL
600+/*
601+ * return true when outstanding tx equals fifo size
602+ */
603+static bool bcm_uart_tx_full(struct uart_port *port)
604+{
605+ unsigned int val;
606+
607+ val = bcm_uart_readl(port, UART_MCTL_REG);
608+ val = (val & UART_MCTL_TXFIFOFILL_MASK) >> UART_MCTL_TXFIFOFILL_SHIFT;
609+ return !(port->fifosize - val);
610+}
611+
612+static int bcm_uart_poll_get_char(struct uart_port *port)
613+{
614+ unsigned int iestat;
615+
616+ iestat = bcm_uart_readl(port, UART_IR_REG);
617+ if (!(iestat & UART_IR_STAT(UART_IR_RXNOTEMPTY)))
618+ return NO_POLL_CHAR;
619+
620+ return bcm_uart_readl(port, UART_FIFO_REG);
621+}
622+
623+static void bcm_uart_poll_put_char(struct uart_port *port, unsigned char c)
624+{
625+ while (bcm_uart_tx_full(port)) {
626+ cpu_relax();
627+ }
628+
629+ bcm_uart_writel(port, c, UART_FIFO_REG);
630+}
631+#endif
632+
599633 /* serial core callbacks */
600634 static const struct uart_ops bcm_uart_ops = {
601635 .tx_empty = bcm_uart_tx_empty,
@@ -614,6 +648,10 @@ static const struct uart_ops bcm_uart_ops = { · 12 unmodified lines
614648 .request_port = bcm_uart_request_port,
615649 .config_port = bcm_uart_config_port,
616650 .verify_port = bcm_uart_verify_port,
651+#ifdef CONFIG_CONSOLE_POLL
652+ .poll_get_char = bcm_uart_poll_get_char,
653+ .poll_put_char = bcm_uart_poll_put_char,
654+#endif
617655 };
618656
619657
drivers/tty/serial/cpm_uart/cpm_uart_core.c+2−3
@@ -678,15 +678,14 @@ static int cpm_uart_tx_pump(struct uart_port *port) · 677 unmodified lines
678678 /* Pick next descriptor and fill from buffer */
679679 bdp = pinfo->tx_cur;
680680
681− while (!(in_be16(&bdp->cbd_sc) & BD_SC_READY) &&
682− xmit->tail != xmit->head) {
681+ while (!(in_be16(&bdp->cbd_sc) & BD_SC_READY) && !uart_circ_empty(xmit)) {
683682 count = 0;
684683 p = cpm2cpu_addr(in_be32(&bdp->cbd_bufaddr), pinfo);
685684 while (count < pinfo->tx_fifosize) {
686685 *p++ = xmit->buf[xmit->tail];
687686 uart_xmit_advance(port, 1);
688687 count++;
689− if (xmit->head == xmit->tail)
688+ if (uart_circ_empty(xmit))
690689 break;
691690 }
692691 out_be16(&bdp->cbd_datlen, count);
drivers/tty/serial/fsl_lpuart.c+5−5
@@ -1296,7 +1296,7 @@ static inline int lpuart_start_rx_dma(struct lpuart_port *sport) · 1295 unmodified lines
12961296 * 10ms at any baud rate.
12971297 */
12981298 sport->rx_dma_rng_buf_len = (DMA_RX_TIMEOUT * baud / bits / 1000) * 2;
1299− sport->rx_dma_rng_buf_len = (1 << (fls(sport->rx_dma_rng_buf_len) - 1));
1299+ sport->rx_dma_rng_buf_len = (1 << fls(sport->rx_dma_rng_buf_len));
13001300 if (sport->rx_dma_rng_buf_len < 16)
13011301 sport->rx_dma_rng_buf_len = 16;
13021302
@@ -1406,12 +1406,12 @@ static int lpuart32_config_rs485(struct uart_port *port, struct ktermios *termio · 103 unmodified lines
14061406 struct lpuart_port, port);
14071407
14081408 unsigned long modem = lpuart32_read(&sport->port, UARTMODIR)
1409− & ~(UARTMODEM_TXRTSPOL | UARTMODEM_TXRTSE);
1409+ & ~(UARTMODIR_TXRTSPOL | UARTMODIR_TXRTSE);
14101410 lpuart32_write(&sport->port, modem, UARTMODIR);
14111411
14121412 if (rs485->flags & SER_RS485_ENABLED) {
14131413 /* Enable auto RS-485 RTS mode */
1414− modem |= UARTMODEM_TXRTSE;
1414+ modem |= UARTMODIR_TXRTSE;
14151415
14161416 /*
14171417 * The hardware defaults to RTS logic HIGH while transfer.
@@ -1420,9 +1420,9 @@ static int lpuart32_config_rs485(struct uart_port *port, struct ktermios *termio · 2 unmodified lines
14201420 * Note: UART is assumed to be active high.
14211421 */
14221422 if (rs485->flags & SER_RS485_RTS_ON_SEND)
1423− modem |= UARTMODEM_TXRTSPOL;
1423+ modem |= UARTMODIR_TXRTSPOL;
14241424 else if (rs485->flags & SER_RS485_RTS_AFTER_SEND)
1425− modem &= ~UARTMODEM_TXRTSPOL;
1425+ modem &= ~UARTMODIR_TXRTSPOL;
14261426 }
14271427
14281428 lpuart32_write(&sport->port, modem, UARTMODIR);
drivers/tty/serial/imx.c+12−36
@@ -289,20 +289,6 @@ static inline int imx_uart_is_imx1(struct imx_port *sport) · 288 unmodified lines
289289 return sport->devdata->devtype == IMX1_UART;
290290 }
291291
292−static inline int imx_uart_is_imx21(struct imx_port *sport)
293−{
294− return sport->devdata->devtype == IMX21_UART;
295−}
296−
297−static inline int imx_uart_is_imx53(struct imx_port *sport)
298−{
299− return sport->devdata->devtype == IMX53_UART;
300−}
301−
302−static inline int imx_uart_is_imx6q(struct imx_port *sport)
303−{
304− return sport->devdata->devtype == IMX6Q_UART;
305−}
306292 /*
307293 * Save and restore functions for UCR1, UCR2 and UCR3 registers
308294 */
@@ -1808,9 +1794,7 @@ imx_uart_set_termios(struct uart_port *port, struct ktermios *termios, · 1499 unmodified lines
18081794
18091795 static const char *imx_uart_type(struct uart_port *port)
18101796 {
1811− struct imx_port *sport = (struct imx_port *)port;
1812−
1813− return sport->port.type == PORT_IMX ? "IMX" : NULL;
1797+ return port->type == PORT_IMX ? "IMX" : NULL;
18141798 }
18151799
18161800 /*
@@ -1818,10 +1802,8 @@ static const char *imx_uart_type(struct uart_port *port) · 1 unmodified line
18181802 */
18191803 static void imx_uart_config_port(struct uart_port *port, int flags)
18201804 {
1821− struct imx_port *sport = (struct imx_port *)port;
1822−
18231805 if (flags & UART_CONFIG_TYPE)
1824− sport->port.type = PORT_IMX;
1806+ port->type = PORT_IMX;
18251807 }
18261808
18271809 /*
@@ -1832,20 +1814,19 @@ static void imx_uart_config_port(struct uart_port *port, int flags) · 4 unmodified lines
18321814 static int
18331815 imx_uart_verify_port(struct uart_port *port, struct serial_struct *ser)
18341816 {
1835− struct imx_port *sport = (struct imx_port *)port;
18361817 int ret = 0;
18371818
18381819 if (ser->type != PORT_UNKNOWN && ser->type != PORT_IMX)
18391820 ret = -EINVAL;
1840− if (sport->port.irq != ser->irq)
1821+ if (port->irq != ser->irq)
18411822 ret = -EINVAL;
18421823 if (ser->io_type != UPIO_MEM)
18431824 ret = -EINVAL;
1844− if (sport->port.uartclk / 16 != ser->baud_base)
1825+ if (port->uartclk / 16 != ser->baud_base)
18451826 ret = -EINVAL;
1846− if (sport->port.mapbase != (unsigned long)ser->iomem_base)
1827+ if (port->mapbase != (unsigned long)ser->iomem_base)
18471828 ret = -EINVAL;
1848− if (sport->port.iobase != ser->port)
1829+ if (port->iobase != ser->port)
18491830 ret = -EINVAL;
18501831 if (ser->hub6 != 0)
18511832 ret = -EINVAL;
@@ -2262,21 +2243,16 @@ static int imx_uart_probe(struct platform_device *pdev) · 410 unmodified lines
22622243 }
22632244 sport->port.line = ret;
22642245
2265− if (of_get_property(np, "uart-has-rtscts", NULL) ||
2266− of_get_property(np, "fsl,uart-has-rtscts", NULL) /* deprecated */)
2267− sport->have_rtscts = 1;
2246+ sport->have_rtscts = of_property_read_bool(np, "uart-has-rtscts") ||
2247+ of_property_read_bool(np, "fsl,uart-has-rtscts"); /* deprecated */
22682248
2269− if (of_get_property(np, "fsl,dte-mode", NULL))
2270− sport->dte_mode = 1;
2249+ sport->dte_mode = of_property_read_bool(np, "fsl,dte-mode");
22712250
2272− if (of_get_property(np, "rts-gpios", NULL))
2273− sport->have_rtsgpio = 1;
2251+ sport->have_rtsgpio = of_property_present(np, "rts-gpios");
22742252
2275− if (of_get_property(np, "fsl,inverted-tx", NULL))
2276− sport->inverted_tx = 1;
2253+ sport->inverted_tx = of_property_read_bool(np, "fsl,inverted-tx");
22772254
2278− if (of_get_property(np, "fsl,inverted-rx", NULL))
2279− sport->inverted_rx = 1;
2255+ sport->inverted_rx = of_property_read_bool(np, "fsl,inverted-rx");
22802256
22812257 if (!of_property_read_u32_array(np, "fsl,dma-info", dma_buf_conf, 2)) {
22822258 sport->rx_period_length = dma_buf_conf[0];
drivers/tty/serial/max310x.c+15−2
@@ -525,6 +525,11 @@ static bool max310x_reg_precious(struct device *dev, unsigned int reg) · 524 unmodified lines
525525 return false;
526526 }
527527
528+static bool max310x_reg_noinc(struct device *dev, unsigned int reg)
529+{
530+ return reg == MAX310X_RHR_REG;
531+}
532+
528533 static int max310x_set_baud(struct uart_port *port, int baud)
529534 {
530535 unsigned int mode = 0, div = 0, frac = 0, c = 0, F = 0;
@@ -651,14 +656,14 @@ static void max310x_batch_write(struct uart_port *port, u8 *txbuf, unsigned int · 120 unmodified lines
651656 {
652657 struct max310x_one *one = to_max310x_port(port);
653658
654− regmap_raw_write(one->regmap, MAX310X_THR_REG, txbuf, len);
659+ regmap_noinc_write(one->regmap, MAX310X_THR_REG, txbuf, len);
655660 }
656661
657662 static void max310x_batch_read(struct uart_port *port, u8 *rxbuf, unsigned int len)
658663 {
659664 struct max310x_one *one = to_max310x_port(port);
660665
661− regmap_raw_read(one->regmap, MAX310X_RHR_REG, rxbuf, len);
666+ regmap_noinc_read(one->regmap, MAX310X_RHR_REG, rxbuf, len);
662667 }
663668
664669 static void max310x_handle_rx(struct uart_port *port, unsigned int rxlen)
@@ -1468,6 +1473,10 @@ static struct regmap_config regcfg = { · 803 unmodified lines
14681473 .writeable_reg = max310x_reg_writeable,
14691474 .volatile_reg = max310x_reg_volatile,
14701475 .precious_reg = max310x_reg_precious,
1476+ .writeable_noinc_reg = max310x_reg_noinc,
1477+ .readable_noinc_reg = max310x_reg_noinc,
1478+ .max_raw_read = MAX310X_FIFO_SIZE,
1479+ .max_raw_write = MAX310X_FIFO_SIZE,
14711480 };
14721481
14731482 #ifdef CONFIG_SPI_MASTER
@@ -1553,6 +1562,10 @@ static struct regmap_config regcfg_i2c = { · 79 unmodified lines
15531562 .volatile_reg = max310x_reg_volatile,
15541563 .precious_reg = max310x_reg_precious,
15551564 .max_register = MAX310X_I2C_REVID_EXTREG,
1565+ .writeable_noinc_reg = max310x_reg_noinc,
1566+ .readable_noinc_reg = max310x_reg_noinc,
1567+ .max_raw_read = MAX310X_FIFO_SIZE,
1568+ .max_raw_write = MAX310X_FIFO_SIZE,
15561569 };
15571570
15581571 static const struct max310x_if_cfg max310x_i2c_if_cfg = {
drivers/tty/serial/meson_uart.c+6−2
@@ -779,7 +779,7 @@ static int meson_uart_remove(struct platform_device *pdev) · 778 unmodified lines
779779 return 0;
780780 }
781781
782−static struct meson_uart_data s4_uart_data = {
782+static struct meson_uart_data meson_g12a_uart_data = {
783783 .has_xtal_div2 = true,
784784 };
785785
@@ -788,9 +788,13 @@ static const struct of_device_id meson_uart_dt_match[] = { · 2 unmodified lines
788788 { .compatible = "amlogic,meson8-uart" },
789789 { .compatible = "amlogic,meson8b-uart" },
790790 { .compatible = "amlogic,meson-gx-uart" },
791+ {
792+ .compatible = "amlogic,meson-g12a-uart",
793+ .data = (void *)&meson_g12a_uart_data,
794+ },
791795 {
792796 .compatible = "amlogic,meson-s4-uart",
793− .data = (void *)&s4_uart_data,
797+ .data = (void *)&meson_g12a_uart_data,
794798 },
795799 { /* sentinel */ },
796800 };
drivers/tty/serial/mxs-auart.c+2−2
@@ -1587,8 +1587,8 @@ static int mxs_auart_probe(struct platform_device *pdev) · 1586 unmodified lines
15871587 }
15881588 s->port.line = ret;
15891589
1590− if (of_get_property(np, "uart-has-rtscts", NULL) ||
1591− of_get_property(np, "fsl,uart-has-rtscts", NULL) /* deprecated */)
1590+ if (of_property_read_bool(np, "uart-has-rtscts") ||
1591+ of_property_read_bool(np, "fsl,uart-has-rtscts") /* deprecated */)
15921592 set_bit(MXS_AUART_RTSCTS, &s->flags);
15931593
15941594 if (s->port.line >= ARRAY_SIZE(auart_port)) {
drivers/tty/serial/qcom_geni_serial.c+5−6
@@ -854,21 +854,19 @@ static void qcom_geni_serial_stop_tx(struct uart_port *uport) · 853 unmodified lines
854854 }
855855
856856 static void qcom_geni_serial_send_chunk_fifo(struct uart_port *uport,
857− unsigned int chunk)
857+ unsigned int remaining)
858858 {
859859 struct qcom_geni_serial_port *port = to_dev_port(uport);
860860 struct circ_buf *xmit = &uport->state->xmit;
861− unsigned int tx_bytes, c, remaining = chunk;
861+ unsigned int tx_bytes;
862862 u8 buf[BYTES_PER_FIFO_WORD];
863863
864864 while (remaining) {
865865 memset(buf, 0, sizeof(buf));
866866 tx_bytes = min(remaining, BYTES_PER_FIFO_WORD);
867867
868− for (c = 0; c < tx_bytes ; c++) {
869− buf[c] = xmit->buf[xmit->tail];
870− uart_xmit_advance(uport, 1);
871− }
868+ memcpy(buf, &xmit->buf[xmit->tail], tx_bytes);
869+ uart_xmit_advance(uport, tx_bytes);
872870
873871 iowrite32_rep(uport->membase + SE_GENI_TX_FIFOn, buf, 1);
874872
@@ -1535,6 +1533,7 @@ static const struct uart_ops qcom_geni_console_pops = { · 660 unmodified lines
15351533 #ifdef CONFIG_CONSOLE_POLL
15361534 .poll_get_char = qcom_geni_serial_get_char,
15371535 .poll_put_char = qcom_geni_serial_poll_put_char,
1536+ .poll_init = qcom_geni_serial_port_setup,
15381537 #endif
15391538 .pm = qcom_geni_serial_pm,
15401539 };
drivers/tty/serial/sb1250-duart.c+1−1
@@ -41,7 +41,7 @@ · 40 unmodified lines
4141 #include <asm/sibyte/swarm.h>
4242
4343
44−#if defined(CONFIG_SIBYTE_BCM1x55) || defined(CONFIG_SIBYTE_BCM1x80)
44+#if defined(CONFIG_SIBYTE_BCM1x80)
4545 #include <asm/sibyte/bcm1480_regs.h>
4646 #include <asm/sibyte/bcm1480_int.h>
4747
drivers/tty/serial/serial_core.c+64−61
@@ -15,6 +15,7 @@ · 14 unmodified lines
1515 #include <linux/init.h>
1616 #include <linux/console.h>
1717 #include <linux/gpio/consumer.h>
18+#include <linux/kernel.h>
1819 #include <linux/of.h>
1920 #include <linux/proc_fs.h>
2021 #include <linux/seq_file.h>
@@ -48,9 +49,6 @@ static struct lock_class_key port_lock_key; · 27 unmodified lines
4849 */
4950 #define RS485_MAX_RTS_DELAY 100 /* msecs */
5051
51−static void uart_change_speed(struct tty_struct *tty, struct uart_state *state,
52− const struct ktermios *old_termios);
53−static void uart_wait_until_sent(struct tty_struct *tty, int timeout);
5452 static void uart_change_pm(struct uart_state *state,
5553 enum uart_pm_state pm_state);
5654
@@ -137,7 +135,7 @@ static void __uart_start(struct tty_struct *tty) · 80 unmodified lines
137135 struct uart_state *state = tty->driver_data;
138136 struct uart_port *port = state->uart_port;
139137
140− if (port && !uart_tx_stopped(port))
138+ if (port && !(port->flags & UPF_DEAD) && !uart_tx_stopped(port))
141139 port->ops->start_tx(port);
142140 }
143141
@@ -177,6 +175,51 @@ static void uart_port_dtr_rts(struct uart_port *uport, bool active) · 33 unmodified lines
177175 uart_clear_mctrl(uport, TIOCM_DTR | TIOCM_RTS);
178176 }
179177
178+/* Caller holds port mutex */
179+static void uart_change_line_settings(struct tty_struct *tty, struct uart_state *state,
180+ const struct ktermios *old_termios)
181+{
182+ struct uart_port *uport = uart_port_check(state);
183+ struct ktermios *termios;
184+ bool old_hw_stopped;
185+
186+ /*
187+ * If we have no tty, termios, or the port does not exist,
188+ * then we can't set the parameters for this port.
189+ */
190+ if (!tty || uport->type == PORT_UNKNOWN)
191+ return;
192+
193+ termios = &tty->termios;
194+ uport->ops->set_termios(uport, termios, old_termios);
195+
196+ /*
197+ * Set modem status enables based on termios cflag
198+ */
199+ spin_lock_irq(&uport->lock);
200+ if (termios->c_cflag & CRTSCTS)
201+ uport->status |= UPSTAT_CTS_ENABLE;
202+ else
203+ uport->status &= ~UPSTAT_CTS_ENABLE;
204+
205+ if (termios->c_cflag & CLOCAL)
206+ uport->status &= ~UPSTAT_DCD_ENABLE;
207+ else
208+ uport->status |= UPSTAT_DCD_ENABLE;
209+
210+ /* reset sw-assisted CTS flow control based on (possibly) new mode */
211+ old_hw_stopped = uport->hw_stopped;
212+ uport->hw_stopped = uart_softcts_mode(uport) &&
213+ !(uport->ops->get_mctrl(uport) & TIOCM_CTS);
214+ if (uport->hw_stopped != old_hw_stopped) {
215+ if (!old_hw_stopped)
216+ uport->ops->stop_tx(uport);
217+ else
218+ __uart_start(tty);
219+ }
220+ spin_unlock_irq(&uport->lock);
221+}
222+
180223 /*
181224 * Startup the port. This will be called once per open. All calls
182225 * will be serialised by the per-port mutex.
@@ -232,7 +275,7 @@ static int uart_port_startup(struct tty_struct *tty, struct uart_state *state, · 49 unmodified lines
232275 /*
233276 * Initialise the hardware port settings.
234277 */
235− uart_change_speed(tty, state, NULL);
278+ uart_change_line_settings(tty, state, NULL);
236279
237280 /*
238281 * Setup the RTS and DTR signals once the
@@ -485,52 +528,6 @@ uart_get_divisor(struct uart_port *port, unsigned int baud) · 246 unmodified lines
485528 }
486529 EXPORT_SYMBOL(uart_get_divisor);
487530
488−/* Caller holds port mutex */
489−static void uart_change_speed(struct tty_struct *tty, struct uart_state *state,
490− const struct ktermios *old_termios)
491−{
492− struct uart_port *uport = uart_port_check(state);
493− struct ktermios *termios;
494− int hw_stopped;
495−
496− /*
497− * If we have no tty, termios, or the port does not exist,
498− * then we can't set the parameters for this port.
499− */
500− if (!tty || uport->type == PORT_UNKNOWN)
501− return;
502−
503− termios = &tty->termios;
504− uport->ops->set_termios(uport, termios, old_termios);
505−
506− /*
507− * Set modem status enables based on termios cflag
508− */
509− spin_lock_irq(&uport->lock);
510− if (termios->c_cflag & CRTSCTS)
511− uport->status |= UPSTAT_CTS_ENABLE;
512− else
513− uport->status &= ~UPSTAT_CTS_ENABLE;
514−
515− if (termios->c_cflag & CLOCAL)
516− uport->status &= ~UPSTAT_DCD_ENABLE;
517− else
518− uport->status |= UPSTAT_DCD_ENABLE;
519−
520− /* reset sw-assisted CTS flow control based on (possibly) new mode */
521− hw_stopped = uport->hw_stopped;
522− uport->hw_stopped = uart_softcts_mode(uport) &&
523− !(uport->ops->get_mctrl(uport) & TIOCM_CTS);
524− if (uport->hw_stopped) {
525− if (!hw_stopped)
526− uport->ops->stop_tx(uport);
527− } else {
528− if (hw_stopped)
529− __uart_start(tty);
530− }
531− spin_unlock_irq(&uport->lock);
532−}
533−
534531 static int uart_put_char(struct tty_struct *tty, unsigned char c)
535532 {
536533 struct uart_state *state = tty->driver_data;
@@ -994,7 +991,7 @@ static int uart_set_info(struct tty_struct *tty, struct tty_port *port, · 457 unmodified lines
994991 current->comm,
995992 tty_name(port->tty));
996993 }
997− uart_change_speed(tty, state, NULL);
994+ uart_change_line_settings(tty, state, NULL);
998995 }
999996 } else {
1000997 retval = uart_startup(tty, state, true);
@@ -1491,7 +1488,7 @@ static int uart_set_iso7816_config(struct uart_port *port, · 490 unmodified lines
14911488 * There are 5 words reserved for future use. Check that userspace
14921489 * doesn't put stuff in there to prevent breakages in the future.
14931490 */
1494− for (i = 0; i < 5; i++)
1491+ for (i = 0; i < ARRAY_SIZE(iso7816.reserved); i++)
14951492 if (iso7816.reserved[i])
14961493 return -EINVAL;
14971494
@@ -1552,7 +1549,7 @@ uart_ioctl(struct tty_struct *tty, unsigned int cmd, unsigned long arg) · 54 unmodified lines
15521549 goto out;
15531550
15541551 /* rs485_config requires more locking than others */
1555− if (cmd == TIOCGRS485)
1552+ if (cmd == TIOCSRS485)
15561553 down_write(&tty->termios_rwsem);
15571554
15581555 mutex_lock(&port->mutex);
@@ -1595,7 +1592,7 @@ uart_ioctl(struct tty_struct *tty, unsigned int cmd, unsigned long arg) · 36 unmodified lines
15951592 }
15961593 out_up:
15971594 mutex_unlock(&port->mutex);
1598− if (cmd == TIOCGRS485)
1595+ if (cmd == TIOCSRS485)
15991596 up_write(&tty->termios_rwsem);
16001597 out:
16011598 return ret;
@@ -1656,15 +1653,15 @@ static void uart_set_termios(struct tty_struct *tty, · 54 unmodified lines
16561653 goto out;
16571654 }
16581655
1659− uart_change_speed(tty, state, old_termios);
1656+ uart_change_line_settings(tty, state, old_termios);
16601657 /* reload cflag from termios; port driver may have overridden flags */
16611658 cflag = tty->termios.c_cflag;
16621659
16631660 /* Handle transition to B0 status */
1664− if ((old_termios->c_cflag & CBAUD) && !(cflag & CBAUD))
1661+ if (((old_termios->c_cflag & CBAUD) != B0) && ((cflag & CBAUD) == B0))
16651662 uart_clear_mctrl(uport, TIOCM_RTS | TIOCM_DTR);
16661663 /* Handle transition away from B0 status */
1667− else if (!(old_termios->c_cflag & CBAUD) && (cflag & CBAUD)) {
1664+ else if (((old_termios->c_cflag & CBAUD) == B0) && ((cflag & CBAUD) != B0)) {
16681665 unsigned int mask = TIOCM_DTR;
16691666
16701667 if (!(cflag & CRTSCTS) || !tty_throttled(tty))
@@ -2452,7 +2449,7 @@ int uart_resume_port(struct uart_driver *drv, struct uart_port *uport) · 781 unmodified lines
24522449 ret = ops->startup(uport);
24532450 if (ret == 0) {
24542451 if (tty)
2455− uart_change_speed(tty, state, NULL);
2452+ uart_change_line_settings(tty, state, NULL);
24562453 spin_lock_irq(&uport->lock);
24572454 if (!(uport->rs485.flags & SER_RS485_ENABLED))
24582455 ops->set_mctrl(uport, uport->mctrl);
@@ -2593,6 +2590,7 @@ static int uart_poll_init(struct tty_driver *driver, int line, char *options) · 134 unmodified lines
25932590 {
25942591 struct uart_driver *drv = driver->driver_state;
25952592 struct uart_state *state = drv->state + line;
2593+ enum uart_pm_state pm_state;
25962594 struct tty_port *tport;
25972595 struct uart_port *port;
25982596 int baud = 9600;
@@ -2610,6 +2608,9 @@ static int uart_poll_init(struct tty_driver *driver, int line, char *options) · 11 unmodified lines
26102608 goto out;
26112609 }
26122610
2611+ pm_state = state->pm_state;
2612+ uart_change_pm(state, UART_PM_STATE_ON);
2613+
26132614 if (port->ops->poll_init) {
26142615 /*
26152616 * We don't set initialized as we only initialized the hw,
@@ -2626,6 +2627,8 @@ static int uart_poll_init(struct tty_driver *driver, int line, char *options) · 10 unmodified lines
26262627 console_list_unlock();
26272628 }
26282629 out:
2630+ if (ret)
2631+ uart_change_pm(state, pm_state);
26292632 mutex_unlock(&tport->mutex);
26302633 return ret;
26312634 }
@@ -3305,13 +3308,13 @@ void uart_handle_cts_change(struct uart_port *uport, bool active) · 673 unmodified lines
33053308 if (uart_softcts_mode(uport)) {
33063309 if (uport->hw_stopped) {
33073310 if (active) {
3308− uport->hw_stopped = 0;
3311+ uport->hw_stopped = false;
33093312 uport->ops->start_tx(uport);
33103313 uart_write_wakeup(uport);
33113314 }
33123315 } else {
33133316 if (!active) {
3314− uport->hw_stopped = 1;
3317+ uport->hw_stopped = true;
33153318 uport->ops->stop_tx(uport);
33163319 }
33173320 }
drivers/tty/serial/sh-sci.c+90−25
@@ -588,14 +588,28 @@ static void sci_start_tx(struct uart_port *port) · 587 unmodified lines
588588
589589 if (s->chan_tx && !uart_circ_empty(&s->port.state->xmit) &&
590590 dma_submit_error(s->cookie_tx)) {
591+ if (s->cfg->regtype == SCIx_RZ_SCIFA_REGTYPE)
592+ /* Switch irq from SCIF to DMA */
593+ disable_irq(s->irqs[SCIx_TXI_IRQ]);
594+
591595 s->cookie_tx = 0;
592596 schedule_work(&s->work_tx);
593597 }
594598 #endif
595599
596− if (!s->chan_tx || port->type == PORT_SCIFA || port->type == PORT_SCIFB) {
600+ if (!s->chan_tx || s->cfg->regtype == SCIx_RZ_SCIFA_REGTYPE ||
601+ port->type == PORT_SCIFA || port->type == PORT_SCIFB) {
597602 /* Set TIE (Transmit Interrupt Enable) bit in SCSCR */
598603 ctrl = serial_port_in(port, SCSCR);
604+
605+ /*
606+ * For SCI, TE (transmit enable) must be set after setting TIE
607+ * (transmit interrupt enable) or in the same instruction to start
608+ * the transmit process.
609+ */
610+ if (port->type == PORT_SCI)
611+ ctrl |= SCSCR_TE;
612+
599613 serial_port_out(port, SCSCR, ctrl | SCSCR_TIE);
600614 }
601615 }
@@ -833,6 +847,11 @@ static void sci_transmit_chars(struct uart_port *port) · 231 unmodified lines
833847 } else if (!uart_circ_empty(xmit) && !stopped) {
834848 c = xmit->buf[xmit->tail];
835849 xmit->tail = (xmit->tail + 1) & (UART_XMIT_SIZE - 1);
850+ } else if (port->type == PORT_SCI && uart_circ_empty(xmit)) {
851+ ctrl = serial_port_in(port, SCSCR);
852+ ctrl &= ~SCSCR_TE;
853+ serial_port_out(port, SCSCR, ctrl);
854+ return;
836855 } else {
837856 break;
838857 }
@@ -846,9 +865,16 @@ static void sci_transmit_chars(struct uart_port *port) · 7 unmodified lines
846865
847866 if (uart_circ_chars_pending(xmit) < WAKEUP_CHARS)
848867 uart_write_wakeup(port);
849− if (uart_circ_empty(xmit))
850− sci_stop_tx(port);
868+ if (uart_circ_empty(xmit)) {
869+ if (port->type == PORT_SCI) {
870+ ctrl = serial_port_in(port, SCSCR);
871+ ctrl &= ~SCSCR_TIE;
872+ ctrl |= SCSCR_TEIE;
873+ serial_port_out(port, SCSCR, ctrl);
874+ }
851875
876+ sci_stop_tx(port);
877+ }
852878 }
853879
854880 static void sci_receive_chars(struct uart_port *port)
@@ -1192,9 +1218,15 @@ static void sci_dma_tx_complete(void *arg) · 337 unmodified lines
11921218 schedule_work(&s->work_tx);
11931219 } else {
11941220 s->cookie_tx = -EINVAL;
1195− if (port->type == PORT_SCIFA || port->type == PORT_SCIFB) {
1221+ if (port->type == PORT_SCIFA || port->type == PORT_SCIFB ||
1222+ s->cfg->regtype == SCIx_RZ_SCIFA_REGTYPE) {
11961223 u16 ctrl = serial_port_in(port, SCSCR);
11971224 serial_port_out(port, SCSCR, ctrl & ~SCSCR_TIE);
1225+ if (s->cfg->regtype == SCIx_RZ_SCIFA_REGTYPE) {
1226+ /* Switch irq from DMA to SCIF */
1227+ dmaengine_pause(s->chan_tx_saved);
1228+ enable_irq(s->irqs[SCIx_TXI_IRQ]);
1229+ }
11981230 }
11991231 }
12001232
@@ -1266,9 +1298,13 @@ static void sci_dma_rx_reenable_irq(struct sci_port *s) · 65 unmodified lines
12661298
12671299 /* Direct new serial port interrupts back to CPU */
12681300 scr = serial_port_in(port, SCSCR);
1269− if (port->type == PORT_SCIFA || port->type == PORT_SCIFB) {
1270− scr &= ~SCSCR_RDRQE;
1301+ if (port->type == PORT_SCIFA || port->type == PORT_SCIFB ||
1302+ s->cfg->regtype == SCIx_RZ_SCIFA_REGTYPE) {
12711303 enable_irq(s->irqs[SCIx_RXI_IRQ]);
1304+ if (s->cfg->regtype == SCIx_RZ_SCIFA_REGTYPE)
1305+ scif_set_rtrg(port, s->rx_trigger);
1306+ else
1307+ scr &= ~SCSCR_RDRQE;
12721308 }
12731309 serial_port_out(port, SCSCR, scr | SCSCR_RIE);
12741310 }
@@ -1505,7 +1541,8 @@ static enum hrtimer_restart sci_dma_rx_timer_fn(struct hrtimer *t) · 230 unmodified lines
15051541 tty_flip_buffer_push(&port->state->port);
15061542 }
15071543
1508− if (port->type == PORT_SCIFA || port->type == PORT_SCIFB)
1544+ if (port->type == PORT_SCIFA || port->type == PORT_SCIFB ||
1545+ s->cfg->regtype == SCIx_RZ_SCIFA_REGTYPE)
15091546 sci_dma_rx_submit(s, true);
15101547
15111548 sci_dma_rx_reenable_irq(s);
@@ -1531,15 +1568,12 @@ static struct dma_chan *sci_request_dma_chan(struct uart_port *port, · 19 unmodified lines
15311568
15321569 memset(&cfg, 0, sizeof(cfg));
15331570 cfg.direction = dir;
1534− if (dir == DMA_MEM_TO_DEV) {
1535− cfg.dst_addr = port->mapbase +
1536− (sci_getreg(port, SCxTDR)->offset << port->regshift);
1537− cfg.dst_addr_width = DMA_SLAVE_BUSWIDTH_1_BYTE;
1538− } else {
1539− cfg.src_addr = port->mapbase +
1540− (sci_getreg(port, SCxRDR)->offset << port->regshift);
1541− cfg.src_addr_width = DMA_SLAVE_BUSWIDTH_1_BYTE;
1542− }
1571+ cfg.dst_addr = port->mapbase +
1572+ (sci_getreg(port, SCxTDR)->offset << port->regshift);
1573+ cfg.dst_addr_width = DMA_SLAVE_BUSWIDTH_1_BYTE;
1574+ cfg.src_addr = port->mapbase +
1575+ (sci_getreg(port, SCxRDR)->offset << port->regshift);
1576+ cfg.src_addr_width = DMA_SLAVE_BUSWIDTH_1_BYTE;
15431577
15441578 ret = dmaengine_slave_config(chan, &cfg);
15451579 if (ret) {
@@ -1574,7 +1608,7 @@ static void sci_request_dma(struct uart_port *port) · 28 unmodified lines
15741608 * Don't request a dma channel if no channel was specified
15751609 * in the device tree.
15761610 */
1577− if (!of_find_property(port->dev->of_node, "dmas", NULL))
1611+ if (!of_property_present(port->dev->of_node, "dmas"))
15781612 return;
15791613
15801614 chan = sci_request_dma_chan(port, DMA_MEM_TO_DEV);
@@ -1632,7 +1666,8 @@ static void sci_request_dma(struct uart_port *port) · 51 unmodified lines
16321666
16331667 s->chan_rx_saved = s->chan_rx = chan;
16341668
1635− if (port->type == PORT_SCIFA || port->type == PORT_SCIFB)
1669+ if (port->type == PORT_SCIFA || port->type == PORT_SCIFB ||
1670+ s->cfg->regtype == SCIx_RZ_SCIFA_REGTYPE)
16361671 sci_dma_rx_submit(s, false);
16371672 }
16381673 }
@@ -1685,9 +1720,15 @@ static irqreturn_t sci_rx_interrupt(int irq, void *ptr) · 46 unmodified lines
16851720 u16 ssr = serial_port_in(port, SCxSR);
16861721
16871722 /* Disable future Rx interrupts */
1688− if (port->type == PORT_SCIFA || port->type == PORT_SCIFB) {
1689− disable_irq_nosync(irq);
1690− scr |= SCSCR_RDRQE;
1723+ if (port->type == PORT_SCIFA || port->type == PORT_SCIFB ||
1724+ s->cfg->regtype == SCIx_RZ_SCIFA_REGTYPE) {
1725+ disable_irq_nosync(s->irqs[SCIx_RXI_IRQ]);
1726+ if (s->cfg->regtype == SCIx_RZ_SCIFA_REGTYPE) {
1727+ scif_set_rtrg(port, 1);
1728+ scr |= SCSCR_RIE;
1729+ } else {
1730+ scr |= SCSCR_RDRQE;
1731+ }
16911732 } else {
16921733 if (sci_dma_rx_submit(s, false) < 0)
16931734 goto handle_pio;
@@ -1737,6 +1778,24 @@ static irqreturn_t sci_tx_interrupt(int irq, void *ptr) · 43 unmodified lines
17371778 return IRQ_HANDLED;
17381779 }
17391780
1781+static irqreturn_t sci_tx_end_interrupt(int irq, void *ptr)
1782+{
1783+ struct uart_port *port = ptr;
1784+ unsigned long flags;
1785+ unsigned short ctrl;
1786+
1787+ if (port->type != PORT_SCI)
1788+ return sci_tx_interrupt(irq, ptr);
1789+
1790+ spin_lock_irqsave(&port->lock, flags);
1791+ ctrl = serial_port_in(port, SCSCR);
1792+ ctrl &= ~(SCSCR_TE | SCSCR_TEIE);
1793+ serial_port_out(port, SCSCR, ctrl);
1794+ spin_unlock_irqrestore(&port->lock, flags);
1795+
1796+ return IRQ_HANDLED;
1797+}
1798+
17401799 static irqreturn_t sci_br_interrupt(int irq, void *ptr)
17411800 {
17421801 struct uart_port *port = ptr;
@@ -1873,7 +1932,7 @@ static const struct sci_irq_desc { · 130 unmodified lines
18731932
18741933 [SCIx_TEI_IRQ] = {
18751934 .desc = "tx end",
1876− .handler = sci_tx_interrupt,
1935+ .handler = sci_tx_end_interrupt,
18771936 },
18781937
18791938 /*
@@ -2580,8 +2639,14 @@ done: · 700 unmodified lines
25802639 sci_set_mctrl(port, port->mctrl);
25812640 }
25822641
2583− scr_val |= SCSCR_RE | SCSCR_TE |
2584− (s->cfg->scscr & ~(SCSCR_CKE1 | SCSCR_CKE0));
2642+ /*
2643+ * For SCI, TE (transmit enable) must be set after setting TIE
2644+ * (transmit interrupt enable) or in the same instruction to
2645+ * start the transmitting process. So skip setting TE here for SCI.
2646+ */
2647+ if (port->type != PORT_SCI)
2648+ scr_val |= SCSCR_TE;
2649+ scr_val |= SCSCR_RE | (s->cfg->scscr & ~(SCSCR_CKE1 | SCSCR_CKE0));
25852650 serial_port_out(port, SCSCR, scr_val | s->hscif_tot);
25862651 if ((srr + 1 == 5) &&
25872652 (port->type == PORT_SCIFA || port->type == PORT_SCIFB)) {
@@ -3149,7 +3214,7 @@ static int sci_remove(struct platform_device *dev) · 561 unmodified lines
31493214 #define SCI_OF_TYPE(data) ((unsigned long)(data) >> 16)
31503215 #define SCI_OF_REGTYPE(data) ((unsigned long)(data) & 0xffff)
31513216
3152−static const struct of_device_id of_sci_match[] = {
3217+static const struct of_device_id of_sci_match[] __maybe_unused = {
31533218 /* SoC-specific types */
31543219 {
31553220 .compatible = "renesas,scif-r7s72100",
drivers/tty/serial/sh-sci.h+3−0
@@ -59,6 +59,9 @@ enum { · 58 unmodified lines
5959 #define SCSMR_SRC_19 0x0600 /* Sampling rate 1/19 */
6060 #define SCSMR_SRC_27 0x0700 /* Sampling rate 1/27 */
6161
62+/* Serial Control Register, SCI only bits */
63+#define SCSCR_TEIE BIT(2) /* Transmit End Interrupt Enable */
64+
6265 /* Serial Control Register, SCIFA/SCIFB only bits */
6366 #define SCSCR_TDRQE BIT(15) /* Tx Data Transfer Request Enable */
6467 #define SCSCR_RDRQE BIT(14) /* Rx Data Transfer Request Enable */
drivers/tty/serial/sprd_serial.c+1−1
@@ -1250,7 +1250,7 @@ static struct platform_driver sprd_platform_driver = { · 1249 unmodified lines
12501250 .remove = sprd_remove,
12511251 .driver = {
12521252 .name = "sprd_serial",
1253− .of_match_table = of_match_ptr(serial_ids),
1253+ .of_match_table = serial_ids,
12541254 .pm = &sprd_pm_ops,
12551255 },
12561256 };
drivers/tty/serial/stm32-usart.c+3−3
@@ -693,8 +693,9 @@ static void stm32_usart_transmit_chars(struct uart_port *port) · 692 unmodified lines
693693 int ret;
694694
695695 if (!stm32_port->hw_flow_control &&
696− port->rs485.flags & SER_RS485_ENABLED) {
697− stm32_port->txdone = false;
696+ port->rs485.flags & SER_RS485_ENABLED &&
697+ (port->x_char ||
698+ !(uart_circ_empty(xmit) || uart_tx_stopped(port)))) {
698699 stm32_usart_tc_interrupt_disable(port);
699700 stm32_usart_rs485_rts_enable(port);
700701 }
@@ -743,7 +744,6 @@ static void stm32_usart_transmit_chars(struct uart_port *port) · 42 unmodified lines
743744 stm32_usart_tx_interrupt_disable(port);
744745 if (!stm32_port->hw_flow_control &&
745746 port->rs485.flags & SER_RS485_ENABLED) {
746− stm32_port->txdone = true;
747747 stm32_usart_tc_interrupt_enable(port);
748748 }
749749 }
drivers/tty/serial/stm32-usart.h+0−1
@@ -203,7 +203,6 @@ struct stm32_port { · 202 unmodified lines
203203 bool hw_flow_control;
204204 bool swap; /* swap RX & TX pins */
205205 bool fifoen;
206− bool txdone;
207206 int rxftcfg; /* RX FIFO threshold CFG */
208207 int txftcfg; /* TX FIFO threshold CFG */
209208 bool wakeup_src;
drivers/tty/serial/sunzilog.c+2−2
@@ -1403,7 +1403,7 @@ static int zs_probe(struct platform_device *op) · 1402 unmodified lines
14031403 int keyboard_mouse = 0;
14041404 int err;
14051405
1406− if (of_find_property(op->dev.of_node, "keyboard", NULL))
1406+ if (of_property_present(op->dev.of_node, "keyboard"))
14071407 keyboard_mouse = 1;
14081408
14091409 /* uarts must come before keyboards/mice */
@@ -1553,7 +1553,7 @@ static int __init sunzilog_init(void) · 143 unmodified lines
15531553
15541554 for_each_node_by_name(dp, "zs") {
15551555 num_sunzilog++;
1556− if (of_find_property(dp, "keyboard", NULL))
1556+ if (of_property_present(dp, "keyboard"))
15571557 num_keybms++;
15581558 }
15591559
drivers/tty/serial/ucc_uart.c+3−4
@@ -366,15 +366,14 @@ static int qe_uart_tx_pump(struct uart_qe_port *qe_port) · 365 unmodified lines
366366 /* Pick next descriptor and fill from buffer */
367367 bdp = qe_port->tx_cur;
368368
369− while (!(ioread16be(&bdp->status) & BD_SC_READY) &&
370− (xmit->tail != xmit->head)) {
369+ while (!(ioread16be(&bdp->status) & BD_SC_READY) && !uart_circ_empty(xmit)) {
371370 count = 0;
372371 p = qe2cpu_addr(be32_to_cpu(bdp->buf), qe_port);
373372 while (count < qe_port->tx_fifosize) {
374373 *p++ = xmit->buf[xmit->tail];
375374 uart_xmit_advance(port, 1);
376375 count++;
377− if (xmit->head == xmit->tail)
376+ if (uart_circ_empty(xmit))
378377 break;
379378 }
380379
@@ -1179,7 +1178,7 @@ static int soft_uart_init(struct platform_device *ofdev) · 798 unmodified lines
11791178 struct qe_firmware_info *qe_fw_info;
11801179 int ret;
11811180
1182− if (of_find_property(np, "soft-uart", NULL)) {
1181+ if (of_property_read_bool(np, "soft-uart")) {
11831182 dev_dbg(&ofdev->dev, "using Soft-UART mode\n");
11841183 soft_uart = 1;
11851184 } else {
drivers/tty/synclink_gt.c+8−16
@@ -287,7 +287,6 @@ struct slgt_info { · 286 unmodified lines
287287 unsigned char *tx_buf;
288288 int tx_count;
289289
290− char *flag_buf;
291290 bool drop_rts_on_tx_done;
292291 struct _input_signal_events input_signal_events;
293292
@@ -730,7 +729,7 @@ static void set_termios(struct tty_struct *tty, · 436 unmodified lines
730729
731730 /* Handle turning off CRTSCTS */
732731 if ((old_termios->c_cflag & CRTSCTS) && !C_CRTSCTS(tty)) {
733− tty->hw_stopped = 0;
732+ tty->hw_stopped = false;
734733 tx_release(tty);
735734 }
736735 }
@@ -1953,13 +1952,13 @@ static void cts_change(struct slgt_info *info, unsigned short status) · 1216 unmodified lines
19531952 if (info->port.tty) {
19541953 if (info->port.tty->hw_stopped) {
19551954 if (info->signals & SerialSignal_CTS) {
1956− info->port.tty->hw_stopped = 0;
1955+ info->port.tty->hw_stopped = false;
19571956 info->pending_bh |= BH_TRANSMIT;
19581957 return;
19591958 }
19601959 } else {
19611960 if (!(info->signals & SerialSignal_CTS))
1962− info->port.tty->hw_stopped = 1;
1961+ info->port.tty->hw_stopped = true;
19631962 }
19641963 }
19651964 }
@@ -3244,13 +3243,7 @@ static int alloc_tmp_rbuf(struct slgt_info *info) · 1278 unmodified lines
32443243 info->tmp_rbuf = kmalloc(info->max_frame_size + 5, GFP_KERNEL);
32453244 if (info->tmp_rbuf == NULL)
32463245 return -ENOMEM;
3247− /* unused flag buffer to satisfy receive_buf calling interface */
3248− info->flag_buf = kzalloc(info->max_frame_size + 5, GFP_KERNEL);
3249− if (!info->flag_buf) {
3250− kfree(info->tmp_rbuf);
3251− info->tmp_rbuf = NULL;
3252− return -ENOMEM;
3253− }
3246+
32543247 return 0;
32553248 }
32563249
@@ -3258,8 +3251,6 @@ static void free_tmp_rbuf(struct slgt_info *info) · 1 unmodified line
32583251 {
32593252 kfree(info->tmp_rbuf);
32603253 info->tmp_rbuf = NULL;
3261− kfree(info->flag_buf);
3262− info->flag_buf = NULL;
32633254 }
32643255
32653256 /*
@@ -4657,7 +4648,8 @@ check_again: · 1391 unmodified lines
46574648 hdlcdev_rx(info,info->tmp_rbuf, framesize);
46584649 else
46594650 #endif
4660− ldisc_receive_buf(tty, info->tmp_rbuf, info->flag_buf, framesize);
4651+ ldisc_receive_buf(tty, info->tmp_rbuf, NULL,
4652+ framesize);
46614653 }
46624654 }
46634655 free_rbufs(info, start, end);
@@ -4691,8 +4683,8 @@ static bool rx_get_buf(struct slgt_info *info) · 27 unmodified lines
46914683 DBGDATA(info, info->rbufs[i].buf, count, "rx");
46924684 DBGINFO(("rx_get_buf size=%d\n", count));
46934685 if (count)
4694− ldisc_receive_buf(info->port.tty, info->rbufs[i].buf,
4695− info->flag_buf, count);
4686+ ldisc_receive_buf(info->port.tty, info->rbufs[i].buf, NULL,
4687+ count);
46964688 free_rbufs(info, i, i);
46974689 return true;
46984690 }
drivers/tty/tty.h+2−0
@@ -62,6 +62,8 @@ int __tty_check_change(struct tty_struct *tty, int sig); · 61 unmodified lines
6262 int tty_check_change(struct tty_struct *tty);
6363 void __stop_tty(struct tty_struct *tty);
6464 void __start_tty(struct tty_struct *tty);
65+void tty_write_unlock(struct tty_struct *tty);
66+int tty_write_lock(struct tty_struct *tty, int ndelay);
6567 void tty_vhangup_session(struct tty_struct *tty);
6668 void tty_open_proc_set_tty(struct file *filp, struct tty_struct *tty);
6769 int tty_signal_session_leader(struct tty_struct *tty, int exit_session);
drivers/tty/tty_io.c+3−21
@@ -933,13 +933,13 @@ static ssize_t tty_read(struct kiocb *iocb, struct iov_iter *to) · 932 unmodified lines
933933 return i;
934934 }
935935
936−static void tty_write_unlock(struct tty_struct *tty)
936+void tty_write_unlock(struct tty_struct *tty)
937937 {
938938 mutex_unlock(&tty->atomic_write_lock);
939939 wake_up_interruptible_poll(&tty->write_wait, EPOLLOUT);
940940 }
941941
942−static int tty_write_lock(struct tty_struct *tty, int ndelay)
942+int tty_write_lock(struct tty_struct *tty, int ndelay)
943943 {
944944 if (!mutex_trylock(&tty->atomic_write_lock)) {
945945 if (ndelay)
@@ -3614,31 +3614,13 @@ static struct ctl_table tty_table[] = { · 2668 unmodified lines
36143614 { }
36153615 };
36163616
3617−static struct ctl_table tty_dir_table[] = {
3618− {
3619− .procname = "tty",
3620− .mode = 0555,
3621− .child = tty_table,
3622− },
3623− { }
3624−};
3625−
3626−static struct ctl_table tty_root_table[] = {
3627− {
3628− .procname = "dev",
3629− .mode = 0555,
3630− .child = tty_dir_table,
3631− },
3632− { }
3633−};
3634−
36353617 /*
36363618 * Ok, now we can initialize the rest of the tty devices and can count
36373619 * on memory allocations, interrupts etc..
36383620 */
36393621 int __init tty_init(void)
36403622 {
3641− register_sysctl_table(tty_root_table);
3623+ register_sysctl_init("dev/tty", tty_table);
36423624 cdev_init(&tty_cdev, &tty_fops);
36433625 if (cdev_add(&tty_cdev, MKDEV(TTYAUX_MAJOR, 0), 1) ||
36443626 register_chrdev_region(MKDEV(TTYAUX_MAJOR, 0), 1, "/dev/tty") < 0)
drivers/tty/tty_ioctl.c+38−16
@@ -7,6 +7,7 @@ · 6 unmodified lines
77 * discipline handling modules (like SLIP).
88 */
99
10+#include <linux/bits.h>
1011 #include <linux/types.h>
1112 #include <linux/termios.h>
1213 #include <linux/errno.h>
@@ -40,10 +41,10 @@ · 27 unmodified lines
4041 /*
4142 * Internal flag options for termios setting behavior
4243 */
43−#define TERMIOS_FLUSH 1
44−#define TERMIOS_WAIT 2
45−#define TERMIOS_TERMIO 4
46−#define TERMIOS_OLD 8
44+#define TERMIOS_FLUSH BIT(0)
45+#define TERMIOS_WAIT BIT(1)
46+#define TERMIOS_TERMIO BIT(2)
47+#define TERMIOS_OLD BIT(3)
4748
4849
4950 /**
@@ -500,21 +501,42 @@ static int set_termios(struct tty_struct *tty, void __user *arg, int opt) · 450 unmodified lines
500501 tmp_termios.c_ispeed = tty_termios_input_baud_rate(&tmp_termios);
501502 tmp_termios.c_ospeed = tty_termios_baud_rate(&tmp_termios);
502503
503− ld = tty_ldisc_ref(tty);
504+ if (opt & (TERMIOS_FLUSH|TERMIOS_WAIT)) {
505+retry_write_wait:
506+ retval = wait_event_interruptible(tty->write_wait, !tty_chars_in_buffer(tty));
507+ if (retval < 0)
508+ return retval;
504509
505− if (ld != NULL) {
506− if ((opt & TERMIOS_FLUSH) && ld->ops->flush_buffer)
507− ld->ops->flush_buffer(tty);
508− tty_ldisc_deref(ld);
509− }
510+ if (tty_write_lock(tty, 0) < 0)
511+ goto retry_write_wait;
510512
511− if (opt & TERMIOS_WAIT) {
512− tty_wait_until_sent(tty, 0);
513− if (signal_pending(current))
514− return -ERESTARTSYS;
515− }
513+ /* Racing writer? */
514+ if (tty_chars_in_buffer(tty)) {
515+ tty_write_unlock(tty);
516+ goto retry_write_wait;
517+ }
516518
517− tty_set_termios(tty, &tmp_termios);
519+ ld = tty_ldisc_ref(tty);
520+ if (ld != NULL) {
521+ if ((opt & TERMIOS_FLUSH) && ld->ops->flush_buffer)
522+ ld->ops->flush_buffer(tty);
523+ tty_ldisc_deref(ld);
524+ }
525+
526+ if ((opt & TERMIOS_WAIT) && tty->ops->wait_until_sent) {
527+ tty->ops->wait_until_sent(tty, 0);
528+ if (signal_pending(current)) {
529+ tty_write_unlock(tty);
530+ return -ERESTARTSYS;
531+ }
532+ }
533+
534+ tty_set_termios(tty, &tmp_termios);
535+
536+ tty_write_unlock(tty);
537+ } else {
538+ tty_set_termios(tty, &tmp_termios);
539+ }
518540
519541 /* FIXME: Arguably if tmp_termios == tty->termios AND the
520542 actual requested termios was not tmp_termios then we may
drivers/tty/tty_ldisc.c+1−2
@@ -58,7 +58,6 @@ static struct tty_ldisc_ops *tty_ldiscs[NR_LDISCS]; · 57 unmodified lines
5858 int tty_register_ldisc(struct tty_ldisc_ops *new_ldisc)
5959 {
6060 unsigned long flags;
61− int ret = 0;
6261
6362 if (new_ldisc->num < N_TTY || new_ldisc->num >= NR_LDISCS)
6463 return -EINVAL;
@@ -67,7 +66,7 @@ int tty_register_ldisc(struct tty_ldisc_ops *new_ldisc) · 2 unmodified lines
6766 tty_ldiscs[new_ldisc->num] = new_ldisc;
6867 raw_spin_unlock_irqrestore(&tty_ldiscs_lock, flags);
6968
70− return ret;
69+ return 0;
7170 }
7271 EXPORT_SYMBOL(tty_register_ldisc);
7372
drivers/tty/vt/vt.c+92−113
@@ -135,10 +135,9 @@ const struct consw *conswitchp; · 134 unmodified lines
135135 #define DEFAULT_CURSOR_BLINK_MS 200
136136
137137 struct vc vc_cons [MAX_NR_CONSOLES];
138+EXPORT_SYMBOL(vc_cons);
138139
139−#ifndef VT_SINGLE_DRIVER
140140 static const struct consw *con_driver_map[MAX_NR_CONSOLES];
141−#endif
142141
143142 static int con_open(struct tty_struct *, struct file *);
144143 static void vc_init(struct vc_data *vc, unsigned int rows,
@@ -162,6 +161,7 @@ int default_utf8 = true; · 17 unmodified lines
162161 module_param(default_utf8, int, S_IRUGO | S_IWUSR);
163162 int global_cursor_default = -1;
164163 module_param(global_cursor_default, int, S_IRUGO | S_IWUSR);
164+EXPORT_SYMBOL(global_cursor_default);
165165
166166 static int cur_default = CUR_UNDERLINE;
167167 module_param(cur_default, int, S_IRUGO | S_IWUSR);
@@ -174,6 +174,7 @@ static int ignore_poke; · 6 unmodified lines
174174
175175 int do_poke_blanked_console;
176176 int console_blanked;
177+EXPORT_SYMBOL(console_blanked);
177178
178179 static int vesa_blank_mode; /* 0:none 1:suspendV 2:suspendH 3:powerdown */
179180 static int vesa_off_interval;
@@ -190,8 +191,10 @@ static DECLARE_WORK(con_driver_unregister_work, con_driver_unregister_callback); · 10 unmodified lines
190191 * saved_* variants are for save/restore around kernel debugger enter/leave
191192 */
192193 int fg_console;
194+EXPORT_SYMBOL(fg_console);
193195 int last_console;
194196 int want_console = -1;
197+
195198 static int saved_fg_console;
196199 static int saved_last_console;
197200 static int saved_want_console;
@@ -223,6 +226,7 @@ static int scrollback_delta; · 25 unmodified lines
223226 * the console on our behalf.
224227 */
225228 int (*console_blank_hook)(int);
229+EXPORT_SYMBOL(console_blank_hook);
226230
227231 static DEFINE_TIMER(console_timer, blank_screen_t);
228232 static int blank_state;
@@ -639,6 +643,7 @@ void update_region(struct vc_data *vc, unsigned long start, int count) · 410 unmodified lines
639643 set_cursor(vc);
640644 }
641645 }
646+EXPORT_SYMBOL(update_region);
642647
643648 /* Structure of attributes is hardware-dependent */
644649
@@ -984,6 +989,7 @@ void redraw_screen(struct vc_data *vc, int is_switch) · 339 unmodified lines
984989 notify_update(vc);
985990 }
986991 }
992+EXPORT_SYMBOL(redraw_screen);
987993
988994 /*
989995 * Allocation, freeing and resizing of VTs.
@@ -1000,10 +1006,10 @@ static void visual_init(struct vc_data *vc, int num, int init) · 10 unmodified lines
10001006 if (vc->vc_sw)
10011007 module_put(vc->vc_sw->owner);
10021008 vc->vc_sw = conswitchp;
1003−#ifndef VT_SINGLE_DRIVER
1009+
10041010 if (con_driver_map[num])
10051011 vc->vc_sw = con_driver_map[num];
1006−#endif
1012+
10071013 __module_get(vc->vc_sw->owner);
10081014 vc->vc_num = num;
10091015 vc->vc_display_fg = &master_display_fg;
@@ -1305,6 +1311,7 @@ int vc_resize(struct vc_data *vc, unsigned int cols, unsigned int rows) · 295 unmodified lines
13051311 {
13061312 return vc_do_resize(vc->port.tty, vc, cols, rows);
13071313 }
1314+EXPORT_SYMBOL(vc_resize);
13081315
13091316 /**
13101317 * vt_resize - resize a VT
@@ -1368,6 +1375,7 @@ enum { EPecma = 0, EPdec, EPeq, EPgt, EPlt}; · 57 unmodified lines
13681375
13691376 const unsigned char color_table[] = { 0, 4, 2, 6, 1, 5, 3, 7,
13701377 8,12,10,14, 9,13,11,15 };
1378+EXPORT_SYMBOL(color_table);
13711379
13721380 /* the default colour table, for VGA+ colour systems */
13731381 unsigned char default_red[] = {
@@ -1375,18 +1383,21 @@ unsigned char default_red[] = { · 1 unmodified line
13751383 0x55, 0xff, 0x55, 0xff, 0x55, 0xff, 0x55, 0xff
13761384 };
13771385 module_param_array(default_red, byte, NULL, S_IRUGO | S_IWUSR);
1386+EXPORT_SYMBOL(default_red);
13781387
13791388 unsigned char default_grn[] = {
13801389 0x00, 0x00, 0xaa, 0x55, 0x00, 0x00, 0xaa, 0xaa,
13811390 0x55, 0x55, 0xff, 0xff, 0x55, 0x55, 0xff, 0xff
13821391 };
13831392 module_param_array(default_grn, byte, NULL, S_IRUGO | S_IWUSR);
1393+EXPORT_SYMBOL(default_grn);
13841394
13851395 unsigned char default_blu[] = {
13861396 0x00, 0x00, 0x00, 0x00, 0xaa, 0xaa, 0xaa, 0xaa,
13871397 0x55, 0x55, 0x55, 0x55, 0xff, 0xff, 0xff, 0xff
13881398 };
13891399 module_param_array(default_blu, byte, NULL, S_IRUGO | S_IWUSR);
1400+EXPORT_SYMBOL(default_blu);
13901401
13911402 /*
13921403 * gotoxy() must verify all boundaries, because the arguments
@@ -3143,93 +3154,84 @@ int tioclinux(struct tty_struct *tty, unsigned long arg) · 1750 unmodified lines
31433154 return -EFAULT;
31443155 ret = 0;
31453156
3146− switch (type)
3147− {
3148− case TIOCL_SETSEL:
3149− ret = set_selection_user((struct tiocl_selection
3150− __user *)(p+1), tty);
3151− break;
3152− case TIOCL_PASTESEL:
3153− ret = paste_selection(tty);
3154− break;
3155− case TIOCL_UNBLANKSCREEN:
3156− console_lock();
3157− unblank_screen();
3158− console_unlock();
3159− break;
3160− case TIOCL_SELLOADLUT:
3161− console_lock();
3162− ret = sel_loadlut(p);
3163− console_unlock();
3164− break;
3165− case TIOCL_GETSHIFTSTATE:
3157+ switch (type) {
3158+ case TIOCL_SETSEL:
3159+ return set_selection_user((struct tiocl_selection
3160+ __user *)(p+1), tty);
3161+ case TIOCL_PASTESEL:
3162+ return paste_selection(tty);
3163+ case TIOCL_UNBLANKSCREEN:
3164+ console_lock();
3165+ unblank_screen();
3166+ console_unlock();
3167+ break;
3168+ case TIOCL_SELLOADLUT:
3169+ console_lock();
3170+ ret = sel_loadlut(p);
3171+ console_unlock();
3172+ break;
3173+ case TIOCL_GETSHIFTSTATE:
3174+ /*
3175+ * Make it possible to react to Shift+Mousebutton. Note that
3176+ * 'shift_state' is an undocumented kernel-internal variable;
3177+ * programs not closely related to the kernel should not use
3178+ * this.
3179+ */
3180+ data = vt_get_shift_state();
3181+ return put_user(data, p);
3182+ case TIOCL_GETMOUSEREPORTING:
3183+ console_lock(); /* May be overkill */
3184+ data = mouse_reporting();
3185+ console_unlock();
3186+ return put_user(data, p);
3187+ case TIOCL_SETVESABLANK:
3188+ console_lock();
3189+ ret = set_vesa_blanking(p);
3190+ console_unlock();
3191+ break;
3192+ case TIOCL_GETKMSGREDIRECT:
3193+ data = vt_get_kmsg_redirect();
3194+ return put_user(data, p);
3195+ case TIOCL_SETKMSGREDIRECT:
3196+ if (!capable(CAP_SYS_ADMIN))
3197+ return -EPERM;
31663198
3167− /*
3168− * Make it possible to react to Shift+Mousebutton.
3169− * Note that 'shift_state' is an undocumented
3170− * kernel-internal variable; programs not closely
3171− * related to the kernel should not use this.
3172− */
3173− data = vt_get_shift_state();
3174− ret = put_user(data, p);
3175− break;
3176− case TIOCL_GETMOUSEREPORTING:
3177− console_lock(); /* May be overkill */
3178− data = mouse_reporting();
3179− console_unlock();
3180− ret = put_user(data, p);
3181− break;
3182− case TIOCL_SETVESABLANK:
3183− console_lock();
3184− ret = set_vesa_blanking(p);
3185− console_unlock();
3186− break;
3187− case TIOCL_GETKMSGREDIRECT:
3188− data = vt_get_kmsg_redirect();
3189− ret = put_user(data, p);
3190− break;
3191− case TIOCL_SETKMSGREDIRECT:
3192− if (!capable(CAP_SYS_ADMIN)) {
3193− ret = -EPERM;
3194− } else {
3195− if (get_user(data, p+1))
3196− ret = -EFAULT;
3197− else
3198− vt_kmsg_redirect(data);
3199− }
3200− break;
3201− case TIOCL_GETFGCONSOLE:
3202− /* No locking needed as this is a transiently
3203− correct return anyway if the caller hasn't
3204− disabled switching */
3205− ret = fg_console;
3206− break;
3207− case TIOCL_SCROLLCONSOLE:
3208− if (get_user(lines, (s32 __user *)(p+4))) {
3209− ret = -EFAULT;
3210− } else {
3211− /* Need the console lock here. Note that lots
3212− of other calls need fixing before the lock
3213− is actually useful ! */
3214− console_lock();
3215− scrollfront(vc_cons[fg_console].d, lines);
3216− console_unlock();
3217− ret = 0;
3218− }
3219− break;
3220− case TIOCL_BLANKSCREEN: /* until explicitly unblanked, not only poked */
3221− console_lock();
3222− ignore_poke = 1;
3223− do_blank_screen(0);
3224− console_unlock();
3225− break;
3226− case TIOCL_BLANKEDSCREEN:
3227− ret = console_blanked;
3228− break;
3229− default:
3230− ret = -EINVAL;
3231− break;
3199+ if (get_user(data, p+1))
3200+ return -EFAULT;
3201+
3202+ vt_kmsg_redirect(data);
3203+
3204+ break;
3205+ case TIOCL_GETFGCONSOLE:
3206+ /*
3207+ * No locking needed as this is a transiently correct return
3208+ * anyway if the caller hasn't disabled switching.
3209+ */
3210+ return fg_console;
3211+ case TIOCL_SCROLLCONSOLE:
3212+ if (get_user(lines, (s32 __user *)(p+4)))
3213+ return -EFAULT;
3214+
3215+ /*
3216+ * Needs the console lock here. Note that lots of other calls
3217+ * need fixing before the lock is actually useful!
3218+ */
3219+ console_lock();
3220+ scrollfront(vc_cons[fg_console].d, lines);
3221+ console_unlock();
3222+ break;
3223+ case TIOCL_BLANKSCREEN: /* until explicitly unblanked, not only poked */
3224+ console_lock();
3225+ ignore_poke = 1;
3226+ do_blank_screen(0);
3227+ console_unlock();
3228+ break;
3229+ case TIOCL_BLANKEDSCREEN:
3230+ return console_blanked;
3231+ default:
3232+ return -EINVAL;
32323233 }
3234+
32333235 return ret;
32343236 }
32353237
@@ -3571,8 +3573,6 @@ int __init vty_init(const struct file_operations *console_fops) · 335 unmodified lines
35713573 return 0;
35723574 }
35733575
3574−#ifndef VT_SINGLE_DRIVER
3575−
35763576 static struct class *vtconsole_class;
35773577
35783578 static int do_bind_con_driver(const struct consw *csw, int first, int last,
@@ -4236,6 +4236,7 @@ void give_up_console(const struct consw *csw) · 657 unmodified lines
42364236 do_unregister_con_driver(csw);
42374237 console_unlock();
42384238 }
4239+EXPORT_SYMBOL(give_up_console);
42394240
42404241 static int __init vtconsole_class_init(void)
42414242 {
@@ -4273,8 +4274,6 @@ static int __init vtconsole_class_init(void) · 31 unmodified lines
42734274 }
42744275 postcore_initcall(vtconsole_class_init);
42754276
4276−#endif
4277−
42784277 /*
42794278 * Screen blanking
42804279 */
@@ -4792,23 +4791,3 @@ void vc_scrolldelta_helper(struct vc_data *c, int lines, · 511 unmodified lines
47924791 c->vc_visible_origin = ubase + (from + from_off) % wrap;
47934792 }
47944793 EXPORT_SYMBOL_GPL(vc_scrolldelta_helper);
4795−
4796−/*
4797− * Visible symbols for modules
4798− */
4799−
4800−EXPORT_SYMBOL(color_table);
4801−EXPORT_SYMBOL(default_red);
4802−EXPORT_SYMBOL(default_grn);
4803−EXPORT_SYMBOL(default_blu);
4804−EXPORT_SYMBOL(update_region);
4805−EXPORT_SYMBOL(redraw_screen);
4806−EXPORT_SYMBOL(vc_resize);
4807−EXPORT_SYMBOL(fg_console);
4808−EXPORT_SYMBOL(console_blank_hook);
4809−EXPORT_SYMBOL(console_blanked);
4810−EXPORT_SYMBOL(vc_cons);
4811−EXPORT_SYMBOL(global_cursor_default);
4812−#ifndef VT_SINGLE_DRIVER
4813−EXPORT_SYMBOL(give_up_console);
4814−#endif
include/linux/serial_8250.h+20−25
@@ -18,16 +18,16 @@ struct plat_serial8250_port { · 17 unmodified lines
1818 unsigned long iobase; /* io base address */
1919 void __iomem *membase; /* ioremap cookie or NULL */
2020 resource_size_t mapbase; /* resource base */
21+ unsigned int uartclk; /* UART clock rate */
2122 unsigned int irq; /* interrupt number */
2223 unsigned long irqflags; /* request_irq flags */
23− unsigned int uartclk; /* UART clock rate */
2424 void *private_data;
2525 unsigned char regshift; /* register shift */
2626 unsigned char iotype; /* UPIO_* */
2727 unsigned char hub6;
2828 unsigned char has_sysrq; /* supports magic SysRq */
29− upf_t flags; /* UPF_* flags */
3029 unsigned int type; /* If UPF_FIXED_TYPE */
30+ upf_t flags; /* UPF_* flags */
3131 unsigned int (*serial_in)(struct uart_port *, int);
3232 void (*serial_out)(struct uart_port *, int, int);
3333 void (*set_termios)(struct uart_port *,
@@ -151,26 +151,22 @@ void serial8250_unregister_port(int line); · 117 unmodified lines
151151 void serial8250_suspend_port(int line);
152152 void serial8250_resume_port(int line);
153153
154−extern int early_serial_setup(struct uart_port *port);
155−
156−extern int early_serial8250_setup(struct earlycon_device *device,
157− const char *options);
158−extern void serial8250_update_uartclk(struct uart_port *port,
159− unsigned int uartclk);
160−extern void serial8250_do_set_termios(struct uart_port *port,
161− struct ktermios *termios, const struct ktermios *old);
162−extern void serial8250_do_set_ldisc(struct uart_port *port,
163− struct ktermios *termios);
164−extern unsigned int serial8250_do_get_mctrl(struct uart_port *port);
165−extern int serial8250_do_startup(struct uart_port *port);
166−extern void serial8250_do_shutdown(struct uart_port *port);
167−extern void serial8250_do_pm(struct uart_port *port, unsigned int state,
168− unsigned int oldstate);
169−extern void serial8250_do_set_mctrl(struct uart_port *port, unsigned int mctrl);
170−extern void serial8250_do_set_divisor(struct uart_port *port, unsigned int baud,
171− unsigned int quot,
172− unsigned int quot_frac);
173−extern int fsl8250_handle_irq(struct uart_port *port);
154+int early_serial_setup(struct uart_port *port);
155+int early_serial8250_setup(struct earlycon_device *device, const char *options);
156+
157+void serial8250_update_uartclk(struct uart_port *port, unsigned int uartclk);
158+void serial8250_do_set_termios(struct uart_port *port, struct ktermios *termios,
159+ const struct ktermios *old);
160+void serial8250_do_set_ldisc(struct uart_port *port, struct ktermios *termios);
161+unsigned int serial8250_do_get_mctrl(struct uart_port *port);
162+int serial8250_do_startup(struct uart_port *port);
163+void serial8250_do_shutdown(struct uart_port *port);
164+void serial8250_do_pm(struct uart_port *port, unsigned int state,
165+ unsigned int oldstate);
166+void serial8250_do_set_mctrl(struct uart_port *port, unsigned int mctrl);
167+void serial8250_do_set_divisor(struct uart_port *port, unsigned int baud,
168+ unsigned int quot, unsigned int quot_frac);
169+int fsl8250_handle_irq(struct uart_port *port);
174170 int serial8250_handle_irq(struct uart_port *port, unsigned int iir);
175171 u16 serial8250_rx_chars(struct uart_8250_port *up, u16 lsr);
176172 void serial8250_read_char(struct uart_8250_port *up, u16 lsr);
@@ -183,9 +179,8 @@ void serial8250_console_write(struct uart_8250_port *up, const char *s, · 6 unmodified lines
183179 int serial8250_console_setup(struct uart_port *port, char *options, bool probe);
184180 int serial8250_console_exit(struct uart_port *port);
185181
186−extern void serial8250_set_isa_configurator(void (*v)
187− (int port, struct uart_port *up,
188− u32 *capabilities));
182+void serial8250_set_isa_configurator(void (*v)(int port, struct uart_port *up,
183+ u32 *capabilities));
189184
190185 #ifdef CONFIG_SERIAL_8250_RT288X
191186 unsigned int au_serial_in(struct uart_port *p, int offset);
include/linux/serial_core.h+7−8
@@ -553,7 +553,7 @@ struct uart_port { · 552 unmodified lines
553553 #define UPSTAT_AUTOXOFF ((__force upstat_t) (1 << 4))
554554 #define UPSTAT_SYNC_FIFO ((__force upstat_t) (1 << 5))
555555
556− int hw_stopped; /* sw-assisted CTS flow state */
556+ bool hw_stopped; /* sw-assisted CTS flow state */
557557 unsigned int mctrl; /* current modem ctrl settings */
558558 unsigned int frame_time; /* frame timing in ns */
559559 unsigned int type; /* port type */
@@ -812,9 +812,8 @@ extern const struct earlycon_id __earlycon_table_end[]; · 252 unmodified lines
812812
813813 #define EARLYCON_DECLARE(_name, fn) OF_EARLYCON_DECLARE(_name, "", fn)
814814
815−extern int of_setup_earlycon(const struct earlycon_id *match,
816− unsigned long node,
817− const char *options);
815+int of_setup_earlycon(const struct earlycon_id *match, unsigned long node,
816+ const char *options);
818817
819818 #ifdef CONFIG_SERIAL_EARLYCON
820819 extern bool earlycon_acpi_spcr_enable __initdata;
@@ -897,11 +896,11 @@ static inline bool uart_softcts_mode(struct uart_port *uport) · 76 unmodified lines
897896 * The following are helper functions for the low level drivers.
898897 */
899898
900−extern void uart_handle_dcd_change(struct uart_port *uport, bool active);
901−extern void uart_handle_cts_change(struct uart_port *uport, bool active);
899+void uart_handle_dcd_change(struct uart_port *uport, bool active);
900+void uart_handle_cts_change(struct uart_port *uport, bool active);
902901
903−extern void uart_insert_char(struct uart_port *port, unsigned int status,
904− unsigned int overrun, unsigned int ch, unsigned int flag);
902+void uart_insert_char(struct uart_port *port, unsigned int status,
903+ unsigned int overrun, unsigned int ch, unsigned int flag);
905904
906905 void uart_xchar_out(struct uart_port *uport, int offset);
907906
include/linux/tty.h+1−1
@@ -227,7 +227,7 @@ struct tty_struct { · 226 unmodified lines
227227 unsigned long unused[0];
228228 } __aligned(sizeof(unsigned long)) ctrl;
229229
230− int hw_stopped;
230+ bool hw_stopped;
231231 unsigned int receive_room;
232232 int flow_change;
233233
include/uapi/linux/gsmmux.h+16−1
@@ -43,10 +43,25 @@ struct gsm_config_ext { · 42 unmodified lines
4343 __u32 keep_alive; /* Control channel keep-alive in 1/100th of a
4444 * second (0 to disable)
4545 */
46− __u32 reserved[7]; /* For future use, must be initialized to zero */
46+ __u32 wait_config; /* Wait for DLCI config before opening virtual link? */
47+ __u32 reserved[6]; /* For future use, must be initialized to zero */
4748 };
4849
4950 #define GSMIOC_GETCONF_EXT _IOR('G', 5, struct gsm_config_ext)
5051 #define GSMIOC_SETCONF_EXT _IOW('G', 6, struct gsm_config_ext)
5152
53+/* Set channel accordingly before calling GSMIOC_GETCONF_DLCI. */
54+struct gsm_dlci_config {
55+ __u32 channel; /* DLCI (0 for the associated DLCI) */
56+ __u32 adaption; /* Convergence layer type */
57+ __u32 mtu; /* Maximum transfer unit */
58+ __u32 priority; /* Priority (0 for default value) */
59+ __u32 i; /* Frame type (1 = UIH, 2 = UI) */
60+ __u32 k; /* Window size (0 for default value) */
61+ __u32 reserved[8]; /* For future use, must be initialized to zero */
62+};
63+
64+#define GSMIOC_GETCONF_DLCI _IOWR('G', 7, struct gsm_dlci_config)
65+#define GSMIOC_SETCONF_DLCI _IOW('G', 8, struct gsm_dlci_config)
66+
5267 #endif