linux/drivers/tty/serial
Sergiu Moga 345bdea212 tty: serial: atmel: Preserve previous USART mode if RS485 disabled
[ Upstream commit 692a8ebcfc ]

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>
Signed-off-by: Sasha Levin <sashal@kernel.org>
2022-09-28 11:10:22 +02:00
..
8250 Revert "serial: 8250: Fix reporting real baudrate value in c_ospeed field" 2022-09-23 14:16:59 +02:00
cpm_uart tty: serial: cpm_uart: Fix behaviour for non existing GPIOs 2020-06-27 13:50:51 +02:00
jsm tty: serial: jsm: hold port lock when reporting modem line changes 2021-09-18 13:40:20 +02:00
21285.c tty: serial: 21285: fix lockup on open 2020-10-28 13:39:14 +01:00
altera_jtaguart.c serial: altera_jtaguart: Replace HTTP links with HTTPS ones 2020-07-21 20:04:54 +02:00
altera_uart.c
amba-pl010.c amba: Make the remove callback return void 2022-04-08 14:40:02 +02:00
amba-pl011.c serial: pl011: UPSTAT_AUTORTS requires .throttle/unthrottle 2022-07-21 21:20:19 +02:00
amba-pl011.h
apbuart.c
apbuart.h
ar933x_uart.c serial: ar933x_uart: disable clk on error handling path in probe 2020-11-12 09:41:07 +01:00
arc_uart.c
atmel_serial.c tty: serial: atmel: Preserve previous USART mode if RS485 disabled 2022-09-28 11:10:22 +02:00
atmel_serial.h
bcm63xx_uart.c Revert "tty: serial: bcm63xx: fix missing clk_put() in bcm63xx_uart" 2020-05-04 11:49:57 +02:00
clps711x.c
digicolor-usart.c serial: digicolor-usart: Don't allow CS5-6 2022-06-14 18:32:33 +02:00
dz.c
dz.h
earlycon-arm-semihost.c
earlycon-riscv-sbi.c
earlycon.c tty: serial: print earlycon info after match->setup 2020-09-16 13:16:20 +02:00
efm32-uart.c
fsl_linflexuart.c
fsl_lpuart.c tty: serial: lpuart: disable flow control while waiting for the transmit engine to complete 2022-09-08 11:11:37 +02:00
icom.c tty: Fix a possible resource leak in icom_probe 2022-06-14 18:32:42 +02:00
icom.h
ifx6x60.c tty: serial, fix kernel-doc 2020-08-18 13:51:18 +02:00
ifx6x60.h
imx_earlycon.c tty: serial: imx: add imx earlycon driver 2020-07-29 17:11:02 +02:00
imx.c serial: imx: fix overrun interrupts in DMA mode 2022-05-09 09:04:59 +02:00
ip22zilog.c
ip22zilog.h
Kconfig tty: serial: imx: enable earlycon by default if IMX_SERIAL_CONSOLE is enabled 2020-11-06 17:23:49 +01:00
kgdb_nmi.c kdb: Switch to use safer dbg_io_ops over console APIs 2020-06-26 15:40:16 +01:00
kgdboc.c kgdboc: fix return value of __setup handler 2022-04-08 14:40:28 +02:00
lantiq.c serial: lantiq: Make driver modular 2020-05-15 12:22:19 +02:00
lpc32xx_hs.c tty: drivers/tty/, stop using tty_schedule_flip() 2022-07-29 17:19:27 +02:00
Makefile tty: serial: imx: add dependence and build for earlycon 2020-08-18 13:54:34 +02:00
max310x.c serial: max310x: unregister uart driver in case of failure and abort 2021-06-03 09:00:40 +02:00
max3100.c
mcf.c serial: mcf: add sysrq capability 2020-10-05 13:32:30 +02:00
men_z135_uart.c tty: serial, fix kernel-doc 2020-08-18 13:51:18 +02:00
meson_uart.c serial: meson: acquire port->lock in startup() 2022-06-14 18:32:33 +02:00
milbeaut_usio.c
mpc52xx_uart.c
mps2-uart.c
msm_serial.c serial: msm_serial: disable interrupts in __msm_console_write() 2022-06-14 18:32:43 +02:00
mux.c
mvebu-uart.c serial: mvebu-uart: uart2 error bits clearing 2022-08-21 15:15:25 +02:00
mxs-auart.c serial: mxs-auart: add missed iounmap() in probe failure and remove 2020-07-10 14:44:46 +02:00
omap-serial.c serial: omap: fix rs485 half-duplex filtering 2021-05-14 09:50:21 +02:00
owl-uart.c tty: serial: owl: Fix missing clk_disable_unprepare() in owl_uart_probe 2022-06-14 18:32:30 +02:00
pch_uart.c serial: pch: don't overwrite xmit->buf[0] by x_char 2022-06-09 10:21:28 +02:00
pic32_uart.c
pic32_uart.h
pmac_zilog.c m68k: Fix WARNING splat in pmac_zilog driver 2020-12-30 11:54:11 +01:00
pmac_zilog.h
pnx8xxx_uart.c
pxa.c
qcom_geni_serial.c soc: qcom-geni-se: Cleanup the code to remove proxy votes 2021-04-07 15:00:13 +02:00
rda-uart.c serial: rda-uart: Don't allow CS5-6 2022-06-14 18:32:33 +02:00
rp2.c serial: rp2: use 'request_firmware' instead of 'request_firmware_nowait' 2021-06-03 09:00:34 +02:00
sa1100.c drivers: tty: serial: Fix deadlock in sa1100_set_termios() 2022-06-14 18:32:42 +02:00
samsung_tty.c tty: serial: samsung_tty: set dma burst_size to 1 2022-07-21 21:20:18 +02:00
sb1250-duart.c MIPS: Replace SIBYTE_1956_WAR by CONFIG_SB1_PASS_2_WORKAROUNDS 2020-09-07 22:24:51 +02:00
sc16is7xx.c sc16is7xx: Fix for incorrect data being transmitted 2022-03-02 11:42:53 +01:00
sccnxp.c
serial_core.c serial: 8250: Fix PM usage_count for console handover 2022-07-21 21:20:19 +02:00
serial_mctrl_gpio.c
serial_mctrl_gpio.h
serial_txx9.c serial: txx9: Don't allow CS5-6 2022-06-14 18:32:33 +02:00
serial-tegra.c serial: tegra: Change lower tolerance baud rate limit for tegra20 and tegra30 2021-12-08 09:03:29 +01:00
sh-sci.c serial: sh-sci: Don't allow CS5-6 2022-06-14 18:32:33 +02:00
sh-sci.h serial: sh-sci: Drop unused include 2020-04-16 16:13:34 +02:00
sifive.c serial: sifive: Sanitize CSIZE and c_iflag 2022-06-14 18:32:33 +02:00
sirfsoc_uart.c
sirfsoc_uart.h
sprd_serial.c
st-asc.c serial: st-asc: Sanitize CSIZE and correct PARENB for CS7 2022-06-14 18:32:34 +02:00
stm32-usart.c serial: stm32: Clear prev values before setting RTS delays 2022-07-21 21:20:19 +02:00
stm32-usart.h serial: stm32: fix tx_empty condition 2021-05-14 09:50:08 +02:00
suncore.c
sunhv.c Revert "serial: sunhv: Initialize lock for non-registered console" 2020-07-21 18:21:49 +02:00
sunsab.c serial: sunsab: Return proper error code from console ->setup() hook 2020-06-25 14:21:28 +02:00
sunsab.h
sunsu.c treewide: Use fallthrough pseudo-keyword 2020-08-23 17:36:59 -05:00
sunzilog.c treewide: Use fallthrough pseudo-keyword 2020-08-23 17:36:59 -05:00
sunzilog.h
tegra-tcu.c
timbuart.c tty: timbuart: convert tasklets to use new tasklet_setup() API 2020-08-18 13:33:13 +02:00
timbuart.h
uartlite.c tty: serial: uartlite: allow 64 bit address 2022-01-27 10:53:53 +01:00
ucc_uart.c tty: serial: Fix refcount leak bug in ucc_uart.c 2022-08-25 11:38:18 +02:00
vr41xx_siu.c
vt8500_serial.c
xilinx_uartps.c serial: xilinx_uartps: Fix race condition causing stuck TX 2021-11-18 14:04:20 +01:00
zs.c
zs.h