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

Configure Feed

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

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

Pull tty/serial driver updates from Greg KH:
"Here is the big set of TTY and Serial driver updates for 6.1-rc1.

Lots of cleanups in here, no real new functionality this time around,
with the diffstat being that we removed more lines than we added!

Included in here are:

- termios unification cleanups from Al Viro, it's nice to finally get
this work done

- tty serial transmit cleanups in various drivers in preparation for
more cleanup and unification in future releases (that work was not
ready for this release)

- n_gsm fixes and updates

- ktermios cleanups and code reductions

- dt bindings json conversions and updates for new devices

- some serial driver updates for new devices

- lots of other tiny cleanups and janitorial stuff. Full details in
the shortlog.

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

* tag 'tty-6.1-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/tty: (102 commits)
serial: cpm_uart: Don't request IRQ too early for console port
tty: serial: do unlock on a common path in altera_jtaguart_console_putc()
tty: serial: unify TX space reads under altera_jtaguart_tx_space()
tty: serial: use FIELD_GET() in lqasc_tx_ready()
tty: serial: extend lqasc_tx_ready() to lqasc_console_putchar()
tty: serial: allow pxa.c to be COMPILE_TESTed
serial: stm32: Fix unused-variable warning
tty: serial: atmel: Add COMMON_CLK dependency to SERIAL_ATMEL
serial: 8250: Fix restoring termios speed after suspend
serial: Deassert Transmit Enable on probe in driver-specific way
serial: 8250_dma: Convert to use uart_xmit_advance()
serial: 8250_omap: Convert to use uart_xmit_advance()
MAINTAINERS: Solve warning regarding inexistent atmel-usart binding
serial: stm32: Deassert Transmit Enable on ->rs485_config()
serial: ar933x: Deassert Transmit Enable on ->rs485_config()
tty: serial: atmel: Use FIELD_PREP/FIELD_GET
tty: serial: atmel: Make the driver aware of the existence of GCLK
tty: serial: atmel: Only divide Clock Divisor if the IP is USART
tty: serial: atmel: Separate mode clearing between UART and USART
dt-bindings: serial: atmel,at91-usart: Add gclk as a possible USART clock
...

