diff mbox series

[v2,6/9] serial: sc16is7xx: add support for rs485 RTS delays in microseconds

Message ID 20190221171758.10322-6-martin.kepplinger@ginzinger.com (mailing list archive)
State New, archived
Headers show
Series [v2,1/9] serial: uapi: add SER_RS485_DELAY_IN_USEC flag to struct serial_rs485 | expand

Commit Message

Martin Kepplinger Feb. 21, 2019, 5:17 p.m. UTC
Read struct serial_rs485's flag SER_RS485_DELAY_IN_USEC and apply the delay
accordingly.

Signed-off-by: Martin Kepplinger <martin.kepplinger@ginzinger.com>
---
 drivers/tty/serial/sc16is7xx.c | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)
diff mbox series

Patch

diff --git a/drivers/tty/serial/sc16is7xx.c b/drivers/tty/serial/sc16is7xx.c
index 635178cf3eed..b0e00b9fb177 100644
--- a/drivers/tty/serial/sc16is7xx.c
+++ b/drivers/tty/serial/sc16is7xx.c
@@ -743,7 +743,13 @@  static void sc16is7xx_tx_proc(struct kthread_work *ws)
 	struct uart_port *port = &(to_sc16is7xx_one(ws, tx_work)->port);
 
 	if ((port->rs485.flags & SER_RS485_ENABLED) &&
-	    (port->rs485.delay_rts_before_send > 0))
+	    (port->rs485.delay_rts_before_send > 0) &&
+	    (port->rs485.flags & SER_RS485_DELAY_IN_USEC))
+		usleep_range(port->rs485.delay_rts_before_send,
+			     port->rs485.delay_rts_before_send);
+	else if ((port->rs485.flags & SER_RS485_ENABLED) &&
+		 (port->rs485.delay_rts_before_send > 0) &&
+		 !(port->rs485.flags & SER_RS485_DELAY_IN_USEC))
 		msleep(port->rs485.delay_rts_before_send);
 
 	sc16is7xx_handle_tx(port);