aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/tty
diff options
context:
space:
mode:
authorRicardo Ribalda Delgado <ricardo.ribalda@gmail.com>2017-11-06 05:49:12 -0500
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2017-11-08 07:09:35 -0500
commit7ecc77011c6fb40d3eef7c6a0ebcec61e69b3ec3 (patch)
treefa409afa4b009b0146f4068fa302edb351e6d565 /drivers/tty
parente5656d43dce828bfcacbecd614e22355073e918b (diff)
serial: 8250_fintek: Return -EINVAL on invalid configuration
Hardware does not support having the same RTS level during RX and TX when RS485 mode is on (URA in Fintek terminology). The manufacturer has also confirmed that the delays are not enabled if the RS485 mode is not enabled. Therefore we should return -EINVAL if the user wants to have the same value for RTS_ON_SEND and RTS_AFTER_SEND. Cc: "Ji-Ze Hong (Peter Hong)" <hpeter@gmail.com> Cc: Lukas Wunner <lukas@wunner.de> Signed-off-by: Ricardo Ribalda Delgado <ricardo.ribalda@gmail.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'drivers/tty')
-rw-r--r--drivers/tty/serial/8250/8250_fintek.c17
1 files changed, 9 insertions, 8 deletions
diff --git a/drivers/tty/serial/8250/8250_fintek.c b/drivers/tty/serial/8250/8250_fintek.c
index be7029f2391e..6c7910d8e136 100644
--- a/drivers/tty/serial/8250/8250_fintek.c
+++ b/drivers/tty/serial/8250/8250_fintek.c
@@ -197,10 +197,17 @@ static int fintek_8250_rs485_config(struct uart_port *port,
197 if (!pdata) 197 if (!pdata)
198 return -EINVAL; 198 return -EINVAL;
199 199
200 if (rs485->flags & SER_RS485_ENABLED) 200 /* Hardware do not support same RTS level on send and receive */
201 if (!(rs485->flags & SER_RS485_RTS_ON_SEND) ==
202 !(rs485->flags & SER_RS485_RTS_AFTER_SEND))
203 return -EINVAL;
204
205 if (rs485->flags & SER_RS485_ENABLED) {
201 memset(rs485->padding, 0, sizeof(rs485->padding)); 206 memset(rs485->padding, 0, sizeof(rs485->padding));
202 else 207 config |= RS485_URA;
208 } else {
203 memset(rs485, 0, sizeof(*rs485)); 209 memset(rs485, 0, sizeof(*rs485));
210 }
204 211
205 rs485->flags &= SER_RS485_ENABLED | SER_RS485_RTS_ON_SEND | 212 rs485->flags &= SER_RS485_ENABLED | SER_RS485_RTS_ON_SEND |
206 SER_RS485_RTS_AFTER_SEND; 213 SER_RS485_RTS_AFTER_SEND;
@@ -215,12 +222,6 @@ static int fintek_8250_rs485_config(struct uart_port *port,
215 config |= RXW4C_IRA; 222 config |= RXW4C_IRA;
216 } 223 }
217 224
218 if ((!!(rs485->flags & SER_RS485_RTS_ON_SEND)) ==
219 (!!(rs485->flags & SER_RS485_RTS_AFTER_SEND)))
220 rs485->flags &= ~SER_RS485_ENABLED;
221 else
222 config |= RS485_URA;
223
224 if (rs485->flags & SER_RS485_RTS_ON_SEND) 225 if (rs485->flags & SER_RS485_RTS_ON_SEND)
225 config |= RTS_INVERT; 226 config |= RTS_INVERT;
226 227