+1433 -1765
-98
Documentation/devicetree/bindings/mfd/atmel-usart.txt
··· 1 - * Atmel Universal Synchronous Asynchronous Receiver/Transmitter (USART) 2 - 3 - Required properties for USART: 4 - - compatible: Should be one of the following: 5 - - "atmel,at91rm9200-usart" 6 - - "atmel,at91sam9260-usart" 7 - - "microchip,sam9x60-usart" 8 - - "atmel,at91rm9200-dbgu", "atmel,at91rm9200-usart" 9 - - "atmel,at91sam9260-dbgu", "atmel,at91sam9260-usart" 10 - - "microchip,sam9x60-dbgu", "microchip,sam9x60-usart" 11 - - reg: Should contain registers location and length 12 - - interrupts: Should contain interrupt 13 - - clock-names: tuple listing input clock names. 14 - Required elements: "usart" 15 - - clocks: phandles to input clocks. 16 - 17 - Required properties for USART in SPI mode: 18 - - #size-cells : Must be <0> 19 - - #address-cells : Must be <1> 20 - - cs-gpios: chipselects (internal cs not supported) 21 - - atmel,usart-mode : Must be <AT91_USART_MODE_SPI> (found in dt-bindings/mfd/at91-usart.h) 22 - 23 - Optional properties in serial and SPI mode: 24 - - dma bindings for dma transfer: 25 - - dmas: DMA specifier, consisting of a phandle to DMA controller node, 26 - memory peripheral interface and USART DMA channel ID, FIFO configuration. 27 - The order of DMA channels is fixed. The first DMA channel must be TX 28 - associated channel and the second one must be RX associated channel. 29 - Refer to dma.txt and atmel-dma.txt for details. 30 - - dma-names: "tx" for TX channel. 31 - "rx" for RX channel. 32 - The order of dma-names is also fixed. The first name must be "tx" 33 - and the second one must be "rx" as in the examples below. 34 - 35 - Optional properties in serial mode: 36 - - atmel,use-dma-rx: use of PDC or DMA for receiving data 37 - - atmel,use-dma-tx: use of PDC or DMA for transmitting data 38 - - {rts,cts,dtr,dsr,rng,dcd}-gpios: specify a GPIO for RTS/CTS/DTR/DSR/RI/DCD line respectively. 39 - It will use specified PIO instead of the peripheral function pin for the USART feature. 40 - If unsure, don't specify this property. 41 - - atmel,fifo-size: maximum number of data the RX and TX FIFOs can store for FIFO 42 - capable USARTs. 43 - - rs485-rts-delay, rs485-rx-during-tx, linux,rs485-enabled-at-boot-time: see rs485.txt 44 - 45 - <chip> compatible description: 46 - - at91rm9200: legacy USART support 47 - - at91sam9260: generic USART implementation for SAM9 SoCs 48 - 49 - Example: 50 - - use PDC: 51 - usart0: serial@fff8c000 { 52 - compatible = "atmel,at91sam9260-usart"; 53 - reg = <0xfff8c000 0x4000>; 54 - interrupts = <7>; 55 - clocks = <&usart0_clk>; 56 - clock-names = "usart"; 57 - atmel,use-dma-rx; 58 - atmel,use-dma-tx; 59 - rts-gpios = <&pioD 15 GPIO_ACTIVE_LOW>; 60 - cts-gpios = <&pioD 16 GPIO_ACTIVE_LOW>; 61 - dtr-gpios = <&pioD 17 GPIO_ACTIVE_LOW>; 62 - dsr-gpios = <&pioD 18 GPIO_ACTIVE_LOW>; 63 - dcd-gpios = <&pioD 20 GPIO_ACTIVE_LOW>; 64 - rng-gpios = <&pioD 19 GPIO_ACTIVE_LOW>; 65 - }; 66 - 67 - - use DMA: 68 - usart0: serial@f001c000 { 69 - compatible = "atmel,at91sam9260-usart"; 70 - reg = <0xf001c000 0x100>; 71 - interrupts = <12 4 5>; 72 - clocks = <&usart0_clk>; 73 - clock-names = "usart"; 74 - atmel,use-dma-rx; 75 - atmel,use-dma-tx; 76 - dmas = <&dma0 2 0x3>, 77 - <&dma0 2 0x204>; 78 - dma-names = "tx", "rx"; 79 - atmel,fifo-size = <32>; 80 - }; 81 - 82 - - SPI mode: 83 - #include <dt-bindings/mfd/at91-usart.h> 84 - 85 - spi0: spi@f001c000 { 86 - #address-cells = <1>; 87 - #size-cells = <0>; 88 - compatible = "atmel,at91rm9200-usart", "atmel,at91sam9260-usart"; 89 - atmel,usart-mode = <AT91_USART_MODE_SPI>; 90 - reg = <0xf001c000 0x100>; 91 - interrupts = <12 IRQ_TYPE_LEVEL_HIGH 5>; 92 - clocks = <&usart0_clk>; 93 - clock-names = "usart"; 94 - dmas = <&dma0 2 AT91_DMA_CFG_PER_ID(3)>, 95 - <&dma0 2 (AT91_DMA_CFG_PER_ID(4) | AT91_DMA_CFG_FIFOCFG_ASAP)>; 96 - dma-names = "tx", "rx"; 97 - cs-gpios = <&pioB 3 0>; 98 - };
+190
Documentation/devicetree/bindings/serial/atmel,at91-usart.yaml
··· 1 + # SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause) 2 + # Copyright (C) 2022 Microchip Technology, Inc. and its subsidiaries 3 + %YAML 1.2 4 + --- 5 + $id: http://devicetree.org/schemas/serial/atmel,at91-usart.yaml# 6 + $schema: http://devicetree.org/meta-schemas/core.yaml# 7 + 8 + title: Atmel Universal Synchronous Asynchronous Receiver/Transmitter (USART) 9 + 10 + maintainers: 11 + - Richard Genoud <richard.genoud@gmail.com> 12 + 13 + properties: 14 + compatible: 15 + oneOf: 16 + - enum: 17 + - atmel,at91rm9200-usart 18 + - atmel,at91sam9260-usart 19 + - microchip,sam9x60-usart 20 + - items: 21 + - const: atmel,at91rm9200-dbgu 22 + - const: atmel,at91rm9200-usart 23 + - items: 24 + - const: atmel,at91sam9260-dbgu 25 + - const: atmel,at91sam9260-usart 26 + - items: 27 + - const: microchip,sam9x60-dbgu 28 + - const: microchip,sam9x60-usart 29 + - const: atmel,at91sam9260-dbgu 30 + - const: atmel,at91sam9260-usart 31 + 32 + reg: 33 + maxItems: 1 34 + 35 + interrupts: 36 + maxItems: 1 37 + 38 + clock-names: 39 + minItems: 1 40 + items: 41 + - const: usart 42 + - const: gclk 43 + 44 + clocks: 45 + minItems: 1 46 + items: 47 + - description: USART Peripheral Clock 48 + - description: USART Generic Clock 49 + 50 + dmas: 51 + items: 52 + - description: TX DMA Channel 53 + - description: RX DMA Channel 54 + 55 + dma-names: 56 + items: 57 + - const: tx 58 + - const: rx 59 + 60 + atmel,usart-mode: 61 + $ref: /schemas/types.yaml#/definitions/uint32 62 + description: 63 + Must be either <AT91_USART_MODE_SPI> for SPI or 64 + <AT91_USART_MODE_SERIAL> for USART (found in dt-bindings/mfd/at91-usart.h). 65 + enum: [ 0, 1 ] 66 + 67 + atmel,use-dma-rx: 68 + type: boolean 69 + description: use of PDC or DMA for receiving data 70 + 71 + atmel,use-dma-tx: 72 + type: boolean 73 + description: use of PDC or DMA for transmitting data 74 + 75 + atmel,fifo-size: 76 + $ref: /schemas/types.yaml#/definitions/uint32 77 + description: 78 + Maximum number of data the RX and TX FIFOs can store for FIFO 79 + capable USARTS. 80 + enum: [ 16, 32 ] 81 + 82 + required: 83 + - compatible 84 + - reg 85 + - interrupts 86 + - clock-names 87 + - clocks 88 + - atmel,usart-mode 89 + 90 + allOf: 91 + - if: 92 + properties: 93 + atmel,usart-mode: 94 + const: 1 95 + then: 96 + allOf: 97 + - $ref: /schemas/spi/spi-controller.yaml# 98 + 99 + properties: 100 + atmel,use-dma-rx: false 101 + 102 + atmel,use-dma-tx: false 103 + 104 + atmel,fifo-size: false 105 + 106 + "#size-cells": 107 + const: 0 108 + 109 + "#address-cells": 110 + const: 1 111 + 112 + required: 113 + - "#size-cells" 114 + - "#address-cells" 115 + 116 + else: 117 + allOf: 118 + - $ref: /schemas/serial/serial.yaml# 119 + - $ref: /schemas/serial/rs485.yaml# 120 + 121 + unevaluatedProperties: false 122 + 123 + examples: 124 + - | 125 + #include <dt-bindings/gpio/gpio.h> 126 + #include <dt-bindings/interrupt-controller/irq.h> 127 + #include <dt-bindings/mfd/at91-usart.h> 128 + #include <dt-bindings/dma/at91.h> 129 + 130 + /* use PDC */ 131 + usart0: serial@fff8c000 { 132 + compatible = "atmel,at91sam9260-usart"; 133 + reg = <0xfff8c000 0x4000>; 134 + atmel,usart-mode = <AT91_USART_MODE_SERIAL>; 135 + interrupts = <7>; 136 + clocks = <&usart0_clk>; 137 + clock-names = "usart"; 138 + atmel,use-dma-rx; 139 + atmel,use-dma-tx; 140 + rts-gpios = <&pioD 15 GPIO_ACTIVE_LOW>; 141 + cts-gpios = <&pioD 16 GPIO_ACTIVE_LOW>; 142 + dtr-gpios = <&pioD 17 GPIO_ACTIVE_LOW>; 143 + dsr-gpios = <&pioD 18 GPIO_ACTIVE_LOW>; 144 + dcd-gpios = <&pioD 20 GPIO_ACTIVE_LOW>; 145 + rng-gpios = <&pioD 19 GPIO_ACTIVE_LOW>; 146 + }; 147 + 148 + - | 149 + #include <dt-bindings/gpio/gpio.h> 150 + #include <dt-bindings/interrupt-controller/irq.h> 151 + #include <dt-bindings/mfd/at91-usart.h> 152 + #include <dt-bindings/dma/at91.h> 153 + 154 + /* use DMA */ 155 + usart1: serial@f001c000 { 156 + compatible = "atmel,at91sam9260-usart"; 157 + reg = <0xf001c000 0x100>; 158 + atmel,usart-mode = <AT91_USART_MODE_SERIAL>; 159 + interrupts = <12 IRQ_TYPE_LEVEL_HIGH 5>; 160 + clocks = <&usart0_clk>; 161 + clock-names = "usart"; 162 + atmel,use-dma-rx; 163 + atmel,use-dma-tx; 164 + dmas = <&dma0 2 AT91_DMA_CFG_PER_ID(3)>, 165 + <&dma0 2 (AT91_DMA_CFG_PER_ID(4) | AT91_DMA_CFG_FIFOCFG_ASAP)>; 166 + dma-names = "tx", "rx"; 167 + atmel,fifo-size = <32>; 168 + }; 169 + 170 + - | 171 + #include <dt-bindings/gpio/gpio.h> 172 + #include <dt-bindings/interrupt-controller/irq.h> 173 + #include <dt-bindings/mfd/at91-usart.h> 174 + #include <dt-bindings/dma/at91.h> 175 + 176 + /* SPI mode */ 177 + spi0: spi@f001c000 { 178 + compatible = "atmel,at91sam9260-usart"; 179 + reg = <0xf001c000 0x100>; 180 + #address-cells = <1>; 181 + #size-cells = <0>; 182 + atmel,usart-mode = <AT91_USART_MODE_SPI>; 183 + interrupts = <12 IRQ_TYPE_LEVEL_HIGH 5>; 184 + clocks = <&usart0_clk>; 185 + clock-names = "usart"; 186 + dmas = <&dma0 2 AT91_DMA_CFG_PER_ID(3)>, 187 + <&dma0 2 (AT91_DMA_CFG_PER_ID(4) | AT91_DMA_CFG_FIFOCFG_ASAP)>; 188 + dma-names = "tx", "rx"; 189 + cs-gpios = <&pioB 3 GPIO_ACTIVE_HIGH>; 190 + };
+1
Documentation/devicetree/bindings/serial/mediatek,uart.yaml
··· 42 42 - mediatek,mt8173-uart 43 43 - mediatek,mt8183-uart 44 44 - mediatek,mt8186-uart 45 + - mediatek,mt8188-uart 45 46 - mediatek,mt8192-uart 46 47 - mediatek,mt8195-uart 47 48 - mediatek,mt8516-uart
+6
Documentation/devicetree/bindings/serial/pl011.yaml
··· 94 94 resets: 95 95 maxItems: 1 96 96 97 + reg-io-width: 98 + description: 99 + The size (in bytes) of the IO accesses that should be performed 100 + on the device. 101 + enum: [1, 4] 102 + 97 103 required: 98 104 - compatible 99 105 - reg
+1 -1
Documentation/devicetree/bindings/serial/renesas,scif.yaml
··· 76 76 77 77 - items: 78 78 - enum: 79 - - renesas,scif-r9a07g043 # RZ/G2UL 79 + - renesas,scif-r9a07g043 # RZ/G2UL and RZ/Five 80 80 - renesas,scif-r9a07g054 # RZ/V2L 81 81 - const: renesas,scif-r9a07g044 # RZ/G2{L,LC} fallback 82 82
+3 -1
Documentation/devicetree/bindings/serial/samsung_uart.yaml
··· 40 40 description: | 41 41 The size (in bytes) of the IO accesses that should be performed 42 42 on the device. 43 - $ref: /schemas/types.yaml#/definitions/uint32 44 43 enum: [ 1, 4 ] 45 44 46 45 clocks: ··· 70 71 description: RX interrupt and optionally TX interrupt. 71 72 minItems: 1 72 73 maxItems: 2 74 + 75 + power-domains: 76 + maxItems: 1 73 77 74 78 samsung,uart-fifosize: 75 79 description: The fifo size supported by the UART channel.
+1
Documentation/devicetree/bindings/serial/snps-dw-apb-uart.yaml
··· 26 26 - rockchip,rk1808-uart 27 27 - rockchip,rk3036-uart 28 28 - rockchip,rk3066-uart 29 + - rockchip,rk3128-uart 29 30 - rockchip,rk3188-uart 30 31 - rockchip,rk3288-uart 31 32 - rockchip,rk3308-uart
-4
Documentation/process/magic-number.rst
··· 71 71 PG_MAGIC 'P' pg_{read,write}_hdr ``include/linux/pg.h`` 72 72 CMAGIC 0x0111 user ``include/linux/a.out.h`` 73 73 MKISS_DRIVER_MAGIC 0x04bf mkiss_channel ``drivers/net/mkiss.h`` 74 - HDLC_MAGIC 0x239e n_hdlc ``drivers/char/n_hdlc.c`` 75 74 APM_BIOS_MAGIC 0x4101 apm_user ``arch/x86/kernel/apm_32.c`` 76 75 DB_MAGIC 0x4442 fc_info ``drivers/net/iph5526_novram.c`` 77 76 DL_MAGIC 0x444d fc_info ``drivers/net/iph5526_novram.c`` ··· 83 84 STRIP_MAGIC 0x5303 strip ``drivers/net/strip.c`` 84 85 SIXPACK_MAGIC 0x5304 sixpack ``drivers/net/hamradio/6pack.h`` 85 86 AX25_MAGIC 0x5316 ax_disp ``drivers/net/mkiss.h`` 86 - TTY_MAGIC 0x5401 tty_struct ``include/linux/tty.h`` 87 - MGSL_MAGIC 0x5401 mgsl_info ``drivers/char/synclink.c`` 88 - TTY_DRIVER_MAGIC 0x5402 tty_driver ``include/linux/tty_driver.h`` 89 87 MGSLPC_MAGIC 0x5402 mgslpc_info ``drivers/char/pcmcia/synclink_cs.c`` 90 88 USB_SERIAL_MAGIC 0x6702 usb_serial ``drivers/usb/serial/usb-serial.h`` 91 89 FULL_DUPLEX_MAGIC 0x6969 ``drivers/net/ethernet/dec/tulip/de2104x.c``
-4
Documentation/translations/it_IT/process/magic-number.rst
··· 77 77 PG_MAGIC 'P' pg_{read,write}_hdr ``include/linux/pg.h`` 78 78 CMAGIC 0x0111 user ``include/linux/a.out.h`` 79 79 MKISS_DRIVER_MAGIC 0x04bf mkiss_channel ``drivers/net/mkiss.h`` 80 - HDLC_MAGIC 0x239e n_hdlc ``drivers/char/n_hdlc.c`` 81 80 APM_BIOS_MAGIC 0x4101 apm_user ``arch/x86/kernel/apm_32.c`` 82 81 DB_MAGIC 0x4442 fc_info ``drivers/net/iph5526_novram.c`` 83 82 DL_MAGIC 0x444d fc_info ``drivers/net/iph5526_novram.c`` ··· 89 90 STRIP_MAGIC 0x5303 strip ``drivers/net/strip.c`` 90 91 SIXPACK_MAGIC 0x5304 sixpack ``drivers/net/hamradio/6pack.h`` 91 92 AX25_MAGIC 0x5316 ax_disp ``drivers/net/mkiss.h`` 92 - TTY_MAGIC 0x5401 tty_struct ``include/linux/tty.h`` 93 - MGSL_MAGIC 0x5401 mgsl_info ``drivers/char/synclink.c`` 94 - TTY_DRIVER_MAGIC 0x5402 tty_driver ``include/linux/tty_driver.h`` 95 93 MGSLPC_MAGIC 0x5402 mgslpc_info ``drivers/char/pcmcia/synclink_cs.c`` 96 94 USB_SERIAL_MAGIC 0x6702 usb_serial ``drivers/usb/serial/usb-serial.h`` 97 95 FULL_DUPLEX_MAGIC 0x6969 ``drivers/net/ethernet/dec/tulip/de2104x.c``
-4
Documentation/translations/zh_CN/process/magic-number.rst
··· 60 60 PG_MAGIC 'P' pg_{read,write}_hdr ``include/linux/pg.h`` 61 61 CMAGIC 0x0111 user ``include/linux/a.out.h`` 62 62 MKISS_DRIVER_MAGIC 0x04bf mkiss_channel ``drivers/net/mkiss.h`` 63 - HDLC_MAGIC 0x239e n_hdlc ``drivers/char/n_hdlc.c`` 64 63 APM_BIOS_MAGIC 0x4101 apm_user ``arch/x86/kernel/apm_32.c`` 65 64 DB_MAGIC 0x4442 fc_info ``drivers/net/iph5526_novram.c`` 66 65 DL_MAGIC 0x444d fc_info ``drivers/net/iph5526_novram.c`` ··· 72 73 STRIP_MAGIC 0x5303 strip ``drivers/net/strip.c`` 73 74 SIXPACK_MAGIC 0x5304 sixpack ``drivers/net/hamradio/6pack.h`` 74 75 AX25_MAGIC 0x5316 ax_disp ``drivers/net/mkiss.h`` 75 - TTY_MAGIC 0x5401 tty_struct ``include/linux/tty.h`` 76 - MGSL_MAGIC 0x5401 mgsl_info ``drivers/char/synclink.c`` 77 - TTY_DRIVER_MAGIC 0x5402 tty_driver ``include/linux/tty_driver.h`` 78 76 MGSLPC_MAGIC 0x5402 mgslpc_info ``drivers/char/pcmcia/synclink_cs.c`` 79 77 USB_SERIAL_MAGIC 0x6702 usb_serial ``drivers/usb/serial/usb-serial.h`` 80 78 FULL_DUPLEX_MAGIC 0x6969 ``drivers/net/ethernet/dec/tulip/de2104x.c``
-4
Documentation/translations/zh_TW/process/magic-number.rst
··· 63 63 PG_MAGIC 'P' pg_{read,write}_hdr ``include/linux/pg.h`` 64 64 CMAGIC 0x0111 user ``include/linux/a.out.h`` 65 65 MKISS_DRIVER_MAGIC 0x04bf mkiss_channel ``drivers/net/mkiss.h`` 66 - HDLC_MAGIC 0x239e n_hdlc ``drivers/char/n_hdlc.c`` 67 66 APM_BIOS_MAGIC 0x4101 apm_user ``arch/x86/kernel/apm_32.c`` 68 67 DB_MAGIC 0x4442 fc_info ``drivers/net/iph5526_novram.c`` 69 68 DL_MAGIC 0x444d fc_info ``drivers/net/iph5526_novram.c`` ··· 75 76 STRIP_MAGIC 0x5303 strip ``drivers/net/strip.c`` 76 77 SIXPACK_MAGIC 0x5304 sixpack ``drivers/net/hamradio/6pack.h`` 77 78 AX25_MAGIC 0x5316 ax_disp ``drivers/net/mkiss.h`` 78 - TTY_MAGIC 0x5401 tty_struct ``include/linux/tty.h`` 79 - MGSL_MAGIC 0x5401 mgsl_info ``drivers/char/synclink.c`` 80 - TTY_DRIVER_MAGIC 0x5402 tty_driver ``include/linux/tty_driver.h`` 81 79 MGSLPC_MAGIC 0x5402 mgslpc_info ``drivers/char/pcmcia/synclink_cs.c`` 82 80 USB_SERIAL_MAGIC 0x6702 usb_serial ``drivers/usb/serial/usb-serial.h`` 83 81 FULL_DUPLEX_MAGIC 0x6969 ``drivers/net/ethernet/dec/tulip/de2104x.c``
+3 -3
MAINTAINERS
··· 13339 13339 MICROCHIP AT91 SERIAL DRIVER 13340 13340 M: Richard Genoud <richard.genoud@gmail.com> 13341 13341 S: Maintained 13342 - F: Documentation/devicetree/bindings/mfd/atmel-usart.txt 13342 + F: Documentation/devicetree/bindings/serial/atmel,at91-usart.yaml 13343 13343 F: drivers/tty/serial/atmel_serial.c 13344 13344 F: drivers/tty/serial/atmel_serial.h 13345 13345 ··· 13347 13347 M: Radu Pirea <radu_nicolae.pirea@upb.ro> 13348 13348 L: linux-kernel@vger.kernel.org 13349 13349 S: Supported 13350 - F: Documentation/devicetree/bindings/mfd/atmel-usart.txt 13350 + F: Documentation/devicetree/bindings/serial/atmel,at91-usart.yaml 13351 13351 F: drivers/mfd/at91-usart.c 13352 13352 F: include/dt-bindings/mfd/at91-usart.h 13353 13353 ··· 13355 13355 M: Radu Pirea <radu_nicolae.pirea@upb.ro> 13356 13356 L: linux-spi@vger.kernel.org 13357 13357 S: Supported 13358 - F: Documentation/devicetree/bindings/mfd/atmel-usart.txt 13358 + F: Documentation/devicetree/bindings/serial/atmel,at91-usart.yaml 13359 13359 F: drivers/spi/spi-at91-usart.c 13360 13360 13361 13361 MICROCHIP AUDIO ASOC DRIVERS
-87
arch/alpha/include/asm/termios.h
··· 1 - /* SPDX-License-Identifier: GPL-2.0 */ 2 - #ifndef _ALPHA_TERMIOS_H 3 - #define _ALPHA_TERMIOS_H 4 - 5 - #include <uapi/asm/termios.h> 6 - 7 - /* eof=^D eol=\0 eol2=\0 erase=del 8 - werase=^W kill=^U reprint=^R sxtc=\0 9 - intr=^C quit=^\ susp=^Z <OSF/1 VDSUSP> 10 - start=^Q stop=^S lnext=^V discard=^U 11 - vmin=\1 vtime=\0 12 - */ 13 - #define INIT_C_CC "\004\000\000\177\027\025\022\000\003\034\032\000\021\023\026\025\001\000" 14 - 15 - /* 16 - * Translate a "termio" structure into a "termios". Ugh. 17 - */ 18 - 19 - #define user_termio_to_kernel_termios(a_termios, u_termio) \ 20 - ({ \ 21 - struct ktermios *k_termios = (a_termios); \ 22 - struct termio k_termio; \ 23 - int canon, ret; \ 24 - \ 25 - ret = copy_from_user(&k_termio, u_termio, sizeof(k_termio)); \ 26 - if (!ret) { \ 27 - /* Overwrite only the low bits. */ \ 28 - *(unsigned short *)&k_termios->c_iflag = k_termio.c_iflag; \ 29 - *(unsigned short *)&k_termios->c_oflag = k_termio.c_oflag; \ 30 - *(unsigned short *)&k_termios->c_cflag = k_termio.c_cflag; \ 31 - *(unsigned short *)&k_termios->c_lflag = k_termio.c_lflag; \ 32 - canon = k_termio.c_lflag & ICANON; \ 33 - \ 34 - k_termios->c_cc[VINTR] = k_termio.c_cc[_VINTR]; \ 35 - k_termios->c_cc[VQUIT] = k_termio.c_cc[_VQUIT]; \ 36 - k_termios->c_cc[VERASE] = k_termio.c_cc[_VERASE]; \ 37 - k_termios->c_cc[VKILL] = k_termio.c_cc[_VKILL]; \ 38 - k_termios->c_cc[VEOL2] = k_termio.c_cc[_VEOL2]; \ 39 - k_termios->c_cc[VSWTC] = k_termio.c_cc[_VSWTC]; \ 40 - k_termios->c_cc[canon ? VEOF : VMIN] = k_termio.c_cc[_VEOF]; \ 41 - k_termios->c_cc[canon ? VEOL : VTIME] = k_termio.c_cc[_VEOL]; \ 42 - } \ 43 - ret; \ 44 - }) 45 - 46 - /* 47 - * Translate a "termios" structure into a "termio". Ugh. 48 - * 49 - * Note the "fun" _VMIN overloading. 50 - */ 51 - #define kernel_termios_to_user_termio(u_termio, a_termios) \ 52 - ({ \ 53 - struct ktermios *k_termios = (a_termios); \ 54 - struct termio k_termio; \ 55 - int canon; \ 56 - \ 57 - k_termio.c_iflag = k_termios->c_iflag; \ 58 - k_termio.c_oflag = k_termios->c_oflag; \ 59 - k_termio.c_cflag = k_termios->c_cflag; \ 60 - canon = (k_termio.c_lflag = k_termios->c_lflag) & ICANON; \ 61 - \ 62 - k_termio.c_line = k_termios->c_line; \ 63 - k_termio.c_cc[_VINTR] = k_termios->c_cc[VINTR]; \ 64 - k_termio.c_cc[_VQUIT] = k_termios->c_cc[VQUIT]; \ 65 - k_termio.c_cc[_VERASE] = k_termios->c_cc[VERASE]; \ 66 - k_termio.c_cc[_VKILL] = k_termios->c_cc[VKILL]; \ 67 - k_termio.c_cc[_VEOF] = k_termios->c_cc[canon ? VEOF : VMIN]; \ 68 - k_termio.c_cc[_VEOL] = k_termios->c_cc[canon ? VEOL : VTIME]; \ 69 - k_termio.c_cc[_VEOL2] = k_termios->c_cc[VEOL2]; \ 70 - k_termio.c_cc[_VSWTC] = k_termios->c_cc[VSWTC]; \ 71 - \ 72 - copy_to_user(u_termio, &k_termio, sizeof(k_termio)); \ 73 - }) 74 - 75 - #define user_termios_to_kernel_termios(k, u) \ 76 - copy_from_user(k, u, sizeof(struct termios2)) 77 - 78 - #define kernel_termios_to_user_termios(u, k) \ 79 - copy_to_user(u, k, sizeof(struct termios2)) 80 - 81 - #define user_termios_to_kernel_termios_1(k, u) \ 82 - copy_from_user(k, u, sizeof(struct termios)) 83 - 84 - #define kernel_termios_to_user_termios_1(u, k) \ 85 - copy_to_user(u, k, sizeof(struct termios)) 86 - 87 - #endif /* _ALPHA_TERMIOS_H */
+1 -1
arch/alpha/kernel/Makefile
··· 9 9 10 10 obj-y := entry.o traps.o process.o osf_sys.o irq.o \ 11 11 irq_alpha.o signal.o setup.o ptrace.o time.o \ 12 - systbls.o err_common.o io.o bugs.o 12 + systbls.o err_common.o io.o bugs.o termios.o 13 13 14 14 obj-$(CONFIG_VGA_HOSE) += console.o 15 15 obj-$(CONFIG_SMP) += smp.o
+56
arch/alpha/kernel/termios.c
··· 1 + // SPDX-License-Identifier: GPL-2.0 2 + #include <linux/termios_internal.h> 3 + 4 + int user_termio_to_kernel_termios(struct ktermios *termios, 5 + struct termio __user *termio) 6 + { 7 + struct termio v; 8 + bool canon; 9 + 10 + if (copy_from_user(&v, termio, sizeof(struct termio))) 11 + return -EFAULT; 12 + 13 + termios->c_iflag = (0xffff0000 & termios->c_iflag) | v.c_iflag; 14 + termios->c_oflag = (0xffff0000 & termios->c_oflag) | v.c_oflag; 15 + termios->c_cflag = (0xffff0000 & termios->c_cflag) | v.c_cflag; 16 + termios->c_lflag = (0xffff0000 & termios->c_lflag) | v.c_lflag; 17 + termios->c_line = (0xffff0000 & termios->c_lflag) | v.c_line; 18 + 19 + canon = v.c_lflag & ICANON; 20 + termios->c_cc[VINTR] = v.c_cc[_VINTR]; 21 + termios->c_cc[VQUIT] = v.c_cc[_VQUIT]; 22 + termios->c_cc[VERASE] = v.c_cc[_VERASE]; 23 + termios->c_cc[VKILL] = v.c_cc[_VKILL]; 24 + termios->c_cc[VEOL2] = v.c_cc[_VEOL2]; 25 + termios->c_cc[VSWTC] = v.c_cc[_VSWTC]; 26 + termios->c_cc[canon ? VEOF : VMIN] = v.c_cc[_VEOF]; 27 + termios->c_cc[canon ? VEOL : VTIME] = v.c_cc[_VEOL]; 28 + 29 + return 0; 30 + } 31 + 32 + int kernel_termios_to_user_termio(struct termio __user *termio, 33 + struct ktermios *termios) 34 + { 35 + struct termio v; 36 + bool canon; 37 + 38 + memset(&v, 0, sizeof(struct termio)); 39 + v.c_iflag = termios->c_iflag; 40 + v.c_oflag = termios->c_oflag; 41 + v.c_cflag = termios->c_cflag; 42 + v.c_lflag = termios->c_lflag; 43 + v.c_line = termios->c_line; 44 + 45 + canon = v.c_lflag & ICANON; 46 + v.c_cc[_VINTR] = termios->c_cc[VINTR]; 47 + v.c_cc[_VQUIT] = termios->c_cc[VQUIT]; 48 + v.c_cc[_VERASE] = termios->c_cc[VERASE]; 49 + v.c_cc[_VKILL] = termios->c_cc[VKILL]; 50 + v.c_cc[_VEOF] = termios->c_cc[canon ? VEOF : VMIN]; 51 + v.c_cc[_VEOL] = termios->c_cc[canon ? VEOL : VTIME]; 52 + v.c_cc[_VEOL2] = termios->c_cc[VEOL2]; 53 + v.c_cc[_VSWTC] = termios->c_cc[VSWTC]; 54 + 55 + return copy_to_user(termio, &v, sizeof(struct termio)); 56 + }
+1
arch/arm/mach-ep93xx/core.c
··· 22 22 #include <linux/io.h> 23 23 #include <linux/gpio.h> 24 24 #include <linux/leds.h> 25 + #include <linux/uaccess.h> 25 26 #include <linux/termios.h> 26 27 #include <linux/amba/bus.h> 27 28 #include <linux/amba/serial.h>
+1
arch/arm/mach-versatile/integrator_ap.c
··· 11 11 #include <linux/of_irq.h> 12 12 #include <linux/of_address.h> 13 13 #include <linux/of_platform.h> 14 + #include <linux/uaccess.h> 14 15 #include <linux/termios.h> 15 16 #include <linux/mfd/syscon.h> 16 17 #include <linux/regmap.h>
-58
arch/ia64/include/asm/termios.h
··· 1 - /* SPDX-License-Identifier: GPL-2.0 */ 2 - /* 3 - * Modified 1999 4 - * David Mosberger-Tang <davidm@hpl.hp.com>, Hewlett-Packard Co 5 - * 6 - * 99/01/28 Added N_IRDA and N_SMSBLOCK 7 - */ 8 - #ifndef _ASM_IA64_TERMIOS_H 9 - #define _ASM_IA64_TERMIOS_H 10 - 11 - #include <uapi/asm/termios.h> 12 - 13 - 14 - /* intr=^C quit=^\ erase=del kill=^U 15 - eof=^D vtime=\0 vmin=\1 sxtc=\0 16 - start=^Q stop=^S susp=^Z eol=\0 17 - reprint=^R discard=^U werase=^W lnext=^V 18 - eol2=\0 19 - */ 20 - #define INIT_C_CC "\003\034\177\025\004\0\1\0\021\023\032\0\022\017\027\026\0" 21 - 22 - /* 23 - * Translate a "termio" structure into a "termios". Ugh. 24 - */ 25 - #define SET_LOW_TERMIOS_BITS(termios, termio, x) { \ 26 - unsigned short __tmp; \ 27 - get_user(__tmp,&(termio)->x); \ 28 - *(unsigned short *) &(termios)->x = __tmp; \ 29 - } 30 - 31 - #define user_termio_to_kernel_termios(termios, termio) \ 32 - ({ \ 33 - SET_LOW_TERMIOS_BITS(termios, termio, c_iflag); \ 34 - SET_LOW_TERMIOS_BITS(termios, termio, c_oflag); \ 35 - SET_LOW_TERMIOS_BITS(termios, termio, c_cflag); \ 36 - SET_LOW_TERMIOS_BITS(termios, termio, c_lflag); \ 37 - copy_from_user((termios)->c_cc, (termio)->c_cc, NCC); \ 38 - }) 39 - 40 - /* 41 - * Translate a "termios" structure into a "termio". Ugh. 42 - */ 43 - #define kernel_termios_to_user_termio(termio, termios) \ 44 - ({ \ 45 - put_user((termios)->c_iflag, &(termio)->c_iflag); \ 46 - put_user((termios)->c_oflag, &(termio)->c_oflag); \ 47 - put_user((termios)->c_cflag, &(termio)->c_cflag); \ 48 - put_user((termios)->c_lflag, &(termio)->c_lflag); \ 49 - put_user((termios)->c_line, &(termio)->c_line); \ 50 - copy_to_user((termio)->c_cc, (termios)->c_cc, NCC); \ 51 - }) 52 - 53 - #define user_termios_to_kernel_termios(k, u) copy_from_user(k, u, sizeof(struct termios2)) 54 - #define kernel_termios_to_user_termios(u, k) copy_to_user(u, k, sizeof(struct termios2)) 55 - #define user_termios_to_kernel_termios_1(k, u) copy_from_user(k, u, sizeof(struct termios)) 56 - #define kernel_termios_to_user_termios_1(u, k) copy_to_user(u, k, sizeof(struct termios)) 57 - 58 - #endif /* _ASM_IA64_TERMIOS_H */
-51
arch/ia64/include/uapi/asm/termios.h
··· 1 - /* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */ 2 - /* 3 - * Modified 1999 4 - * David Mosberger-Tang <davidm@hpl.hp.com>, Hewlett-Packard Co 5 - * 6 - * 99/01/28 Added N_IRDA and N_SMSBLOCK 7 - */ 8 - #ifndef _UAPI_ASM_IA64_TERMIOS_H 9 - #define _UAPI_ASM_IA64_TERMIOS_H 10 - 11 - 12 - #include <asm/termbits.h> 13 - #include <asm/ioctls.h> 14 - 15 - struct winsize { 16 - unsigned short ws_row; 17 - unsigned short ws_col; 18 - unsigned short ws_xpixel; 19 - unsigned short ws_ypixel; 20 - }; 21 - 22 - #define NCC 8 23 - struct termio { 24 - unsigned short c_iflag; /* input mode flags */ 25 - unsigned short c_oflag; /* output mode flags */ 26 - unsigned short c_cflag; /* control mode flags */ 27 - unsigned short c_lflag; /* local mode flags */ 28 - unsigned char c_line; /* line discipline */ 29 - unsigned char c_cc[NCC]; /* control characters */ 30 - }; 31 - 32 - /* modem lines */ 33 - #define TIOCM_LE 0x001 34 - #define TIOCM_DTR 0x002 35 - #define TIOCM_RTS 0x004 36 - #define TIOCM_ST 0x008 37 - #define TIOCM_SR 0x010 38 - #define TIOCM_CTS 0x020 39 - #define TIOCM_CAR 0x040 40 - #define TIOCM_RNG 0x080 41 - #define TIOCM_DSR 0x100 42 - #define TIOCM_CD TIOCM_CAR 43 - #define TIOCM_RI TIOCM_RNG 44 - #define TIOCM_OUT1 0x2000 45 - #define TIOCM_OUT2 0x4000 46 - #define TIOCM_LOOP 0x8000 47 - 48 - /* ioctl (fd, TIOCSERGETLSR, &result) where result may be as below */ 49 - 50 - 51 - #endif /* _UAPI_ASM_IA64_TERMIOS_H */
-1
arch/loongarch/include/asm/Kbuild
··· 21 21 generic-y += statfs.h 22 22 generic-y += socket.h 23 23 generic-y += sockios.h 24 - generic-y += termios.h 25 24 generic-y += termbits.h 26 25 generic-y += poll.h 27 26 generic-y += param.h
-105
arch/mips/include/asm/termios.h
··· 1 - /* 2 - * This file is subject to the terms and conditions of the GNU General Public 3 - * License. See the file "COPYING" in the main directory of this archive 4 - * for more details. 5 - * 6 - * Copyright (C) 1995, 1996, 2000, 2001 by Ralf Baechle 7 - * Copyright (C) 2000, 2001 Silicon Graphics, Inc. 8 - */ 9 - #ifndef _ASM_TERMIOS_H 10 - #define _ASM_TERMIOS_H 11 - 12 - #include <linux/uaccess.h> 13 - #include <uapi/asm/termios.h> 14 - 15 - /* 16 - * intr=^C quit=^\ erase=del kill=^U 17 - * vmin=\1 vtime=\0 eol2=\0 swtc=\0 18 - * start=^Q stop=^S susp=^Z vdsusp= 19 - * reprint=^R discard=^U werase=^W lnext=^V 20 - * eof=^D eol=\0 21 - */ 22 - #define INIT_C_CC "\003\034\177\025\1\0\0\0\021\023\032\0\022\017\027\026\004\0" 23 - 24 - #include <linux/string.h> 25 - 26 - /* 27 - * Translate a "termio" structure into a "termios". Ugh. 28 - */ 29 - static inline int user_termio_to_kernel_termios(struct ktermios *termios, 30 - struct termio __user *termio) 31 - { 32 - unsigned short iflag, oflag, cflag, lflag; 33 - unsigned int err; 34 - 35 - if (!access_ok(termio, sizeof(struct termio))) 36 - return -EFAULT; 37 - 38 - err = __get_user(iflag, &termio->c_iflag); 39 - termios->c_iflag = (termios->c_iflag & 0xffff0000) | iflag; 40 - err |=__get_user(oflag, &termio->c_oflag); 41 - termios->c_oflag = (termios->c_oflag & 0xffff0000) | oflag; 42 - err |=__get_user(cflag, &termio->c_cflag); 43 - termios->c_cflag = (termios->c_cflag & 0xffff0000) | cflag; 44 - err |=__get_user(lflag, &termio->c_lflag); 45 - termios->c_lflag = (termios->c_lflag & 0xffff0000) | lflag; 46 - err |=__get_user(termios->c_line, &termio->c_line); 47 - if (err) 48 - return -EFAULT; 49 - 50 - if (__copy_from_user(termios->c_cc, termio->c_cc, NCC)) 51 - return -EFAULT; 52 - 53 - return 0; 54 - } 55 - 56 - /* 57 - * Translate a "termios" structure into a "termio". Ugh. 58 - */ 59 - static inline int kernel_termios_to_user_termio(struct termio __user *termio, 60 - struct ktermios *termios) 61 - { 62 - int err; 63 - 64 - if (!access_ok(termio, sizeof(struct termio))) 65 - return -EFAULT; 66 - 67 - err = __put_user(termios->c_iflag, &termio->c_iflag); 68 - err |= __put_user(termios->c_oflag, &termio->c_oflag); 69 - err |= __put_user(termios->c_cflag, &termio->c_cflag); 70 - err |= __put_user(termios->c_lflag, &termio->c_lflag); 71 - err |= __put_user(termios->c_line, &termio->c_line); 72 - if (err) 73 - return -EFAULT; 74 - 75 - if (__copy_to_user(termio->c_cc, termios->c_cc, NCC)) 76 - return -EFAULT; 77 - 78 - return 0; 79 - } 80 - 81 - static inline int user_termios_to_kernel_termios(struct ktermios __user *k, 82 - struct termios2 *u) 83 - { 84 - return copy_from_user(k, u, sizeof(struct termios2)) ? -EFAULT : 0; 85 - } 86 - 87 - static inline int kernel_termios_to_user_termios(struct termios2 __user *u, 88 - struct ktermios *k) 89 - { 90 - return copy_to_user(u, k, sizeof(struct termios2)) ? -EFAULT : 0; 91 - } 92 - 93 - static inline int user_termios_to_kernel_termios_1(struct ktermios *k, 94 - struct termios __user *u) 95 - { 96 - return copy_from_user(k, u, sizeof(struct termios)) ? -EFAULT : 0; 97 - } 98 - 99 - static inline int kernel_termios_to_user_termios_1(struct termios __user *u, 100 - struct ktermios *k) 101 - { 102 - return copy_to_user(u, k, sizeof(struct termios)) ? -EFAULT : 0; 103 - } 104 - 105 - #endif /* _ASM_TERMIOS_H */
-52
arch/parisc/include/asm/termios.h
··· 1 - /* SPDX-License-Identifier: GPL-2.0 */ 2 - #ifndef _PARISC_TERMIOS_H 3 - #define _PARISC_TERMIOS_H 4 - 5 - #include <uapi/asm/termios.h> 6 - 7 - 8 - /* intr=^C quit=^\ erase=del kill=^U 9 - eof=^D vtime=\0 vmin=\1 sxtc=\0 10 - start=^Q stop=^S susp=^Z eol=\0 11 - reprint=^R discard=^U werase=^W lnext=^V 12 - eol2=\0 13 - */ 14 - #define INIT_C_CC "\003\034\177\025\004\0\1\0\021\023\032\0\022\017\027\026\0" 15 - 16 - /* 17 - * Translate a "termio" structure into a "termios". Ugh. 18 - */ 19 - #define SET_LOW_TERMIOS_BITS(termios, termio, x) { \ 20 - unsigned short __tmp; \ 21 - get_user(__tmp,&(termio)->x); \ 22 - *(unsigned short *) &(termios)->x = __tmp; \ 23 - } 24 - 25 - #define user_termio_to_kernel_termios(termios, termio) \ 26 - ({ \ 27 - SET_LOW_TERMIOS_BITS(termios, termio, c_iflag); \ 28 - SET_LOW_TERMIOS_BITS(termios, termio, c_oflag); \ 29 - SET_LOW_TERMIOS_BITS(termios, termio, c_cflag); \ 30 - SET_LOW_TERMIOS_BITS(termios, termio, c_lflag); \ 31 - copy_from_user((termios)->c_cc, (termio)->c_cc, NCC); \ 32 - }) 33 - 34 - /* 35 - * Translate a "termios" structure into a "termio". Ugh. 36 - */ 37 - #define kernel_termios_to_user_termio(termio, termios) \ 38 - ({ \ 39 - put_user((termios)->c_iflag, &(termio)->c_iflag); \ 40 - put_user((termios)->c_oflag, &(termio)->c_oflag); \ 41 - put_user((termios)->c_cflag, &(termio)->c_cflag); \ 42 - put_user((termios)->c_lflag, &(termio)->c_lflag); \ 43 - put_user((termios)->c_line, &(termio)->c_line); \ 44 - copy_to_user((termio)->c_cc, (termios)->c_cc, NCC); \ 45 - }) 46 - 47 - #define user_termios_to_kernel_termios(k, u) copy_from_user(k, u, sizeof(struct termios2)) 48 - #define kernel_termios_to_user_termios(u, k) copy_to_user(u, k, sizeof(struct termios2)) 49 - #define user_termios_to_kernel_termios_1(k, u) copy_from_user(k, u, sizeof(struct termios)) 50 - #define kernel_termios_to_user_termios_1(u, k) copy_to_user(u, k, sizeof(struct termios)) 51 - 52 - #endif /* _PARISC_TERMIOS_H */
-44
arch/parisc/include/uapi/asm/termios.h
··· 1 - /* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */ 2 - #ifndef _UAPI_PARISC_TERMIOS_H 3 - #define _UAPI_PARISC_TERMIOS_H 4 - 5 - #include <asm/termbits.h> 6 - #include <asm/ioctls.h> 7 - 8 - struct winsize { 9 - unsigned short ws_row; 10 - unsigned short ws_col; 11 - unsigned short ws_xpixel; 12 - unsigned short ws_ypixel; 13 - }; 14 - 15 - #define NCC 8 16 - struct termio { 17 - unsigned short c_iflag; /* input mode flags */ 18 - unsigned short c_oflag; /* output mode flags */ 19 - unsigned short c_cflag; /* control mode flags */ 20 - unsigned short c_lflag; /* local mode flags */ 21 - unsigned char c_line; /* line discipline */ 22 - unsigned char c_cc[NCC]; /* control characters */ 23 - }; 24 - 25 - /* modem lines */ 26 - #define TIOCM_LE 0x001 27 - #define TIOCM_DTR 0x002 28 - #define TIOCM_RTS 0x004 29 - #define TIOCM_ST 0x008 30 - #define TIOCM_SR 0x010 31 - #define TIOCM_CTS 0x020 32 - #define TIOCM_CAR 0x040 33 - #define TIOCM_RNG 0x080 34 - #define TIOCM_DSR 0x100 35 - #define TIOCM_CD TIOCM_CAR 36 - #define TIOCM_RI TIOCM_RNG 37 - #define TIOCM_OUT1 0x2000 38 - #define TIOCM_OUT2 0x4000 39 - #define TIOCM_LOOP 0x8000 40 - 41 - /* ioctl (fd, TIOCSERGETLSR, &result) where result may be as below */ 42 - 43 - 44 - #endif /* _UAPI_PARISC_TERMIOS_H */
-18
arch/powerpc/include/asm/termios.h
··· 1 - /* SPDX-License-Identifier: GPL-2.0-or-later */ 2 - /* 3 - * Liberally adapted from alpha/termios.h. In particular, the c_cc[] 4 - * fields have been reordered so that termio & termios share the 5 - * common subset in the same order (for brain dead programs that don't 6 - * know or care about the differences). 7 - */ 8 - #ifndef _ASM_POWERPC_TERMIOS_H 9 - #define _ASM_POWERPC_TERMIOS_H 10 - 11 - #include <uapi/asm/termios.h> 12 - 13 - /* ^C ^\ del ^U ^D 1 0 0 0 0 ^W ^R ^Z ^Q ^S ^V ^U */ 14 - #define INIT_C_CC "\003\034\177\025\004\001\000\000\000\000\027\022\032\021\023\026\025" 15 - 16 - #include <asm-generic/termios-base.h> 17 - 18 - #endif /* _ASM_POWERPC_TERMIOS_H */
-26
arch/s390/include/asm/termios.h
··· 1 - /* SPDX-License-Identifier: GPL-2.0 */ 2 - /* 3 - * S390 version 4 - * 5 - * Derived from "include/asm-i386/termios.h" 6 - */ 7 - #ifndef _S390_TERMIOS_H 8 - #define _S390_TERMIOS_H 9 - 10 - #include <uapi/asm/termios.h> 11 - 12 - 13 - /* intr=^C quit=^\ erase=del kill=^U 14 - eof=^D vtime=\0 vmin=\1 sxtc=\0 15 - start=^Q stop=^S susp=^Z eol=\0 16 - reprint=^R discard=^U werase=^W lnext=^V 17 - eol2=\0 18 - */ 19 - #define INIT_C_CC "\003\034\177\025\004\0\1\0\021\023\032\0\022\017\027\026\0" 20 - 21 - #define user_termios_to_kernel_termios(k, u) copy_from_user(k, u, sizeof(struct termios2)) 22 - #define kernel_termios_to_user_termios(u, k) copy_to_user(u, k, sizeof(struct termios2)) 23 - 24 - #include <asm-generic/termios-base.h> 25 - 26 - #endif /* _S390_TERMIOS_H */
-50
arch/s390/include/uapi/asm/termios.h
··· 1 - /* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */ 2 - /* 3 - * S390 version 4 - * 5 - * Derived from "include/asm-i386/termios.h" 6 - */ 7 - 8 - #ifndef _UAPI_S390_TERMIOS_H 9 - #define _UAPI_S390_TERMIOS_H 10 - 11 - #include <asm/termbits.h> 12 - #include <asm/ioctls.h> 13 - 14 - struct winsize { 15 - unsigned short ws_row; 16 - unsigned short ws_col; 17 - unsigned short ws_xpixel; 18 - unsigned short ws_ypixel; 19 - }; 20 - 21 - #define NCC 8 22 - struct termio { 23 - unsigned short c_iflag; /* input mode flags */ 24 - unsigned short c_oflag; /* output mode flags */ 25 - unsigned short c_cflag; /* control mode flags */ 26 - unsigned short c_lflag; /* local mode flags */ 27 - unsigned char c_line; /* line discipline */ 28 - unsigned char c_cc[NCC]; /* control characters */ 29 - }; 30 - 31 - /* modem lines */ 32 - #define TIOCM_LE 0x001 33 - #define TIOCM_DTR 0x002 34 - #define TIOCM_RTS 0x004 35 - #define TIOCM_ST 0x008 36 - #define TIOCM_SR 0x010 37 - #define TIOCM_CTS 0x020 38 - #define TIOCM_CAR 0x040 39 - #define TIOCM_RNG 0x080 40 - #define TIOCM_DSR 0x100 41 - #define TIOCM_CD TIOCM_CAR 42 - #define TIOCM_RI TIOCM_RNG 43 - #define TIOCM_OUT1 0x2000 44 - #define TIOCM_OUT2 0x4000 45 - #define TIOCM_LOOP 0x8000 46 - 47 - /* ioctl (fd, TIOCSERGETLSR, &result) where result may be as below */ 48 - 49 - 50 - #endif /* _UAPI_S390_TERMIOS_H */
-147
arch/sparc/include/asm/termios.h
··· 1 - /* SPDX-License-Identifier: GPL-2.0 */ 2 - #ifndef _SPARC_TERMIOS_H 3 - #define _SPARC_TERMIOS_H 4 - 5 - #include <uapi/asm/termios.h> 6 - 7 - 8 - /* 9 - * c_cc characters in the termio structure. Oh, how I love being 10 - * backwardly compatible. Notice that character 4 and 5 are 11 - * interpreted differently depending on whether ICANON is set in 12 - * c_lflag. If it's set, they are used as _VEOF and _VEOL, otherwise 13 - * as _VMIN and V_TIME. This is for compatibility with OSF/1 (which 14 - * is compatible with sysV)... 15 - */ 16 - #define _VMIN 4 17 - #define _VTIME 5 18 - 19 - /* intr=^C quit=^\ erase=del kill=^U 20 - eof=^D eol=\0 eol2=\0 sxtc=\0 21 - start=^Q stop=^S susp=^Z dsusp=^Y 22 - reprint=^R discard=^U werase=^W lnext=^V 23 - vmin=\1 vtime=\0 24 - */ 25 - #define INIT_C_CC "\003\034\177\025\004\000\000\000\021\023\032\031\022\025\027\026\001" 26 - 27 - /* 28 - * Translate a "termio" structure into a "termios". Ugh. 29 - */ 30 - #define user_termio_to_kernel_termios(termios, termio) \ 31 - ({ \ 32 - unsigned short tmp; \ 33 - int err; \ 34 - err = get_user(tmp, &(termio)->c_iflag); \ 35 - (termios)->c_iflag = (0xffff0000 & ((termios)->c_iflag)) | tmp; \ 36 - err |= get_user(tmp, &(termio)->c_oflag); \ 37 - (termios)->c_oflag = (0xffff0000 & ((termios)->c_oflag)) | tmp; \ 38 - err |= get_user(tmp, &(termio)->c_cflag); \ 39 - (termios)->c_cflag = (0xffff0000 & ((termios)->c_cflag)) | tmp; \ 40 - err |= get_user(tmp, &(termio)->c_lflag); \ 41 - (termios)->c_lflag = (0xffff0000 & ((termios)->c_lflag)) | tmp; \ 42 - err |= copy_from_user((termios)->c_cc, (termio)->c_cc, NCC); \ 43 - err; \ 44 - }) 45 - 46 - /* 47 - * Translate a "termios" structure into a "termio". Ugh. 48 - * 49 - * Note the "fun" _VMIN overloading. 50 - */ 51 - #define kernel_termios_to_user_termio(termio, termios) \ 52 - ({ \ 53 - int err; \ 54 - err = put_user((termios)->c_iflag, &(termio)->c_iflag); \ 55 - err |= put_user((termios)->c_oflag, &(termio)->c_oflag); \ 56 - err |= put_user((termios)->c_cflag, &(termio)->c_cflag); \ 57 - err |= put_user((termios)->c_lflag, &(termio)->c_lflag); \ 58 - err |= put_user((termios)->c_line, &(termio)->c_line); \ 59 - err |= copy_to_user((termio)->c_cc, (termios)->c_cc, NCC); \ 60 - if (!((termios)->c_lflag & ICANON)) { \ 61 - err |= put_user((termios)->c_cc[VMIN], &(termio)->c_cc[_VMIN]); \ 62 - err |= put_user((termios)->c_cc[VTIME], &(termio)->c_cc[_VTIME]); \ 63 - } \ 64 - err; \ 65 - }) 66 - 67 - #define user_termios_to_kernel_termios(k, u) \ 68 - ({ \ 69 - int err; \ 70 - err = get_user((k)->c_iflag, &(u)->c_iflag); \ 71 - err |= get_user((k)->c_oflag, &(u)->c_oflag); \ 72 - err |= get_user((k)->c_cflag, &(u)->c_cflag); \ 73 - err |= get_user((k)->c_lflag, &(u)->c_lflag); \ 74 - err |= get_user((k)->c_line, &(u)->c_line); \ 75 - err |= copy_from_user((k)->c_cc, (u)->c_cc, NCCS); \ 76 - if ((k)->c_lflag & ICANON) { \ 77 - err |= get_user((k)->c_cc[VEOF], &(u)->c_cc[VEOF]); \ 78 - err |= get_user((k)->c_cc[VEOL], &(u)->c_cc[VEOL]); \ 79 - } else { \ 80 - err |= get_user((k)->c_cc[VMIN], &(u)->c_cc[_VMIN]); \ 81 - err |= get_user((k)->c_cc[VTIME], &(u)->c_cc[_VTIME]); \ 82 - } \ 83 - err |= get_user((k)->c_ispeed, &(u)->c_ispeed); \ 84 - err |= get_user((k)->c_ospeed, &(u)->c_ospeed); \ 85 - err; \ 86 - }) 87 - 88 - #define kernel_termios_to_user_termios(u, k) \ 89 - ({ \ 90 - int err; \ 91 - err = put_user((k)->c_iflag, &(u)->c_iflag); \ 92 - err |= put_user((k)->c_oflag, &(u)->c_oflag); \ 93 - err |= put_user((k)->c_cflag, &(u)->c_cflag); \ 94 - err |= put_user((k)->c_lflag, &(u)->c_lflag); \ 95 - err |= put_user((k)->c_line, &(u)->c_line); \ 96 - err |= copy_to_user((u)->c_cc, (k)->c_cc, NCCS); \ 97 - if (!((k)->c_lflag & ICANON)) { \ 98 - err |= put_user((k)->c_cc[VMIN], &(u)->c_cc[_VMIN]); \ 99 - err |= put_user((k)->c_cc[VTIME], &(u)->c_cc[_VTIME]); \ 100 - } else { \ 101 - err |= put_user((k)->c_cc[VEOF], &(u)->c_cc[VEOF]); \ 102 - err |= put_user((k)->c_cc[VEOL], &(u)->c_cc[VEOL]); \ 103 - } \ 104 - err |= put_user((k)->c_ispeed, &(u)->c_ispeed); \ 105 - err |= put_user((k)->c_ospeed, &(u)->c_ospeed); \ 106 - err; \ 107 - }) 108 - 109 - #define user_termios_to_kernel_termios_1(k, u) \ 110 - ({ \ 111 - int err; \ 112 - err = get_user((k)->c_iflag, &(u)->c_iflag); \ 113 - err |= get_user((k)->c_oflag, &(u)->c_oflag); \ 114 - err |= get_user((k)->c_cflag, &(u)->c_cflag); \ 115 - err |= get_user((k)->c_lflag, &(u)->c_lflag); \ 116 - err |= get_user((k)->c_line, &(u)->c_line); \ 117 - err |= copy_from_user((k)->c_cc, (u)->c_cc, NCCS); \ 118 - if ((k)->c_lflag & ICANON) { \ 119 - err |= get_user((k)->c_cc[VEOF], &(u)->c_cc[VEOF]); \ 120 - err |= get_user((k)->c_cc[VEOL], &(u)->c_cc[VEOL]); \ 121 - } else { \ 122 - err |= get_user((k)->c_cc[VMIN], &(u)->c_cc[_VMIN]); \ 123 - err |= get_user((k)->c_cc[VTIME], &(u)->c_cc[_VTIME]); \ 124 - } \ 125 - err; \ 126 - }) 127 - 128 - #define kernel_termios_to_user_termios_1(u, k) \ 129 - ({ \ 130 - int err; \ 131 - err = put_user((k)->c_iflag, &(u)->c_iflag); \ 132 - err |= put_user((k)->c_oflag, &(u)->c_oflag); \ 133 - err |= put_user((k)->c_cflag, &(u)->c_cflag); \ 134 - err |= put_user((k)->c_lflag, &(u)->c_lflag); \ 135 - err |= put_user((k)->c_line, &(u)->c_line); \ 136 - err |= copy_to_user((u)->c_cc, (k)->c_cc, NCCS); \ 137 - if (!((k)->c_lflag & ICANON)) { \ 138 - err |= put_user((k)->c_cc[VMIN], &(u)->c_cc[_VMIN]); \ 139 - err |= put_user((k)->c_cc[VTIME], &(u)->c_cc[_VTIME]); \ 140 - } else { \ 141 - err |= put_user((k)->c_cc[VEOF], &(u)->c_cc[VEOF]); \ 142 - err |= put_user((k)->c_cc[VEOL], &(u)->c_cc[VEOL]); \ 143 - } \ 144 - err; \ 145 - }) 146 - 147 - #endif /* _SPARC_TERMIOS_H */
+3 -1
arch/sparc/kernel/Makefile
··· 87 87 obj-y += auxio_$(BITS).o 88 88 obj-$(CONFIG_SUN_PM) += apc.o pmc.o 89 89 90 + obj-y += termios.o 91 + 90 92 obj-$(CONFIG_MODULES) += module.o 91 93 obj-$(CONFIG_MODULES) += sparc_ksyms.o 92 94 obj-$(CONFIG_SPARC_LED) += led.o 93 95 obj-$(CONFIG_KGDB) += kgdb_$(BITS).o 94 - 95 96 96 97 obj-$(CONFIG_DYNAMIC_FTRACE) += ftrace.o 97 98 obj-$(CONFIG_FUNCTION_GRAPH_TRACER) += ftrace.o ··· 104 103 obj-$(CONFIG_SPARC64_PCI) += pci_psycho.o pci_sabre.o pci_schizo.o 105 104 obj-$(CONFIG_SPARC64_PCI) += pci_sun4v.o pci_sun4v_asm.o pci_fire.o 106 105 obj-$(CONFIG_SPARC64_PCI_MSI) += pci_msi.o 106 + 107 107 108 108 obj-$(CONFIG_COMPAT) += sys32.o sys_sparc32.o signal32.o 109 109
+115
arch/sparc/kernel/termios.c
··· 1 + // SPDX-License-Identifier: GPL-2.0 2 + #include <linux/termios_internal.h> 3 + 4 + /* 5 + * c_cc characters in the termio structure. Oh, how I love being 6 + * backwardly compatible. Notice that character 4 and 5 are 7 + * interpreted differently depending on whether ICANON is set in 8 + * c_lflag. If it's set, they are used as _VEOF and _VEOL, otherwise 9 + * as _VMIN and V_TIME. This is for compatibility with OSF/1 (which 10 + * is compatible with sysV)... 11 + */ 12 + #define _VMIN 4 13 + #define _VTIME 5 14 + 15 + int kernel_termios_to_user_termio(struct termio __user *termio, 16 + struct ktermios *termios) 17 + { 18 + struct termio v; 19 + memset(&v, 0, sizeof(struct termio)); 20 + v.c_iflag = termios->c_iflag; 21 + v.c_oflag = termios->c_oflag; 22 + v.c_cflag = termios->c_cflag; 23 + v.c_lflag = termios->c_lflag; 24 + v.c_line = termios->c_line; 25 + memcpy(v.c_cc, termios->c_cc, NCC); 26 + if (!(v.c_lflag & ICANON)) { 27 + v.c_cc[_VMIN] = termios->c_cc[VMIN]; 28 + v.c_cc[_VTIME] = termios->c_cc[VTIME]; 29 + } 30 + return copy_to_user(termio, &v, sizeof(struct termio)); 31 + } 32 + 33 + int user_termios_to_kernel_termios(struct ktermios *k, 34 + struct termios2 __user *u) 35 + { 36 + int err; 37 + err = get_user(k->c_iflag, &u->c_iflag); 38 + err |= get_user(k->c_oflag, &u->c_oflag); 39 + err |= get_user(k->c_cflag, &u->c_cflag); 40 + err |= get_user(k->c_lflag, &u->c_lflag); 41 + err |= get_user(k->c_line, &u->c_line); 42 + err |= copy_from_user(k->c_cc, u->c_cc, NCCS); 43 + if (k->c_lflag & ICANON) { 44 + err |= get_user(k->c_cc[VEOF], &u->c_cc[VEOF]); 45 + err |= get_user(k->c_cc[VEOL], &u->c_cc[VEOL]); 46 + } else { 47 + err |= get_user(k->c_cc[VMIN], &u->c_cc[_VMIN]); 48 + err |= get_user(k->c_cc[VTIME], &u->c_cc[_VTIME]); 49 + } 50 + err |= get_user(k->c_ispeed, &u->c_ispeed); 51 + err |= get_user(k->c_ospeed, &u->c_ospeed); 52 + return err; 53 + } 54 + 55 + int kernel_termios_to_user_termios(struct termios2 __user *u, 56 + struct ktermios *k) 57 + { 58 + int err; 59 + err = put_user(k->c_iflag, &u->c_iflag); 60 + err |= put_user(k->c_oflag, &u->c_oflag); 61 + err |= put_user(k->c_cflag, &u->c_cflag); 62 + err |= put_user(k->c_lflag, &u->c_lflag); 63 + err |= put_user(k->c_line, &u->c_line); 64 + err |= copy_to_user(u->c_cc, k->c_cc, NCCS); 65 + if (!(k->c_lflag & ICANON)) { 66 + err |= put_user(k->c_cc[VMIN], &u->c_cc[_VMIN]); 67 + err |= put_user(k->c_cc[VTIME], &u->c_cc[_VTIME]); 68 + } else { 69 + err |= put_user(k->c_cc[VEOF], &u->c_cc[VEOF]); 70 + err |= put_user(k->c_cc[VEOL], &u->c_cc[VEOL]); 71 + } 72 + err |= put_user(k->c_ispeed, &u->c_ispeed); 73 + err |= put_user(k->c_ospeed, &u->c_ospeed); 74 + return err; 75 + } 76 + 77 + int user_termios_to_kernel_termios_1(struct ktermios *k, 78 + struct termios __user *u) 79 + { 80 + int err; 81 + err = get_user(k->c_iflag, &u->c_iflag); 82 + err |= get_user(k->c_oflag, &u->c_oflag); 83 + err |= get_user(k->c_cflag, &u->c_cflag); 84 + err |= get_user(k->c_lflag, &u->c_lflag); 85 + err |= get_user(k->c_line, &u->c_line); 86 + err |= copy_from_user(k->c_cc, u->c_cc, NCCS); 87 + if (k->c_lflag & ICANON) { 88 + err |= get_user(k->c_cc[VEOF], &u->c_cc[VEOF]); 89 + err |= get_user(k->c_cc[VEOL], &u->c_cc[VEOL]); 90 + } else { 91 + err |= get_user(k->c_cc[VMIN], &u->c_cc[_VMIN]); 92 + err |= get_user(k->c_cc[VTIME], &u->c_cc[_VTIME]); 93 + } 94 + return err; 95 + } 96 + 97 + int kernel_termios_to_user_termios_1(struct termios __user *u, 98 + struct ktermios *k) 99 + { 100 + int err; 101 + err = put_user(k->c_iflag, &u->c_iflag); 102 + err |= put_user(k->c_oflag, &u->c_oflag); 103 + err |= put_user(k->c_cflag, &u->c_cflag); 104 + err |= put_user(k->c_lflag, &u->c_lflag); 105 + err |= put_user(k->c_line, &u->c_line); 106 + err |= copy_to_user(u->c_cc, k->c_cc, NCCS); 107 + if (!(k->c_lflag & ICANON)) { 108 + err |= put_user(k->c_cc[VMIN], &u->c_cc[_VMIN]); 109 + err |= put_user(k->c_cc[VTIME], &u->c_cc[_VTIME]); 110 + } else { 111 + err |= put_user(k->c_cc[VEOF], &u->c_cc[VEOF]); 112 + err |= put_user(k->c_cc[VEOL], &u->c_cc[VEOL]); 113 + } 114 + return err; 115 + }
+1 -1
drivers/ipack/devices/ipoctal.c
··· 497 497 } 498 498 499 499 static void ipoctal_set_termios(struct tty_struct *tty, 500 - struct ktermios *old_termios) 500 + const struct ktermios *old_termios) 501 501 { 502 502 unsigned int cflag; 503 503 unsigned char mr1 = 0;
+2 -2
drivers/mmc/core/sdio_uart.c
··· 246 246 247 247 static void sdio_uart_change_speed(struct sdio_uart_port *port, 248 248 struct ktermios *termios, 249 - struct ktermios *old) 249 + const struct ktermios *old) 250 250 { 251 251 unsigned char cval, fcr = 0; 252 252 unsigned int baud, quot; ··· 859 859 } 860 860 861 861 static void sdio_uart_set_termios(struct tty_struct *tty, 862 - struct ktermios *old_termios) 862 + const struct ktermios *old_termios) 863 863 { 864 864 struct sdio_uart_port *port = tty->driver_data; 865 865 unsigned int cflag = tty->termios.c_cflag;
+2 -1
drivers/net/usb/hso.c
··· 1380 1380 } 1381 1381 1382 1382 /* setup the term */ 1383 - static void hso_serial_set_termios(struct tty_struct *tty, struct ktermios *old) 1383 + static void hso_serial_set_termios(struct tty_struct *tty, 1384 + const struct ktermios *old) 1384 1385 { 1385 1386 struct hso_serial *serial = tty->driver_data; 1386 1387 unsigned long flags;
+1
drivers/net/wwan/wwan_core.c
··· 13 13 #include <linux/skbuff.h> 14 14 #include <linux/slab.h> 15 15 #include <linux/types.h> 16 + #include <linux/uaccess.h> 16 17 #include <linux/termios.h> 17 18 #include <linux/wwan.h> 18 19 #include <net/rtnetlink.h>
+1 -1
drivers/s390/char/tty3270.c
··· 1760 1760 * Check for visible/invisible input switches 1761 1761 */ 1762 1762 static void 1763 - tty3270_set_termios(struct tty_struct *tty, struct ktermios *old) 1763 + tty3270_set_termios(struct tty_struct *tty, const struct ktermios *old) 1764 1764 { 1765 1765 struct tty3270 *tp; 1766 1766 int new;
+2 -1
drivers/staging/fwserial/fwserial.c
··· 1267 1267 return err; 1268 1268 } 1269 1269 1270 - static void fwtty_set_termios(struct tty_struct *tty, struct ktermios *old) 1270 + static void fwtty_set_termios(struct tty_struct *tty, 1271 + const struct ktermios *old) 1271 1272 { 1272 1273 struct fwtty_port *port = tty->driver_data; 1273 1274 unsigned int baud;
+1 -1
drivers/staging/greybus/uart.c
··· 480 480 } 481 481 482 482 static void gb_tty_set_termios(struct tty_struct *tty, 483 - struct ktermios *termios_old) 483 + const struct ktermios *termios_old) 484 484 { 485 485 struct gb_uart_set_line_coding_request newline; 486 486 struct gb_tty *gb_tty = tty->driver_data;
+3 -3
drivers/tty/amiserial.c
··· 94 94 static unsigned char current_ctl_bits; 95 95 96 96 static void change_speed(struct tty_struct *tty, struct serial_state *info, 97 - struct ktermios *old); 97 + const struct ktermios *old); 98 98 static void rs_wait_until_sent(struct tty_struct *tty, int timeout); 99 99 100 100 ··· 566 566 * the specified baud rate for a serial port. 567 567 */ 568 568 static void change_speed(struct tty_struct *tty, struct serial_state *info, 569 - struct ktermios *old_termios) 569 + const struct ktermios *old_termios) 570 570 { 571 571 struct tty_port *port = &info->tport; 572 572 int quot = 0, baud_base, baud; ··· 1169 1169 return 0; 1170 1170 } 1171 1171 1172 - static void rs_set_termios(struct tty_struct *tty, struct ktermios *old_termios) 1172 + static void rs_set_termios(struct tty_struct *tty, const struct ktermios *old_termios) 1173 1173 { 1174 1174 struct serial_state *info = tty->driver_data; 1175 1175 unsigned long flags;
+5 -6
drivers/tty/hvc/hvc_iucv.c
··· 29 29 30 30 31 31 /* General device driver settings */ 32 - #define HVC_IUCV_MAGIC 0xc9e4c3e5 33 32 #define MAX_HVC_IUCV_LINES HVC_ALLOC_TTY_ADAPTERS 34 33 #define MEMPOOL_MIN_NR (PAGE_SIZE / sizeof(struct iucv_tty_buffer)/4) 35 34 ··· 130 131 */ 131 132 static struct hvc_iucv_private *hvc_iucv_get_private(uint32_t num) 132 133 { 133 - if ((num < HVC_IUCV_MAGIC) || (num - HVC_IUCV_MAGIC > hvc_iucv_devices)) 134 + if (num > hvc_iucv_devices) 134 135 return NULL; 135 - return hvc_iucv_table[num - HVC_IUCV_MAGIC]; 136 + return hvc_iucv_table[num]; 136 137 } 137 138 138 139 /** ··· 1071 1072 priv->is_console = is_console; 1072 1073 1073 1074 /* allocate hvc device */ 1074 - priv->hvc = hvc_alloc(HVC_IUCV_MAGIC + id, /* PAGE_SIZE */ 1075 - HVC_IUCV_MAGIC + id, &hvc_iucv_ops, 256); 1075 + priv->hvc = hvc_alloc(id, /* PAGE_SIZE */ 1076 + id, &hvc_iucv_ops, 256); 1076 1077 if (IS_ERR(priv->hvc)) { 1077 1078 rc = PTR_ERR(priv->hvc); 1078 1079 goto out_error_hvc; ··· 1370 1371 1371 1372 /* register the first terminal device as console 1372 1373 * (must be done before allocating hvc terminal devices) */ 1373 - rc = hvc_instantiate(HVC_IUCV_MAGIC, IUCV_HVC_CON_IDX, &hvc_iucv_ops); 1374 + rc = hvc_instantiate(0, IUCV_HVC_CON_IDX, &hvc_iucv_ops); 1374 1375 if (rc) { 1375 1376 pr_err("Registering HVC terminal device as " 1376 1377 "Linux console failed\n");
+2 -1
drivers/tty/hvc/hvcs.c
··· 69 69 #include <asm/hvconsole.h> 70 70 #include <asm/hvcserver.h> 71 71 #include <linux/uaccess.h> 72 + #include <linux/termios_internal.h> 72 73 #include <asm/vio.h> 73 74 74 75 /* ··· 840 839 hvcsd->p_partition_ID = pi->partition_ID; 841 840 842 841 /* copy the null-term char too */ 843 - strlcpy(hvcsd->p_location_code, pi->location_code, 842 + strscpy(hvcsd->p_location_code, pi->location_code, 844 843 sizeof(hvcsd->p_location_code)); 845 844 } 846 845
+5 -4
drivers/tty/moxa.c
··· 491 491 static unsigned int moxa_write_room(struct tty_struct *); 492 492 static void moxa_flush_buffer(struct tty_struct *); 493 493 static unsigned int moxa_chars_in_buffer(struct tty_struct *); 494 - static void moxa_set_termios(struct tty_struct *, struct ktermios *); 494 + static void moxa_set_termios(struct tty_struct *, const struct ktermios *); 495 495 static void moxa_stop(struct tty_struct *); 496 496 static void moxa_start(struct tty_struct *); 497 497 static void moxa_hangup(struct tty_struct *); ··· 499 499 static int moxa_tiocmset(struct tty_struct *tty, 500 500 unsigned int set, unsigned int clear); 501 501 static void moxa_poll(struct timer_list *); 502 - static void moxa_set_tty_param(struct tty_struct *, struct ktermios *); 502 + static void moxa_set_tty_param(struct tty_struct *, const struct ktermios *); 503 503 static void moxa_shutdown(struct tty_port *); 504 504 static int moxa_carrier_raised(struct tty_port *); 505 505 static void moxa_dtr_rts(struct tty_port *, int); ··· 1602 1602 } 1603 1603 1604 1604 static void moxa_set_termios(struct tty_struct *tty, 1605 - struct ktermios *old_termios) 1605 + const struct ktermios *old_termios) 1606 1606 { 1607 1607 struct moxa_port *ch = tty->driver_data; 1608 1608 ··· 1761 1761 1762 1762 /******************************************************************************/ 1763 1763 1764 - static void moxa_set_tty_param(struct tty_struct *tty, struct ktermios *old_termios) 1764 + static void moxa_set_tty_param(struct tty_struct *tty, 1765 + const struct ktermios *old_termios) 1765 1766 { 1766 1767 register struct ktermios *ts = &tty->termios; 1767 1768 struct moxa_port *ch = tty->driver_data;
+5 -3
drivers/tty/mxser.c
··· 398 398 oldmcr = inb(io + UART_MCR); 399 399 outb(0, io + UART_MCR); 400 400 mxser_set_must_xon1_value(io, 0x11); 401 - if ((hwid = inb(io + UART_MCR)) != 0) { 401 + if (inb(io + UART_MCR) != 0) { 402 402 outb(oldmcr, io + UART_MCR); 403 403 return MOXA_OTHER_UART; 404 404 } ··· 571 571 * This routine is called to set the UART divisor registers to match 572 572 * the specified baud rate for a serial port. 573 573 */ 574 - static void mxser_change_speed(struct tty_struct *tty, struct ktermios *old_termios) 574 + static void mxser_change_speed(struct tty_struct *tty, 575 + const struct ktermios *old_termios) 575 576 { 576 577 struct mxser_port *info = tty->driver_data; 577 578 unsigned cflag, cval; ··· 1349 1348 spin_unlock_irqrestore(&info->slock, flags); 1350 1349 } 1351 1350 1352 - static void mxser_set_termios(struct tty_struct *tty, struct ktermios *old_termios) 1351 + static void mxser_set_termios(struct tty_struct *tty, 1352 + const struct ktermios *old_termios) 1353 1353 { 1354 1354 struct mxser_port *info = tty->driver_data; 1355 1355 unsigned long flags;
+120 -82
drivers/tty/n_gsm.c
··· 63 63 static int debug; 64 64 module_param(debug, int, 0600); 65 65 66 + /* Module debug bits */ 67 + #define DBG_DUMP BIT(0) /* Data transmission dump. */ 68 + #define DBG_CD_ON BIT(1) /* Always assume CD line on. */ 69 + #define DBG_DATA BIT(2) /* Data transmission details. */ 70 + #define DBG_ERRORS BIT(3) /* Details for fail conditions. */ 71 + #define DBG_TTY BIT(4) /* Transmission statistics for DLCI TTYs. */ 72 + #define DBG_PAYLOAD BIT(5) /* Limits DBG_DUMP to payload frames. */ 73 + 66 74 /* Defaults: these are from the specification */ 67 75 68 76 #define T1 10 /* 100mS */ ··· 172 164 struct net_device *net; /* network interface, if created */ 173 165 }; 174 166 167 + /* Total number of supported devices */ 168 + #define GSM_TTY_MINORS 256 169 + 175 170 /* DLCI 0, 62/63 are special or reserved see gsmtty_open */ 176 171 177 172 #define NUM_DLCI 64 ··· 193 182 int len; /* Length of block for retransmission */ 194 183 int done; /* Done flag */ 195 184 int error; /* Error if any */ 185 + }; 186 + 187 + enum gsm_encoding { 188 + GSM_BASIC_OPT, 189 + GSM_ADV_OPT, 196 190 }; 197 191 198 192 enum gsm_mux_state { ··· 246 230 unsigned int address; 247 231 unsigned int count; 248 232 bool escape; 249 - int encoding; 233 + enum gsm_encoding encoding; 250 234 u8 control; 251 235 u8 fcs; 252 236 u8 *txframe; /* TX framing buffer */ ··· 543 527 */ 544 528 dev = tty_register_device(gsm_tty_driver, base + i, NULL); 545 529 if (IS_ERR(dev)) { 546 - if (debug & 8) 530 + if (debug & DBG_ERRORS) 547 531 pr_info("%s failed to register device minor %u", 548 532 __func__, base + i); 549 533 for (i--; i >= 1; i--) ··· 597 581 static void gsm_print_packet(const char *hdr, int addr, int cr, 598 582 u8 control, const u8 *data, int dlen) 599 583 { 600 - if (!(debug & 1)) 584 + if (!(debug & DBG_DUMP)) 601 585 return; 586 + /* Only show user payload frames if debug & DBG_PAYLOAD */ 587 + if (!(debug & DBG_PAYLOAD) && addr != 0) 588 + if ((control & ~PF) == UI || (control & ~PF) == UIH) 589 + return; 602 590 603 591 pr_info("%s %d) %c: ", hdr, addr, "RC"[cr]); 604 592 ··· 713 693 *dp++ = (addr << 2) | (ocr << 1) | EA; 714 694 *dp++ = control; 715 695 716 - if (gsm->encoding == 0) 696 + if (gsm->encoding == GSM_BASIC_OPT) 717 697 *dp++ = EA; /* Length of data = 0 */ 718 698 719 699 *dp = 0xFF - gsm_fcs_add_block(INIT_FCS, msg->data, dp - msg->data); ··· 832 812 int len, ret; 833 813 834 814 835 - if (gsm->encoding == 0) { 815 + if (gsm->encoding == GSM_BASIC_OPT) { 836 816 gsm->txframe[0] = GSM0_SOF; 837 817 memcpy(gsm->txframe + 1, msg->data, msg->len); 838 818 gsm->txframe[msg->len + 1] = GSM0_SOF; ··· 844 824 len += 2; 845 825 } 846 826 847 - if (debug & 4) 827 + if (debug & DBG_DATA) 848 828 gsm_hex_dump_bytes(__func__, gsm->txframe, len); 849 829 gsm_print_packet("-->", msg->addr, gsm->initiator, msg->ctrl, msg->data, 850 830 msg->len); ··· 984 964 u8 *fcs = dp + msg->len; 985 965 986 966 /* Fill in the header */ 987 - if (gsm->encoding == 0) { 967 + if (gsm->encoding == GSM_BASIC_OPT) { 988 968 if (msg->len < 128) 989 969 *--dp = (msg->len << 1) | EA; 990 970 else { ··· 1326 1306 1327 1307 1328 1308 /** 1309 + * gsm_control_command - send a command frame to a control 1310 + * @gsm: gsm channel 1311 + * @cmd: the command to use 1312 + * @data: data to follow encoded info 1313 + * @dlen: length of data 1314 + * 1315 + * Encode up and queue a UI/UIH frame containing our command. 1316 + */ 1317 + static int gsm_control_command(struct gsm_mux *gsm, int cmd, const u8 *data, 1318 + int dlen) 1319 + { 1320 + struct gsm_msg *msg = gsm_data_alloc(gsm, 0, dlen + 2, gsm->ftype); 1321 + 1322 + if (msg == NULL) 1323 + return -ENOMEM; 1324 + 1325 + msg->data[0] = (cmd << 1) | CR | EA; /* Set C/R */ 1326 + msg->data[1] = (dlen << 1) | EA; 1327 + memcpy(msg->data + 2, data, dlen); 1328 + gsm_data_queue(gsm->dlci[0], msg); 1329 + 1330 + return 0; 1331 + } 1332 + 1333 + /** 1329 1334 * gsm_control_reply - send a response frame to a control 1330 1335 * @gsm: gsm channel 1331 1336 * @cmd: the command to use ··· 1452 1407 unsigned int modem = 0; 1453 1408 struct gsm_dlci *dlci; 1454 1409 int len = clen; 1455 - int slen; 1410 + int cl = clen; 1456 1411 const u8 *dp = data; 1457 1412 struct tty_struct *tty; 1458 1413 1459 - while (gsm_read_ea(&addr, *dp++) == 0) { 1460 - len--; 1461 - if (len == 0) 1462 - return; 1463 - } 1464 - /* Must be at least one byte following the EA */ 1465 - len--; 1466 - if (len <= 0) 1414 + len = gsm_read_ea_val(&addr, data, cl); 1415 + if (len < 1) 1467 1416 return; 1468 1417 1469 1418 addr >>= 1; ··· 1466 1427 return; 1467 1428 dlci = gsm->dlci[addr]; 1468 1429 1469 - slen = len; 1470 - while (gsm_read_ea(&modem, *dp++) == 0) { 1471 - len--; 1472 - if (len == 0) 1473 - return; 1474 - } 1475 - len--; 1430 + /* Must be at least one byte following the EA */ 1431 + if ((cl - len) < 1) 1432 + return; 1433 + 1434 + dp += len; 1435 + cl -= len; 1436 + 1437 + /* get the modem status */ 1438 + len = gsm_read_ea_val(&modem, dp, cl); 1439 + if (len < 1) 1440 + return; 1441 + 1476 1442 tty = tty_port_tty_get(&dlci->port); 1477 - gsm_process_modem(tty, dlci, modem, slen - len); 1443 + gsm_process_modem(tty, dlci, modem, cl); 1478 1444 if (tty) { 1479 1445 tty_wakeup(tty); 1480 1446 tty_kref_put(tty); ··· 1655 1611 1656 1612 static void gsm_control_transmit(struct gsm_mux *gsm, struct gsm_control *ctrl) 1657 1613 { 1658 - struct gsm_msg *msg = gsm_data_alloc(gsm, 0, ctrl->len + 2, gsm->ftype); 1659 - if (msg == NULL) 1660 - return; 1661 - msg->data[0] = (ctrl->cmd << 1) | CR | EA; /* command */ 1662 - msg->data[1] = (ctrl->len << 1) | EA; 1663 - memcpy(msg->data + 2, ctrl->data, ctrl->len); 1664 - gsm_data_queue(gsm->dlci[0], msg); 1614 + gsm_control_command(gsm, ctrl->cmd, ctrl->data, ctrl->len); 1665 1615 } 1666 1616 1667 1617 /** ··· 1775 1737 static void gsm_dlci_close(struct gsm_dlci *dlci) 1776 1738 { 1777 1739 del_timer(&dlci->t1); 1778 - if (debug & 8) 1740 + if (debug & DBG_ERRORS) 1779 1741 pr_debug("DLCI %d goes closed.\n", dlci->addr); 1780 1742 dlci->state = DLCI_CLOSED; 1781 1743 /* Prevent us from sending data before the link is up again */ ··· 1809 1771 /* This will let a tty open continue */ 1810 1772 dlci->state = DLCI_OPEN; 1811 1773 dlci->constipated = false; 1812 - if (debug & 8) 1774 + if (debug & DBG_ERRORS) 1813 1775 pr_debug("DLCI %d goes open.\n", dlci->addr); 1814 1776 /* Send current modem state */ 1815 1777 if (dlci->addr) ··· 1845 1807 gsm_command(dlci->gsm, dlci->addr, SABM|PF); 1846 1808 mod_timer(&dlci->t1, jiffies + gsm->t1 * HZ / 100); 1847 1809 } else if (!dlci->addr && gsm->control == (DM | PF)) { 1848 - if (debug & 8) 1810 + if (debug & DBG_ERRORS) 1849 1811 pr_info("DLCI %d opening in ADM mode.\n", 1850 1812 dlci->addr); 1851 1813 dlci->mode = DLCI_MODE_ADM; ··· 1948 1910 struct tty_port *port = &dlci->port; 1949 1911 struct tty_struct *tty; 1950 1912 unsigned int modem = 0; 1951 - int len = clen; 1952 - int slen = 0; 1913 + int len; 1953 1914 1954 - if (debug & 16) 1955 - pr_debug("%d bytes for tty\n", len); 1915 + if (debug & DBG_TTY) 1916 + pr_debug("%d bytes for tty\n", clen); 1956 1917 switch (dlci->adaption) { 1957 1918 /* Unsupported types */ 1958 1919 case 4: /* Packetised interruptible data */ ··· 1959 1922 case 3: /* Packetised uininterruptible voice/data */ 1960 1923 break; 1961 1924 case 2: /* Asynchronous serial with line state in each frame */ 1962 - while (gsm_read_ea(&modem, *data++) == 0) { 1963 - len--; 1964 - slen++; 1965 - if (len == 0) 1966 - return; 1967 - } 1968 - len--; 1969 - slen++; 1925 + len = gsm_read_ea_val(&modem, data, clen); 1926 + if (len < 1) 1927 + return; 1970 1928 tty = tty_port_tty_get(port); 1971 1929 if (tty) { 1972 - gsm_process_modem(tty, dlci, modem, slen); 1930 + gsm_process_modem(tty, dlci, modem, len); 1973 1931 tty_wakeup(tty); 1974 1932 tty_kref_put(tty); 1975 1933 } 1934 + /* Skip processed modem data */ 1935 + data += len; 1936 + clen -= len; 1976 1937 fallthrough; 1977 1938 case 1: /* Line state will go via DLCI 0 controls only */ 1978 1939 default: 1979 - tty_insert_flip_string(port, data, len); 1940 + tty_insert_flip_string(port, data, clen); 1980 1941 tty_flip_buffer_push(port); 1981 1942 } 1982 1943 } ··· 1995 1960 { 1996 1961 /* See what command is involved */ 1997 1962 unsigned int command = 0; 1998 - while (len-- > 0) { 1999 - if (gsm_read_ea(&command, *data++) == 1) { 2000 - int clen = *data++; 2001 - len--; 2002 - /* FIXME: this is properly an EA */ 2003 - clen >>= 1; 2004 - /* Malformed command ? */ 2005 - if (clen > len) 2006 - return; 2007 - if (command & 1) 2008 - gsm_control_message(dlci->gsm, command, 2009 - data, clen); 2010 - else 2011 - gsm_control_response(dlci->gsm, command, 2012 - data, clen); 2013 - return; 2014 - } 2015 - } 1963 + unsigned int clen = 0; 1964 + unsigned int dlen; 1965 + 1966 + /* read the command */ 1967 + dlen = gsm_read_ea_val(&command, data, len); 1968 + len -= dlen; 1969 + data += dlen; 1970 + 1971 + /* read any control data */ 1972 + dlen = gsm_read_ea_val(&clen, data, len); 1973 + len -= dlen; 1974 + data += dlen; 1975 + 1976 + /* Malformed command? */ 1977 + if (clen > len) 1978 + return; 1979 + 1980 + if (command & 1) 1981 + gsm_control_message(dlci->gsm, command, data, clen); 1982 + else 1983 + gsm_control_response(dlci->gsm, command, data, clen); 2016 1984 } 2017 1985 2018 1986 /** ··· 2037 1999 sent = gsm_dlci_data_sweep(gsm); 2038 2000 mutex_unlock(&gsm->tx_mutex); 2039 2001 2040 - if (sent && debug & 4) 2002 + if (sent && debug & DBG_DATA) 2041 2003 pr_info("%s TX queue stalled\n", __func__); 2042 2004 } 2043 2005 ··· 2171 2133 2172 2134 if (gsm->fcs != GOOD_FCS) { 2173 2135 gsm->bad_fcs++; 2174 - if (debug & 4) 2136 + if (debug & DBG_DATA) 2175 2137 pr_debug("BAD FCS %02x\n", gsm->fcs); 2176 2138 return; 2177 2139 } ··· 2535 2497 if (dlci == NULL) 2536 2498 return -ENOMEM; 2537 2499 2538 - if (gsm->encoding == 0) 2500 + if (gsm->encoding == GSM_BASIC_OPT) 2539 2501 gsm->receive = gsm0_receive; 2540 2502 else 2541 2503 gsm->receive = gsm1_receive; ··· 2652 2614 gsm->n2 = N2; 2653 2615 gsm->ftype = UIH; 2654 2616 gsm->adaption = 1; 2655 - gsm->encoding = 1; 2617 + gsm->encoding = GSM_ADV_OPT; 2656 2618 gsm->mru = 64; /* Default to encoding 1 so these should be 64 */ 2657 2619 gsm->mtu = 64; 2658 2620 gsm->dead = true; /* Avoid early tty opens */ ··· 2754 2716 gsm->initiator = c->initiator; 2755 2717 gsm->mru = c->mru; 2756 2718 gsm->mtu = c->mtu; 2757 - gsm->encoding = c->encapsulation; 2719 + gsm->encoding = c->encapsulation ? GSM_ADV_OPT : GSM_BASIC_OPT; 2758 2720 gsm->adaption = c->adaption; 2759 2721 gsm->n2 = c->n2; 2760 2722 ··· 2798 2760 set_bit(TTY_DO_WRITE_WAKEUP, &gsm->tty->flags); 2799 2761 return -ENOSPC; 2800 2762 } 2801 - if (debug & 4) 2763 + if (debug & DBG_DATA) 2802 2764 gsm_hex_dump_bytes(__func__, data, len); 2803 2765 return gsm->tty->ops->write(gsm->tty, data, len); 2804 2766 } ··· 2884 2846 struct gsm_mux *gsm = tty->disc_data; 2885 2847 char flags = TTY_NORMAL; 2886 2848 2887 - if (debug & 4) 2849 + if (debug & DBG_DATA) 2888 2850 gsm_hex_dump_bytes(__func__, cp, count); 2889 2851 2890 2852 for (; count; count--, cp++) { ··· 2977 2939 tty->receive_room = 65536; 2978 2940 2979 2941 /* Attach the initial passive connection */ 2980 - gsm->encoding = 1; 2981 - 2942 + gsm->encoding = GSM_ADV_OPT; 2982 2943 gsmld_attach_gsm(tty, gsm); 2983 2944 2984 2945 return 0; ··· 3373 3336 struct gsm_control *ctrl; 3374 3337 int len = 2; 3375 3338 3376 - if (dlci->gsm->encoding != 0) 3339 + if (dlci->gsm->encoding != GSM_BASIC_OPT) 3377 3340 return 0; 3378 3341 3379 3342 modembits[0] = (dlci->addr << 2) | 2 | EA; /* DLCI, Valid, EA */ ··· 3402 3365 /* Send convergence layer type 2 empty data frame. */ 3403 3366 gsm_modem_upd_via_data(dlci, brk); 3404 3367 return 0; 3405 - } else if (dlci->gsm->encoding == 0) { 3368 + } else if (dlci->gsm->encoding == GSM_BASIC_OPT) { 3406 3369 /* Send as MSC control message. */ 3407 3370 return gsm_modem_upd_via_msc(dlci, brk); 3408 3371 } ··· 3419 3382 /* Not yet open so no carrier info */ 3420 3383 if (dlci->state != DLCI_OPEN) 3421 3384 return 0; 3422 - if (debug & 2) 3385 + if (debug & DBG_CD_ON) 3423 3386 return 1; 3424 3387 3425 3388 /* 3426 3389 * Basic mode with control channel in ADM mode may not respond 3427 3390 * to CMD_MSC at all and modem_rx is empty. 3428 3391 */ 3429 - if (gsm->encoding == 0 && gsm->dlci[0]->mode == DLCI_MODE_ADM && 3430 - !dlci->modem_rx) 3392 + if (gsm->encoding == GSM_BASIC_OPT && 3393 + gsm->dlci[0]->mode == DLCI_MODE_ADM && !dlci->modem_rx) 3431 3394 return 1; 3432 3395 3433 3396 return dlci->modem_rx & TIOCM_CD; ··· 3675 3638 } 3676 3639 } 3677 3640 3678 - static void gsmtty_set_termios(struct tty_struct *tty, struct ktermios *old) 3641 + static void gsmtty_set_termios(struct tty_struct *tty, 3642 + const struct ktermios *old) 3679 3643 { 3680 3644 struct gsm_dlci *dlci = tty->driver_data; 3681 3645 if (dlci->state == DLCI_CLOSED) ··· 3774 3736 return status; 3775 3737 } 3776 3738 3777 - gsm_tty_driver = tty_alloc_driver(256, TTY_DRIVER_REAL_RAW | 3739 + gsm_tty_driver = tty_alloc_driver(GSM_TTY_MINORS, TTY_DRIVER_REAL_RAW | 3778 3740 TTY_DRIVER_DYNAMIC_DEV | TTY_DRIVER_HARDWARE_BREAK); 3779 3741 if (IS_ERR(gsm_tty_driver)) { 3780 3742 pr_err("gsm_init: tty allocation failed.\n");
-28
drivers/tty/n_hdlc.c
··· 76 76 * OF THE POSSIBILITY OF SUCH DAMAGE. 77 77 */ 78 78 79 - #define HDLC_MAGIC 0x239e 80 - 81 79 #include <linux/module.h> 82 80 #include <linux/init.h> 83 81 #include <linux/kernel.h> ··· 96 98 #include <linux/if.h> 97 99 #include <linux/bitops.h> 98 100 99 - #include <asm/termios.h> 100 101 #include <linux/uaccess.h> 101 102 #include "tty.h" 102 103 ··· 121 124 122 125 /** 123 126 * struct n_hdlc - per device instance data structure 124 - * @magic: magic value for structure 125 127 * @tbusy: reentrancy flag for tx wakeup code 126 128 * @woke_up: tx wakeup needs to be run again as it was called while @tbusy 127 129 * @tx_buf_list: list of pending transmit frame buffers ··· 129 133 * @rx_free_buf_list: list unused received frame buffers 130 134 */ 131 135 struct n_hdlc { 132 - int magic; 133 136 bool tbusy; 134 137 bool woke_up; 135 138 struct n_hdlc_buf_list tx_buf_list; ··· 195 200 { 196 201 struct n_hdlc *n_hdlc = tty->disc_data; 197 202 198 - if (n_hdlc->magic != HDLC_MAGIC) { 199 - pr_warn("n_hdlc: trying to close unopened tty!\n"); 200 - return; 201 - } 202 203 #if defined(TTY_NO_WRITE_SPLIT) 203 204 clear_bit(TTY_NO_WRITE_SPLIT, &tty->flags); 204 205 #endif ··· 377 386 378 387 pr_debug("%s() called count=%d\n", __func__, count); 379 388 380 - /* verify line is using HDLC discipline */ 381 - if (n_hdlc->magic != HDLC_MAGIC) { 382 - pr_err("line not using HDLC discipline\n"); 383 - return; 384 - } 385 - 386 389 if (count > maxframe) { 387 390 pr_debug("rx count>maxframesize, data discarded\n"); 388 391 return; ··· 527 542 528 543 pr_debug("%s() called count=%zd\n", __func__, count); 529 544 530 - if (n_hdlc->magic != HDLC_MAGIC) 531 - return -EIO; 532 - 533 545 /* verify frame size */ 534 546 if (count > maxframe) { 535 547 pr_debug("%s: truncating user packet from %zu to %d\n", ··· 591 609 592 610 pr_debug("%s() called %d\n", __func__, cmd); 593 611 594 - /* Verify the status of the device */ 595 - if (n_hdlc->magic != HDLC_MAGIC) 596 - return -EBADF; 597 - 598 612 switch (cmd) { 599 613 case FIONREAD: 600 614 /* report count of read data available */ ··· 650 672 { 651 673 struct n_hdlc *n_hdlc = tty->disc_data; 652 674 __poll_t mask = 0; 653 - 654 - if (n_hdlc->magic != HDLC_MAGIC) 655 - return 0; 656 675 657 676 /* 658 677 * queue the current process into any wait queue that may awaken in the ··· 713 738 714 739 n_hdlc_alloc_buf(&n_hdlc->rx_free_buf_list, DEFAULT_RX_BUF_COUNT, "rx"); 715 740 n_hdlc_alloc_buf(&n_hdlc->tx_free_buf_list, DEFAULT_TX_BUF_COUNT, "tx"); 716 - 717 - /* Initialize the control block */ 718 - n_hdlc->magic = HDLC_MAGIC; 719 741 720 742 return n_hdlc; 721 743
+1 -1
drivers/tty/n_tty.c
··· 1758 1758 * 1759 1759 * Locking: Caller holds @tty->termios_rwsem 1760 1760 */ 1761 - static void n_tty_set_termios(struct tty_struct *tty, struct ktermios *old) 1761 + static void n_tty_set_termios(struct tty_struct *tty, const struct ktermios *old) 1762 1762 { 1763 1763 struct n_tty_data *ldata = tty->disc_data; 1764 1764
+1 -1
drivers/tty/pty.c
··· 240 240 } 241 241 242 242 static void pty_set_termios(struct tty_struct *tty, 243 - struct ktermios *old_termios) 243 + const struct ktermios *old_termios) 244 244 { 245 245 /* See if packet mode change of state. */ 246 246 if (tty->link && tty->link->ctrl.packet) {
+1 -1
drivers/tty/serial/21285.c
··· 243 243 244 244 static void 245 245 serial21285_set_termios(struct uart_port *port, struct ktermios *termios, 246 - struct ktermios *old) 246 + const struct ktermios *old) 247 247 { 248 248 unsigned long flags; 249 249 unsigned int baud, quot, h_lcr, b;
+1 -1
drivers/tty/serial/8250/8250_bcm7271.c
··· 755 755 756 756 static void brcmstb_set_termios(struct uart_port *up, 757 757 struct ktermios *termios, 758 - struct ktermios *old) 758 + const struct ktermios *old) 759 759 { 760 760 struct uart_8250_port *p8250 = up_to_u8250p(up); 761 761 struct brcmuart_priv *priv = up->private_data;
+11 -5
drivers/tty/serial/8250/8250_core.c
··· 298 298 jiffies + uart_poll_timeout(&up->port) + HZ / 5); 299 299 } 300 300 301 - static int univ8250_setup_irq(struct uart_8250_port *up) 301 + static void univ8250_setup_timer(struct uart_8250_port *up) 302 302 { 303 303 struct uart_port *port = &up->port; 304 - int retval = 0; 305 304 306 305 /* 307 306 * The above check will only give an accurate result the first time ··· 321 322 */ 322 323 if (!port->irq) 323 324 mod_timer(&up->timer, jiffies + uart_poll_timeout(port)); 324 - else 325 - retval = serial_link_irq_chain(up); 325 + } 326 326 327 - return retval; 327 + static int univ8250_setup_irq(struct uart_8250_port *up) 328 + { 329 + struct uart_port *port = &up->port; 330 + 331 + if (port->irq) 332 + return serial_link_irq_chain(up); 333 + 334 + return 0; 328 335 } 329 336 330 337 static void univ8250_release_irq(struct uart_8250_port *up) ··· 386 381 static const struct uart_8250_ops univ8250_driver_ops = { 387 382 .setup_irq = univ8250_setup_irq, 388 383 .release_irq = univ8250_release_irq, 384 + .setup_timer = univ8250_setup_timer, 389 385 }; 390 386 391 387 static struct uart_8250_port serial8250_ports[UART_NR];
+2 -5
drivers/tty/serial/8250/8250_dma.c
··· 26 26 27 27 dma->tx_running = 0; 28 28 29 - xmit->tail += dma->tx_size; 30 - xmit->tail &= UART_XMIT_SIZE - 1; 31 - p->port.icount.tx += dma->tx_size; 29 + uart_xmit_advance(&p->port, dma->tx_size); 32 30 33 31 if (uart_circ_chars_pending(xmit) < WAKEUP_CHARS) 34 32 uart_write_wakeup(&p->port); ··· 105 107 106 108 dma_async_issue_pending(dma->txchan); 107 109 serial8250_clear_THRI(p); 108 - if (dma->tx_err) 109 - dma->tx_err = 0; 110 + dma->tx_err = 0; 110 111 111 112 return 0; 112 113 err:
+1 -1
drivers/tty/serial/8250/8250_dw.c
··· 350 350 } 351 351 352 352 static void dw8250_set_termios(struct uart_port *p, struct ktermios *termios, 353 - struct ktermios *old) 353 + const struct ktermios *old) 354 354 { 355 355 unsigned long newrate = tty_termios_baud_rate(termios) * 16; 356 356 struct dw8250_data *d = to_dw8250_data(p->private_data);
+2 -1
drivers/tty/serial/8250/8250_dwlib.c
··· 92 92 serial8250_do_set_divisor(p, baud, quot, quot_frac); 93 93 } 94 94 95 - void dw8250_do_set_termios(struct uart_port *p, struct ktermios *termios, struct ktermios *old) 95 + void dw8250_do_set_termios(struct uart_port *p, struct ktermios *termios, 96 + const struct ktermios *old) 96 97 { 97 98 p->status &= ~UPSTAT_AUTOCTS; 98 99 if (termios->c_cflag & CRTSCTS)
+1 -1
drivers/tty/serial/8250/8250_dwlib.h
··· 47 47 unsigned int uart_16550_compatible:1; 48 48 }; 49 49 50 - void dw8250_do_set_termios(struct uart_port *p, struct ktermios *termios, struct ktermios *old); 50 + void dw8250_do_set_termios(struct uart_port *p, struct ktermios *termios, const struct ktermios *old); 51 51 void dw8250_setup_port(struct uart_port *p); 52 52 53 53 static inline struct dw8250_data *to_dw8250_data(struct dw8250_port_data *data)
+1 -1
drivers/tty/serial/8250/8250_fintek.c
··· 278 278 279 279 static void fintek_8250_set_termios(struct uart_port *port, 280 280 struct ktermios *termios, 281 - struct ktermios *old) 281 + const struct ktermios *old) 282 282 { 283 283 struct fintek_8250 *pdata = port->private_data; 284 284 unsigned int baud = tty_termios_baud_rate(termios);
+1 -1
drivers/tty/serial/8250/8250_lpss.c
··· 70 70 } 71 71 72 72 static void byt_set_termios(struct uart_port *p, struct ktermios *termios, 73 - struct ktermios *old) 73 + const struct ktermios *old) 74 74 { 75 75 unsigned int baud = tty_termios_baud_rate(termios); 76 76 struct lpss8250 *lpss = to_lpss8250(p->private_data);
-1
drivers/tty/serial/8250/8250_men_mcb.c
··· 7 7 #include <linux/serial.h> 8 8 #include <linux/serial_core.h> 9 9 #include <linux/serial_8250.h> 10 - #include <uapi/linux/serial_core.h> 11 10 12 11 #define MEN_UART_ID_Z025 0x19 13 12 #define MEN_UART_ID_Z057 0x39
+2 -3
drivers/tty/serial/8250/8250_mid.c
··· 206 206 207 207 /*****************************************************************************/ 208 208 209 - static void mid8250_set_termios(struct uart_port *p, 210 - struct ktermios *termios, 211 - struct ktermios *old) 209 + static void mid8250_set_termios(struct uart_port *p, struct ktermios *termios, 210 + const struct ktermios *old) 212 211 { 213 212 unsigned int baud = tty_termios_baud_rate(termios); 214 213 struct mid8250 *mid = p->private_data;
+1 -1
drivers/tty/serial/8250/8250_mtk.c
··· 291 291 292 292 static void 293 293 mtk8250_set_termios(struct uart_port *port, struct ktermios *termios, 294 - struct ktermios *old) 294 + const struct ktermios *old) 295 295 { 296 296 static const unsigned short fraction_L_mapping[] = { 297 297 0, 1, 0x5, 0x15, 0x55, 0x57, 0x57, 0x77, 0x7F, 0xFF, 0xFF
+5 -4
drivers/tty/serial/8250/8250_omap.c
··· 342 342 omap8250_update_mdr1(up, priv); 343 343 344 344 up->port.ops->set_mctrl(&up->port, up->port.mctrl); 345 + 346 + if (up->port.rs485.flags & SER_RS485_ENABLED) 347 + serial8250_em485_stop_tx(up); 345 348 } 346 349 347 350 /* ··· 353 350 */ 354 351 static void omap_8250_set_termios(struct uart_port *port, 355 352 struct ktermios *termios, 356 - struct ktermios *old) 353 + const struct ktermios *old) 357 354 { 358 355 struct uart_8250_port *up = up_to_u8250p(port); 359 356 struct omap8250_priv *priv = up->port.private_data; ··· 987 984 988 985 dma->tx_running = 0; 989 986 990 - xmit->tail += dma->tx_size; 991 - xmit->tail &= UART_XMIT_SIZE - 1; 992 - p->port.icount.tx += dma->tx_size; 987 + uart_xmit_advance(&p->port, dma->tx_size); 993 988 994 989 if (priv->delayed_restore) { 995 990 priv->delayed_restore = 0;
+6 -8
drivers/tty/serial/8250/8250_pci.c
··· 1232 1232 serial8250_do_set_mctrl(port, mctrl); 1233 1233 } 1234 1234 1235 + /* 1236 + * We require EFR features for clock programming, so set UPF_FULL_PROBE 1237 + * for full probing regardless of CONFIG_SERIAL_8250_16550A_VARIANTS setting. 1238 + */ 1235 1239 static int pci_oxsemi_tornado_setup(struct serial_private *priv, 1236 1240 const struct pciserial_board *board, 1237 1241 struct uart_8250_port *up, int idx) ··· 1243 1239 struct pci_dev *dev = priv->dev; 1244 1240 1245 1241 if (pci_oxsemi_tornado_p(dev)) { 1242 + up->port.flags |= UPF_FULL_PROBE; 1246 1243 up->port.get_divisor = pci_oxsemi_tornado_get_divisor; 1247 1244 up->port.set_divisor = pci_oxsemi_tornado_set_divisor; 1248 1245 up->port.set_mctrl = pci_oxsemi_tornado_set_mctrl; ··· 1632 1627 resource_size_t bar_data[3]; 1633 1628 u8 config_base; 1634 1629 struct serial_private *priv = pci_get_drvdata(dev); 1635 - struct uart_8250_port *port; 1636 1630 1637 1631 if (!(pci_resource_flags(dev, 5) & IORESOURCE_IO) || 1638 1632 !(pci_resource_flags(dev, 4) & IORESOURCE_IO) || ··· 1678 1674 1679 1675 pci_write_config_byte(dev, config_base + 0x06, dev->irq); 1680 1676 1681 - if (priv) { 1682 - /* re-apply RS232/485 mode when 1683 - * pciserial_resume_ports() 1684 - */ 1685 - port = serial8250_get_port(priv->line[i]); 1686 - uart_rs485_config(&port->port); 1687 - } else { 1677 + if (!priv) { 1688 1678 /* First init without port data 1689 1679 * force init to RS232 Mode 1690 1680 */
+35 -27
drivers/tty/serial/8250/8250_port.c
··· 600 600 static int serial8250_em485_init(struct uart_8250_port *p) 601 601 { 602 602 if (p->em485) 603 - return 0; 603 + goto deassert_rts; 604 604 605 605 p->em485 = kmalloc(sizeof(struct uart_8250_em485), GFP_ATOMIC); 606 606 if (!p->em485) ··· 616 616 p->em485->active_timer = NULL; 617 617 p->em485->tx_stopped = true; 618 618 619 - p->rs485_stop_tx(p); 619 + deassert_rts: 620 + if (p->em485->tx_stopped) 621 + p->rs485_stop_tx(p); 620 622 621 623 return 0; 622 624 } ··· 752 750 } 753 751 754 752 serial8250_rpm_put(p); 753 + } 754 + 755 + static void serial8250_clear_IER(struct uart_8250_port *up) 756 + { 757 + if (up->capabilities & UART_CAP_UUE) 758 + serial_out(up, UART_IER, UART_IER_UUE); 759 + else 760 + serial_out(up, UART_IER, 0); 755 761 } 756 762 757 763 #ifdef CONFIG_SERIAL_8250_RSA ··· 1031 1021 up->port.type = PORT_16550A; 1032 1022 up->capabilities |= UART_CAP_FIFO; 1033 1023 1034 - if (!IS_ENABLED(CONFIG_SERIAL_8250_16550A_VARIANTS)) 1024 + if (!IS_ENABLED(CONFIG_SERIAL_8250_16550A_VARIANTS) && 1025 + !(up->port.flags & UPF_FULL_PROBE)) 1035 1026 return; 1036 1027 1037 1028 /* ··· 1144 1133 * internal UARTs. 1145 1134 * We're going to explicitly set the UUE bit to 0 before 1146 1135 * trying to write and read a 1 just to make sure it's not 1147 - * already a 1 and maybe locked there before we even start start. 1136 + * already a 1 and maybe locked there before we even start. 1148 1137 */ 1149 1138 iersave = serial_in(up, UART_IER); 1150 1139 serial_out(up, UART_IER, iersave & ~UART_IER_UUE); ··· 1340 1329 serial8250_out_MCR(up, save_mcr); 1341 1330 serial8250_clear_fifos(up); 1342 1331 serial_in(up, UART_RX); 1343 - if (up->capabilities & UART_CAP_UUE) 1344 - serial_out(up, UART_IER, UART_IER_UUE); 1345 - else 1346 - serial_out(up, UART_IER, 0); 1332 + serial8250_clear_IER(up); 1347 1333 1348 1334 out_unlock: 1349 1335 spin_unlock_irqrestore(&port->lock, flags); ··· 2050 2042 2051 2043 static void serial8250_set_mctrl(struct uart_port *port, unsigned int mctrl) 2052 2044 { 2045 + if (port->rs485.flags & SER_RS485_ENABLED) 2046 + return; 2047 + 2053 2048 if (port->set_mctrl) 2054 2049 port->set_mctrl(port, mctrl); 2055 2050 else ··· 2153 2142 * First save the IER then disable the interrupts 2154 2143 */ 2155 2144 ier = serial_port_in(port, UART_IER); 2156 - if (up->capabilities & UART_CAP_UUE) 2157 - serial_port_out(port, UART_IER, UART_IER_UUE); 2158 - else 2159 - serial_port_out(port, UART_IER, 0); 2145 + serial8250_clear_IER(up); 2160 2146 2161 2147 wait_for_xmitr(up, UART_LSR_BOTH_EMPTY); 2162 2148 /* ··· 2302 2294 if (port->irq && (up->port.flags & UPF_SHARE_IRQ)) 2303 2295 up->port.irqflags |= IRQF_SHARED; 2304 2296 2297 + retval = up->ops->setup_irq(up); 2298 + if (retval) 2299 + goto out; 2300 + 2305 2301 if (port->irq && !(up->port.flags & UPF_NO_THRE_TEST)) { 2306 2302 unsigned char iir1; 2307 2303 ··· 2348 2336 } 2349 2337 } 2350 2338 2351 - retval = up->ops->setup_irq(up); 2352 - if (retval) 2353 - goto out; 2339 + up->ops->setup_timer(up); 2354 2340 2355 2341 /* 2356 2342 * Now, initialize the UART ··· 2661 2651 2662 2652 static unsigned int serial8250_get_baud_rate(struct uart_port *port, 2663 2653 struct ktermios *termios, 2664 - struct ktermios *old) 2654 + const struct ktermios *old) 2665 2655 { 2666 2656 unsigned int tolerance = port->uartclk / 100; 2667 2657 unsigned int min; ··· 2747 2737 2748 2738 void 2749 2739 serial8250_do_set_termios(struct uart_port *port, struct ktermios *termios, 2750 - struct ktermios *old) 2740 + const struct ktermios *old) 2751 2741 { 2752 2742 struct uart_8250_port *up = up_to_u8250p(port); 2753 2743 unsigned char cval; ··· 2885 2875 2886 2876 static void 2887 2877 serial8250_set_termios(struct uart_port *port, struct ktermios *termios, 2888 - struct ktermios *old) 2878 + const struct ktermios *old) 2889 2879 { 2890 2880 if (port->set_termios) 2891 2881 port->set_termios(port, termios, old); ··· 3197 3187 if (flags & UART_CONFIG_TYPE) 3198 3188 autoconfig(up); 3199 3189 3200 - if (port->rs485.flags & SER_RS485_ENABLED) 3201 - uart_rs485_config(port); 3202 - 3203 3190 /* if access method is AU, it is a 16550 with a quirk */ 3204 3191 if (port->type == PORT_16550A && port->iotype == UPIO_AU) 3205 3192 up->bugs |= UART_BUG_NOMSR; ··· 3321 3314 unsigned int baud, quot, frac = 0; 3322 3315 3323 3316 termios.c_cflag = port->cons->cflag; 3324 - if (port->state->port.tty && termios.c_cflag == 0) 3317 + termios.c_ispeed = port->cons->ispeed; 3318 + termios.c_ospeed = port->cons->ospeed; 3319 + if (port->state->port.tty && termios.c_cflag == 0) { 3325 3320 termios.c_cflag = port->state->port.tty->termios.c_cflag; 3321 + termios.c_ispeed = port->state->port.tty->termios.c_ispeed; 3322 + termios.c_ospeed = port->state->port.tty->termios.c_ospeed; 3323 + } 3326 3324 3327 3325 baud = serial8250_get_baud_rate(port, &termios, NULL); 3328 3326 quot = serial8250_get_divisor(port, baud, &frac); ··· 3395 3383 * First save the IER then disable the interrupts 3396 3384 */ 3397 3385 ier = serial_port_in(port, UART_IER); 3398 - 3399 - if (up->capabilities & UART_CAP_UUE) 3400 - serial_port_out(port, UART_IER, UART_IER_UUE); 3401 - else 3402 - serial_port_out(port, UART_IER, 0); 3386 + serial8250_clear_IER(up); 3403 3387 3404 3388 /* check scratch reg to see if port powered off during system sleep */ 3405 3389 if (up->canary && (up->canary != serial_port_in(port, UART_SCR))) {
+3 -2
drivers/tty/serial/Kconfig
··· 127 127 128 128 config SERIAL_ATMEL 129 129 bool "AT91 on-chip serial port support" 130 + depends on COMMON_CLK 130 131 depends on ARCH_AT91 || COMPILE_TEST 131 132 select SERIAL_CORE 132 133 select SERIAL_MCTRL_GPIO if GPIOLIB ··· 428 427 429 428 config SERIAL_PXA_NON8250 430 429 bool 431 - depends on !SERIAL_8250 430 + depends on !SERIAL_8250 || COMPILE_TEST 432 431 433 432 config SERIAL_PXA_CONSOLE 434 433 bool "Console on PXA serial port (DEPRECATED)" ··· 1326 1325 1327 1326 config SERIAL_FSL_LPUART_CONSOLE 1328 1327 bool "Console on Freescale lpuart serial port" 1329 - depends on SERIAL_FSL_LPUART=y 1328 + depends on SERIAL_FSL_LPUART 1330 1329 select SERIAL_CORE_CONSOLE 1331 1330 select SERIAL_EARLYCON 1332 1331 help
+21 -15
drivers/tty/serial/altera_jtaguart.c
··· 9 9 * (C) Copyright 2010, Tobias Klauser <tklauser@distanz.ch> 10 10 */ 11 11 12 + #include <linux/bitfield.h> 12 13 #include <linux/kernel.h> 13 14 #include <linux/init.h> 14 15 #include <linux/interrupt.h> ··· 49 48 #define ALTERA_JTAGUART_CONTROL_WI_MSK 0x00000200 50 49 #define ALTERA_JTAGUART_CONTROL_AC_MSK 0x00000400 51 50 #define ALTERA_JTAGUART_CONTROL_WSPACE_MSK 0xFFFF0000 52 - #define ALTERA_JTAGUART_CONTROL_WSPACE_OFF 16 53 51 54 52 /* 55 53 * Local per-uart structure. ··· 59 59 unsigned long imr; /* Local IMR mirror */ 60 60 }; 61 61 62 + static unsigned int altera_jtaguart_tx_space(struct uart_port *port, u32 *ctlp) 63 + { 64 + u32 ctl = readl(port->membase + ALTERA_JTAGUART_CONTROL_REG); 65 + 66 + if (ctlp) 67 + *ctlp = ctl; 68 + 69 + return FIELD_GET(ALTERA_JTAGUART_CONTROL_WSPACE_MSK, ctl); 70 + } 71 + 62 72 static unsigned int altera_jtaguart_tx_empty(struct uart_port *port) 63 73 { 64 - return (readl(port->membase + ALTERA_JTAGUART_CONTROL_REG) & 65 - ALTERA_JTAGUART_CONTROL_WSPACE_MSK) ? TIOCSER_TEMT : 0; 74 + return altera_jtaguart_tx_space(port, NULL) ? TIOCSER_TEMT : 0; 66 75 } 67 76 68 77 static unsigned int altera_jtaguart_get_mctrl(struct uart_port *port) ··· 115 106 } 116 107 117 108 static void altera_jtaguart_set_termios(struct uart_port *port, 118 - struct ktermios *termios, 119 - struct ktermios *old) 109 + struct ktermios *termios, 110 + const struct ktermios *old) 120 111 { 121 112 /* Just copy the old termios settings back */ 122 113 if (old) ··· 159 150 160 151 pending = uart_circ_chars_pending(xmit); 161 152 if (pending > 0) { 162 - count = (readl(port->membase + ALTERA_JTAGUART_CONTROL_REG) & 163 - ALTERA_JTAGUART_CONTROL_WSPACE_MSK) >> 164 - ALTERA_JTAGUART_CONTROL_WSPACE_OFF; 153 + count = altera_jtaguart_tx_space(port, NULL); 165 154 if (count > pending) 166 155 count = pending; 167 156 if (count > 0) { ··· 305 298 #if defined(CONFIG_SERIAL_ALTERA_JTAGUART_CONSOLE_BYPASS) 306 299 static void altera_jtaguart_console_putc(struct uart_port *port, unsigned char c) 307 300 { 308 - unsigned long status; 309 301 unsigned long flags; 302 + u32 status; 310 303 311 304 spin_lock_irqsave(&port->lock, flags); 312 - while (((status = readl(port->membase + ALTERA_JTAGUART_CONTROL_REG)) & 313 - ALTERA_JTAGUART_CONTROL_WSPACE_MSK) == 0) { 305 + while (!altera_jtaguart_tx_space(port, &status)) { 306 + spin_unlock_irqrestore(&port->lock, flags); 307 + 314 308 if ((status & ALTERA_JTAGUART_CONTROL_AC_MSK) == 0) { 315 - spin_unlock_irqrestore(&port->lock, flags); 316 309 return; /* no connection activity */ 317 310 } 318 - spin_unlock_irqrestore(&port->lock, flags); 311 + 319 312 cpu_relax(); 320 313 spin_lock_irqsave(&port->lock, flags); 321 314 } ··· 328 321 unsigned long flags; 329 322 330 323 spin_lock_irqsave(&port->lock, flags); 331 - while ((readl(port->membase + ALTERA_JTAGUART_CONTROL_REG) & 332 - ALTERA_JTAGUART_CONTROL_WSPACE_MSK) == 0) { 324 + while (!altera_jtaguart_tx_space(port, NULL)) { 333 325 spin_unlock_irqrestore(&port->lock, flags); 334 326 cpu_relax(); 335 327 spin_lock_irqsave(&port->lock, flags);
+7 -11
drivers/tty/serial/altera_uart.c
··· 175 175 176 176 static void altera_uart_set_termios(struct uart_port *port, 177 177 struct ktermios *termios, 178 - struct ktermios *old) 178 + const struct ktermios *old) 179 179 { 180 180 unsigned long flags; 181 181 unsigned int baud, baudclk; ··· 199 199 */ 200 200 } 201 201 202 - static void altera_uart_rx_chars(struct altera_uart *pp) 202 + static void altera_uart_rx_chars(struct uart_port *port) 203 203 { 204 - struct uart_port *port = &pp->port; 205 204 unsigned char ch, flag; 206 205 unsigned short status; 207 206 ··· 245 246 tty_flip_buffer_push(&port->state->port); 246 247 } 247 248 248 - static void altera_uart_tx_chars(struct altera_uart *pp) 249 + static void altera_uart_tx_chars(struct uart_port *port) 249 250 { 250 - struct uart_port *port = &pp->port; 251 251 struct circ_buf *xmit = &port->state->xmit; 252 252 253 253 if (port->x_char) { ··· 270 272 if (uart_circ_chars_pending(xmit) < WAKEUP_CHARS) 271 273 uart_write_wakeup(port); 272 274 273 - if (xmit->head == xmit->tail) { 274 - pp->imr &= ~ALTERA_UART_CONTROL_TRDY_MSK; 275 - altera_uart_update_ctrl_reg(pp); 276 - } 275 + if (uart_circ_empty(xmit)) 276 + altera_uart_stop_tx(port); 277 277 } 278 278 279 279 static irqreturn_t altera_uart_interrupt(int irq, void *data) ··· 284 288 285 289 spin_lock(&port->lock); 286 290 if (isr & ALTERA_UART_STATUS_RRDY_MSK) 287 - altera_uart_rx_chars(pp); 291 + altera_uart_rx_chars(port); 288 292 if (isr & ALTERA_UART_STATUS_TRDY_MSK) 289 - altera_uart_tx_chars(pp); 293 + altera_uart_tx_chars(port); 290 294 spin_unlock(&port->lock); 291 295 292 296 return IRQ_RETVAL(isr);
+1 -1
drivers/tty/serial/amba-pl010.c
··· 370 370 371 371 static void 372 372 pl010_set_termios(struct uart_port *port, struct ktermios *termios, 373 - struct ktermios *old) 373 + const struct ktermios *old) 374 374 { 375 375 unsigned int lcr_h, old_cr; 376 376 unsigned long flags;
+18 -2
drivers/tty/serial/amba-pl011.c
··· 2030 2030 2031 2031 static void 2032 2032 pl011_set_termios(struct uart_port *port, struct ktermios *termios, 2033 - struct ktermios *old) 2033 + const struct ktermios *old) 2034 2034 { 2035 2035 struct uart_amba_port *uap = 2036 2036 container_of(port, struct uart_amba_port, port); ··· 2162 2162 2163 2163 static void 2164 2164 sbsa_uart_set_termios(struct uart_port *port, struct ktermios *termios, 2165 - struct ktermios *old) 2165 + const struct ktermios *old) 2166 2166 { 2167 2167 struct uart_amba_port *uap = 2168 2168 container_of(port, struct uart_amba_port, port); ··· 2777 2777 struct uart_amba_port *uap; 2778 2778 struct vendor_data *vendor = id->data; 2779 2779 int portnr, ret; 2780 + u32 val; 2780 2781 2781 2782 portnr = pl011_find_free_port(); 2782 2783 if (portnr < 0) ··· 2801 2800 uap->port.rs485_config = pl011_rs485_config; 2802 2801 uap->port.rs485_supported = pl011_rs485_supported; 2803 2802 snprintf(uap->type, sizeof(uap->type), "PL011 rev%u", amba_rev(dev)); 2803 + 2804 + if (device_property_read_u32(&dev->dev, "reg-io-width", &val) == 0) { 2805 + switch (val) { 2806 + case 1: 2807 + uap->port.iotype = UPIO_MEM; 2808 + break; 2809 + case 4: 2810 + uap->port.iotype = UPIO_MEM32; 2811 + break; 2812 + default: 2813 + dev_warn(&dev->dev, "unsupported reg-io-width (%d)\n", 2814 + val); 2815 + return -EINVAL; 2816 + } 2817 + } 2804 2818 2805 2819 ret = pl011_setup_port(&dev->dev, uap, &dev->res, portnr); 2806 2820 if (ret)
+1 -1
drivers/tty/serial/apbuart.c
··· 228 228 } 229 229 230 230 static void apbuart_set_termios(struct uart_port *port, 231 - struct ktermios *termios, struct ktermios *old) 231 + struct ktermios *termios, const struct ktermios *old) 232 232 { 233 233 unsigned int cr; 234 234 unsigned long flags;
+8 -1
drivers/tty/serial/ar933x_uart.c
··· 283 283 284 284 static void ar933x_uart_set_termios(struct uart_port *port, 285 285 struct ktermios *new, 286 - struct ktermios *old) 286 + const struct ktermios *old) 287 287 { 288 288 struct ar933x_uart_port *up = 289 289 container_of(port, struct ar933x_uart_port, port); ··· 583 583 static int ar933x_config_rs485(struct uart_port *port, struct ktermios *termios, 584 584 struct serial_rs485 *rs485conf) 585 585 { 586 + struct ar933x_uart_port *up = 587 + container_of(port, struct ar933x_uart_port, port); 588 + 589 + if (port->rs485.flags & SER_RS485_ENABLED) 590 + gpiod_set_value(up->rts_gpiod, 591 + !!(rs485conf->flags & SER_RS485_RTS_AFTER_SEND)); 592 + 586 593 return 0; 587 594 } 588 595
+1 -1
drivers/tty/serial/arc_uart.c
··· 351 351 352 352 static void 353 353 arc_serial_set_termios(struct uart_port *port, struct ktermios *new, 354 - struct ktermios *old) 354 + const struct ktermios *old) 355 355 { 356 356 struct arc_uart_port *uart = to_arc_port(port); 357 357 unsigned int baud, uartl, uarth, hw_val;
+81 -6
drivers/tty/serial/atmel_serial.c
··· 15 15 #include <linux/init.h> 16 16 #include <linux/serial.h> 17 17 #include <linux/clk.h> 18 + #include <linux/clk-provider.h> 18 19 #include <linux/console.h> 19 20 #include <linux/sysrq.h> 20 21 #include <linux/tty_flip.h> ··· 111 110 struct atmel_uart_port { 112 111 struct uart_port uart; /* uart */ 113 112 struct clk *clk; /* uart clock */ 113 + struct clk *gclk; /* uart generic clock */ 114 114 int may_wakeup; /* cached value of device_may_wakeup for times we need to disable it */ 115 115 u32 backup_imr; /* IMR saved during suspend */ 116 116 int break_active; /* break being received */ ··· 152 150 u32 rts_low; 153 151 bool ms_irq_enabled; 154 152 u32 rtor; /* address of receiver timeout register if it exists */ 153 + bool is_usart; 155 154 bool has_frac_baudrate; 156 155 bool has_hw_timer; 157 156 struct timer_list uart_timer; ··· 229 226 return ((port->rs485.flags & SER_RS485_ENABLED) && 230 227 !(port->rs485.flags & SER_RS485_RX_DURING_TX)) || 231 228 (port->iso7816.flags & SER_ISO7816_ENABLED); 229 + } 230 + 231 + static inline int atmel_error_rate(int desired_value, int actual_value) 232 + { 233 + return 100 - (desired_value * 100) / actual_value; 232 234 } 233 235 234 236 #ifdef CONFIG_SERIAL_ATMEL_PDC ··· 1833 1825 */ 1834 1826 atmel_port->has_frac_baudrate = false; 1835 1827 atmel_port->has_hw_timer = false; 1828 + atmel_port->is_usart = false; 1836 1829 1837 1830 if (name == new_uart) { 1838 1831 dev_dbg(port->dev, "Uart with hw timer"); ··· 1843 1834 dev_dbg(port->dev, "Usart\n"); 1844 1835 atmel_port->has_frac_baudrate = true; 1845 1836 atmel_port->has_hw_timer = true; 1837 + atmel_port->is_usart = true; 1846 1838 atmel_port->rtor = ATMEL_US_RTOR; 1847 1839 version = atmel_uart_readl(port, ATMEL_US_VERSION); 1848 1840 switch (version) { ··· 1873 1863 dev_dbg(port->dev, "This version is usart\n"); 1874 1864 atmel_port->has_frac_baudrate = true; 1875 1865 atmel_port->has_hw_timer = true; 1866 + atmel_port->is_usart = true; 1876 1867 atmel_port->rtor = ATMEL_US_RTOR; 1877 1868 break; 1878 1869 case 0x203: ··· 2124 2113 * This is called on uart_close() or a suspend event. 2125 2114 */ 2126 2115 clk_disable_unprepare(atmel_port->clk); 2116 + if (__clk_is_enabled(atmel_port->gclk)) 2117 + clk_disable_unprepare(atmel_port->gclk); 2127 2118 break; 2128 2119 default: 2129 2120 dev_err(port->dev, "atmel_serial: unknown pm %d\n", state); ··· 2135 2122 /* 2136 2123 * Change the port parameters 2137 2124 */ 2138 - static void atmel_set_termios(struct uart_port *port, struct ktermios *termios, 2139 - struct ktermios *old) 2125 + static void atmel_set_termios(struct uart_port *port, 2126 + struct ktermios *termios, 2127 + const struct ktermios *old) 2140 2128 { 2141 2129 struct atmel_uart_port *atmel_port = to_atmel_uart_port(port); 2142 2130 unsigned long flags; 2143 - unsigned int old_mode, mode, imr, quot, baud, div, cd, fp = 0; 2131 + unsigned int old_mode, mode, imr, quot, div, cd, fp = 0; 2132 + unsigned int baud, actual_baud, gclk_rate; 2133 + int ret; 2144 2134 2145 2135 /* save the current mode register */ 2146 2136 mode = old_mode = atmel_uart_readl(port, ATMEL_US_MR); 2147 2137 2148 2138 /* reset the mode, clock divisor, parity, stop bits and data size */ 2149 - mode &= ~(ATMEL_US_USCLKS | ATMEL_US_CHRL | ATMEL_US_NBSTOP | 2150 - ATMEL_US_PAR | ATMEL_US_USMODE); 2139 + if (atmel_port->is_usart) 2140 + mode &= ~(ATMEL_US_NBSTOP | ATMEL_US_PAR | ATMEL_US_CHRL | 2141 + ATMEL_US_USCLKS | ATMEL_US_USMODE); 2142 + else 2143 + mode &= ~(ATMEL_UA_BRSRCCK | ATMEL_US_PAR | ATMEL_UA_FILTER); 2151 2144 2152 2145 baud = uart_get_baud_rate(port, termios, old, 0, port->uartclk / 16); 2153 2146 ··· 2301 2282 cd = uart_get_divisor(port, baud); 2302 2283 } 2303 2284 2304 - if (cd > 65535) { /* BRGR is 16-bit, so switch to slower clock */ 2285 + /* 2286 + * If the current value of the Clock Divisor surpasses the 16 bit 2287 + * ATMEL_US_CD mask and the IP is USART, switch to the Peripheral 2288 + * Clock implicitly divided by 8. 2289 + * If the IP is UART however, keep the highest possible value for 2290 + * the CD and avoid needless division of CD, since UART IP's do not 2291 + * support implicit division of the Peripheral Clock. 2292 + */ 2293 + if (atmel_port->is_usart && cd > ATMEL_US_CD) { 2305 2294 cd /= 8; 2306 2295 mode |= ATMEL_US_USCLKS_MCK_DIV8; 2296 + } else { 2297 + cd = min_t(unsigned int, cd, ATMEL_US_CD); 2307 2298 } 2299 + 2300 + /* 2301 + * If there is no Fractional Part, there is a high chance that 2302 + * we may be able to generate a baudrate closer to the desired one 2303 + * if we use the GCLK as the clock source driving the baudrate 2304 + * generator. 2305 + */ 2306 + if (!atmel_port->has_frac_baudrate) { 2307 + if (__clk_is_enabled(atmel_port->gclk)) 2308 + clk_disable_unprepare(atmel_port->gclk); 2309 + gclk_rate = clk_round_rate(atmel_port->gclk, 16 * baud); 2310 + actual_baud = clk_get_rate(atmel_port->clk) / (16 * cd); 2311 + if (gclk_rate && abs(atmel_error_rate(baud, actual_baud)) > 2312 + abs(atmel_error_rate(baud, gclk_rate / 16))) { 2313 + clk_set_rate(atmel_port->gclk, 16 * baud); 2314 + ret = clk_prepare_enable(atmel_port->gclk); 2315 + if (ret) 2316 + goto gclk_fail; 2317 + 2318 + if (atmel_port->is_usart) { 2319 + mode &= ~ATMEL_US_USCLKS; 2320 + mode |= ATMEL_US_USCLKS_GCLK; 2321 + } else { 2322 + mode |= ATMEL_UA_BRSRCCK; 2323 + } 2324 + 2325 + /* 2326 + * Set the Clock Divisor for GCLK to 1. 2327 + * Since we were able to generate the smallest 2328 + * multiple of the desired baudrate times 16, 2329 + * then we surely can generate a bigger multiple 2330 + * with the exact error rate for an equally increased 2331 + * CD. Thus no need to take into account 2332 + * a higher value for CD. 2333 + */ 2334 + cd = 1; 2335 + } 2336 + } 2337 + 2338 + gclk_fail: 2308 2339 quot = cd | fp << ATMEL_US_FP_OFFSET; 2309 2340 2310 2341 if (!(port->iso7816.flags & SER_ISO7816_ENABLED)) ··· 2949 2880 ret = clk_prepare_enable(atmel_port->clk); 2950 2881 if (ret) 2951 2882 goto err; 2883 + 2884 + atmel_port->gclk = devm_clk_get_optional(&pdev->dev, "gclk"); 2885 + if (IS_ERR(atmel_port->gclk)) { 2886 + ret = PTR_ERR(atmel_port->gclk); 2887 + goto err_clk_disable_unprepare; 2888 + } 2952 2889 2953 2890 ret = atmel_init_port(atmel_port, pdev); 2954 2891 if (ret)
+40 -35
drivers/tty/serial/atmel_serial.h
··· 9 9 * Based on AT91RM9200 datasheet revision E. 10 10 */ 11 11 12 + #include <linux/bitfield.h> 13 + 12 14 #ifndef ATMEL_SERIAL_H 13 15 #define ATMEL_SERIAL_H 14 16 ··· 41 39 42 40 #define ATMEL_US_MR 0x04 /* Mode Register */ 43 41 #define ATMEL_US_USMODE GENMASK(3, 0) /* Mode of the USART */ 44 - #define ATMEL_US_USMODE_NORMAL 0 45 - #define ATMEL_US_USMODE_RS485 1 46 - #define ATMEL_US_USMODE_HWHS 2 47 - #define ATMEL_US_USMODE_MODEM 3 48 - #define ATMEL_US_USMODE_ISO7816_T0 4 49 - #define ATMEL_US_USMODE_ISO7816_T1 6 50 - #define ATMEL_US_USMODE_IRDA 8 42 + #define ATMEL_US_USMODE_NORMAL FIELD_PREP(ATMEL_US_USMODE, 0) 43 + #define ATMEL_US_USMODE_RS485 FIELD_PREP(ATMEL_US_USMODE, 1) 44 + #define ATMEL_US_USMODE_HWHS FIELD_PREP(ATMEL_US_USMODE, 2) 45 + #define ATMEL_US_USMODE_MODEM FIELD_PREP(ATMEL_US_USMODE, 3) 46 + #define ATMEL_US_USMODE_ISO7816_T0 FIELD_PREP(ATMEL_US_USMODE, 4) 47 + #define ATMEL_US_USMODE_ISO7816_T1 FIELD_PREP(ATMEL_US_USMODE, 6) 48 + #define ATMEL_US_USMODE_IRDA FIELD_PREP(ATMEL_US_USMODE, 8) 51 49 #define ATMEL_US_USCLKS GENMASK(5, 4) /* Clock Selection */ 52 - #define ATMEL_US_USCLKS_MCK (0 << 4) 53 - #define ATMEL_US_USCLKS_MCK_DIV8 (1 << 4) 54 - #define ATMEL_US_USCLKS_SCK (3 << 4) 50 + #define ATMEL_US_USCLKS_MCK FIELD_PREP(ATMEL_US_USCLKS, 0) 51 + #define ATMEL_US_USCLKS_MCK_DIV8 FIELD_PREP(ATMEL_US_USCLKS, 1) 52 + #define ATMEL_US_USCLKS_GCLK FIELD_PREP(ATMEL_US_USCLKS, 2) 53 + #define ATMEL_US_USCLKS_SCK FIELD_PREP(ATMEL_US_USCLKS, 3) 54 + #define ATMEL_UA_FILTER BIT(4) 55 55 #define ATMEL_US_CHRL GENMASK(7, 6) /* Character Length */ 56 - #define ATMEL_US_CHRL_5 (0 << 6) 57 - #define ATMEL_US_CHRL_6 (1 << 6) 58 - #define ATMEL_US_CHRL_7 (2 << 6) 59 - #define ATMEL_US_CHRL_8 (3 << 6) 56 + #define ATMEL_US_CHRL_5 FIELD_PREP(ATMEL_US_CHRL, 0) 57 + #define ATMEL_US_CHRL_6 FIELD_PREP(ATMEL_US_CHRL, 1) 58 + #define ATMEL_US_CHRL_7 FIELD_PREP(ATMEL_US_CHRL, 2) 59 + #define ATMEL_US_CHRL_8 FIELD_PREP(ATMEL_US_CHRL, 3) 60 60 #define ATMEL_US_SYNC BIT(8) /* Synchronous Mode Select */ 61 61 #define ATMEL_US_PAR GENMASK(11, 9) /* Parity Type */ 62 - #define ATMEL_US_PAR_EVEN (0 << 9) 63 - #define ATMEL_US_PAR_ODD (1 << 9) 64 - #define ATMEL_US_PAR_SPACE (2 << 9) 65 - #define ATMEL_US_PAR_MARK (3 << 9) 66 - #define ATMEL_US_PAR_NONE (4 << 9) 67 - #define ATMEL_US_PAR_MULTI_DROP (6 << 9) 62 + #define ATMEL_US_PAR_EVEN FIELD_PREP(ATMEL_US_PAR, 0) 63 + #define ATMEL_US_PAR_ODD FIELD_PREP(ATMEL_US_PAR, 1) 64 + #define ATMEL_US_PAR_SPACE FIELD_PREP(ATMEL_US_PAR, 2) 65 + #define ATMEL_US_PAR_MARK FIELD_PREP(ATMEL_US_PAR, 3) 66 + #define ATMEL_US_PAR_NONE FIELD_PREP(ATMEL_US_PAR, 4) 67 + #define ATMEL_US_PAR_MULTI_DROP FIELD_PREP(ATMEL_US_PAR, 6) 68 68 #define ATMEL_US_NBSTOP GENMASK(13, 12) /* Number of Stop Bits */ 69 - #define ATMEL_US_NBSTOP_1 (0 << 12) 70 - #define ATMEL_US_NBSTOP_1_5 (1 << 12) 71 - #define ATMEL_US_NBSTOP_2 (2 << 12) 69 + #define ATMEL_US_NBSTOP_1 FIELD_PREP(ATMEL_US_NBSTOP, 0) 70 + #define ATMEL_US_NBSTOP_1_5 FIELD_PREP(ATMEL_US_NBSTOP, 1) 71 + #define ATMEL_US_NBSTOP_2 FIELD_PREP(ATMEL_US_NBSTOP, 2) 72 + #define ATMEL_UA_BRSRCCK BIT(12) /* Clock Selection for UART */ 72 73 #define ATMEL_US_CHMODE GENMASK(15, 14) /* Channel Mode */ 73 - #define ATMEL_US_CHMODE_NORMAL (0 << 14) 74 - #define ATMEL_US_CHMODE_ECHO (1 << 14) 75 - #define ATMEL_US_CHMODE_LOC_LOOP (2 << 14) 76 - #define ATMEL_US_CHMODE_REM_LOOP (3 << 14) 74 + #define ATMEL_US_CHMODE_NORMAL FIELD_PREP(ATMEL_US_CHMODE, 0) 75 + #define ATMEL_US_CHMODE_ECHO FIELD_PREP(ATMEL_US_CHMODE, 1) 76 + #define ATMEL_US_CHMODE_LOC_LOOP FIELD_PREP(ATMEL_US_CHMODE, 2) 77 + #define ATMEL_US_CHMODE_REM_LOOP FIELD_PREP(ATMEL_US_CHMODE, 3) 77 78 #define ATMEL_US_MSBF BIT(16) /* Bit Order */ 78 79 #define ATMEL_US_MODE9 BIT(17) /* 9-bit Character Length */ 79 80 #define ATMEL_US_CLKO BIT(18) /* Clock Output Select */ ··· 84 79 #define ATMEL_US_INACK BIT(20) /* Inhibit Non Acknowledge */ 85 80 #define ATMEL_US_DSNACK BIT(21) /* Disable Successive NACK */ 86 81 #define ATMEL_US_MAX_ITER_MASK GENMASK(26, 24) /* Max Iterations */ 87 - #define ATMEL_US_MAX_ITER(n) (((n) << 24) & ATMEL_US_MAX_ITER_MASK) 82 + #define ATMEL_US_MAX_ITER(n) FIELD_PREP(ATMEL_US_MAX_ITER_MASK, (n)) 88 83 #define ATMEL_US_FILTER BIT(28) /* Infrared Receive Line Filter */ 89 84 90 85 #define ATMEL_US_IER 0x08 /* Interrupt Enable Register */ ··· 136 131 137 132 #define ATMEL_US_CMPR 0x90 /* Comparaison Register */ 138 133 #define ATMEL_US_FMR 0xa0 /* FIFO Mode Register */ 139 - #define ATMEL_US_TXRDYM(data) (((data) & 0x3) << 0) /* TX Ready Mode */ 140 - #define ATMEL_US_RXRDYM(data) (((data) & 0x3) << 4) /* RX Ready Mode */ 134 + #define ATMEL_US_TXRDYM(data) FIELD_PREP(GENMASK(1, 0), (data)) /* TX Ready Mode */ 135 + #define ATMEL_US_RXRDYM(data) FIELD_PREP(GENMASK(5, 4), (data)) /* RX Ready Mode */ 141 136 #define ATMEL_US_ONE_DATA 0x0 142 137 #define ATMEL_US_TWO_DATA 0x1 143 138 #define ATMEL_US_FOUR_DATA 0x2 144 139 #define ATMEL_US_FRTSC BIT(7) /* FIFO RTS pin Control */ 145 - #define ATMEL_US_TXFTHRES(thr) (((thr) & 0x3f) << 8) /* TX FIFO Threshold */ 146 - #define ATMEL_US_RXFTHRES(thr) (((thr) & 0x3f) << 16) /* RX FIFO Threshold */ 147 - #define ATMEL_US_RXFTHRES2(thr) (((thr) & 0x3f) << 24) /* RX FIFO Threshold2 */ 140 + #define ATMEL_US_TXFTHRES(thr) FIELD_PREP(GENMASK(13, 8), (thr)) /* TX FIFO Threshold */ 141 + #define ATMEL_US_RXFTHRES(thr) FIELD_PREP(GENMASK(21, 16), (thr)) /* RX FIFO Threshold */ 142 + #define ATMEL_US_RXFTHRES2(thr) FIELD_PREP(GENMASK(29, 24), (thr)) /* RX FIFO Threshold2 */ 148 143 149 144 #define ATMEL_US_FLR 0xa4 /* FIFO Level Register */ 150 - #define ATMEL_US_TXFL(reg) (((reg) >> 0) & 0x3f) /* TX FIFO Level */ 151 - #define ATMEL_US_RXFL(reg) (((reg) >> 16) & 0x3f) /* RX FIFO Level */ 145 + #define ATMEL_US_TXFL(reg) FIELD_GET(GENMASK(5, 0), (reg)) /* TX FIFO Level */ 146 + #define ATMEL_US_RXFL(reg) FIELD_GET(GENMASK(21, 16), (reg)) /* RX FIFO Level */ 152 147 153 148 #define ATMEL_US_FIER 0xa8 /* FIFO Interrupt Enable Register */ 154 149 #define ATMEL_US_FIDR 0xac /* FIFO Interrupt Disable Register */
+2 -3
drivers/tty/serial/bcm63xx_uart.c
··· 492 492 /* 493 493 * serial core request to change current uart setting 494 494 */ 495 - static void bcm_uart_set_termios(struct uart_port *port, 496 - struct ktermios *new, 497 - struct ktermios *old) 495 + static void bcm_uart_set_termios(struct uart_port *port, struct ktermios *new, 496 + const struct ktermios *old) 498 497 { 499 498 unsigned int ctl, baud, quot, ier; 500 499 unsigned long flags;
+1 -1
drivers/tty/serial/clps711x.c
··· 251 251 252 252 static void uart_clps711x_set_termios(struct uart_port *port, 253 253 struct ktermios *termios, 254 - struct ktermios *old) 254 + const struct ktermios *old) 255 255 { 256 256 u32 ubrlcr; 257 257 unsigned int baud, quot;
-1
drivers/tty/serial/cpm_uart/cpm_uart.h
··· 87 87 struct gpio_desc *gpios[NUM_GPIOS]; 88 88 }; 89 89 90 - extern int cpm_uart_nr; 91 90 extern struct uart_cpm_port cpm_uart_ports[UART_NR]; 92 91 93 92 /* these are located in their respective files */
+22 -35
drivers/tty/serial/cpm_uart/cpm_uart_core.c
··· 484 484 485 485 static void cpm_uart_set_termios(struct uart_port *port, 486 486 struct ktermios *termios, 487 - struct ktermios *old) 487 + const struct ktermios *old) 488 488 { 489 489 int baud; 490 490 unsigned long flags; 491 491 u16 cval, scval, prev_mode; 492 - int bits, sbits; 493 492 struct uart_cpm_port *pinfo = 494 493 container_of(port, struct uart_cpm_port, port); 495 494 smc_t __iomem *smcp = pinfo->smcp; ··· 514 515 if (maxidl > 0x10) 515 516 maxidl = 0x10; 516 517 517 - /* Character length programmed into the mode register is the 518 - * sum of: 1 start bit, number of data bits, 0 or 1 parity bit, 519 - * 1 or 2 stop bits, minus 1. 520 - * The value 'bits' counts this for us. 521 - */ 522 518 cval = 0; 523 519 scval = 0; 524 - 525 - /* byte size */ 526 - bits = tty_get_char_size(termios->c_cflag); 527 - sbits = bits - 5; 528 520 529 521 if (termios->c_cflag & CSTOPB) { 530 522 cval |= SMCMR_SL; /* Two stops */ 531 523 scval |= SCU_PSMR_SL; 532 - bits++; 533 524 } 534 525 535 526 if (termios->c_cflag & PARENB) { 536 527 cval |= SMCMR_PEN; 537 528 scval |= SCU_PSMR_PEN; 538 - bits++; 539 529 if (!(termios->c_cflag & PARODD)) { 540 530 cval |= SMCMR_PM_EVEN; 541 531 scval |= (SCU_PSMR_REVP | SCU_PSMR_TEVP); ··· 568 580 569 581 spin_lock_irqsave(&port->lock, flags); 570 582 571 - /* Start bit has not been added (so don't, because we would just 572 - * subtract it later), and we need to add one for the number of 573 - * stops bits (there is always at least one). 574 - */ 575 - bits++; 576 583 if (IS_SMC(pinfo)) { 584 + unsigned int bits = tty_get_frame_size(termios->c_cflag); 585 + 577 586 /* 578 587 * MRBLR can be changed while an SMC/SCC is operating only 579 588 * if it is done in a single bus cycle with one 16-bit move ··· 589 604 */ 590 605 prev_mode = in_be16(&smcp->smc_smcmr) & (SMCMR_REN | SMCMR_TEN); 591 606 /* Output in *one* operation, so we don't interrupt RX/TX if they 592 - * were already enabled. */ 593 - out_be16(&smcp->smc_smcmr, smcr_mk_clen(bits) | cval | 594 - SMCMR_SM_UART | prev_mode); 607 + * were already enabled. 608 + * Character length programmed into the register is frame bits minus 1. 609 + */ 610 + out_be16(&smcp->smc_smcmr, smcr_mk_clen(bits - 1) | cval | 611 + SMCMR_SM_UART | prev_mode); 595 612 } else { 613 + unsigned int bits = tty_get_char_size(termios->c_cflag); 614 + 596 615 out_be16(&pinfo->sccup->scc_genscc.scc_mrblr, pinfo->rx_fifosize); 597 616 out_be16(&pinfo->sccup->scc_maxidl, maxidl); 598 - out_be16(&sccp->scc_psmr, (sbits << 12) | scval); 617 + out_be16(&sccp->scc_psmr, (UART_LCR_WLEN(bits) << 12) | scval); 599 618 } 600 619 601 620 if (pinfo->clk) ··· 1203 1214 pinfo->port.fifosize = pinfo->tx_nrfifos * pinfo->tx_fifosize; 1204 1215 spin_lock_init(&pinfo->port.lock); 1205 1216 1206 - pinfo->port.irq = irq_of_parse_and_map(np, 0); 1207 - if (pinfo->port.irq == NO_IRQ) { 1208 - ret = -EINVAL; 1209 - goto out_pram; 1210 - } 1211 - 1212 1217 for (i = 0; i < NUM_GPIOS; i++) { 1213 1218 struct gpio_desc *gpiod; 1214 1219 ··· 1212 1229 1213 1230 if (IS_ERR(gpiod)) { 1214 1231 ret = PTR_ERR(gpiod); 1215 - goto out_irq; 1232 + goto out_pram; 1216 1233 } 1217 1234 1218 1235 if (gpiod) { ··· 1238 1255 1239 1256 return cpm_uart_request_port(&pinfo->port); 1240 1257 1241 - out_irq: 1242 - irq_dispose_mapping(pinfo->port.irq); 1243 1258 out_pram: 1244 1259 cpm_uart_unmap_pram(pinfo, pram); 1245 1260 out_mem: ··· 1417 1436 /* initialize the device pointer for the port */ 1418 1437 pinfo->port.dev = &ofdev->dev; 1419 1438 1420 - ret = cpm_uart_init_port(ofdev->dev.of_node, pinfo); 1421 - if (ret) 1422 - return ret; 1439 + pinfo->port.irq = irq_of_parse_and_map(ofdev->dev.of_node, 0); 1440 + if (!pinfo->port.irq) 1441 + return -EINVAL; 1423 1442 1424 - return uart_add_one_port(&cpm_reg, &pinfo->port); 1443 + ret = cpm_uart_init_port(ofdev->dev.of_node, pinfo); 1444 + if (!ret) 1445 + return uart_add_one_port(&cpm_reg, &pinfo->port); 1446 + 1447 + irq_dispose_mapping(pinfo->port.irq); 1448 + 1449 + return ret; 1425 1450 } 1426 1451 1427 1452 static int cpm_uart_remove(struct platform_device *ofdev)
+1 -1
drivers/tty/serial/digicolor-usart.c
··· 287 287 288 288 static void digicolor_uart_set_termios(struct uart_port *port, 289 289 struct ktermios *termios, 290 - struct ktermios *old) 290 + const struct ktermios *old) 291 291 { 292 292 unsigned int baud, divisor; 293 293 u8 config = 0;
+7 -4
drivers/tty/serial/dz.c
··· 559 559 } 560 560 561 561 static void dz_set_termios(struct uart_port *uport, struct ktermios *termios, 562 - struct ktermios *old_termios) 562 + const struct ktermios *old_termios) 563 563 { 564 564 struct dz_port *dport = to_dport(uport); 565 565 unsigned long flags; ··· 592 592 593 593 baud = uart_get_baud_rate(uport, termios, old_termios, 50, 9600); 594 594 bflag = dz_encode_baud_rate(baud); 595 - if (bflag < 0) { /* Try to keep unchanged. */ 596 - baud = uart_get_baud_rate(uport, old_termios, NULL, 50, 9600); 597 - bflag = dz_encode_baud_rate(baud); 595 + if (bflag < 0) { 596 + if (old_termios) { 597 + /* Keep unchanged. */ 598 + baud = tty_termios_baud_rate(old_termios); 599 + bflag = dz_encode_baud_rate(baud); 600 + } 598 601 if (bflag < 0) { /* Resort to 9600. */ 599 602 baud = 9600; 600 603 bflag = DZ_B9600;
+3 -3
drivers/tty/serial/earlycon.c
··· 67 67 if (*s) 68 68 earlycon->index = simple_strtoul(s, NULL, 10); 69 69 len = s - name; 70 - strlcpy(earlycon->name, name, min(len + 1, sizeof(earlycon->name))); 70 + strscpy(earlycon->name, name, min(len + 1, sizeof(earlycon->name))); 71 71 earlycon->data = &early_console_dev; 72 72 } 73 73 ··· 123 123 device->baud = simple_strtoul(options, NULL, 0); 124 124 length = min(strcspn(options, " ") + 1, 125 125 (size_t)(sizeof(device->options))); 126 - strlcpy(device->options, options, length); 126 + strscpy(device->options, options, length); 127 127 } 128 128 129 129 return 0; ··· 304 304 305 305 if (options) { 306 306 early_console_dev.baud = simple_strtoul(options, NULL, 0); 307 - strlcpy(early_console_dev.options, options, 307 + strscpy(early_console_dev.options, options, 308 308 sizeof(early_console_dev.options)); 309 309 } 310 310 earlycon_init(&early_console_dev, match->name);
+1 -1
drivers/tty/serial/fsl_linflexuart.c
··· 401 401 402 402 static void 403 403 linflex_set_termios(struct uart_port *port, struct ktermios *termios, 404 - struct ktermios *old) 404 + const struct ktermios *old) 405 405 { 406 406 unsigned long flags; 407 407 unsigned long cr, old_cr, cr1;
+11 -16
drivers/tty/serial/fsl_lpuart.c
··· 1284 1284 struct dma_slave_config dma_rx_sconfig = {}; 1285 1285 struct circ_buf *ring = &sport->rx_ring; 1286 1286 int ret, nent; 1287 - int bits, baud; 1288 1287 struct tty_port *port = &sport->port.state->port; 1289 1288 struct tty_struct *tty = port->tty; 1290 1289 struct ktermios *termios = &tty->termios; 1291 1290 struct dma_chan *chan = sport->dma_rx_chan; 1292 - 1293 - baud = tty_get_baud_rate(tty); 1294 - 1295 - bits = (termios->c_cflag & CSIZE) == CS7 ? 9 : 10; 1296 - if (termios->c_cflag & PARENB) 1297 - bits++; 1291 + unsigned int bits = tty_get_frame_size(termios->c_cflag); 1292 + unsigned int baud = tty_get_baud_rate(tty); 1298 1293 1299 1294 /* 1300 1295 * Calculate length of one DMA buffer size to keep latency below ··· 1771 1776 if (sport->lpuart_dma_rx_use) { 1772 1777 del_timer_sync(&sport->lpuart_timer); 1773 1778 lpuart_dma_rx_free(&sport->port); 1779 + sport->lpuart_dma_rx_use = false; 1774 1780 } 1775 1781 1776 1782 if (sport->lpuart_dma_tx_use) { ··· 1780 1784 sport->dma_tx_in_progress = false; 1781 1785 dmaengine_terminate_all(sport->dma_tx_chan); 1782 1786 } 1787 + sport->lpuart_dma_tx_use = false; 1783 1788 } 1784 1789 1785 1790 if (sport->dma_tx_chan) ··· 1830 1833 1831 1834 static void 1832 1835 lpuart_set_termios(struct uart_port *port, struct ktermios *termios, 1833 - struct ktermios *old) 1836 + const struct ktermios *old) 1834 1837 { 1835 1838 struct lpuart_port *sport = container_of(port, struct lpuart_port, port); 1836 1839 unsigned long flags; ··· 2070 2073 2071 2074 static void 2072 2075 lpuart32_set_termios(struct uart_port *port, struct ktermios *termios, 2073 - struct ktermios *old) 2076 + const struct ktermios *old) 2074 2077 { 2075 2078 struct lpuart_port *sport = container_of(port, struct lpuart_port, port); 2076 2079 unsigned long flags; ··· 2726 2729 if (ret) 2727 2730 goto failed_reset; 2728 2731 2729 - ret = uart_add_one_port(&lpuart_reg, &sport->port); 2730 - if (ret) 2731 - goto failed_attach_port; 2732 - 2733 2732 ret = uart_get_rs485_mode(&sport->port); 2734 2733 if (ret) 2735 2734 goto failed_get_rs485; 2736 2735 2737 - uart_rs485_config(&sport->port); 2736 + ret = uart_add_one_port(&lpuart_reg, &sport->port); 2737 + if (ret) 2738 + goto failed_attach_port; 2738 2739 2739 2740 ret = devm_request_irq(&pdev->dev, sport->port.irq, handler, 0, 2740 2741 DRIVER_NAME, sport); ··· 2742 2747 return 0; 2743 2748 2744 2749 failed_irq_request: 2745 - failed_get_rs485: 2746 2750 uart_remove_one_port(&lpuart_reg, &sport->port); 2747 2751 failed_attach_port: 2752 + failed_get_rs485: 2748 2753 failed_reset: 2749 2754 lpuart_disable_clks(sport); 2750 2755 return ret; ··· 2795 2800 * EDMA driver during suspend will forcefully release any 2796 2801 * non-idle DMA channels. If port wakeup is enabled or if port 2797 2802 * is console port or 'no_console_suspend' is set the Rx DMA 2798 - * cannot resume as as expected, hence gracefully release the 2803 + * cannot resume as expected, hence gracefully release the 2799 2804 * Rx DMA path before suspend and start Rx DMA path on resume. 2800 2805 */ 2801 2806 if (irq_wake) {
+2 -3
drivers/tty/serial/icom.c
··· 1351 1351 kref_put(&icom_port->adapter->kref, icom_kref_release); 1352 1352 } 1353 1353 1354 - static void icom_set_termios(struct uart_port *port, 1355 - struct ktermios *termios, 1356 - struct ktermios *old_termios) 1354 + static void icom_set_termios(struct uart_port *port, struct ktermios *termios, 1355 + const struct ktermios *old_termios) 1357 1356 { 1358 1357 struct icom_port *icom_port = to_icom_port(port); 1359 1358 int baud;
+3 -7
drivers/tty/serial/imx.c
··· 380 380 { 381 381 *ucr2 &= ~(UCR2_CTSC | UCR2_CTS); 382 382 383 - sport->port.mctrl |= TIOCM_RTS; 384 - mctrl_gpio_set(sport->gpios, sport->port.mctrl); 383 + mctrl_gpio_set(sport->gpios, sport->port.mctrl | TIOCM_RTS); 385 384 } 386 385 387 386 /* called with port.lock taken and irqs caller dependent */ ··· 389 390 *ucr2 &= ~UCR2_CTSC; 390 391 *ucr2 |= UCR2_CTS; 391 392 392 - sport->port.mctrl &= ~TIOCM_RTS; 393 - mctrl_gpio_set(sport->gpios, sport->port.mctrl); 393 + mctrl_gpio_set(sport->gpios, sport->port.mctrl & ~TIOCM_RTS); 394 394 } 395 395 396 396 static void start_hrtimer_ms(struct hrtimer *hrt, unsigned long msec) ··· 1618 1620 1619 1621 static void 1620 1622 imx_uart_set_termios(struct uart_port *port, struct ktermios *termios, 1621 - struct ktermios *old) 1623 + const struct ktermios *old) 1622 1624 { 1623 1625 struct imx_port *sport = (struct imx_port *)port; 1624 1626 unsigned long flags; ··· 2344 2346 !(sport->port.rs485.flags & SER_RS485_RX_DURING_TX))) 2345 2347 dev_err(&pdev->dev, 2346 2348 "low-active RTS not possible when receiver is off, enabling receiver\n"); 2347 - 2348 - uart_rs485_config(&sport->port); 2349 2349 2350 2350 /* Disable interrupts before requesting them */ 2351 2351 ucr1 = imx_uart_readl(sport, UCR1);
+1 -1
drivers/tty/serial/ip22zilog.c
··· 873 873 /* The port lock is not held. */ 874 874 static void 875 875 ip22zilog_set_termios(struct uart_port *port, struct ktermios *termios, 876 - struct ktermios *old) 876 + const struct ktermios *old) 877 877 { 878 878 struct uart_ip22zilog_port *up = 879 879 container_of(port, struct uart_ip22zilog_port, port);
+2 -1
drivers/tty/serial/jsm/jsm_driver.c
··· 211 211 212 212 break; 213 213 default: 214 - return -ENXIO; 214 + rc = -ENXIO; 215 + goto out_kfree_brd; 215 216 } 216 217 217 218 rc = request_irq(brd->irq, brd->bd_ops->intr, IRQF_SHARED, "JSM", brd);
+2 -2
drivers/tty/serial/jsm/jsm_tty.c
··· 300 300 } 301 301 302 302 static void jsm_tty_set_termios(struct uart_port *port, 303 - struct ktermios *termios, 304 - struct ktermios *old_termios) 303 + struct ktermios *termios, 304 + const struct ktermios *old_termios) 305 305 { 306 306 unsigned long lock_flags; 307 307 struct jsm_channel *channel =
+14 -11
drivers/tty/serial/lantiq.c
··· 8 8 * Copyright (C) 2010 Thomas Langer, <thomas.langer@lantiq.com> 9 9 */ 10 10 11 + #include <linux/bitfield.h> 11 12 #include <linux/clk.h> 12 13 #include <linux/console.h> 13 14 #include <linux/device.h> ··· 94 93 #define ASCFSTAT_RXFFLMASK 0x003F 95 94 #define ASCFSTAT_TXFFLMASK 0x3F00 96 95 #define ASCFSTAT_TXFREEMASK 0x3F000000 97 - #define ASCFSTAT_TXFREEOFF 24 98 96 99 97 static void lqasc_tx_chars(struct uart_port *port); 100 98 static struct ltq_uart_port *lqasc_port[MAXPORTS]; ··· 137 137 lqasc_stop_tx(struct uart_port *port) 138 138 { 139 139 return; 140 + } 141 + 142 + static bool lqasc_tx_ready(struct uart_port *port) 143 + { 144 + u32 fstat = __raw_readl(port->membase + LTQ_ASC_FSTAT); 145 + 146 + return FIELD_GET(ASCFSTAT_TXFREEMASK, fstat); 140 147 } 141 148 142 149 static void ··· 235 228 return; 236 229 } 237 230 238 - while (((__raw_readl(port->membase + LTQ_ASC_FSTAT) & 239 - ASCFSTAT_TXFREEMASK) >> ASCFSTAT_TXFREEOFF) != 0) { 231 + while (lqasc_tx_ready(port)) { 240 232 if (port->x_char) { 241 233 writeb(port->x_char, port->membase + LTQ_ASC_TBUF); 242 234 port->icount.tx++; ··· 411 405 } 412 406 413 407 static void 414 - lqasc_set_termios(struct uart_port *port, 415 - struct ktermios *new, struct ktermios *old) 408 + lqasc_set_termios(struct uart_port *port, struct ktermios *new, 409 + const struct ktermios *old) 416 410 { 417 411 unsigned int cflag; 418 412 unsigned int iflag; ··· 606 600 static void 607 601 lqasc_console_putchar(struct uart_port *port, unsigned char ch) 608 602 { 609 - int fifofree; 610 - 611 603 if (!port->membase) 612 604 return; 613 605 614 - do { 615 - fifofree = (__raw_readl(port->membase + LTQ_ASC_FSTAT) 616 - & ASCFSTAT_TXFREEMASK) >> ASCFSTAT_TXFREEOFF; 617 - } while (fifofree == 0); 606 + while (!lqasc_tx_ready(port)) 607 + ; 608 + 618 609 writeb(ch, port->membase + LTQ_ASC_TBUF); 619 610 } 620 611
+1 -1
drivers/tty/serial/liteuart.c
··· 178 178 } 179 179 180 180 static void liteuart_set_termios(struct uart_port *port, struct ktermios *new, 181 - struct ktermios *old) 181 + const struct ktermios *old) 182 182 { 183 183 unsigned int baud; 184 184 unsigned long flags;
+9 -3
drivers/tty/serial/lpc32xx_hs.c
··· 278 278 279 279 static void serial_lpc32xx_stop_tx(struct uart_port *port); 280 280 281 + static bool serial_lpc32xx_tx_ready(struct uart_port *port) 282 + { 283 + u32 level = readl(LPC32XX_HSUART_LEVEL(port->membase)); 284 + 285 + return LPC32XX_HSU_TX_LEV(level) < 64; 286 + } 287 + 281 288 static void __serial_lpc32xx_tx(struct uart_port *port) 282 289 { 283 290 struct circ_buf *xmit = &port->state->xmit; ··· 300 293 goto exit_tx; 301 294 302 295 /* Transfer data */ 303 - while (LPC32XX_HSU_TX_LEV(readl( 304 - LPC32XX_HSUART_LEVEL(port->membase))) < 64) { 296 + while (serial_lpc32xx_tx_ready(port)) { 305 297 writel((u32) xmit->buf[xmit->tail], 306 298 LPC32XX_HSUART_FIFO(port->membase)); 307 299 xmit->tail = (xmit->tail + 1) & (UART_XMIT_SIZE - 1); ··· 499 493 /* port->lock is not held. */ 500 494 static void serial_lpc32xx_set_termios(struct uart_port *port, 501 495 struct ktermios *termios, 502 - struct ktermios *old) 496 + const struct ktermios *old) 503 497 { 504 498 unsigned long flags; 505 499 unsigned int baud, quot;
+1 -1
drivers/tty/serial/max3100.c
··· 418 418 419 419 static void 420 420 max3100_set_termios(struct uart_port *port, struct ktermios *termios, 421 - struct ktermios *old) 421 + const struct ktermios *old) 422 422 { 423 423 struct max3100_port *s = container_of(port, 424 424 struct max3100_port,
+1 -1
drivers/tty/serial/max310x.c
··· 906 906 907 907 static void max310x_set_termios(struct uart_port *port, 908 908 struct ktermios *termios, 909 - struct ktermios *old) 909 + const struct ktermios *old) 910 910 { 911 911 unsigned int lcr = 0, flow = 0; 912 912 int baud;
+1 -1
drivers/tty/serial/mcf.c
··· 192 192 /****************************************************************************/ 193 193 194 194 static void mcf_set_termios(struct uart_port *port, struct ktermios *termios, 195 - struct ktermios *old) 195 + const struct ktermios *old) 196 196 { 197 197 unsigned long flags; 198 198 unsigned int baud, baudclk;
+2 -2
drivers/tty/serial/men_z135_uart.c
··· 646 646 } 647 647 648 648 static void men_z135_set_termios(struct uart_port *port, 649 - struct ktermios *termios, 650 - struct ktermios *old) 649 + struct ktermios *termios, 650 + const struct ktermios *old) 651 651 { 652 652 struct men_z135_port *uart = to_men_z135(port); 653 653 unsigned int baud;
+4 -27
drivers/tty/serial/meson_uart.c
··· 335 335 336 336 static void meson_uart_set_termios(struct uart_port *port, 337 337 struct ktermios *termios, 338 - struct ktermios *old) 338 + const struct ktermios *old) 339 339 { 340 340 unsigned int cflags, iflags, baud; 341 341 unsigned long flags; ··· 667 667 .cons = MESON_SERIAL_CONSOLE, 668 668 }; 669 669 670 - static inline struct clk *meson_uart_probe_clock(struct device *dev, 671 - const char *id) 672 - { 673 - struct clk *clk = NULL; 674 - int ret; 675 - 676 - clk = devm_clk_get(dev, id); 677 - if (IS_ERR(clk)) 678 - return clk; 679 - 680 - ret = clk_prepare_enable(clk); 681 - if (ret) { 682 - dev_err(dev, "couldn't enable clk\n"); 683 - return ERR_PTR(ret); 684 - } 685 - 686 - devm_add_action_or_reset(dev, 687 - (void(*)(void *))clk_disable_unprepare, 688 - clk); 689 - 690 - return clk; 691 - } 692 - 693 670 static int meson_uart_probe_clocks(struct platform_device *pdev, 694 671 struct uart_port *port) 695 672 { ··· 674 697 struct clk *clk_pclk = NULL; 675 698 struct clk *clk_baud = NULL; 676 699 677 - clk_pclk = meson_uart_probe_clock(&pdev->dev, "pclk"); 700 + clk_pclk = devm_clk_get_enabled(&pdev->dev, "pclk"); 678 701 if (IS_ERR(clk_pclk)) 679 702 return PTR_ERR(clk_pclk); 680 703 681 - clk_xtal = meson_uart_probe_clock(&pdev->dev, "xtal"); 704 + clk_xtal = devm_clk_get_enabled(&pdev->dev, "xtal"); 682 705 if (IS_ERR(clk_xtal)) 683 706 return PTR_ERR(clk_xtal); 684 707 685 - clk_baud = meson_uart_probe_clock(&pdev->dev, "baud"); 708 + clk_baud = devm_clk_get_enabled(&pdev->dev, "baud"); 686 709 if (IS_ERR(clk_baud)) 687 710 return PTR_ERR(clk_baud); 688 711
+2 -1
drivers/tty/serial/milbeaut_usio.c
··· 298 298 } 299 299 300 300 static void mlb_usio_set_termios(struct uart_port *port, 301 - struct ktermios *termios, struct ktermios *old) 301 + struct ktermios *termios, 302 + const struct ktermios *old) 302 303 { 303 304 unsigned int escr, smr = MLB_USIO_SMR_SOE; 304 305 unsigned long flags, baud, quot;
+15 -15
drivers/tty/serial/mpc52xx_uart.c
··· 101 101 void (*cw_restore_ints)(struct uart_port *port); 102 102 unsigned int (*set_baudrate)(struct uart_port *port, 103 103 struct ktermios *new, 104 - struct ktermios *old); 104 + const struct ktermios *old); 105 105 int (*clock_alloc)(struct uart_port *port); 106 106 void (*clock_relse)(struct uart_port *port); 107 107 int (*clock)(struct uart_port *port, int enable); ··· 287 287 288 288 static unsigned int mpc5200_psc_set_baudrate(struct uart_port *port, 289 289 struct ktermios *new, 290 - struct ktermios *old) 290 + const struct ktermios *old) 291 291 { 292 292 unsigned int baud; 293 293 unsigned int divisor; ··· 305 305 306 306 static unsigned int mpc5200b_psc_set_baudrate(struct uart_port *port, 307 307 struct ktermios *new, 308 - struct ktermios *old) 308 + const struct ktermios *old) 309 309 { 310 310 unsigned int baud; 311 311 unsigned int divisor; ··· 533 533 534 534 static unsigned int mpc512x_psc_set_baudrate(struct uart_port *port, 535 535 struct ktermios *new, 536 - struct ktermios *old) 536 + const struct ktermios *old) 537 537 { 538 538 unsigned int baud; 539 539 unsigned int divisor; ··· 880 880 881 881 static unsigned int mpc5125_psc_set_baudrate(struct uart_port *port, 882 882 struct ktermios *new, 883 - struct ktermios *old) 883 + const struct ktermios *old) 884 884 { 885 885 unsigned int baud; 886 886 unsigned int divisor; ··· 1167 1167 1168 1168 static void 1169 1169 mpc52xx_uart_set_termios(struct uart_port *port, struct ktermios *new, 1170 - struct ktermios *old) 1170 + const struct ktermios *old) 1171 1171 { 1172 1172 unsigned long flags; 1173 1173 unsigned char mr1, mr2; ··· 1364 1364 /* Interrupt handling */ 1365 1365 /* ======================================================================== */ 1366 1366 1367 - static inline unsigned int 1367 + static inline bool 1368 1368 mpc52xx_uart_int_rx_chars(struct uart_port *port) 1369 1369 { 1370 1370 struct tty_port *tport = &port->state->port; ··· 1425 1425 return psc_ops->raw_rx_rdy(port); 1426 1426 } 1427 1427 1428 - static inline int 1428 + static inline bool 1429 1429 mpc52xx_uart_int_tx_chars(struct uart_port *port) 1430 1430 { 1431 1431 struct circ_buf *xmit = &port->state->xmit; ··· 1435 1435 psc_ops->write_char(port, port->x_char); 1436 1436 port->icount.tx++; 1437 1437 port->x_char = 0; 1438 - return 1; 1438 + return true; 1439 1439 } 1440 1440 1441 1441 /* Nothing to do ? */ 1442 1442 if (uart_circ_empty(xmit) || uart_tx_stopped(port)) { 1443 1443 mpc52xx_uart_stop_tx(port); 1444 - return 0; 1444 + return false; 1445 1445 } 1446 1446 1447 1447 /* Send chars */ ··· 1460 1460 /* Maybe we're done after all */ 1461 1461 if (uart_circ_empty(xmit)) { 1462 1462 mpc52xx_uart_stop_tx(port); 1463 - return 0; 1463 + return false; 1464 1464 } 1465 1465 1466 - return 1; 1466 + return true; 1467 1467 } 1468 1468 1469 1469 static irqreturn_t 1470 1470 mpc5xxx_uart_process_int(struct uart_port *port) 1471 1471 { 1472 1472 unsigned long pass = ISR_PASS_LIMIT; 1473 - unsigned int keepgoing; 1473 + bool keepgoing; 1474 1474 u8 status; 1475 1475 1476 1476 /* While we have stuff to do, we continue */ 1477 1477 do { 1478 1478 /* If we don't find anything to do, we stop */ 1479 - keepgoing = 0; 1479 + keepgoing = false; 1480 1480 1481 1481 psc_ops->rx_clr_irq(port); 1482 1482 if (psc_ops->rx_rdy(port)) ··· 1495 1495 1496 1496 /* Limit number of iteration */ 1497 1497 if (!(--pass)) 1498 - keepgoing = 0; 1498 + keepgoing = false; 1499 1499 1500 1500 } while (keepgoing); 1501 1501
+1 -1
drivers/tty/serial/mps2-uart.c
··· 358 358 359 359 static void 360 360 mps2_uart_set_termios(struct uart_port *port, struct ktermios *termios, 361 - struct ktermios *old) 361 + const struct ktermios *old) 362 362 { 363 363 unsigned long flags; 364 364 unsigned int baud, bauddiv;
+1 -1
drivers/tty/serial/msm_serial.c
··· 1263 1263 } 1264 1264 1265 1265 static void msm_set_termios(struct uart_port *port, struct ktermios *termios, 1266 - struct ktermios *old) 1266 + const struct ktermios *old) 1267 1267 { 1268 1268 struct msm_port *msm_port = to_msm_port(port); 1269 1269 struct msm_dma *dma = &msm_port->rx_dma;
+1 -1
drivers/tty/serial/mux.c
··· 289 289 */ 290 290 static void 291 291 mux_set_termios(struct uart_port *port, struct ktermios *termios, 292 - struct ktermios *old) 292 + const struct ktermios *old) 293 293 { 294 294 } 295 295
+1 -1
drivers/tty/serial/mvebu-uart.c
··· 564 564 565 565 static void mvebu_uart_set_termios(struct uart_port *port, 566 566 struct ktermios *termios, 567 - struct ktermios *old) 567 + const struct ktermios *old) 568 568 { 569 569 unsigned long flags; 570 570 unsigned int baud, min_baud, max_baud;
+1 -1
drivers/tty/serial/mxs-auart.c
··· 959 959 #define CTS_AT_AUART() !mctrl_gpio_to_gpiod(s->gpios, UART_GPIO_CTS) 960 960 static void mxs_auart_settermios(struct uart_port *u, 961 961 struct ktermios *termios, 962 - struct ktermios *old) 962 + const struct ktermios *old) 963 963 { 964 964 struct mxs_auart_port *s = to_auart_port(u); 965 965 u32 ctrl, ctrl2, div;
+25 -24
drivers/tty/serial/omap-serial.c
··· 300 300 serial_out(up, UART_OMAP_SCR, up->scr); 301 301 res = (port->rs485.flags & SER_RS485_RTS_AFTER_SEND) ? 302 302 1 : 0; 303 - if (up->rts_gpiod && 304 - gpiod_get_value(up->rts_gpiod) != res) { 303 + if (gpiod_get_value(up->rts_gpiod) != res) { 305 304 if (port->rs485.delay_rts_after_send > 0) 306 305 mdelay( 307 306 port->rs485.delay_rts_after_send); ··· 336 337 serial_out(up, UART_IER, up->ier); 337 338 } 338 339 340 + static void serial_omap_put_char(struct uart_omap_port *up, unsigned char ch) 341 + { 342 + serial_out(up, UART_TX, ch); 343 + 344 + if ((up->port.rs485.flags & SER_RS485_ENABLED) && 345 + !(up->port.rs485.flags & SER_RS485_RX_DURING_TX)) 346 + up->rs485_tx_filter_count++; 347 + } 348 + 339 349 static void transmit_chars(struct uart_omap_port *up, unsigned int lsr) 340 350 { 341 351 struct circ_buf *xmit = &up->port.state->xmit; 342 352 int count; 343 353 344 354 if (up->port.x_char) { 345 - serial_out(up, UART_TX, up->port.x_char); 355 + serial_omap_put_char(up, up->port.x_char); 346 356 up->port.icount.tx++; 347 357 up->port.x_char = 0; 348 - if ((up->port.rs485.flags & SER_RS485_ENABLED) && 349 - !(up->port.rs485.flags & SER_RS485_RX_DURING_TX)) 350 - up->rs485_tx_filter_count++; 351 - 352 358 return; 353 359 } 354 360 if (uart_circ_empty(xmit) || uart_tx_stopped(&up->port)) { ··· 362 358 } 363 359 count = up->port.fifosize / 4; 364 360 do { 365 - serial_out(up, UART_TX, xmit->buf[xmit->tail]); 361 + serial_omap_put_char(up, xmit->buf[xmit->tail]); 366 362 xmit->tail = (xmit->tail + 1) & (UART_XMIT_SIZE - 1); 367 363 up->port.icount.tx++; 368 - if ((up->port.rs485.flags & SER_RS485_ENABLED) && 369 - !(up->port.rs485.flags & SER_RS485_RX_DURING_TX)) 370 - up->rs485_tx_filter_count++; 371 364 372 365 if (uart_circ_empty(xmit)) 373 366 break; ··· 398 397 399 398 /* if rts not already enabled */ 400 399 res = (port->rs485.flags & SER_RS485_RTS_ON_SEND) ? 1 : 0; 401 - if (up->rts_gpiod && gpiod_get_value(up->rts_gpiod) != res) { 400 + if (gpiod_get_value(up->rts_gpiod) != res) { 402 401 gpiod_set_value(up->rts_gpiod, res); 403 402 if (port->rs485.delay_rts_before_send > 0) 404 403 mdelay(port->rs485.delay_rts_before_send); ··· 803 802 804 803 static void 805 804 serial_omap_set_termios(struct uart_port *port, struct ktermios *termios, 806 - struct ktermios *old) 805 + const struct ktermios *old) 807 806 { 808 807 struct uart_omap_port *up = to_uart_omap_port(port); 809 808 unsigned char cval = 0; ··· 1337 1336 up->ier = 0; 1338 1337 serial_out(up, UART_IER, 0); 1339 1338 1340 - if (up->rts_gpiod) { 1341 - /* enable / disable rts */ 1342 - val = (rs485->flags & SER_RS485_ENABLED) ? 1343 - SER_RS485_RTS_AFTER_SEND : SER_RS485_RTS_ON_SEND; 1344 - val = (rs485->flags & val) ? 1 : 0; 1345 - gpiod_set_value(up->rts_gpiod, val); 1346 - } 1339 + /* enable / disable rts */ 1340 + val = (rs485->flags & SER_RS485_ENABLED) ? 1341 + SER_RS485_RTS_AFTER_SEND : SER_RS485_RTS_ON_SEND; 1342 + val = (rs485->flags & val) ? 1 : 0; 1343 + gpiod_set_value(up->rts_gpiod, val); 1347 1344 1348 1345 /* Enable interrupts */ 1349 1346 up->ier = mode; ··· 1546 1547 ret = PTR_ERR(up->rts_gpiod); 1547 1548 if (ret == -EPROBE_DEFER) 1548 1549 return ret; 1549 - /* 1550 - * FIXME: the code historically ignored any other error than 1551 - * -EPROBE_DEFER and just went on without GPIO. 1552 - */ 1550 + 1553 1551 up->rts_gpiod = NULL; 1552 + up->port.rs485_supported = (const struct serial_rs485) { }; 1553 + if (rs485conf->flags & SER_RS485_ENABLED) { 1554 + dev_err(dev, "disabling RS-485 (rts-gpio missing in device tree)\n"); 1555 + memset(rs485conf, 0, sizeof(*rs485conf)); 1556 + } 1554 1557 } else { 1555 1558 gpiod_set_consumer_name(up->rts_gpiod, "omap-serial"); 1556 1559 }
+1 -1
drivers/tty/serial/owl-uart.c
··· 328 328 329 329 static void owl_uart_set_termios(struct uart_port *port, 330 330 struct ktermios *termios, 331 - struct ktermios *old) 331 + const struct ktermios *old) 332 332 { 333 333 struct owl_uart_port *owl_port = to_owl_uart_port(port); 334 334 unsigned int baud;
+3 -4
drivers/tty/serial/pch_uart.c
··· 898 898 fifo_size--; 899 899 } 900 900 901 - bytes = min((int)CIRC_CNT(xmit->head, xmit->tail, 902 - UART_XMIT_SIZE), CIRC_CNT_TO_END(xmit->head, 903 - xmit->tail, UART_XMIT_SIZE)); 901 + bytes = CIRC_CNT_TO_END(xmit->head, xmit->tail, UART_XMIT_SIZE); 904 902 if (!bytes) { 905 903 dev_dbg(priv->port.dev, "%s 0 bytes return\n", __func__); 906 904 pch_uart_hal_disable_interrupt(priv, PCH_UART_HAL_TX_INT); ··· 1299 1301 *bits. Update read_status_mask and ignore_status_mask to indicate 1300 1302 *the types of events we are interested in receiving. */ 1301 1303 static void pch_uart_set_termios(struct uart_port *port, 1302 - struct ktermios *termios, struct ktermios *old) 1304 + struct ktermios *termios, 1305 + const struct ktermios *old) 1303 1306 { 1304 1307 int rtn; 1305 1308 unsigned int baud, parity, bits, stb;
+14 -38
drivers/tty/serial/pic32_uart.c
··· 50 50 * @irq_rx_name: irq rx name 51 51 * @irq_tx: virtual tx interrupt number 52 52 * @irq_tx_name: irq tx name 53 - * @cts_gpio: clear to send gpio 53 + * @cts_gpiod: clear to send GPIO 54 54 * @dev: device descriptor 55 55 **/ 56 56 struct pic32_sport { ··· 65 65 const char *irq_tx_name; 66 66 bool enable_tx_irq; 67 67 68 - bool hw_flow_ctrl; 69 - int cts_gpio; 68 + struct gpio_desc *cts_gpiod; 70 69 71 70 struct clk *clk; 72 71 ··· 157 158 PIC32_UART_MODE_LPBK); 158 159 } 159 160 160 - /* get the state of CTS input pin for this port */ 161 - static unsigned int get_cts_state(struct pic32_sport *sport) 162 - { 163 - /* read and invert UxCTS */ 164 - if (gpio_is_valid(sport->cts_gpio)) 165 - return !gpio_get_value(sport->cts_gpio); 166 - 167 - return 1; 168 - } 169 - 170 161 /* serial core request to return the state of misc UART input pins */ 171 162 static unsigned int pic32_uart_get_mctrl(struct uart_port *port) 172 163 { 173 164 struct pic32_sport *sport = to_pic32_sport(port); 174 165 unsigned int mctrl = 0; 175 166 176 - if (!sport->hw_flow_ctrl) 167 + /* get the state of CTS input pin for this port */ 168 + if (!sport->cts_gpiod) 177 169 mctrl |= TIOCM_CTS; 178 - else if (get_cts_state(sport)) 170 + else if (gpiod_get_value(sport->cts_gpiod)) 179 171 mctrl |= TIOCM_CTS; 180 172 181 173 /* DSR and CD are not supported in PIC32, so return 1 ··· 599 609 /* serial core request to change current uart setting */ 600 610 static void pic32_uart_set_termios(struct uart_port *port, 601 611 struct ktermios *new, 602 - struct ktermios *old) 612 + const struct ktermios *old) 603 613 { 604 614 struct pic32_sport *sport = to_pic32_sport(port); 605 615 unsigned int baud; ··· 638 648 PIC32_UART_MODE_PDSEL0); 639 649 } 640 650 /* if hw flow ctrl, then the pins must be specified in device tree */ 641 - if ((new->c_cflag & CRTSCTS) && sport->hw_flow_ctrl) { 651 + if ((new->c_cflag & CRTSCTS) && sport->cts_gpiod) { 642 652 /* enable hardware flow control */ 643 653 pic32_uart_writel(sport, PIC32_SET(PIC32_UART_MODE), 644 654 PIC32_UART_MODE_UEN1); ··· 865 875 866 876 static int pic32_uart_probe(struct platform_device *pdev) 867 877 { 868 - struct device_node *np = pdev->dev.of_node; 878 + struct device *dev = &pdev->dev; 879 + struct device_node *np = dev->of_node; 869 880 struct pic32_sport *sport; 870 881 int uart_idx = 0; 871 882 struct resource *res_mem; ··· 895 904 /* Hardware flow control: gpios 896 905 * !Note: Basically, CTS is needed for reading the status. 897 906 */ 898 - sport->hw_flow_ctrl = false; 899 - sport->cts_gpio = of_get_named_gpio(np, "cts-gpios", 0); 900 - if (gpio_is_valid(sport->cts_gpio)) { 901 - sport->hw_flow_ctrl = true; 902 - 903 - ret = devm_gpio_request(sport->dev, 904 - sport->cts_gpio, "CTS"); 905 - if (ret) { 906 - dev_err(&pdev->dev, 907 - "error requesting CTS GPIO\n"); 908 - goto err; 909 - } 910 - 911 - ret = gpio_direction_input(sport->cts_gpio); 912 - if (ret) { 913 - dev_err(&pdev->dev, "error setting CTS GPIO\n"); 914 - goto err; 915 - } 916 - } 907 + sport->cts_gpiod = devm_gpiod_get_optional(dev, "cts", GPIOD_IN); 908 + if (IS_ERR(sport->cts_gpiod)) 909 + return dev_err_probe(dev, PTR_ERR(sport->cts_gpiod), "error requesting CTS GPIO\n"); 910 + gpiod_set_consumer_name(sport->cts_gpiod, "CTS"); 917 911 918 912 pic32_sports[uart_idx] = sport; 919 913 port = &sport->port; ··· 919 943 } 920 944 921 945 #ifdef CONFIG_SERIAL_PIC32_CONSOLE 922 - if (uart_console(port) && (pic32_console.flags & CON_ENABLED)) { 946 + if (uart_console_enabled(port)) { 923 947 /* The peripheral clock has been enabled by console_setup, 924 948 * so disable it till the port is used. 925 949 */
+2 -2
drivers/tty/serial/pmac_zilog.c
··· 1202 1202 1203 1203 1204 1204 static void __pmz_set_termios(struct uart_port *port, struct ktermios *termios, 1205 - struct ktermios *old) 1205 + const struct ktermios *old) 1206 1206 { 1207 1207 struct uart_pmac_port *uap = to_pmz(port); 1208 1208 unsigned long baud; ··· 1244 1244 1245 1245 /* The port lock is not held. */ 1246 1246 static void pmz_set_termios(struct uart_port *port, struct ktermios *termios, 1247 - struct ktermios *old) 1247 + const struct ktermios *old) 1248 1248 { 1249 1249 struct uart_pmac_port *uap = to_pmz(port); 1250 1250 unsigned long flags;
+1 -1
drivers/tty/serial/pxa.c
··· 423 423 424 424 static void 425 425 serial_pxa_set_termios(struct uart_port *port, struct ktermios *termios, 426 - struct ktermios *old) 426 + const struct ktermios *old) 427 427 { 428 428 struct uart_pxa_port *up = (struct uart_pxa_port *)port; 429 429 unsigned char cval, fcr = 0;
+5 -3
drivers/tty/serial/qcom_geni_serial.c
··· 22 22 #include <linux/slab.h> 23 23 #include <linux/tty.h> 24 24 #include <linux/tty_flip.h> 25 + #include <dt-bindings/interconnect/qcom,icc.h> 25 26 26 27 /* UART specific GENI registers */ 27 28 #define SE_UART_LOOPBACK_CFG 0x22c ··· 1006 1005 } 1007 1006 1008 1007 static void qcom_geni_serial_set_termios(struct uart_port *uport, 1009 - struct ktermios *termios, struct ktermios *old) 1008 + struct ktermios *termios, 1009 + const struct ktermios *old) 1010 1010 { 1011 1011 unsigned int baud; 1012 1012 u32 bits_per_char; ··· 1526 1524 * even with no_console_suspend 1527 1525 */ 1528 1526 if (uart_console(uport)) { 1529 - geni_icc_set_tag(&port->se, 0x3); 1527 + geni_icc_set_tag(&port->se, QCOM_ICC_TAG_ACTIVE_ONLY); 1530 1528 geni_icc_set_bw(&port->se); 1531 1529 } 1532 1530 return uart_suspend_port(private_data->drv, uport); ··· 1541 1539 1542 1540 ret = uart_resume_port(private_data->drv, uport); 1543 1541 if (uart_console(uport)) { 1544 - geni_icc_set_tag(&port->se, 0x7); 1542 + geni_icc_set_tag(&port->se, QCOM_ICC_TAG_ALWAYS); 1545 1543 geni_icc_set_bw(&port->se); 1546 1544 } 1547 1545 return ret;
+1 -1
drivers/tty/serial/rda-uart.c
··· 238 238 239 239 static void rda_uart_set_termios(struct uart_port *port, 240 240 struct ktermios *termios, 241 - struct ktermios *old) 241 + const struct ktermios *old) 242 242 { 243 243 struct rda_uart_port *rda_port = to_rda_uart_port(port); 244 244 unsigned long flags;
+2 -3
drivers/tty/serial/rp2.c
··· 370 370 up->ucode + RP2_RX_SWFLOW); 371 371 } 372 372 373 - static void rp2_uart_set_termios(struct uart_port *port, 374 - struct ktermios *new, 375 - struct ktermios *old) 373 + static void rp2_uart_set_termios(struct uart_port *port, struct ktermios *new, 374 + const struct ktermios *old) 376 375 { 377 376 struct rp2_uart_port *up = port_to_up(port); 378 377 unsigned long flags;
+1 -1
drivers/tty/serial/sa1100.c
··· 409 409 410 410 static void 411 411 sa1100_set_termios(struct uart_port *port, struct ktermios *termios, 412 - struct ktermios *old) 412 + const struct ktermios *old) 413 413 { 414 414 struct sa1100_port *sport = 415 415 container_of(port, struct sa1100_port, port);
+1 -1
drivers/tty/serial/samsung_tty.c
··· 1530 1530 1531 1531 static void s3c24xx_serial_set_termios(struct uart_port *port, 1532 1532 struct ktermios *termios, 1533 - struct ktermios *old) 1533 + const struct ktermios *old) 1534 1534 { 1535 1535 const struct s3c2410_uartcfg *cfg = s3c24xx_port_to_cfg(port); 1536 1536 struct s3c24xx_uart_port *ourport = to_ourport(port);
+1 -1
drivers/tty/serial/sb1250-duart.c
··· 531 531 } 532 532 533 533 static void sbd_set_termios(struct uart_port *uport, struct ktermios *termios, 534 - struct ktermios *old_termios) 534 + const struct ktermios *old_termios) 535 535 { 536 536 struct sbd_port *sport = to_sport(uport); 537 537 unsigned int mode1 = 0, mode2 = 0, aux = 0;
+1 -1
drivers/tty/serial/sc16is7xx.c
··· 1015 1015 1016 1016 static void sc16is7xx_set_termios(struct uart_port *port, 1017 1017 struct ktermios *termios, 1018 - struct ktermios *old) 1018 + const struct ktermios *old) 1019 1019 { 1020 1020 struct sc16is7xx_port *s = dev_get_drvdata(port->dev); 1021 1021 struct sc16is7xx_one *one = to_sc16is7xx_one(port, port);
+2 -1
drivers/tty/serial/sccnxp.c
··· 636 636 } 637 637 638 638 static void sccnxp_set_termios(struct uart_port *port, 639 - struct ktermios *termios, struct ktermios *old) 639 + struct ktermios *termios, 640 + const struct ktermios *old) 640 641 { 641 642 struct sccnxp_port *s = dev_get_drvdata(port->dev); 642 643 unsigned long flags;
+5 -10
drivers/tty/serial/serial-tegra.c
··· 1270 1270 } 1271 1271 1272 1272 static void tegra_uart_set_termios(struct uart_port *u, 1273 - struct ktermios *termios, struct ktermios *oldtermios) 1273 + struct ktermios *termios, 1274 + const struct ktermios *oldtermios) 1274 1275 { 1275 1276 struct tegra_uart_port *tup = to_tegra_uport(u); 1276 1277 unsigned int baud; 1277 1278 unsigned long flags; 1278 1279 unsigned int lcr; 1279 1280 unsigned char char_bits; 1280 - int symb_bit = 1; 1281 1281 struct clk *parent_clk = clk_get_parent(tup->uart_clk); 1282 1282 unsigned long parent_clk_rate = clk_get_rate(parent_clk); 1283 1283 int max_divider = (tup->cdata->support_clk_src_div) ? 0x7FFF : 0xFFFF; ··· 1304 1304 termios->c_cflag &= ~CMSPAR; 1305 1305 1306 1306 if ((termios->c_cflag & PARENB) == PARENB) { 1307 - symb_bit++; 1308 1307 if (termios->c_cflag & PARODD) { 1309 1308 lcr |= UART_LCR_PARITY; 1310 1309 lcr &= ~UART_LCR_EPAR; ··· 1316 1317 } 1317 1318 1318 1319 char_bits = tty_get_char_size(termios->c_cflag); 1319 - symb_bit += char_bits; 1320 1320 lcr &= ~UART_LCR_WLEN8; 1321 1321 lcr |= UART_LCR_WLEN(char_bits); 1322 1322 1323 1323 /* Stop bits */ 1324 - if (termios->c_cflag & CSTOPB) { 1324 + if (termios->c_cflag & CSTOPB) 1325 1325 lcr |= UART_LCR_STOP; 1326 - symb_bit += 2; 1327 - } else { 1326 + else 1328 1327 lcr &= ~UART_LCR_STOP; 1329 - symb_bit++; 1330 - } 1331 1328 1332 1329 tegra_uart_write(tup, lcr, UART_LCR); 1333 1330 tup->lcr_shadow = lcr; 1334 - tup->symb_bit = symb_bit; 1331 + tup->symb_bit = tty_get_frame_size(termios->c_cflag); 1335 1332 1336 1333 /* Baud rate. */ 1337 1334 baud = uart_get_baud_rate(u, termios, oldtermios,
+25 -21
drivers/tty/serial/serial_core.c
··· 49 49 #define RS485_MAX_RTS_DELAY 100 /* msecs */ 50 50 51 51 static void uart_change_speed(struct tty_struct *tty, struct uart_state *state, 52 - struct ktermios *old_termios); 52 + const struct ktermios *old_termios); 53 53 static void uart_wait_until_sent(struct tty_struct *tty, int timeout); 54 54 static void uart_change_pm(struct uart_state *state, 55 55 enum uart_pm_state pm_state); ··· 158 158 unsigned long flags; 159 159 unsigned int old; 160 160 161 - if (port->rs485.flags & SER_RS485_ENABLED) { 162 - set &= ~TIOCM_RTS; 163 - clear &= ~TIOCM_RTS; 164 - } 165 - 166 161 spin_lock_irqsave(&port->lock, flags); 167 162 old = port->mctrl; 168 163 port->mctrl = (old & ~clear) | set; 169 - if (old != port->mctrl) 164 + if (old != port->mctrl && !(port->rs485.flags & SER_RS485_ENABLED)) 170 165 port->ops->set_mctrl(port, port->mctrl); 171 166 spin_unlock_irqrestore(&port->lock, flags); 172 167 } ··· 375 380 */ 376 381 unsigned int 377 382 uart_get_baud_rate(struct uart_port *port, struct ktermios *termios, 378 - struct ktermios *old, unsigned int min, unsigned int max) 383 + const struct ktermios *old, unsigned int min, unsigned int max) 379 384 { 380 385 unsigned int try; 381 386 unsigned int baud; ··· 487 492 488 493 /* Caller holds port mutex */ 489 494 static void uart_change_speed(struct tty_struct *tty, struct uart_state *state, 490 - struct ktermios *old_termios) 495 + const struct ktermios *old_termios) 491 496 { 492 497 struct uart_port *uport = uart_port_check(state); 493 498 struct ktermios *termios; ··· 1386 1391 !!(rs485->flags & SER_RS485_TERMINATE_BUS)); 1387 1392 } 1388 1393 1389 - int uart_rs485_config(struct uart_port *port) 1394 + static int uart_rs485_config(struct uart_port *port) 1390 1395 { 1391 1396 struct serial_rs485 *rs485 = &port->rs485; 1392 1397 int ret; ··· 1400 1405 1401 1406 return ret; 1402 1407 } 1403 - EXPORT_SYMBOL_GPL(uart_rs485_config); 1404 1408 1405 1409 static int uart_get_rs485_config(struct uart_port *port, 1406 1410 struct serial_rs485 __user *rs485) ··· 1438 1444 1439 1445 spin_lock_irqsave(&port->lock, flags); 1440 1446 ret = port->rs485_config(port, &tty->termios, &rs485); 1441 - if (!ret) 1447 + if (!ret) { 1442 1448 port->rs485 = rs485; 1449 + 1450 + /* Reset RTS and other mctrl lines when disabling RS485 */ 1451 + if (!(rs485.flags & SER_RS485_ENABLED)) 1452 + port->ops->set_mctrl(port, port->mctrl); 1453 + } 1443 1454 spin_unlock_irqrestore(&port->lock, flags); 1444 1455 if (ret) 1445 1456 return ret; ··· 1618 1619 } 1619 1620 1620 1621 static void uart_set_termios(struct tty_struct *tty, 1621 - struct ktermios *old_termios) 1622 + const struct ktermios *old_termios) 1622 1623 { 1623 1624 struct uart_state *state = tty->driver_data; 1624 1625 struct uart_port *uport; ··· 2351 2352 2352 2353 spin_lock_irq(&uport->lock); 2353 2354 ops->stop_tx(uport); 2354 - ops->set_mctrl(uport, 0); 2355 + if (!(uport->rs485.flags & SER_RS485_ENABLED)) 2356 + ops->set_mctrl(uport, 0); 2355 2357 /* save mctrl so it can be restored on resume */ 2356 2358 mctrl = uport->mctrl; 2357 2359 uport->mctrl = 0; ··· 2440 2440 2441 2441 uart_change_pm(state, UART_PM_STATE_ON); 2442 2442 spin_lock_irq(&uport->lock); 2443 - ops->set_mctrl(uport, 0); 2443 + if (!(uport->rs485.flags & SER_RS485_ENABLED)) 2444 + ops->set_mctrl(uport, 0); 2444 2445 spin_unlock_irq(&uport->lock); 2445 2446 if (console_suspend_enabled || !uart_console(uport)) { 2446 2447 /* Protected by port mutex for now */ ··· 2452 2451 if (tty) 2453 2452 uart_change_speed(tty, state, NULL); 2454 2453 spin_lock_irq(&uport->lock); 2455 - ops->set_mctrl(uport, uport->mctrl); 2454 + if (!(uport->rs485.flags & SER_RS485_ENABLED)) 2455 + ops->set_mctrl(uport, uport->mctrl); 2456 + else 2457 + uart_rs485_config(uport); 2456 2458 ops->start_tx(uport); 2457 2459 spin_unlock_irq(&uport->lock); 2458 2460 tty_port_set_initialized(port, 1); ··· 2501 2497 "MMIO 0x%llx", (unsigned long long)port->mapbase); 2502 2498 break; 2503 2499 default: 2504 - strlcpy(address, "*unknown*", sizeof(address)); 2500 + strscpy(address, "*unknown*", sizeof(address)); 2505 2501 break; 2506 2502 } 2507 2503 ··· 2562 2558 */ 2563 2559 spin_lock_irqsave(&port->lock, flags); 2564 2560 port->mctrl &= TIOCM_DTR; 2565 - if (port->rs485.flags & SER_RS485_ENABLED && 2566 - !(port->rs485.flags & SER_RS485_RTS_AFTER_SEND)) 2567 - port->mctrl |= TIOCM_RTS; 2568 - port->ops->set_mctrl(port, port->mctrl); 2561 + if (!(port->rs485.flags & SER_RS485_ENABLED)) 2562 + port->ops->set_mctrl(port, port->mctrl); 2563 + else 2564 + uart_rs485_config(port); 2569 2565 spin_unlock_irqrestore(&port->lock, flags); 2570 2566 2571 2567 /*
+1 -1
drivers/tty/serial/serial_txx9.c
··· 594 594 595 595 static void 596 596 serial_txx9_set_termios(struct uart_port *up, struct ktermios *termios, 597 - struct ktermios *old) 597 + const struct ktermios *old) 598 598 { 599 599 unsigned int cval, fcr = 0; 600 600 unsigned long flags;
+3 -5
drivers/tty/serial/sh-sci.c
··· 1407 1407 spin_lock_irq(&port->lock); 1408 1408 head = xmit->head; 1409 1409 tail = xmit->tail; 1410 - buf = s->tx_dma_addr + (tail & (UART_XMIT_SIZE - 1)); 1411 - s->tx_dma_len = min_t(unsigned int, 1412 - CIRC_CNT(head, tail, UART_XMIT_SIZE), 1413 - CIRC_CNT_TO_END(head, tail, UART_XMIT_SIZE)); 1410 + buf = s->tx_dma_addr + tail; 1411 + s->tx_dma_len = CIRC_CNT_TO_END(head, tail, UART_XMIT_SIZE); 1414 1412 if (!s->tx_dma_len) { 1415 1413 /* Transmit buffer has been flushed */ 1416 1414 spin_unlock_irq(&port->lock); ··· 2365 2367 } 2366 2368 2367 2369 static void sci_set_termios(struct uart_port *port, struct ktermios *termios, 2368 - struct ktermios *old) 2370 + const struct ktermios *old) 2369 2371 { 2370 2372 unsigned int baud, smr_val = SCSMR_ASYNC, scr_val = 0, i, bits; 2371 2373 unsigned int brr = 255, cks = 0, srr = 15, dl = 0, sccks = 0;
+1 -1
drivers/tty/serial/sifive.c
··· 646 646 647 647 static void sifive_serial_set_termios(struct uart_port *port, 648 648 struct ktermios *termios, 649 - struct ktermios *old) 649 + const struct ktermios *old) 650 650 { 651 651 struct sifive_serial_port *ssp = port_to_sifive_serial_port(port); 652 652 unsigned long flags;
+2 -3
drivers/tty/serial/sprd_serial.c
··· 771 771 devm_free_irq(port->dev, port->irq, port); 772 772 } 773 773 774 - static void sprd_set_termios(struct uart_port *port, 775 - struct ktermios *termios, 776 - struct ktermios *old) 774 + static void sprd_set_termios(struct uart_port *port, struct ktermios *termios, 775 + const struct ktermios *old) 777 776 { 778 777 unsigned int baud, quot; 779 778 unsigned int lcr = 0, fc;
+1 -1
drivers/tty/serial/st-asc.c
··· 500 500 } 501 501 502 502 static void asc_set_termios(struct uart_port *port, struct ktermios *termios, 503 - struct ktermios *old) 503 + const struct ktermios *old) 504 504 { 505 505 struct asc_port *ascport = to_asc_port(port); 506 506 struct gpio_desc *gpiod;
+57 -51
drivers/tty/serial/stm32-usart.c
··· 37 37 38 38 39 39 /* Register offsets */ 40 - static struct stm32_usart_info stm32f4_info = { 40 + static struct stm32_usart_info __maybe_unused stm32f4_info = { 41 41 .ofs = { 42 42 .isr = 0x00, 43 43 .rdr = 0x04, ··· 58 58 } 59 59 }; 60 60 61 - static struct stm32_usart_info stm32f7_info = { 61 + static struct stm32_usart_info __maybe_unused stm32f7_info = { 62 62 .ofs = { 63 63 .cr1 = 0x00, 64 64 .cr2 = 0x04, ··· 80 80 } 81 81 }; 82 82 83 - static struct stm32_usart_info stm32h7_info = { 83 + static struct stm32_usart_info __maybe_unused stm32h7_info = { 84 84 .ofs = { 85 85 .cr1 = 0x00, 86 86 .cr2 = 0x04, ··· 129 129 val = readl_relaxed(port->membase + reg); 130 130 val &= ~bits; 131 131 writel_relaxed(val, port->membase + reg); 132 + } 133 + 134 + static unsigned int stm32_usart_tx_empty(struct uart_port *port) 135 + { 136 + struct stm32_port *stm32_port = to_stm32_port(port); 137 + const struct stm32_usart_offsets *ofs = &stm32_port->info->ofs; 138 + 139 + if (readl_relaxed(port->membase + ofs->isr) & USART_SR_TC) 140 + return TIOCSER_TEMT; 141 + 142 + return 0; 143 + } 144 + 145 + static void stm32_usart_rs485_rts_enable(struct uart_port *port) 146 + { 147 + struct stm32_port *stm32_port = to_stm32_port(port); 148 + struct serial_rs485 *rs485conf = &port->rs485; 149 + 150 + if (stm32_port->hw_flow_control || 151 + !(rs485conf->flags & SER_RS485_ENABLED)) 152 + return; 153 + 154 + if (rs485conf->flags & SER_RS485_RTS_ON_SEND) { 155 + mctrl_gpio_set(stm32_port->gpios, 156 + stm32_port->port.mctrl | TIOCM_RTS); 157 + } else { 158 + mctrl_gpio_set(stm32_port->gpios, 159 + stm32_port->port.mctrl & ~TIOCM_RTS); 160 + } 161 + } 162 + 163 + static void stm32_usart_rs485_rts_disable(struct uart_port *port) 164 + { 165 + struct stm32_port *stm32_port = to_stm32_port(port); 166 + struct serial_rs485 *rs485conf = &port->rs485; 167 + 168 + if (stm32_port->hw_flow_control || 169 + !(rs485conf->flags & SER_RS485_ENABLED)) 170 + return; 171 + 172 + if (rs485conf->flags & SER_RS485_RTS_ON_SEND) { 173 + mctrl_gpio_set(stm32_port->gpios, 174 + stm32_port->port.mctrl & ~TIOCM_RTS); 175 + } else { 176 + mctrl_gpio_set(stm32_port->gpios, 177 + stm32_port->port.mctrl | TIOCM_RTS); 178 + } 132 179 } 133 180 134 181 static void stm32_usart_config_reg_rs485(u32 *cr1, u32 *cr3, u32 delay_ADE, ··· 260 213 } 261 214 262 215 stm32_usart_set_bits(port, ofs->cr1, BIT(cfg->uart_enable_bit)); 216 + 217 + /* Adjust RTS polarity in case it's driven in software */ 218 + if (stm32_usart_tx_empty(port)) 219 + stm32_usart_rs485_rts_disable(port); 220 + else 221 + stm32_usart_rs485_rts_enable(port); 263 222 264 223 return 0; 265 224 } ··· 582 529 stm32_usart_clr_bits(port, ofs->cr1, USART_CR1_TCIE); 583 530 } 584 531 585 - static void stm32_usart_rs485_rts_enable(struct uart_port *port) 586 - { 587 - struct stm32_port *stm32_port = to_stm32_port(port); 588 - struct serial_rs485 *rs485conf = &port->rs485; 589 - 590 - if (stm32_port->hw_flow_control || 591 - !(rs485conf->flags & SER_RS485_ENABLED)) 592 - return; 593 - 594 - if (rs485conf->flags & SER_RS485_RTS_ON_SEND) { 595 - mctrl_gpio_set(stm32_port->gpios, 596 - stm32_port->port.mctrl | TIOCM_RTS); 597 - } else { 598 - mctrl_gpio_set(stm32_port->gpios, 599 - stm32_port->port.mctrl & ~TIOCM_RTS); 600 - } 601 - } 602 - 603 - static void stm32_usart_rs485_rts_disable(struct uart_port *port) 604 - { 605 - struct stm32_port *stm32_port = to_stm32_port(port); 606 - struct serial_rs485 *rs485conf = &port->rs485; 607 - 608 - if (stm32_port->hw_flow_control || 609 - !(rs485conf->flags & SER_RS485_ENABLED)) 610 - return; 611 - 612 - if (rs485conf->flags & SER_RS485_RTS_ON_SEND) { 613 - mctrl_gpio_set(stm32_port->gpios, 614 - stm32_port->port.mctrl & ~TIOCM_RTS); 615 - } else { 616 - mctrl_gpio_set(stm32_port->gpios, 617 - stm32_port->port.mctrl | TIOCM_RTS); 618 - } 619 - } 620 - 621 532 static void stm32_usart_transmit_chars_pio(struct uart_port *port) 622 533 { 623 534 struct stm32_port *stm32_port = to_stm32_port(port); ··· 822 805 } 823 806 824 807 return IRQ_HANDLED; 825 - } 826 - 827 - static unsigned int stm32_usart_tx_empty(struct uart_port *port) 828 - { 829 - struct stm32_port *stm32_port = to_stm32_port(port); 830 - const struct stm32_usart_offsets *ofs = &stm32_port->info->ofs; 831 - 832 - if (readl_relaxed(port->membase + ofs->isr) & USART_SR_TC) 833 - return TIOCSER_TEMT; 834 - 835 - return 0; 836 808 } 837 809 838 810 static void stm32_usart_set_mctrl(struct uart_port *port, unsigned int mctrl) ··· 1095 1089 1096 1090 static void stm32_usart_set_termios(struct uart_port *port, 1097 1091 struct ktermios *termios, 1098 - struct ktermios *old) 1092 + const struct ktermios *old) 1099 1093 { 1100 1094 struct stm32_port *stm32_port = to_stm32_port(port); 1101 1095 const struct stm32_usart_offsets *ofs = &stm32_port->info->ofs;
+1 -1
drivers/tty/serial/sunhv.c
··· 323 323 324 324 /* port->lock is not held. */ 325 325 static void sunhv_set_termios(struct uart_port *port, struct ktermios *termios, 326 - struct ktermios *old) 326 + const struct ktermios *old) 327 327 { 328 328 unsigned int baud = uart_get_baud_rate(port, termios, old, 0, 4000000); 329 329 unsigned int quot = uart_get_divisor(port, baud);
+1 -1
drivers/tty/serial/sunplus-uart.c
··· 333 333 334 334 static void sunplus_set_termios(struct uart_port *port, 335 335 struct ktermios *termios, 336 - struct ktermios *oldtermios) 336 + const struct ktermios *oldtermios) 337 337 { 338 338 u32 ext, div, div_l, div_h, baud, lcr; 339 339 u32 clk = port->uartclk;
+9 -13
drivers/tty/serial/sunsab.c
··· 681 681 unsigned int quot) 682 682 { 683 683 unsigned char dafo; 684 - int bits, n, m; 684 + int n, m; 685 685 686 686 /* Byte size and parity */ 687 687 switch (cflag & CSIZE) { 688 - case CS5: dafo = SAB82532_DAFO_CHL5; bits = 7; break; 689 - case CS6: dafo = SAB82532_DAFO_CHL6; bits = 8; break; 690 - case CS7: dafo = SAB82532_DAFO_CHL7; bits = 9; break; 691 - case CS8: dafo = SAB82532_DAFO_CHL8; bits = 10; break; 688 + case CS5: dafo = SAB82532_DAFO_CHL5; break; 689 + case CS6: dafo = SAB82532_DAFO_CHL6; break; 690 + case CS7: dafo = SAB82532_DAFO_CHL7; break; 691 + case CS8: dafo = SAB82532_DAFO_CHL8; break; 692 692 /* Never happens, but GCC is too dumb to figure it out */ 693 - default: dafo = SAB82532_DAFO_CHL5; bits = 7; break; 693 + default: dafo = SAB82532_DAFO_CHL5; break; 694 694 } 695 695 696 - if (cflag & CSTOPB) { 696 + if (cflag & CSTOPB) 697 697 dafo |= SAB82532_DAFO_STOP; 698 - bits++; 699 - } 700 698 701 - if (cflag & PARENB) { 699 + if (cflag & PARENB) 702 700 dafo |= SAB82532_DAFO_PARE; 703 - bits++; 704 - } 705 701 706 702 if (cflag & PARODD) { 707 703 dafo |= SAB82532_DAFO_PAR_ODD; ··· 772 776 773 777 /* port->lock is not held. */ 774 778 static void sunsab_set_termios(struct uart_port *port, struct ktermios *termios, 775 - struct ktermios *old) 779 + const struct ktermios *old) 776 780 { 777 781 struct uart_sunsab_port *up = 778 782 container_of(port, struct uart_sunsab_port, port);
+4 -4
drivers/tty/serial/sunsu.c
··· 897 897 898 898 static void 899 899 sunsu_set_termios(struct uart_port *port, struct ktermios *termios, 900 - struct ktermios *old) 900 + const struct ktermios *old) 901 901 { 902 902 unsigned int baud, quot; 903 903 ··· 1217 1217 serio->id.type = SERIO_RS232; 1218 1218 if (up->su_type == SU_PORT_KBD) { 1219 1219 serio->id.proto = SERIO_SUNKBD; 1220 - strlcpy(serio->name, "sukbd", sizeof(serio->name)); 1220 + strscpy(serio->name, "sukbd", sizeof(serio->name)); 1221 1221 } else { 1222 1222 serio->id.proto = SERIO_SUN; 1223 1223 serio->id.extra = 1; 1224 - strlcpy(serio->name, "sums", sizeof(serio->name)); 1224 + strscpy(serio->name, "sums", sizeof(serio->name)); 1225 1225 } 1226 - strlcpy(serio->phys, 1226 + strscpy(serio->phys, 1227 1227 (!(up->port.line & 1) ? "su/serio0" : "su/serio1"), 1228 1228 sizeof(serio->phys)); 1229 1229
+4 -4
drivers/tty/serial/sunzilog.c
··· 938 938 /* The port lock is not held. */ 939 939 static void 940 940 sunzilog_set_termios(struct uart_port *port, struct ktermios *termios, 941 - struct ktermios *old) 941 + const struct ktermios *old) 942 942 { 943 943 struct uart_sunzilog_port *up = 944 944 container_of(port, struct uart_sunzilog_port, port); ··· 1307 1307 serio->id.type = SERIO_RS232; 1308 1308 if (up->flags & SUNZILOG_FLAG_CONS_KEYB) { 1309 1309 serio->id.proto = SERIO_SUNKBD; 1310 - strlcpy(serio->name, "zskbd", sizeof(serio->name)); 1310 + strscpy(serio->name, "zskbd", sizeof(serio->name)); 1311 1311 } else { 1312 1312 serio->id.proto = SERIO_SUN; 1313 1313 serio->id.extra = 1; 1314 - strlcpy(serio->name, "zsms", sizeof(serio->name)); 1314 + strscpy(serio->name, "zsms", sizeof(serio->name)); 1315 1315 } 1316 - strlcpy(serio->phys, 1316 + strscpy(serio->phys, 1317 1317 ((up->flags & SUNZILOG_FLAG_CONS_KEYB) ? 1318 1318 "zs/serio0" : "zs/serio1"), 1319 1319 sizeof(serio->phys));
+1 -1
drivers/tty/serial/tegra-tcu.c
··· 126 126 127 127 static void tegra_tcu_uart_set_termios(struct uart_port *port, 128 128 struct ktermios *new, 129 - struct ktermios *old) 129 + const struct ktermios *old) 130 130 { 131 131 } 132 132
+2 -2
drivers/tty/serial/timbuart.c
··· 275 275 } 276 276 277 277 static void timbuart_set_termios(struct uart_port *port, 278 - struct ktermios *termios, 279 - struct ktermios *old) 278 + struct ktermios *termios, 279 + const struct ktermios *old) 280 280 { 281 281 unsigned int baud; 282 282 short bindex;
+3 -2
drivers/tty/serial/uartlite.c
··· 314 314 clk_disable(pdata->clk); 315 315 } 316 316 317 - static void ulite_set_termios(struct uart_port *port, struct ktermios *termios, 318 - struct ktermios *old) 317 + static void ulite_set_termios(struct uart_port *port, 318 + struct ktermios *termios, 319 + const struct ktermios *old) 319 320 { 320 321 unsigned long flags; 321 322 struct uartlite_data *pdata = port->private_data;
+3 -15
drivers/tty/serial/ucc_uart.c
··· 843 843 * Set the serial port parameters. 844 844 */ 845 845 static void qe_uart_set_termios(struct uart_port *port, 846 - struct ktermios *termios, struct ktermios *old) 846 + struct ktermios *termios, 847 + const struct ktermios *old) 847 848 { 848 849 struct uart_qe_port *qe_port = 849 850 container_of(port, struct uart_qe_port, port); ··· 854 853 u16 upsmr = ioread16be(&uccp->upsmr); 855 854 struct ucc_uart_pram __iomem *uccup = qe_port->uccup; 856 855 u16 supsmr = ioread16be(&uccup->supsmr); 857 - u8 char_length = 2; /* 1 + CL + PEN + 1 + SL */ 858 - 859 - /* Character length programmed into the mode register is the 860 - * sum of: 1 start bit, number of data bits, 0 or 1 parity bit, 861 - * 1 or 2 stop bits, minus 1. 862 - * The value 'bits' counts this for us. 863 - */ 864 856 865 857 /* byte size */ 866 858 upsmr &= UCC_UART_UPSMR_CL_MASK; ··· 863 869 case CS5: 864 870 upsmr |= UCC_UART_UPSMR_CL_5; 865 871 supsmr |= UCC_UART_SUPSMR_CL_5; 866 - char_length += 5; 867 872 break; 868 873 case CS6: 869 874 upsmr |= UCC_UART_UPSMR_CL_6; 870 875 supsmr |= UCC_UART_SUPSMR_CL_6; 871 - char_length += 6; 872 876 break; 873 877 case CS7: 874 878 upsmr |= UCC_UART_UPSMR_CL_7; 875 879 supsmr |= UCC_UART_SUPSMR_CL_7; 876 - char_length += 7; 877 880 break; 878 881 default: /* case CS8 */ 879 882 upsmr |= UCC_UART_UPSMR_CL_8; 880 883 supsmr |= UCC_UART_SUPSMR_CL_8; 881 - char_length += 8; 882 884 break; 883 885 } 884 886 ··· 882 892 if (termios->c_cflag & CSTOPB) { 883 893 upsmr |= UCC_UART_UPSMR_SL; 884 894 supsmr |= UCC_UART_SUPSMR_SL; 885 - char_length++; /* + SL */ 886 895 } 887 896 888 897 if (termios->c_cflag & PARENB) { 889 898 upsmr |= UCC_UART_UPSMR_PEN; 890 899 supsmr |= UCC_UART_SUPSMR_PEN; 891 - char_length++; /* + PEN */ 892 900 893 901 if (!(termios->c_cflag & PARODD)) { 894 902 upsmr &= ~(UCC_UART_UPSMR_RPM_MASK | ··· 941 953 iowrite16be(upsmr, &uccp->upsmr); 942 954 if (soft_uart) { 943 955 iowrite16be(supsmr, &uccup->supsmr); 944 - iowrite8(char_length, &uccup->rx_length); 956 + iowrite8(tty_get_frame_size(termios->c_cflag), &uccup->rx_length); 945 957 946 958 /* Soft-UART requires a 1X multiplier for TX */ 947 959 qe_setbrg(qe_port->us_info.rx_clock, baud, 16);
+9 -8
drivers/tty/serial/vt8500_serial.c
··· 187 187 tty_flip_buffer_push(tport); 188 188 } 189 189 190 + static unsigned int vt8500_tx_empty(struct uart_port *port) 191 + { 192 + unsigned int idx = vt8500_read(port, VT8500_URFIDX) & 0x1f; 193 + 194 + return idx < 16 ? TIOCSER_TEMT : 0; 195 + } 196 + 190 197 static void handle_tx(struct uart_port *port) 191 198 { 192 199 struct circ_buf *xmit = &port->state->xmit; ··· 208 201 return; 209 202 } 210 203 211 - while ((vt8500_read(port, VT8500_URFIDX) & 0x1f) < 16) { 204 + while (vt8500_tx_empty(port)) { 212 205 if (uart_circ_empty(xmit)) 213 206 break; 214 207 ··· 265 258 spin_unlock(&port->lock); 266 259 267 260 return IRQ_HANDLED; 268 - } 269 - 270 - static unsigned int vt8500_tx_empty(struct uart_port *port) 271 - { 272 - return (vt8500_read(port, VT8500_URFIDX) & 0x1f) < 16 ? 273 - TIOCSER_TEMT : 0; 274 261 } 275 262 276 263 static unsigned int vt8500_get_mctrl(struct uart_port *port) ··· 356 355 357 356 static void vt8500_set_termios(struct uart_port *port, 358 357 struct ktermios *termios, 359 - struct ktermios *old) 358 + const struct ktermios *old) 360 359 { 361 360 struct vt8500_port *vt8500_port = 362 361 container_of(port, struct vt8500_port, uart);
+55 -7
drivers/tty/serial/xilinx_uartps.c
··· 2 2 /* 3 3 * Cadence UART driver (found in Xilinx Zynq) 4 4 * 5 - * 2011 - 2014 (C) Xilinx Inc. 5 + * Copyright (c) 2011 - 2014 Xilinx, Inc. 6 6 * 7 7 * This driver has originally been pushed by Xilinx using a Zynq-branding. This 8 8 * still shows in the naming of this file, the kconfig symbols and some symbols ··· 361 361 isrstatus &= ~CDNS_UART_IXR_TXEMPTY; 362 362 } 363 363 364 + isrstatus &= port->read_status_mask; 365 + isrstatus &= ~port->ignore_status_mask; 364 366 /* 365 367 * Skip RX processing if RX is disabled as RXEMPTY will never be set 366 368 * as read bytes will not be removed from the FIFO. ··· 677 675 * @old: Values of the previously saved termios structure 678 676 */ 679 677 static void cdns_uart_set_termios(struct uart_port *port, 680 - struct ktermios *termios, struct ktermios *old) 678 + struct ktermios *termios, 679 + const struct ktermios *old) 681 680 { 682 681 u32 cval = 0; 683 682 unsigned int baud, minbaud, maxbaud; ··· 1133 1130 */ 1134 1131 static void cdns_uart_console_putchar(struct uart_port *port, unsigned char ch) 1135 1132 { 1136 - while (readl(port->membase + CDNS_UART_SR) & CDNS_UART_SR_TXFULL) 1133 + unsigned int ctrl_reg; 1134 + unsigned long timeout; 1135 + 1136 + timeout = jiffies + msecs_to_jiffies(1000); 1137 + while (1) { 1138 + ctrl_reg = readl(port->membase + CDNS_UART_CR); 1139 + if (!(ctrl_reg & CDNS_UART_CR_TX_DIS)) 1140 + break; 1141 + if (time_after(jiffies, timeout)) { 1142 + dev_warn(port->dev, 1143 + "timeout waiting for Enable\n"); 1144 + return; 1145 + } 1137 1146 cpu_relax(); 1147 + } 1148 + 1149 + timeout = jiffies + msecs_to_jiffies(1000); 1150 + while (1) { 1151 + ctrl_reg = readl(port->membase + CDNS_UART_SR); 1152 + 1153 + if (!(ctrl_reg & CDNS_UART_SR_TXFULL)) 1154 + break; 1155 + if (time_after(jiffies, timeout)) { 1156 + dev_warn(port->dev, 1157 + "timeout waiting for TX fifo\n"); 1158 + return; 1159 + } 1160 + cpu_relax(); 1161 + } 1138 1162 writel(ch, port->membase + CDNS_UART_FIFO); 1139 1163 } 1140 1164 ··· 1359 1329 unsigned long flags; 1360 1330 u32 ctrl_reg; 1361 1331 int may_wake; 1332 + int ret; 1362 1333 1363 1334 may_wake = device_may_wakeup(device); 1364 1335 1365 1336 if (console_suspend_enabled && uart_console(port) && !may_wake) { 1366 - clk_enable(cdns_uart->pclk); 1367 - clk_enable(cdns_uart->uartclk); 1337 + ret = clk_enable(cdns_uart->pclk); 1338 + if (ret) 1339 + return ret; 1340 + 1341 + ret = clk_enable(cdns_uart->uartclk); 1342 + if (ret) { 1343 + clk_disable(cdns_uart->pclk); 1344 + return ret; 1345 + } 1368 1346 1369 1347 spin_lock_irqsave(&port->lock, flags); 1370 1348 ··· 1421 1383 { 1422 1384 struct uart_port *port = dev_get_drvdata(dev); 1423 1385 struct cdns_uart *cdns_uart = port->private_data; 1386 + int ret; 1424 1387 1425 - clk_enable(cdns_uart->pclk); 1426 - clk_enable(cdns_uart->uartclk); 1388 + ret = clk_enable(cdns_uart->pclk); 1389 + if (ret) 1390 + return ret; 1391 + 1392 + ret = clk_enable(cdns_uart->uartclk); 1393 + if (ret) { 1394 + clk_disable(cdns_uart->pclk); 1395 + return ret; 1396 + } 1427 1397 return 0; 1428 1398 }; 1429 1399 ··· 1597 1551 port->dev = &pdev->dev; 1598 1552 port->uartclk = clk_get_rate(cdns_uart_data->uartclk); 1599 1553 port->private_data = cdns_uart_data; 1554 + port->read_status_mask = CDNS_UART_IXR_TXEMPTY | CDNS_UART_IXR_RXTRIG | 1555 + CDNS_UART_IXR_OVERRUN | CDNS_UART_IXR_TOUT; 1600 1556 cdns_uart_data->port = port; 1601 1557 platform_set_drvdata(pdev, port); 1602 1558
+1 -1
drivers/tty/serial/zs.c
··· 846 846 } 847 847 848 848 static void zs_set_termios(struct uart_port *uport, struct ktermios *termios, 849 - struct ktermios *old_termios) 849 + const struct ktermios *old_termios) 850 850 { 851 851 struct zs_port *zport = to_zport(uport); 852 852 struct zs_scc *scc = zport->scc;
+1 -1
drivers/tty/tty.h
··· 73 73 bool tty_buffer_restart_work(struct tty_port *port); 74 74 bool tty_buffer_cancel_work(struct tty_port *port); 75 75 void tty_buffer_flush_work(struct tty_port *port); 76 - speed_t tty_termios_input_baud_rate(struct ktermios *termios); 76 + speed_t tty_termios_input_baud_rate(const struct ktermios *termios); 77 77 void tty_ldisc_hangup(struct tty_struct *tty, bool reset); 78 78 int tty_ldisc_reinit(struct tty_struct *tty, int disc); 79 79 long tty_ioctl(struct file *file, unsigned int cmd, unsigned long arg);
+9 -17
drivers/tty/tty_baudrate.c
··· 49 49 * 50 50 * Convert termios baud rate data into a speed. This should be called 51 51 * with the termios lock held if this termios is a terminal termios 52 - * structure. May change the termios data. Device drivers can call this 53 - * function but should use ->c_[io]speed directly as they are updated. 52 + * structure. Device drivers can call this function but should use 53 + * ->c_[io]speed directly as they are updated. 54 54 * 55 55 * Locking: none 56 56 */ 57 57 58 - speed_t tty_termios_baud_rate(struct ktermios *termios) 58 + speed_t tty_termios_baud_rate(const struct ktermios *termios) 59 59 { 60 60 unsigned int cbaud; 61 61 ··· 67 67 68 68 if (cbaud & CBAUDEX) { 69 69 cbaud &= ~CBAUDEX; 70 - 71 - if (cbaud < 1 || cbaud + 15 > n_baud_table) 72 - termios->c_cflag &= ~CBAUDEX; 73 - else 74 - cbaud += 15; 70 + cbaud += 15; 75 71 } 76 72 return cbaud >= n_baud_table ? 0 : baud_table[cbaud]; 77 73 } ··· 79 83 * 80 84 * Convert termios baud rate data into a speed. This should be called 81 85 * with the termios lock held if this termios is a terminal termios 82 - * structure. May change the termios data. Device drivers can call this 83 - * function but should use ->c_[io]speed directly as they are updated. 86 + * structure. Device drivers can call this function but should use 87 + * ->c_[io]speed directly as they are updated. 84 88 * 85 89 * Locking: none 86 90 */ 87 91 88 - speed_t tty_termios_input_baud_rate(struct ktermios *termios) 92 + speed_t tty_termios_input_baud_rate(const struct ktermios *termios) 89 93 { 90 94 unsigned int cbaud = (termios->c_cflag >> IBSHIFT) & CBAUD; 91 95 92 96 if (cbaud == B0) 93 97 return tty_termios_baud_rate(termios); 94 98 95 - /* Magic token for arbitrary speed via c_ispeed*/ 99 + /* Magic token for arbitrary speed via c_ispeed */ 96 100 if (cbaud == BOTHER) 97 101 return termios->c_ispeed; 98 102 99 103 if (cbaud & CBAUDEX) { 100 104 cbaud &= ~CBAUDEX; 101 - 102 - if (cbaud < 1 || cbaud + 15 > n_baud_table) 103 - termios->c_cflag &= ~(CBAUDEX << IBSHIFT); 104 - else 105 - cbaud += 15; 105 + cbaud += 15; 106 106 } 107 107 return cbaud >= n_baud_table ? 0 : baud_table[cbaud]; 108 108 }
+1 -10
drivers/tty/tty_io.c
··· 99 99 #include <linux/serial.h> 100 100 #include <linux/ratelimit.h> 101 101 #include <linux/compat.h> 102 - 103 102 #include <linux/uaccess.h> 103 + #include <linux/termios_internal.h> 104 104 105 105 #include <linux/kbd_kern.h> 106 106 #include <linux/vt_kern.h> ··· 170 170 tty_ldisc_deinit(tty); 171 171 put_device(tty->dev); 172 172 kvfree(tty->write_buf); 173 - tty->magic = 0xDEADDEAD; 174 173 kfree(tty); 175 174 } 176 175 ··· 261 262 #ifdef TTY_PARANOIA_CHECK 262 263 if (!tty) { 263 264 pr_warn("(%d:%d): %s: NULL tty\n", 264 - imajor(inode), iminor(inode), routine); 265 - return 1; 266 - } 267 - if (tty->magic != TTY_MAGIC) { 268 - pr_warn("(%d:%d): %s: bad magic number\n", 269 265 imajor(inode), iminor(inode), routine); 270 266 return 1; 271 267 } ··· 1527 1533 if (tty->ops->cleanup) 1528 1534 tty->ops->cleanup(tty); 1529 1535 1530 - tty->magic = 0; 1531 1536 tty_driver_kref_put(driver); 1532 1537 module_put(owner); 1533 1538 ··· 3086 3093 return NULL; 3087 3094 3088 3095 kref_init(&tty->kref); 3089 - tty->magic = TTY_MAGIC; 3090 3096 if (tty_ldisc_init(tty)) { 3091 3097 kfree(tty); 3092 3098 return NULL; ··· 3321 3329 return ERR_PTR(-ENOMEM); 3322 3330 3323 3331 kref_init(&driver->kref); 3324 - driver->magic = TTY_DRIVER_MAGIC; 3325 3332 driver->num = lines; 3326 3333 driver->owner = owner; 3327 3334 driver->flags = flags;
+77 -2
drivers/tty/tty_ioctl.c
··· 21 21 #include <linux/bitops.h> 22 22 #include <linux/mutex.h> 23 23 #include <linux/compat.h> 24 + #include <linux/termios_internal.h> 24 25 #include "tty.h" 25 26 26 27 #include <asm/io.h> ··· 220 219 * Termios Helper Methods 221 220 */ 222 221 223 - static void unset_locked_termios(struct tty_struct *tty, struct ktermios *old) 222 + static void unset_locked_termios(struct tty_struct *tty, const struct ktermios *old) 224 223 { 225 224 struct ktermios *termios = &tty->termios; 226 225 struct ktermios *locked = &tty->termios_locked; ··· 250 249 * in some cases where only minimal reconfiguration is supported 251 250 */ 252 251 253 - void tty_termios_copy_hw(struct ktermios *new, struct ktermios *old) 252 + void tty_termios_copy_hw(struct ktermios *new, const struct ktermios *old) 254 253 { 255 254 /* The bits a dumb device handles in software. Smart devices need 256 255 to always provide a set_termios method */ ··· 374 373 return 0; 375 374 } 376 375 EXPORT_SYMBOL_GPL(tty_set_termios); 376 + 377 + 378 + /* 379 + * Translate a "termio" structure into a "termios". Ugh. 380 + */ 381 + __weak int user_termio_to_kernel_termios(struct ktermios *termios, 382 + struct termio __user *termio) 383 + { 384 + struct termio v; 385 + 386 + if (copy_from_user(&v, termio, sizeof(struct termio))) 387 + return -EFAULT; 388 + 389 + termios->c_iflag = (0xffff0000 & termios->c_iflag) | v.c_iflag; 390 + termios->c_oflag = (0xffff0000 & termios->c_oflag) | v.c_oflag; 391 + termios->c_cflag = (0xffff0000 & termios->c_cflag) | v.c_cflag; 392 + termios->c_lflag = (0xffff0000 & termios->c_lflag) | v.c_lflag; 393 + termios->c_line = (0xffff0000 & termios->c_lflag) | v.c_line; 394 + memcpy(termios->c_cc, v.c_cc, NCC); 395 + return 0; 396 + } 397 + 398 + /* 399 + * Translate a "termios" structure into a "termio". Ugh. 400 + */ 401 + __weak int kernel_termios_to_user_termio(struct termio __user *termio, 402 + struct ktermios *termios) 403 + { 404 + struct termio v; 405 + memset(&v, 0, sizeof(struct termio)); 406 + v.c_iflag = termios->c_iflag; 407 + v.c_oflag = termios->c_oflag; 408 + v.c_cflag = termios->c_cflag; 409 + v.c_lflag = termios->c_lflag; 410 + v.c_line = termios->c_line; 411 + memcpy(v.c_cc, termios->c_cc, NCC); 412 + return copy_to_user(termio, &v, sizeof(struct termio)); 413 + } 414 + 415 + #ifdef TCGETS2 416 + __weak int user_termios_to_kernel_termios(struct ktermios *k, 417 + struct termios2 __user *u) 418 + { 419 + return copy_from_user(k, u, sizeof(struct termios2)); 420 + } 421 + __weak int kernel_termios_to_user_termios(struct termios2 __user *u, 422 + struct ktermios *k) 423 + { 424 + return copy_to_user(u, k, sizeof(struct termios2)); 425 + } 426 + __weak int user_termios_to_kernel_termios_1(struct ktermios *k, 427 + struct termios __user *u) 428 + { 429 + return copy_from_user(k, u, sizeof(struct termios)); 430 + } 431 + __weak int kernel_termios_to_user_termios_1(struct termios __user *u, 432 + struct ktermios *k) 433 + { 434 + return copy_to_user(u, k, sizeof(struct termios)); 435 + } 436 + 437 + #else 438 + 439 + __weak int user_termios_to_kernel_termios(struct ktermios *k, 440 + struct termios __user *u) 441 + { 442 + return copy_from_user(k, u, sizeof(struct termios)); 443 + } 444 + __weak int kernel_termios_to_user_termios(struct termios __user *u, 445 + struct ktermios *k) 446 + { 447 + return copy_to_user(u, k, sizeof(struct termios)); 448 + } 449 + #endif /* TCGETS2 */ 377 450 378 451 /** 379 452 * set_termios - set termios values for a tty
-6
drivers/tty/tty_mutex.c
··· 14 14 15 15 void tty_lock(struct tty_struct *tty) 16 16 { 17 - if (WARN(tty->magic != TTY_MAGIC, "L Bad %p\n", tty)) 18 - return; 19 17 tty_kref_get(tty); 20 18 mutex_lock(&tty->legacy_mutex); 21 19 } ··· 23 25 { 24 26 int ret; 25 27 26 - if (WARN(tty->magic != TTY_MAGIC, "L Bad %p\n", tty)) 27 - return -EIO; 28 28 tty_kref_get(tty); 29 29 ret = mutex_lock_interruptible(&tty->legacy_mutex); 30 30 if (ret) ··· 32 36 33 37 void tty_unlock(struct tty_struct *tty) 34 38 { 35 - if (WARN(tty->magic != TTY_MAGIC, "U Bad %p\n", tty)) 36 - return; 37 39 mutex_unlock(&tty->legacy_mutex); 38 40 tty_kref_put(tty); 39 41 }
+1
drivers/tty/vcc.c
··· 11 11 #include <linux/sysfs.h> 12 12 #include <linux/tty.h> 13 13 #include <linux/tty_flip.h> 14 + #include <linux/termios_internal.h> 14 15 #include <asm/vio.h> 15 16 #include <asm/ldc.h> 16 17
+5 -6
drivers/tty/vt/vt.c
··· 154 154 static void con_driver_unregister_callback(struct work_struct *ignored); 155 155 static void blank_screen_t(struct timer_list *unused); 156 156 static void set_palette(struct vc_data *vc); 157 + static void unblank_screen(void); 157 158 158 159 #define vt_get_kmsg_redirect() vt_kmsg_redirect(-1) 159 160 160 - static int printable; /* Is console ready for printing? */ 161 161 int default_utf8 = true; 162 162 module_param(default_utf8, int, S_IRUGO | S_IWUSR); 163 163 int global_cursor_default = -1; ··· 3084 3084 ushort start_x, cnt; 3085 3085 int kmsg_console; 3086 3086 3087 - /* console busy or not yet initialized */ 3088 - if (!printable) 3089 - return; 3087 + WARN_CONSOLE_UNLOCKED(); 3088 + 3089 + /* this protects against concurrent oops only */ 3090 3090 if (!spin_trylock(&printing_lock)) 3091 3091 return; 3092 3092 ··· 3537 3537 pr_info("Console: %s %s %dx%d\n", 3538 3538 vc->vc_can_do_color ? "colour" : "mono", 3539 3539 display_desc, vc->vc_cols, vc->vc_rows); 3540 - printable = 1; 3541 3540 3542 3541 console_unlock(); 3543 3542 ··· 4451 4452 * call it with 1 as an argument and so force a mode restore... that may kill 4452 4453 * X or at least garbage the screen but would also make the Oops visible... 4453 4454 */ 4454 - void unblank_screen(void) 4455 + static void unblank_screen(void) 4455 4456 { 4456 4457 do_unblank_screen(0); 4457 4458 }
+2 -2
drivers/usb/class/cdc-acm.c
··· 51 51 static DEFINE_MUTEX(acm_minors_lock); 52 52 53 53 static void acm_tty_set_termios(struct tty_struct *tty, 54 - struct ktermios *termios_old); 54 + const struct ktermios *termios_old); 55 55 56 56 /* 57 57 * acm_minors accessors ··· 1049 1049 } 1050 1050 1051 1051 static void acm_tty_set_termios(struct tty_struct *tty, 1052 - struct ktermios *termios_old) 1052 + const struct ktermios *termios_old) 1053 1053 { 1054 1054 struct acm *acm = tty->driver_data; 1055 1055 struct ktermios *termios = &tty->termios;
+1 -1
drivers/usb/serial/ark3116.c
··· 189 189 190 190 static void ark3116_set_termios(struct tty_struct *tty, 191 191 struct usb_serial_port *port, 192 - struct ktermios *old_termios) 192 + const struct ktermios *old_termios) 193 193 { 194 194 struct usb_serial *serial = port->serial; 195 195 struct ark3116_private *priv = usb_get_serial_port_data(port);
+4 -2
drivers/usb/serial/belkin_sa.c
··· 44 44 static void belkin_sa_read_int_callback(struct urb *urb); 45 45 static void belkin_sa_process_read_urb(struct urb *urb); 46 46 static void belkin_sa_set_termios(struct tty_struct *tty, 47 - struct usb_serial_port *port, struct ktermios * old); 47 + struct usb_serial_port *port, 48 + const struct ktermios *old_termios); 48 49 static void belkin_sa_break_ctl(struct tty_struct *tty, int break_state); 49 50 static int belkin_sa_tiocmget(struct tty_struct *tty); 50 51 static int belkin_sa_tiocmset(struct tty_struct *tty, ··· 274 273 } 275 274 276 275 static void belkin_sa_set_termios(struct tty_struct *tty, 277 - struct usb_serial_port *port, struct ktermios *old_termios) 276 + struct usb_serial_port *port, 277 + const struct ktermios *old_termios) 278 278 { 279 279 struct usb_serial *serial = port->serial; 280 280 struct belkin_sa_private *priv = usb_get_serial_port_data(port);
+3 -2
drivers/usb/serial/ch341.c
··· 106 106 107 107 static void ch341_set_termios(struct tty_struct *tty, 108 108 struct usb_serial_port *port, 109 - struct ktermios *old_termios); 109 + const struct ktermios *old_termios); 110 110 111 111 static int ch341_control_out(struct usb_device *dev, u8 request, 112 112 u16 value, u16 index) ··· 482 482 * tty->termios contains the new setting to be used. 483 483 */ 484 484 static void ch341_set_termios(struct tty_struct *tty, 485 - struct usb_serial_port *port, struct ktermios *old_termios) 485 + struct usb_serial_port *port, 486 + const struct ktermios *old_termios) 486 487 { 487 488 struct ch341_private *priv = usb_get_serial_port_data(port); 488 489 unsigned baud_rate;
+8 -5
drivers/usb/serial/cp210x.c
··· 31 31 static int cp210x_open(struct tty_struct *tty, struct usb_serial_port *); 32 32 static void cp210x_close(struct usb_serial_port *); 33 33 static void cp210x_change_speed(struct tty_struct *, struct usb_serial_port *, 34 - struct ktermios *); 34 + const struct ktermios *); 35 35 static void cp210x_set_termios(struct tty_struct *, struct usb_serial_port *, 36 - struct ktermios*); 36 + const struct ktermios *); 37 37 static bool cp210x_tx_empty(struct usb_serial_port *port); 38 38 static int cp210x_tiocmget(struct tty_struct *); 39 39 static int cp210x_tiocmset(struct tty_struct *, unsigned int, unsigned int); ··· 1040 1040 * otherwise. 1041 1041 */ 1042 1042 static void cp210x_change_speed(struct tty_struct *tty, 1043 - struct usb_serial_port *port, struct ktermios *old_termios) 1043 + struct usb_serial_port *port, 1044 + const struct ktermios *old_termios) 1044 1045 { 1045 1046 struct usb_serial *serial = port->serial; 1046 1047 struct cp210x_serial_private *priv = usb_get_serial_data(serial); ··· 1123 1122 } 1124 1123 1125 1124 static void cp210x_set_flow_control(struct tty_struct *tty, 1126 - struct usb_serial_port *port, struct ktermios *old_termios) 1125 + struct usb_serial_port *port, 1126 + const struct ktermios *old_termios) 1127 1127 { 1128 1128 struct cp210x_serial_private *priv = usb_get_serial_data(port->serial); 1129 1129 struct cp210x_port_private *port_priv = usb_get_serial_port_data(port); ··· 1234 1232 } 1235 1233 1236 1234 static void cp210x_set_termios(struct tty_struct *tty, 1237 - struct usb_serial_port *port, struct ktermios *old_termios) 1235 + struct usb_serial_port *port, 1236 + const struct ktermios *old_termios) 1238 1237 { 1239 1238 struct cp210x_serial_private *priv = usb_get_serial_data(port->serial); 1240 1239 u16 bits;
+4 -2
drivers/usb/serial/cypress_m8.c
··· 125 125 static unsigned int cypress_write_room(struct tty_struct *tty); 126 126 static void cypress_earthmate_init_termios(struct tty_struct *tty); 127 127 static void cypress_set_termios(struct tty_struct *tty, 128 - struct usb_serial_port *port, struct ktermios *old); 128 + struct usb_serial_port *port, 129 + const struct ktermios *old_termios); 129 130 static int cypress_tiocmget(struct tty_struct *tty); 130 131 static int cypress_tiocmset(struct tty_struct *tty, 131 132 unsigned int set, unsigned int clear); ··· 860 859 } 861 860 862 861 static void cypress_set_termios(struct tty_struct *tty, 863 - struct usb_serial_port *port, struct ktermios *old_termios) 862 + struct usb_serial_port *port, 863 + const struct ktermios *old_termios) 864 864 { 865 865 struct cypress_private *priv = usb_get_serial_port_data(port); 866 866 struct device *dev = &port->dev;
+4 -2
drivers/usb/serial/digi_acceleport.c
··· 215 215 static void digi_rx_throttle(struct tty_struct *tty); 216 216 static void digi_rx_unthrottle(struct tty_struct *tty); 217 217 static void digi_set_termios(struct tty_struct *tty, 218 - struct usb_serial_port *port, struct ktermios *old_termios); 218 + struct usb_serial_port *port, 219 + const struct ktermios *old_termios); 219 220 static void digi_break_ctl(struct tty_struct *tty, int break_state); 220 221 static int digi_tiocmget(struct tty_struct *tty); 221 222 static int digi_tiocmset(struct tty_struct *tty, unsigned int set, ··· 650 649 651 650 652 651 static void digi_set_termios(struct tty_struct *tty, 653 - struct usb_serial_port *port, struct ktermios *old_termios) 652 + struct usb_serial_port *port, 653 + const struct ktermios *old_termios) 654 654 { 655 655 struct digi_port *priv = usb_get_serial_port_data(port); 656 656 struct device *dev = &port->dev;
+2 -1
drivers/usb/serial/f81232.c
··· 603 603 } 604 604 605 605 static void f81232_set_termios(struct tty_struct *tty, 606 - struct usb_serial_port *port, struct ktermios *old_termios) 606 + struct usb_serial_port *port, 607 + const struct ktermios *old_termios) 607 608 { 608 609 struct f81232_private *priv = usb_get_serial_port_data(port); 609 610 u8 new_lcr = 0;
+2 -2
drivers/usb/serial/f81534.c
··· 944 944 } 945 945 946 946 static void f81534_set_termios(struct tty_struct *tty, 947 - struct usb_serial_port *port, 948 - struct ktermios *old_termios) 947 + struct usb_serial_port *port, 948 + const struct ktermios *old_termios) 949 949 { 950 950 u8 new_lcr = 0; 951 951 int status;
+4 -2
drivers/usb/serial/ftdi_sio.c
··· 1089 1089 static int ftdi_prepare_write_buffer(struct usb_serial_port *port, 1090 1090 void *dest, size_t size); 1091 1091 static void ftdi_set_termios(struct tty_struct *tty, 1092 - struct usb_serial_port *port, struct ktermios *old); 1092 + struct usb_serial_port *port, 1093 + const struct ktermios *old_termios); 1093 1094 static int ftdi_tiocmget(struct tty_struct *tty); 1094 1095 static int ftdi_tiocmset(struct tty_struct *tty, 1095 1096 unsigned int set, unsigned int clear); ··· 2641 2640 * WARNING: set_termios calls this with old_termios in kernel space 2642 2641 */ 2643 2642 static void ftdi_set_termios(struct tty_struct *tty, 2644 - struct usb_serial_port *port, struct ktermios *old_termios) 2643 + struct usb_serial_port *port, 2644 + const struct ktermios *old_termios) 2645 2645 { 2646 2646 struct usb_device *dev = port->serial->dev; 2647 2647 struct device *ddev = &port->dev;
+4 -3
drivers/usb/serial/io_edgeport.c
··· 281 281 static int calc_baud_rate_divisor(struct device *dev, int baud_rate, int *divisor); 282 282 static void change_port_settings(struct tty_struct *tty, 283 283 struct edgeport_port *edge_port, 284 - struct ktermios *old_termios); 284 + const struct ktermios *old_termios); 285 285 static int send_cmd_write_uart_register(struct edgeport_port *edge_port, 286 286 __u8 regNum, __u8 regValue); 287 287 static int write_cmd_usb(struct edgeport_port *edge_port, ··· 1441 1441 * the termios structure 1442 1442 *****************************************************************************/ 1443 1443 static void edge_set_termios(struct tty_struct *tty, 1444 - struct usb_serial_port *port, struct ktermios *old_termios) 1444 + struct usb_serial_port *port, 1445 + const struct ktermios *old_termios) 1445 1446 { 1446 1447 struct edgeport_port *edge_port = usb_get_serial_port_data(port); 1447 1448 ··· 2326 2325 *****************************************************************************/ 2327 2326 2328 2327 static void change_port_settings(struct tty_struct *tty, 2329 - struct edgeport_port *edge_port, struct ktermios *old_termios) 2328 + struct edgeport_port *edge_port, const struct ktermios *old_termios) 2330 2329 { 2331 2330 struct device *dev = &edge_port->port->dev; 2332 2331 struct edgeport_serial *edge_serial =
+5 -3
drivers/usb/serial/io_ti.c
··· 221 221 static int restart_read(struct edgeport_port *edge_port); 222 222 223 223 static void edge_set_termios(struct tty_struct *tty, 224 - struct usb_serial_port *port, struct ktermios *old_termios); 224 + struct usb_serial_port *port, 225 + const struct ktermios *old_termios); 225 226 static void edge_send(struct usb_serial_port *port, struct tty_struct *tty); 226 227 227 228 static int do_download_mode(struct edgeport_serial *serial, ··· 2211 2210 } 2212 2211 2213 2212 static void change_port_settings(struct tty_struct *tty, 2214 - struct edgeport_port *edge_port, struct ktermios *old_termios) 2213 + struct edgeport_port *edge_port, const struct ktermios *old_termios) 2215 2214 { 2216 2215 struct device *dev = &edge_port->port->dev; 2217 2216 struct ump_uart_config *config; ··· 2352 2351 } 2353 2352 2354 2353 static void edge_set_termios(struct tty_struct *tty, 2355 - struct usb_serial_port *port, struct ktermios *old_termios) 2354 + struct usb_serial_port *port, 2355 + const struct ktermios *old_termios) 2356 2356 { 2357 2357 struct edgeport_port *edge_port = usb_get_serial_port_data(port); 2358 2358
+4 -2
drivers/usb/serial/ir-usb.c
··· 51 51 static void ir_write_bulk_callback(struct urb *urb); 52 52 static void ir_process_read_urb(struct urb *urb); 53 53 static void ir_set_termios(struct tty_struct *tty, 54 - struct usb_serial_port *port, struct ktermios *old_termios); 54 + struct usb_serial_port *port, 55 + const struct ktermios *old_termios); 55 56 56 57 /* Not that this lot means you can only have one per system */ 57 58 static u8 ir_baud; ··· 377 376 } 378 377 379 378 static void ir_set_termios(struct tty_struct *tty, 380 - struct usb_serial_port *port, struct ktermios *old_termios) 379 + struct usb_serial_port *port, 380 + const struct ktermios *old_termios) 381 381 { 382 382 struct usb_device *udev = port->serial->dev; 383 383 unsigned char *transfer_buffer;
+2 -1
drivers/usb/serial/iuu_phoenix.c
··· 879 879 } 880 880 881 881 static void iuu_set_termios(struct tty_struct *tty, 882 - struct usb_serial_port *port, struct ktermios *old_termios) 882 + struct usb_serial_port *port, 883 + const struct ktermios *old_termios) 883 884 { 884 885 const u32 supported_mask = CMSPAR|PARENB|PARODD; 885 886 struct iuu_private *priv = usb_get_serial_port_data(port);
+2 -1
drivers/usb/serial/keyspan.c
··· 616 616 617 617 618 618 static void keyspan_set_termios(struct tty_struct *tty, 619 - struct usb_serial_port *port, struct ktermios *old_termios) 619 + struct usb_serial_port *port, 620 + const struct ktermios *old_termios) 620 621 { 621 622 int baud_rate, device_port; 622 623 struct keyspan_port_private *p_priv;
+2 -1
drivers/usb/serial/keyspan_pda.c
··· 321 321 } 322 322 323 323 static void keyspan_pda_set_termios(struct tty_struct *tty, 324 - struct usb_serial_port *port, struct ktermios *old_termios) 324 + struct usb_serial_port *port, 325 + const struct ktermios *old_termios) 325 326 { 326 327 struct usb_serial *serial = port->serial; 327 328 speed_t speed;
+3 -2
drivers/usb/serial/kl5kusb105.c
··· 56 56 static int klsi_105_open(struct tty_struct *tty, struct usb_serial_port *port); 57 57 static void klsi_105_close(struct usb_serial_port *port); 58 58 static void klsi_105_set_termios(struct tty_struct *tty, 59 - struct usb_serial_port *port, struct ktermios *old); 59 + struct usb_serial_port *port, 60 + const struct ktermios *old_termios); 60 61 static int klsi_105_tiocmget(struct tty_struct *tty); 61 62 static void klsi_105_process_read_urb(struct urb *urb); 62 63 static int klsi_105_prepare_write_buffer(struct usb_serial_port *port, ··· 367 366 368 367 static void klsi_105_set_termios(struct tty_struct *tty, 369 368 struct usb_serial_port *port, 370 - struct ktermios *old_termios) 369 + const struct ktermios *old_termios) 371 370 { 372 371 struct klsi_105_private *priv = usb_get_serial_port_data(port); 373 372 struct device *dev = &port->dev;
+4 -2
drivers/usb/serial/kobil_sct.c
··· 62 62 static void kobil_read_int_callback(struct urb *urb); 63 63 static void kobil_write_int_callback(struct urb *urb); 64 64 static void kobil_set_termios(struct tty_struct *tty, 65 - struct usb_serial_port *port, struct ktermios *old); 65 + struct usb_serial_port *port, 66 + const struct ktermios *old); 66 67 static void kobil_init_termios(struct tty_struct *tty); 67 68 68 69 static const struct usb_device_id id_table[] = { ··· 475 474 } 476 475 477 476 static void kobil_set_termios(struct tty_struct *tty, 478 - struct usb_serial_port *port, struct ktermios *old) 477 + struct usb_serial_port *port, 478 + const struct ktermios *old) 479 479 { 480 480 struct kobil_private *priv; 481 481 int result;
+3 -2
drivers/usb/serial/mct_u232.c
··· 45 45 static void mct_u232_dtr_rts(struct usb_serial_port *port, int on); 46 46 static void mct_u232_read_int_callback(struct urb *urb); 47 47 static void mct_u232_set_termios(struct tty_struct *tty, 48 - struct usb_serial_port *port, struct ktermios *old); 48 + struct usb_serial_port *port, 49 + const struct ktermios *old_termios); 49 50 static void mct_u232_break_ctl(struct tty_struct *tty, int break_state); 50 51 static int mct_u232_tiocmget(struct tty_struct *tty); 51 52 static int mct_u232_tiocmset(struct tty_struct *tty, ··· 594 593 595 594 static void mct_u232_set_termios(struct tty_struct *tty, 596 595 struct usb_serial_port *port, 597 - struct ktermios *old_termios) 596 + const struct ktermios *old_termios) 598 597 { 599 598 struct usb_serial *serial = port->serial; 600 599 struct mct_u232_private *priv = usb_get_serial_port_data(port);
+3 -2
drivers/usb/serial/mos7720.c
··· 1356 1356 */ 1357 1357 static void change_port_settings(struct tty_struct *tty, 1358 1358 struct moschip_port *mos7720_port, 1359 - struct ktermios *old_termios) 1359 + const struct ktermios *old_termios) 1360 1360 { 1361 1361 struct usb_serial_port *port; 1362 1362 struct usb_serial *serial; ··· 1494 1494 * termios structure. 1495 1495 */ 1496 1496 static void mos7720_set_termios(struct tty_struct *tty, 1497 - struct usb_serial_port *port, struct ktermios *old_termios) 1497 + struct usb_serial_port *port, 1498 + const struct ktermios *old_termios) 1498 1499 { 1499 1500 int status; 1500 1501 struct moschip_port *mos7720_port;
+3 -2
drivers/usb/serial/mos7840.c
··· 1188 1188 *****************************************************************************/ 1189 1189 1190 1190 static void mos7840_change_port_settings(struct tty_struct *tty, 1191 - struct moschip_port *mos7840_port, struct ktermios *old_termios) 1191 + struct moschip_port *mos7840_port, 1192 + const struct ktermios *old_termios) 1192 1193 { 1193 1194 struct usb_serial_port *port = mos7840_port->port; 1194 1195 int baud; ··· 1331 1330 1332 1331 static void mos7840_set_termios(struct tty_struct *tty, 1333 1332 struct usb_serial_port *port, 1334 - struct ktermios *old_termios) 1333 + const struct ktermios *old_termios) 1335 1334 { 1336 1335 struct moschip_port *mos7840_port = usb_get_serial_port_data(port); 1337 1336 int status;
+2 -2
drivers/usb/serial/mxuport.c
··· 760 760 } 761 761 762 762 static int mxuport_set_termios_flow(struct tty_struct *tty, 763 - struct ktermios *old_termios, 763 + const struct ktermios *old_termios, 764 764 struct usb_serial_port *port, 765 765 struct usb_serial *serial) 766 766 { ··· 834 834 835 835 static void mxuport_set_termios(struct tty_struct *tty, 836 836 struct usb_serial_port *port, 837 - struct ktermios *old_termios) 837 + const struct ktermios *old_termios) 838 838 { 839 839 struct usb_serial *serial = port->serial; 840 840 u8 *buf;
+4 -2
drivers/usb/serial/oti6858.c
··· 119 119 static int oti6858_open(struct tty_struct *tty, struct usb_serial_port *port); 120 120 static void oti6858_close(struct usb_serial_port *port); 121 121 static void oti6858_set_termios(struct tty_struct *tty, 122 - struct usb_serial_port *port, struct ktermios *old); 122 + struct usb_serial_port *port, 123 + const struct ktermios *old_termios); 123 124 static void oti6858_init_termios(struct tty_struct *tty); 124 125 static void oti6858_read_int_callback(struct urb *urb); 125 126 static void oti6858_read_bulk_callback(struct urb *urb); ··· 396 395 } 397 396 398 397 static void oti6858_set_termios(struct tty_struct *tty, 399 - struct usb_serial_port *port, struct ktermios *old_termios) 398 + struct usb_serial_port *port, 399 + const struct ktermios *old_termios) 400 400 { 401 401 struct oti6858_private *priv = usb_get_serial_port_data(port); 402 402 unsigned long flags;
+2 -1
drivers/usb/serial/pl2303.c
··· 789 789 } 790 790 791 791 static void pl2303_set_termios(struct tty_struct *tty, 792 - struct usb_serial_port *port, struct ktermios *old_termios) 792 + struct usb_serial_port *port, 793 + const struct ktermios *old_termios) 793 794 { 794 795 struct usb_serial *serial = port->serial; 795 796 struct pl2303_serial_private *spriv = usb_get_serial_data(serial);
+2 -2
drivers/usb/serial/quatech2.c
··· 261 261 } 262 262 263 263 static void qt2_set_termios(struct tty_struct *tty, 264 - struct usb_serial_port *port, 265 - struct ktermios *old_termios) 264 + struct usb_serial_port *port, 265 + const struct ktermios *old_termios) 266 266 { 267 267 struct usb_device *dev = port->serial->dev; 268 268 struct qt2_port_private *port_priv;
+2 -1
drivers/usb/serial/spcp8x5.c
··· 283 283 } 284 284 285 285 static void spcp8x5_set_termios(struct tty_struct *tty, 286 - struct usb_serial_port *port, struct ktermios *old_termios) 286 + struct usb_serial_port *port, 287 + const struct ktermios *old_termios) 287 288 { 288 289 struct usb_serial *serial = port->serial; 289 290 struct spcp8x5_private *priv = usb_get_serial_port_data(port);
+2 -2
drivers/usb/serial/ssu100.c
··· 214 214 215 215 216 216 static void ssu100_set_termios(struct tty_struct *tty, 217 - struct usb_serial_port *port, 218 - struct ktermios *old_termios) 217 + struct usb_serial_port *port, 218 + const struct ktermios *old_termios) 219 219 { 220 220 struct usb_device *dev = port->serial->dev; 221 221 struct ktermios *termios = &tty->termios;
+4 -2
drivers/usb/serial/ti_usb_3410_5052.c
··· 314 314 static void ti_throttle(struct tty_struct *tty); 315 315 static void ti_unthrottle(struct tty_struct *tty); 316 316 static void ti_set_termios(struct tty_struct *tty, 317 - struct usb_serial_port *port, struct ktermios *old_termios); 317 + struct usb_serial_port *port, 318 + const struct ktermios *old_termios); 318 319 static int ti_tiocmget(struct tty_struct *tty); 319 320 static int ti_tiocmset(struct tty_struct *tty, 320 321 unsigned int set, unsigned int clear); ··· 893 892 } 894 893 895 894 static void ti_set_termios(struct tty_struct *tty, 896 - struct usb_serial_port *port, struct ktermios *old_termios) 895 + struct usb_serial_port *port, 896 + const struct ktermios *old_termios) 897 897 { 898 898 struct ti_port *tport = usb_get_serial_port_data(port); 899 899 struct ti_uart_config *config;
+2 -2
drivers/usb/serial/upd78f0730.c
··· 296 296 } 297 297 298 298 static void upd78f0730_set_termios(struct tty_struct *tty, 299 - struct usb_serial_port *port, 300 - struct ktermios *old_termios) 299 + struct usb_serial_port *port, 300 + const struct ktermios *old_termios) 301 301 { 302 302 struct device *dev = &port->dev; 303 303 struct upd78f0730_line_control request;
+2 -1
drivers/usb/serial/usb-serial.c
··· 519 519 return retval; 520 520 } 521 521 522 - static void serial_set_termios(struct tty_struct *tty, struct ktermios *old) 522 + static void serial_set_termios(struct tty_struct *tty, 523 + const struct ktermios *old) 523 524 { 524 525 struct usb_serial_port *port = tty->driver_data; 525 526
+4 -2
drivers/usb/serial/whiteheat.c
··· 82 82 static void whiteheat_get_serial(struct tty_struct *tty, 83 83 struct serial_struct *ss); 84 84 static void whiteheat_set_termios(struct tty_struct *tty, 85 - struct usb_serial_port *port, struct ktermios *old); 85 + struct usb_serial_port *port, 86 + const struct ktermios *old_termios); 86 87 static int whiteheat_tiocmget(struct tty_struct *tty); 87 88 static int whiteheat_tiocmset(struct tty_struct *tty, 88 89 unsigned int set, unsigned int clear); ··· 443 442 444 443 445 444 static void whiteheat_set_termios(struct tty_struct *tty, 446 - struct usb_serial_port *port, struct ktermios *old_termios) 445 + struct usb_serial_port *port, 446 + const struct ktermios *old_termios) 447 447 { 448 448 firm_setup_port(tty); 449 449 }
+12 -8
drivers/usb/serial/xr_serial.c
··· 104 104 static int xr21v141x_uart_disable(struct usb_serial_port *port); 105 105 static int xr21v141x_fifo_reset(struct usb_serial_port *port); 106 106 static void xr21v141x_set_line_settings(struct tty_struct *tty, 107 - struct usb_serial_port *port, struct ktermios *old_termios); 107 + struct usb_serial_port *port, 108 + const struct ktermios *old_termios); 108 109 109 110 struct xr_type { 110 111 int reg_width; ··· 134 133 int (*disable)(struct usb_serial_port *port); 135 134 int (*fifo_reset)(struct usb_serial_port *port); 136 135 void (*set_line_settings)(struct tty_struct *tty, 137 - struct usb_serial_port *port, 138 - struct ktermios *old_termios); 136 + struct usb_serial_port *port, 137 + const struct ktermios *old_termios); 139 138 }; 140 139 141 140 enum xr_type_id { ··· 623 622 } 624 623 625 624 static void xr_set_flow_mode(struct tty_struct *tty, 626 - struct usb_serial_port *port, 627 - struct ktermios *old_termios) 625 + struct usb_serial_port *port, 626 + const struct ktermios *old_termios) 628 627 { 629 628 struct xr_data *data = usb_get_serial_port_data(port); 630 629 const struct xr_type *type = data->type; ··· 675 674 } 676 675 677 676 static void xr21v141x_set_line_settings(struct tty_struct *tty, 678 - struct usb_serial_port *port, struct ktermios *old_termios) 677 + struct usb_serial_port *port, 678 + const struct ktermios *old_termios) 679 679 { 680 680 struct ktermios *termios = &tty->termios; 681 681 u8 bits = 0; ··· 734 732 } 735 733 736 734 static void xr_cdc_set_line_coding(struct tty_struct *tty, 737 - struct usb_serial_port *port, struct ktermios *old_termios) 735 + struct usb_serial_port *port, 736 + const struct ktermios *old_termios) 738 737 { 739 738 struct xr_data *data = usb_get_serial_port_data(port); 740 739 struct usb_host_interface *alt = port->serial->interface->cur_altsetting; ··· 812 809 } 813 810 814 811 static void xr_set_termios(struct tty_struct *tty, 815 - struct usb_serial_port *port, struct ktermios *old_termios) 812 + struct usb_serial_port *port, 813 + const struct ktermios *old_termios) 816 814 { 817 815 struct xr_data *data = usb_get_serial_port_data(port); 818 816
-78
include/asm-generic/termios-base.h
··· 1 - /* SPDX-License-Identifier: GPL-2.0 */ 2 - /* termios.h: generic termios/termio user copying/translation 3 - */ 4 - 5 - #ifndef _ASM_GENERIC_TERMIOS_BASE_H 6 - #define _ASM_GENERIC_TERMIOS_BASE_H 7 - 8 - #include <linux/uaccess.h> 9 - 10 - #ifndef __ARCH_TERMIO_GETPUT 11 - 12 - /* 13 - * Translate a "termio" structure into a "termios". Ugh. 14 - */ 15 - static inline int user_termio_to_kernel_termios(struct ktermios *termios, 16 - struct termio __user *termio) 17 - { 18 - unsigned short tmp; 19 - 20 - if (get_user(tmp, &termio->c_iflag) < 0) 21 - goto fault; 22 - termios->c_iflag = (0xffff0000 & termios->c_iflag) | tmp; 23 - 24 - if (get_user(tmp, &termio->c_oflag) < 0) 25 - goto fault; 26 - termios->c_oflag = (0xffff0000 & termios->c_oflag) | tmp; 27 - 28 - if (get_user(tmp, &termio->c_cflag) < 0) 29 - goto fault; 30 - termios->c_cflag = (0xffff0000 & termios->c_cflag) | tmp; 31 - 32 - if (get_user(tmp, &termio->c_lflag) < 0) 33 - goto fault; 34 - termios->c_lflag = (0xffff0000 & termios->c_lflag) | tmp; 35 - 36 - if (get_user(termios->c_line, &termio->c_line) < 0) 37 - goto fault; 38 - 39 - if (copy_from_user(termios->c_cc, termio->c_cc, NCC) != 0) 40 - goto fault; 41 - 42 - return 0; 43 - 44 - fault: 45 - return -EFAULT; 46 - } 47 - 48 - /* 49 - * Translate a "termios" structure into a "termio". Ugh. 50 - */ 51 - static inline int kernel_termios_to_user_termio(struct termio __user *termio, 52 - struct ktermios *termios) 53 - { 54 - if (put_user(termios->c_iflag, &termio->c_iflag) < 0 || 55 - put_user(termios->c_oflag, &termio->c_oflag) < 0 || 56 - put_user(termios->c_cflag, &termio->c_cflag) < 0 || 57 - put_user(termios->c_lflag, &termio->c_lflag) < 0 || 58 - put_user(termios->c_line, &termio->c_line) < 0 || 59 - copy_to_user(termio->c_cc, termios->c_cc, NCC) != 0) 60 - return -EFAULT; 61 - 62 - return 0; 63 - } 64 - 65 - #ifndef user_termios_to_kernel_termios 66 - #define user_termios_to_kernel_termios(k, u) copy_from_user(k, u, sizeof(struct termios)) 67 - #endif 68 - 69 - #ifndef kernel_termios_to_user_termios 70 - #define kernel_termios_to_user_termios(u, k) copy_to_user(u, k, sizeof(struct termios)) 71 - #endif 72 - 73 - #define user_termios_to_kernel_termios_1(k, u) copy_from_user(k, u, sizeof(struct termios)) 74 - #define kernel_termios_to_user_termios_1(u, k) copy_to_user(u, k, sizeof(struct termios)) 75 - 76 - #endif /* __ARCH_TERMIO_GETPUT */ 77 - 78 - #endif /* _ASM_GENERIC_TERMIOS_BASE_H */
-108
include/asm-generic/termios.h
··· 1 - /* SPDX-License-Identifier: GPL-2.0 */ 2 - #ifndef _ASM_GENERIC_TERMIOS_H 3 - #define _ASM_GENERIC_TERMIOS_H 4 - 5 - 6 - #include <linux/uaccess.h> 7 - #include <uapi/asm-generic/termios.h> 8 - 9 - /* intr=^C quit=^\ erase=del kill=^U 10 - eof=^D vtime=\0 vmin=\1 sxtc=\0 11 - start=^Q stop=^S susp=^Z eol=\0 12 - reprint=^R discard=^U werase=^W lnext=^V 13 - eol2=\0 14 - */ 15 - #define INIT_C_CC "\003\034\177\025\004\0\1\0\021\023\032\0\022\017\027\026\0" 16 - 17 - /* 18 - * Translate a "termio" structure into a "termios". Ugh. 19 - */ 20 - static inline int user_termio_to_kernel_termios(struct ktermios *termios, 21 - const struct termio __user *termio) 22 - { 23 - unsigned short tmp; 24 - 25 - if (get_user(tmp, &termio->c_iflag) < 0) 26 - goto fault; 27 - termios->c_iflag = (0xffff0000 & termios->c_iflag) | tmp; 28 - 29 - if (get_user(tmp, &termio->c_oflag) < 0) 30 - goto fault; 31 - termios->c_oflag = (0xffff0000 & termios->c_oflag) | tmp; 32 - 33 - if (get_user(tmp, &termio->c_cflag) < 0) 34 - goto fault; 35 - termios->c_cflag = (0xffff0000 & termios->c_cflag) | tmp; 36 - 37 - if (get_user(tmp, &termio->c_lflag) < 0) 38 - goto fault; 39 - termios->c_lflag = (0xffff0000 & termios->c_lflag) | tmp; 40 - 41 - if (get_user(termios->c_line, &termio->c_line) < 0) 42 - goto fault; 43 - 44 - if (copy_from_user(termios->c_cc, termio->c_cc, NCC) != 0) 45 - goto fault; 46 - 47 - return 0; 48 - 49 - fault: 50 - return -EFAULT; 51 - } 52 - 53 - /* 54 - * Translate a "termios" structure into a "termio". Ugh. 55 - */ 56 - static inline int kernel_termios_to_user_termio(struct termio __user *termio, 57 - struct ktermios *termios) 58 - { 59 - if (put_user(termios->c_iflag, &termio->c_iflag) < 0 || 60 - put_user(termios->c_oflag, &termio->c_oflag) < 0 || 61 - put_user(termios->c_cflag, &termio->c_cflag) < 0 || 62 - put_user(termios->c_lflag, &termio->c_lflag) < 0 || 63 - put_user(termios->c_line, &termio->c_line) < 0 || 64 - copy_to_user(termio->c_cc, termios->c_cc, NCC) != 0) 65 - return -EFAULT; 66 - 67 - return 0; 68 - } 69 - 70 - #ifdef TCGETS2 71 - static inline int user_termios_to_kernel_termios(struct ktermios *k, 72 - struct termios2 __user *u) 73 - { 74 - return copy_from_user(k, u, sizeof(struct termios2)); 75 - } 76 - 77 - static inline int kernel_termios_to_user_termios(struct termios2 __user *u, 78 - struct ktermios *k) 79 - { 80 - return copy_to_user(u, k, sizeof(struct termios2)); 81 - } 82 - 83 - static inline int user_termios_to_kernel_termios_1(struct ktermios *k, 84 - struct termios __user *u) 85 - { 86 - return copy_from_user(k, u, sizeof(struct termios)); 87 - } 88 - 89 - static inline int kernel_termios_to_user_termios_1(struct termios __user *u, 90 - struct ktermios *k) 91 - { 92 - return copy_to_user(u, k, sizeof(struct termios)); 93 - } 94 - #else /* TCGETS2 */ 95 - static inline int user_termios_to_kernel_termios(struct ktermios *k, 96 - struct termios __user *u) 97 - { 98 - return copy_from_user(k, u, sizeof(struct termios)); 99 - } 100 - 101 - static inline int kernel_termios_to_user_termios(struct termios __user *u, 102 - struct ktermios *k) 103 - { 104 - return copy_to_user(u, k, sizeof(struct termios)); 105 - } 106 - #endif /* TCGETS2 */ 107 - 108 - #endif /* _ASM_GENERIC_TERMIOS_H */
+1
include/linux/serdev.h
··· 7 7 8 8 #include <linux/types.h> 9 9 #include <linux/device.h> 10 + #include <linux/uaccess.h> 10 11 #include <linux/termios.h> 11 12 #include <linux/delay.h> 12 13
+3 -2
include/linux/serial_8250.h
··· 32 32 void (*serial_out)(struct uart_port *, int, int); 33 33 void (*set_termios)(struct uart_port *, 34 34 struct ktermios *new, 35 - struct ktermios *old); 35 + const struct ktermios *old); 36 36 void (*set_ldisc)(struct uart_port *, 37 37 struct ktermios *); 38 38 unsigned int (*get_mctrl)(struct uart_port *); ··· 74 74 struct uart_8250_ops { 75 75 int (*setup_irq)(struct uart_8250_port *); 76 76 void (*release_irq)(struct uart_8250_port *); 77 + void (*setup_timer)(struct uart_8250_port *); 77 78 }; 78 79 79 80 struct uart_8250_em485 { ··· 158 157 extern void serial8250_update_uartclk(struct uart_port *port, 159 158 unsigned int uartclk); 160 159 extern void serial8250_do_set_termios(struct uart_port *port, 161 - struct ktermios *termios, struct ktermios *old); 160 + struct ktermios *termios, const struct ktermios *old); 162 161 extern void serial8250_do_set_ldisc(struct uart_port *port, 163 162 struct ktermios *termios); 164 163 extern unsigned int serial8250_do_get_mctrl(struct uart_port *port);
+18 -18
include/linux/serial_core.h
··· 387 387 void (*shutdown)(struct uart_port *); 388 388 void (*flush_buffer)(struct uart_port *); 389 389 void (*set_termios)(struct uart_port *, struct ktermios *new, 390 - struct ktermios *old); 390 + const struct ktermios *old); 391 391 void (*set_ldisc)(struct uart_port *, struct ktermios *); 392 392 void (*pm)(struct uart_port *, unsigned int state, 393 393 unsigned int oldstate); ··· 422 422 __u32 buf_overrun; 423 423 }; 424 424 425 - typedef unsigned int __bitwise upf_t; 425 + typedef u64 __bitwise upf_t; 426 426 typedef unsigned int __bitwise upstat_t; 427 427 428 428 struct uart_port { ··· 433 433 void (*serial_out)(struct uart_port *, int, int); 434 434 void (*set_termios)(struct uart_port *, 435 435 struct ktermios *new, 436 - struct ktermios *old); 436 + const struct ktermios *old); 437 437 void (*set_ldisc)(struct uart_port *, 438 438 struct ktermios *); 439 439 unsigned int (*get_mctrl)(struct uart_port *); ··· 513 513 #define UPF_BUGGY_UART ((__force upf_t) ASYNC_BUGGY_UART /* 14 */ ) 514 514 #define UPF_MAGIC_MULTIPLIER ((__force upf_t) ASYNC_MAGIC_MULTIPLIER /* 16 */ ) 515 515 516 - #define UPF_NO_THRE_TEST ((__force upf_t) (1 << 19)) 516 + #define UPF_NO_THRE_TEST ((__force upf_t) BIT_ULL(19)) 517 517 /* Port has hardware-assisted h/w flow control */ 518 - #define UPF_AUTO_CTS ((__force upf_t) (1 << 20)) 519 - #define UPF_AUTO_RTS ((__force upf_t) (1 << 21)) 518 + #define UPF_AUTO_CTS ((__force upf_t) BIT_ULL(20)) 519 + #define UPF_AUTO_RTS ((__force upf_t) BIT_ULL(21)) 520 520 #define UPF_HARD_FLOW ((__force upf_t) (UPF_AUTO_CTS | UPF_AUTO_RTS)) 521 521 /* Port has hardware-assisted s/w flow control */ 522 - #define UPF_SOFT_FLOW ((__force upf_t) (1 << 22)) 523 - #define UPF_CONS_FLOW ((__force upf_t) (1 << 23)) 524 - #define UPF_SHARE_IRQ ((__force upf_t) (1 << 24)) 525 - #define UPF_EXAR_EFR ((__force upf_t) (1 << 25)) 526 - #define UPF_BUG_THRE ((__force upf_t) (1 << 26)) 522 + #define UPF_SOFT_FLOW ((__force upf_t) BIT_ULL(22)) 523 + #define UPF_CONS_FLOW ((__force upf_t) BIT_ULL(23)) 524 + #define UPF_SHARE_IRQ ((__force upf_t) BIT_ULL(24)) 525 + #define UPF_EXAR_EFR ((__force upf_t) BIT_ULL(25)) 526 + #define UPF_BUG_THRE ((__force upf_t) BIT_ULL(26)) 527 527 /* The exact UART type is known and should not be probed. */ 528 - #define UPF_FIXED_TYPE ((__force upf_t) (1 << 27)) 529 - #define UPF_BOOT_AUTOCONF ((__force upf_t) (1 << 28)) 530 - #define UPF_FIXED_PORT ((__force upf_t) (1 << 29)) 531 - #define UPF_DEAD ((__force upf_t) (1 << 30)) 532 - #define UPF_IOREMAP ((__force upf_t) (1 << 31)) 528 + #define UPF_FIXED_TYPE ((__force upf_t) BIT_ULL(27)) 529 + #define UPF_BOOT_AUTOCONF ((__force upf_t) BIT_ULL(28)) 530 + #define UPF_FIXED_PORT ((__force upf_t) BIT_ULL(29)) 531 + #define UPF_DEAD ((__force upf_t) BIT_ULL(30)) 532 + #define UPF_IOREMAP ((__force upf_t) BIT_ULL(31)) 533 + #define UPF_FULL_PROBE ((__force upf_t) BIT_ULL(32)) 533 534 534 535 #define __UPF_CHANGE_MASK 0x17fff 535 536 #define UPF_CHANGE_MASK ((__force upf_t) __UPF_CHANGE_MASK) ··· 670 669 void uart_update_timeout(struct uart_port *port, unsigned int cflag, 671 670 unsigned int baud); 672 671 unsigned int uart_get_baud_rate(struct uart_port *port, struct ktermios *termios, 673 - struct ktermios *old, unsigned int min, 672 + const struct ktermios *old, unsigned int min, 674 673 unsigned int max); 675 674 unsigned int uart_get_divisor(struct uart_port *port, unsigned int baud); 676 675 ··· 951 950 !((cflag) & CLOCAL)) 952 951 953 952 int uart_get_rs485_mode(struct uart_port *port); 954 - int uart_rs485_config(struct uart_port *port); 955 953 #endif /* LINUX_SERIAL_CORE_H */
+49
include/linux/termios_internal.h
··· 1 + /* SPDX-License-Identifier: GPL-2.0 */ 2 + #ifndef _LINUX_TERMIOS_CONV_H 3 + #define _LINUX_TERMIOS_CONV_H 4 + 5 + #include <linux/uaccess.h> 6 + #include <asm/termios.h> 7 + 8 + /* intr=^C quit=^\ erase=del kill=^U 9 + eof=^D vtime=\0 vmin=\1 sxtc=\0 10 + start=^Q stop=^S susp=^Z eol=\0 11 + reprint=^R discard=^O werase=^W lnext=^V 12 + eol2=\0 13 + */ 14 + 15 + #ifdef VDSUSP 16 + #define INIT_C_CC_VDSUSP_EXTRA [VDSUSP] = 'Y'-0x40, 17 + #else 18 + #define INIT_C_CC_VDSUSP_EXTRA 19 + #endif 20 + 21 + #define INIT_C_CC { \ 22 + [VINTR] = 'C'-0x40, \ 23 + [VQUIT] = '\\'-0x40, \ 24 + [VERASE] = '\177', \ 25 + [VKILL] = 'U'-0x40, \ 26 + [VEOF] = 'D'-0x40, \ 27 + [VSTART] = 'Q'-0x40, \ 28 + [VSTOP] = 'S'-0x40, \ 29 + [VSUSP] = 'Z'-0x40, \ 30 + [VREPRINT] = 'R'-0x40, \ 31 + [VDISCARD] = 'O'-0x40, \ 32 + [VWERASE] = 'W'-0x40, \ 33 + [VLNEXT] = 'V'-0x40, \ 34 + INIT_C_CC_VDSUSP_EXTRA \ 35 + [VMIN] = 1 } 36 + 37 + int user_termio_to_kernel_termios(struct ktermios *, struct termio __user *); 38 + int kernel_termios_to_user_termio(struct termio __user *, struct ktermios *); 39 + #ifdef TCGETS2 40 + int user_termios_to_kernel_termios(struct ktermios *, struct termios2 __user *); 41 + int kernel_termios_to_user_termios(struct termios2 __user *, struct ktermios *); 42 + int user_termios_to_kernel_termios_1(struct ktermios *, struct termios __user *); 43 + int kernel_termios_to_user_termios_1(struct termios __user *, struct ktermios *); 44 + #else /* TCGETS2 */ 45 + int user_termios_to_kernel_termios(struct ktermios *, struct termios __user *); 46 + int kernel_termios_to_user_termios(struct termios __user *, struct ktermios *); 47 + #endif /* TCGETS2 */ 48 + 49 + #endif /* _LINUX_TERMIOS_CONV_H */
+2 -8
include/linux/tty.h
··· 122 122 /** 123 123 * struct tty_struct - state associated with a tty while open 124 124 * 125 - * @magic: magic value set early in @alloc_tty_struct to %TTY_MAGIC, for 126 - * debugging purposes 127 125 * @kref: reference counting by tty_kref_get() and tty_kref_put(), reaching zero 128 126 * frees the structure 129 127 * @dev: class device or %NULL (e.g. ptys, serdev) ··· 191 193 * &struct tty_port. 192 194 */ 193 195 struct tty_struct { 194 - int magic; 195 196 struct kref kref; 196 197 struct device *dev; 197 198 struct tty_driver *driver; ··· 256 259 struct file *file; 257 260 struct list_head list; 258 261 }; 259 - 260 - /* tty magic number */ 261 - #define TTY_MAGIC 0x5401 262 262 263 263 /** 264 264 * DOC: TTY Struct Flags ··· 428 434 void do_SAK(struct tty_struct *tty); 429 435 void __do_SAK(struct tty_struct *tty); 430 436 void no_tty(void); 431 - speed_t tty_termios_baud_rate(struct ktermios *termios); 437 + speed_t tty_termios_baud_rate(const struct ktermios *termios); 432 438 void tty_termios_encode_baud_rate(struct ktermios *termios, speed_t ibaud, 433 439 speed_t obaud); 434 440 void tty_encode_baud_rate(struct tty_struct *tty, speed_t ibaud, ··· 452 458 unsigned char tty_get_char_size(unsigned int cflag); 453 459 unsigned char tty_get_frame_size(unsigned int cflag); 454 460 455 - void tty_termios_copy_hw(struct ktermios *new, struct ktermios *old); 461 + void tty_termios_copy_hw(struct ktermios *new, const struct ktermios *old); 456 462 int tty_termios_hw_change(const struct ktermios *a, const struct ktermios *b); 457 463 int tty_set_termios(struct tty_struct *tty, struct ktermios *kt); 458 464
+3 -7
include/linux/tty_driver.h
··· 7 7 #include <linux/kref.h> 8 8 #include <linux/list.h> 9 9 #include <linux/cdev.h> 10 + #include <linux/uaccess.h> 10 11 #include <linux/termios.h> 11 12 #include <linux/seq_file.h> 12 13 ··· 142 141 * 143 142 * Optional. 144 143 * 145 - * @set_termios: ``void ()(struct tty_struct *tty, struct ktermios *old)`` 144 + * @set_termios: ``void ()(struct tty_struct *tty, const struct ktermios *old)`` 146 145 * 147 146 * This routine allows the @tty driver to be notified when device's 148 147 * termios settings have changed. New settings are in @tty->termios. ··· 366 365 unsigned int cmd, unsigned long arg); 367 366 long (*compat_ioctl)(struct tty_struct *tty, 368 367 unsigned int cmd, unsigned long arg); 369 - void (*set_termios)(struct tty_struct *tty, struct ktermios * old); 368 + void (*set_termios)(struct tty_struct *tty, const struct ktermios *old); 370 369 void (*throttle)(struct tty_struct * tty); 371 370 void (*unthrottle)(struct tty_struct * tty); 372 371 void (*stop)(struct tty_struct *tty); ··· 397 396 /** 398 397 * struct tty_driver -- driver for TTY devices 399 398 * 400 - * @magic: set to %TTY_DRIVER_MAGIC in __tty_alloc_driver() 401 399 * @kref: reference counting. Reaching zero frees all the internals and the 402 400 * driver. 403 401 * @cdevs: allocated/registered character /dev devices ··· 432 432 * @driver_name, @name, @type, @subtype, @init_termios, and @ops. 433 433 */ 434 434 struct tty_driver { 435 - int magic; 436 435 struct kref kref; 437 436 struct cdev **cdevs; 438 437 struct module *owner; ··· 487 488 { 488 489 driver->ops = op; 489 490 } 490 - 491 - /* tty driver magic number */ 492 - #define TTY_DRIVER_MAGIC 0x5402 493 491 494 492 /** 495 493 * DOC: TTY Driver Flags
+2 -2
include/linux/tty_ldisc.h
··· 130 130 * a pointer to wordsize-sensitive structure belongs here, but most of 131 131 * ldiscs will happily leave it %NULL. 132 132 * 133 - * @set_termios: [TTY] ``void ()(struct tty_struct *tty, struct ktermios *old)`` 133 + * @set_termios: [TTY] ``void ()(struct tty_struct *tty, const struct ktermios *old)`` 134 134 * 135 135 * This function notifies the line discpline that a change has been made 136 136 * to the termios structure. ··· 227 227 unsigned long arg); 228 228 int (*compat_ioctl)(struct tty_struct *tty, unsigned int cmd, 229 229 unsigned long arg); 230 - void (*set_termios)(struct tty_struct *tty, struct ktermios *old); 230 + void (*set_termios)(struct tty_struct *tty, const struct ktermios *old); 231 231 __poll_t (*poll)(struct tty_struct *tty, struct file *file, 232 232 struct poll_table_struct *wait); 233 233 void (*hangup)(struct tty_struct *tty);
+2 -2
include/linux/usb/serial.h
··· 276 276 unsigned int cmd, unsigned long arg); 277 277 void (*get_serial)(struct tty_struct *tty, struct serial_struct *ss); 278 278 int (*set_serial)(struct tty_struct *tty, struct serial_struct *ss); 279 - void (*set_termios)(struct tty_struct *tty, 280 - struct usb_serial_port *port, struct ktermios *old); 279 + void (*set_termios)(struct tty_struct *tty, struct usb_serial_port *port, 280 + const struct ktermios *old); 281 281 void (*break_ctl)(struct tty_struct *tty, int break_state); 282 282 unsigned int (*chars_in_buffer)(struct tty_struct *tty); 283 283 void (*wait_until_sent)(struct tty_struct *tty, long timeout);
-1
include/linux/vt_kern.h
··· 30 30 void reset_palette(struct vc_data *vc); 31 31 void do_blank_screen(int entering_gfx); 32 32 void do_unblank_screen(int leaving_gfx); 33 - void unblank_screen(void); 34 33 void poke_blanked_console(void); 35 34 int con_font_op(struct vc_data *vc, struct console_font_op *op); 36 35 int con_set_cmap(unsigned char __user *cmap);
-3
kernel/panic.c
··· 329 329 if (_crash_kexec_post_notifiers) 330 330 __crash_kexec(NULL); 331 331 332 - #ifdef CONFIG_VT 333 - unblank_screen(); 334 - #endif 335 332 console_unblank(); 336 333 337 334 /*
-3
lib/bust_spinlocks.c
··· 22 22 if (yes) { 23 23 ++oops_in_progress; 24 24 } else { 25 - #ifdef CONFIG_VT 26 - unblank_screen(); 27 - #endif 28 25 console_unblank(); 29 26 if (--oops_in_progress == 0) 30 27 wake_up_klogd();
+2 -1
net/bluetooth/rfcomm/tty.c
··· 855 855 return -ENOIOCTLCMD; 856 856 } 857 857 858 - static void rfcomm_tty_set_termios(struct tty_struct *tty, struct ktermios *old) 858 + static void rfcomm_tty_set_termios(struct tty_struct *tty, 859 + const struct ktermios *old) 859 860 { 860 861 struct ktermios *new = &tty->termios; 861 862 int old_baud_rate = tty_termios_baud_rate(old);