linux-stable/drivers/tty/serial
Sergiu Moga 692a8ebcfc tty: serial: atmel: Preserve previous USART mode if RS485 disabled
Whenever the atmel_rs485_config() driver method would be called,
the USART mode is reset to normal mode before even checking if
RS485 flag is set, thus resulting in losing the previous USART
mode in the case where the checking fails.

Some tools, such as `linux-serial-test`, lead to the driver calling
this method when doing the setup of the serial port: after setting the
port mode (Hardware Flow Control, Normal Mode, RS485 Mode, etc.),
`linux-serial-test` tries to enable/disable RS485 depending on
the commandline arguments that were passed.

Example of how this issue could reveal itself:
When doing a serial communication with Hardware Flow Control through
`linux-serial-test`, the tool would lead to the driver roughly doing
the following:
- set the corresponding bit to 1 (ATMEL_US_USMODE_HWHS bit in the
ATMEL_US_MR register) through the atmel_set_termios() to enable
Hardware Flow Control
- disable RS485 through the atmel_config_rs485() method
Thus, when the latter is called, the mode will be reset and the
previously set bit is unset, leaving USART in normal mode instead of
the expected Hardware Flow Control mode.

This fix ensures that this reset is only done if the checking for
RS485 succeeds and that the previous mode is preserved otherwise.

