serial: 8250_fintek: Check SER_RS485_RTS_* only with RS485
PATCH 1/1 serial: 8250_fintek: Check SER_RS485_RTS_* only with RS485
SER_RS485_RTS_ON_SEND and SER_RS485_RTS_AFTER_SEND relate to behavior within RS485 operation. The driver checks if they have the same value which is not possible to realize with the hardware. The check is taken regardless of SER_RS485_ENABLED flag and -EINVAL is returned when the check fails, which creates problems.
This check makes it unnecessarily complicated to turn RS485 mode off as simple zeroed serial_rs485 struct will trigger that equal values check. In addition, the driver itself memsets its rs485 structure to zero when RS485 is disabled but if userspace would try to make an TIOCSRS485 ioctl() call with the very same struct, it would end up failing with -EINVAL which doesn't make much sense.
Resolve the problem by moving the check inside SER_RS485_ENABLED block.
--- drivers/tty/serial/8250/8250_fintek.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)
drivers/tty/serial/8250/8250_fintek.c +4 -4
@@ -200,12 +200,12 @@ static int fintek_8250_rs485_config(struct uart_port *port,if (!pdata)return -EINVAL ; -/* Hardware do not support same RTS level on send and receive */ -if (!(rs485->flags &SER_RS485_RTS_ON_SEND ) == - !(rs485->flags &SER_RS485_RTS_AFTER_SEND )) -return -EINVAL ;if (rs485->flags &SER_RS485_ENABLED ) { +/* Hardware do not support same RTS level on send and receive */ +if (!(rs485->flags &SER_RS485_RTS_ON_SEND ) == + !(rs485->flags &SER_RS485_RTS_AFTER_SEND )) +return -EINVAL ;memset (rs485->padding,0 ,sizeof (rs485->padding)); config |=RS485_URA ; }else {
Signature · 1 line
tg: (4419da5d5d4b..) fix/8250-fintek-rts-check (depends on: tty-next)
Quoted 14 lines · Ilpo Järvinen
SER_RS485_RTS_ON_SENDandSER_RS485_RTS_AFTER_SENDrelate to behavior within RS485 operation. The driver checks if they have the same value which is not possible to realize with the hardware. The check is taken regardless ofSER_RS485_ENABLEDflag and-EINVALis returned when the check fails, which creates problems.This check makes it unnecessarily complicated to turn RS485 mode off as simple zeroed
serial_rs485struct will trigger that equal values check. In addition, the driver itself memsets its rs485 structure to zero when RS485 is disabled but if userspace would try to make an TIOCSRS485ioctl()call with the very same struct, it would end up failing with-EINVALwhich doesn't make much sense.
Quoted 5 lines
Resolve the problem by moving the check inside
SER_RS485_ENABLEDblock.Fixes 7ecc77011c6f ("serial: 8250_fintek: Return -EINVAL on invalid configuration")Cc Ricardo Ribalda Delgado <[email protected]>Signed-off-by Ilpo Järvinen <[email protected]>
Quoted 29 lines
--- drivers/tty/serial/8250/8250_fintek.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)drivers/tty/serial/8250/8250_fintek.c +4
-5@@ -200,12 +200,12 @@ static int fintek_8250_rs485_config(struct uart_port *port,if (!pdata)return -EINVAL ; -/* Hardware do not support same RTS level on send and receive */ -if (!(rs485->flags &SER_RS485_RTS_ON_SEND ) == - !(rs485->flags &SER_RS485_RTS_AFTER_SEND )) -return -EINVAL ;if (rs485->flags &SER_RS485_ENABLED ) { +/* Hardware do not support same RTS level on send and receive */ +if (!(rs485->flags &SER_RS485_RTS_ON_SEND ) == + !(rs485->flags &SER_RS485_RTS_AFTER_SEND )) +return -EINVAL ;memset (rs485->padding,0 ,sizeof (rs485->padding)); config |=RS485_URA ; }else { --tg: (
4419da5d5d4b..) fix/8250-fintek-rts-check (depends on: tty-next)