aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLukas Wunner <[email protected]>2020-02-28 14:31:04 +0100
committerGreg Kroah-Hartman <[email protected]>2020-03-07 09:52:01 +0100
commit6d3e54e1955ed1cd2da9a90c944290e91772cbcb (patch)
tree6dd962e29ad98dafb9f33cf1b8ba2e3c6c382e3b
parent283e096ffb7077c2b677eee043ff36965e43d37b (diff)
serial: 8250: Sanitize rs485 config harder
Amend the generic ->rs485_config() callback to sanitize RTS polarity and zero-fill the padding (in addition to the existing sanitization of the RTS delays). Signed-off-by: Lukas Wunner <[email protected]> Cc: Matwey V. Kornilov <[email protected]> Link: https://lore.kernel.org/r/ff833721bc372d38678f289eb2a44dbf016d5203.1582895077.git.lukas@wunner.de Signed-off-by: Greg Kroah-Hartman <[email protected]>
-rw-r--r--drivers/tty/serial/8250/8250_port.c8
1 files changed, 8 insertions, 0 deletions
diff --git a/drivers/tty/serial/8250/8250_port.c b/drivers/tty/serial/8250/8250_port.c
index 73244806d701..d281aea061d6 100644
--- a/drivers/tty/serial/8250/8250_port.c
+++ b/drivers/tty/serial/8250/8250_port.c
@@ -676,10 +676,18 @@ int serial8250_em485_config(struct uart_port *port, struct serial_rs485 *rs485)
{
struct uart_8250_port *up = up_to_u8250p(port);
+ /* pick sane settings if the user hasn't */
+ if (!!(rs485->flags & SER_RS485_RTS_ON_SEND) ==
+ !!(rs485->flags & SER_RS485_RTS_AFTER_SEND)) {
+ rs485->flags |= SER_RS485_RTS_ON_SEND;
+ rs485->flags &= ~SER_RS485_RTS_AFTER_SEND;
+ }
+
/* clamp the delays to [0, 100ms] */
rs485->delay_rts_before_send = min(rs485->delay_rts_before_send, 100U);
rs485->delay_rts_after_send = min(rs485->delay_rts_after_send, 100U);
+ memset(rs485->padding, 0, sizeof(rs485->padding));
port->rs485 = *rs485;
/*