Fixes: e8faff7330 ("ARM: 6092/1: atmel_serial: support for RS485 communications")
Cc: stable <stable@kernel.org>
Reviewed-by: Ilpo Järvinen <ilpo.jarvinen@linux.intel.com>
Signed-off-by: Sergiu Moga <sergiu.moga@microchip.com>
Link: https://lore.kernel.org/r/20220824142902.502596-1-sergiu.moga@microchip.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2022-08-30 14:33:08 +02:00
..
8250 TTY / Serial driver changes for 6.0-rc1 2022-08-08 11:31:40 -07:00
cpm_uart serial: cpm_uart: Fix build error without CONFIG_SERIAL_CPM_CONSOLE 2022-05-19 18:31:58 +02:00
jsm serial: jsm: Use B0 instead of 0 2022-05-19 18:26:17 +02:00
21285.c serial: make uart_console_write->putchar()'s character an unsigned char 2022-03-03 15:06:31 +01:00
altera_jtaguart.c tty: serial: altera: use altera_jtaguart_stop_tx() 2022-04-14 18:27:18 +02:00
altera_uart.c serial: make uart_console_write->putchar()'s character an unsigned char 2022-03-03 15:06:31 +01:00
amba-pl010.c serial: make uart_console_write->putchar()'s character an unsigned char 2022-03-03 15:06:31 +01:00
amba-pl011.c TTY / Serial driver changes for 6.0-rc1 2022-08-08 11:31:40 -07:00
apbuart.c serial: make uart_console_write->putchar()'s character an unsigned char 2022-03-03 15:06:31 +01:00
apbuart.h
ar933x_uart.c serial: ar933x: Remove superfluous code in ar933x_config_rs485() 2022-07-14 16:34:23 +02:00
arc_uart.c serial: make uart_console_write->putchar()'s character an unsigned char 2022-03-03 15:06:31 +01:00
atmel_serial.c tty: serial: atmel: Preserve previous USART mode if RS485 disabled 2022-08-30 14:33:08 +02:00
atmel_serial.h
bcm63xx_uart.c serial: make uart_console_write->putchar()'s character an unsigned char 2022-03-03 15:06:31 +01:00
clps711x.c serial: make uart_console_write->putchar()'s character an unsigned char 2022-03-03 15:06:31 +01:00
digicolor-usart.c serial: digicolor-usart: Don't allow CS5-6 2022-05-19 18:32:39 +02:00
dz.c serial: make uart_console_write->putchar()'s character an unsigned char 2022-03-03 15:06:31 +01:00
dz.h
earlycon-arm-semihost.c serial: make uart_console_write->putchar()'s character an unsigned char 2022-03-03 15:06:31 +01:00
earlycon-riscv-sbi.c serial: make uart_console_write->putchar()'s character an unsigned char 2022-03-03 15:06:31 +01:00
earlycon.c earlycon: prevent multiple register_console() 2022-06-30 17:10:11 +02:00
fsl_linflexuart.c serial: make uart_console_write->putchar()'s character an unsigned char 2022-03-03 15:06:31 +01:00
fsl_lpuart.c tty: serial: lpuart: disable flow control while waiting for the transmit engine to complete 2022-08-30 14:32:33 +02:00
icom.c serial: icom: remove unused struct icom_port members 2022-04-22 16:19:53 +02:00
imx.c serial: Embed rs485_supported to uart_port 2022-07-08 15:14:09 +02:00
imx_earlycon.c serial: make uart_console_write->putchar()'s character an unsigned char 2022-03-03 15:06:31 +01:00
ip22zilog.c serial: make uart_console_write->putchar()'s character an unsigned char 2022-03-03 15:06:31 +01:00
ip22zilog.h
Kconfig TTY / Serial driver changes for 6.0-rc1 2022-08-08 11:31:40 -07:00
kgdb_nmi.c
kgdboc.c serial: kgdboc: Fix typo in comment 2022-06-27 14:37:09 +02:00
lantiq.c serial: make uart_console_write->putchar()'s character an unsigned char 2022-03-03 15:06:31 +01:00
liteuart.c serial: make uart_console_write->putchar()'s character an unsigned char 2022-03-03 15:06:31 +01:00
lpc32xx_hs.c serial: make uart_console_write->putchar()'s character an unsigned char 2022-03-03 15:06:31 +01:00
Makefile serial: remove VR41XX serial driver 2022-07-16 08:16:01 +02:00
max310x.c serial: Embed rs485_supported to uart_port 2022-07-08 15:14:09 +02:00
max3100.c TTY/Serial driver changes for 5.18-rc1 2022-03-28 13:00:51 -07:00
mcf.c serial: Embed rs485_supported to uart_port 2022-07-08 15:14:09 +02:00
men_z135_uart.c serial: men_z135_uart: Drop duplicated iotype assignment 2022-05-05 22:34:55 +02:00
meson_uart.c serial: Convert SERIAL_XMIT_SIZE to UART_XMIT_SIZE 2022-06-27 14:41:31 +02:00
milbeaut_usio.c serial: make uart_console_write->putchar()'s character an unsigned char 2022-03-03 15:06:31 +01:00
mpc52xx_uart.c powerpc/mpc5xxx: Switch mpc5xxx_get_bus_frequency() to use fwnode 2022-06-22 12:51:49 +10:00
mps2-uart.c serial: make uart_console_write->putchar()'s character an unsigned char 2022-03-03 15:06:31 +01:00
msm_serial.c serial: msm: Rename UART_* defines to MSM_UART_* 2022-06-27 14:41:31 +02:00
mux.c serial: Drop timeout from uart_port 2022-06-27 14:34:45 +02:00
mvebu-uart.c TTY / Serial driver changes for 6.0-rc1 2022-08-08 11:31:40 -07:00
mxs-auart.c serial: make uart_console_write->putchar()'s character an unsigned char 2022-03-03 15:06:31 +01:00
omap-serial.c serial: Embed rs485_supported to uart_port 2022-07-08 15:14:09 +02:00
owl-uart.c serial: Convert SERIAL_XMIT_SIZE to UART_XMIT_SIZE 2022-06-27 14:41:31 +02:00
pch_uart.c serial: Consolidate BOTH_EMPTY use 2022-06-27 14:41:31 +02:00
pic32_uart.c serial: pic32: fix missing clk_disable_unprepare() on error in pic32_uart_startup() 2022-06-10 13:33:28 +02:00
pmac_zilog.c serial: pmac_zilog: remove unused header 2022-06-10 13:33:57 +02:00
pmac_zilog.h serial: pmac_zilog: remove unused uart_pmac_port::termios_cache 2022-05-19 18:23:19 +02:00
pxa.c serial: Consolidate BOTH_EMPTY use 2022-06-27 14:41:31 +02:00
qcom_geni_serial.c TTY / Serial driver changes for 6.0-rc1 2022-08-08 11:31:40 -07:00
rda-uart.c serial: Convert SERIAL_XMIT_SIZE to UART_XMIT_SIZE 2022-06-27 14:41:31 +02:00
rp2.c
sa1100.c drivers: tty: serial: Fix deadlock in sa1100_set_termios() 2022-04-22 16:23:37 +02:00
samsung_tty.c TTY / Serial driver changes for 6.0-rc1 2022-08-08 11:31:40 -07:00
sb1250-duart.c serial: make uart_console_write->putchar()'s character an unsigned char 2022-03-03 15:06:31 +01:00
sc16is7xx.c serial: Embed rs485_supported to uart_port 2022-07-08 15:14:09 +02:00
sccnxp.c serial: make uart_console_write->putchar()'s character an unsigned char 2022-03-03 15:06:31 +01:00
serial-tegra.c drivers: tty: serial: Add missing of_node_put() in serial-tegra.c 2022-06-27 14:36:02 +02:00
serial_core.c TTY / Serial driver changes for 6.0-rc1 2022-08-08 11:31:40 -07:00
serial_mctrl_gpio.c Documentation: serial: move GPIO kernel-doc to the functions 2022-07-28 10:37:42 +02:00
serial_mctrl_gpio.h serial: mctrl_gpio: add a new API to enable / disable wake_irq 2022-02-08 11:07:16 +01:00
serial_txx9.c serial: txx9: Don't allow CS5-6 2022-05-19 18:32:40 +02:00
sh-sci.c serial: sh-sci: Don't allow CS5-6 2022-05-19 18:32:40 +02:00
sh-sci.h
sifive.c serial: sifive: Remove useless license text when SPDX-License-Identifier is already used 2022-06-27 14:32:37 +02:00
sprd_serial.c serial: make uart_console_write->putchar()'s character an unsigned char 2022-03-03 15:06:31 +01:00
st-asc.c serial: st-asc: remove include of pm_runtime.h 2022-06-27 14:39:51 +02:00
stm32-usart.c TTY / Serial driver changes for 6.0-rc1 2022-08-08 11:31:40 -07:00
stm32-usart.h serial: stm32: make info structs static to avoid sparse warnings 2022-07-28 10:35:23 +02:00
suncore.c
sunhv.c
sunplus-uart.c serial: sunplus-uart: change sunplus_console_ports from global to static 2022-04-22 16:21:33 +02:00
sunsab.c serial: make uart_console_write->putchar()'s character an unsigned char 2022-03-03 15:06:31 +01:00
sunsab.h
sunsu.c serial: Consolidate BOTH_EMPTY use 2022-06-27 14:41:31 +02:00
sunzilog.c serial: make uart_console_write->putchar()'s character an unsigned char 2022-03-03 15:06:31 +01:00
sunzilog.h
tegra-tcu.c
timbuart.c
timbuart.h
uartlite.c serial: uartlite: Fix BRKINT clearing 2022-05-19 18:32:39 +02:00
ucc_uart.c tty: serial: Fix refcount leak bug in ucc_uart.c 2022-06-27 14:36:07 +02:00
vt8500_serial.c serial: make uart_console_write->putchar()'s character an unsigned char 2022-03-03 15:06:31 +01:00
xilinx_uartps.c serial: xilinx_uartps: cache xmit in cdns_uart_handle_tx() 2022-04-22 16:21:53 +02:00
zs.c serial: zs: use NULL as a pointer, not 0 2022-04-22 16:21:53 +02:00
zs.h