To prevent echo in some configurations, make sure we do not read back when we are sending if RS485 is configured this way. We need to shuffle stop_rx() around, implement start_rx() and call it in apropriate places. Signed-off-by: Juergen Beisert <jbe@xxxxxxxxxxxxxx> Signed-off-by: Wolfram Sang <w.sang@xxxxxxxxxxxxxx> --- drivers/tty/serial/8250.c | 34 +++++++++++++++++++++++++--------- 1 files changed, 25 insertions(+), 9 deletions(-) diff --git a/drivers/tty/serial/8250.c b/drivers/tty/serial/8250.c index b5d3248..6a2f47f 100644 --- a/drivers/tty/serial/8250.c +++ b/drivers/tty/serial/8250.c @@ -1304,6 +1304,26 @@ static void autoconfig_irq(struct uart_8250_port *up) up->port.irq = (irq > 0) ? irq : 0; } +static void serial8250_stop_rx(struct uart_port *port) +{ + struct uart_8250_port *up = + container_of(port, struct uart_8250_port, port); + + up->ier &= ~UART_IER_RLSI; + up->port.read_status_mask &= ~UART_LSR_DR; + serial_out(up, UART_IER, up->ier); +} + +static void serial8250_start_rx(struct uart_port *port) +{ + struct uart_8250_port *up = + container_of(port, struct uart_8250_port, port); + + up->ier |= UART_IER_RLSI; + up->port.read_status_mask |= UART_LSR_DR; + serial_out(up, UART_IER, up->ier); +} + static inline void __stop_tx(struct uart_8250_port *p) { if (p->ier & UART_IER_THRI) { @@ -1326,6 +1346,9 @@ static void serial8250_stop_tx(struct uart_port *port) up->acr |= UART_ACR_TXDIS; serial_icr_write(up, UART_ACR, up->acr); } + + if (!(up->rs485_flags & SER_RS485_RX_DURING_TX)) + serial8250_start_rx(port); } static void transmit_chars(struct uart_8250_port *up); @@ -1357,16 +1380,9 @@ static void serial8250_start_tx(struct uart_port *port) up->acr &= ~UART_ACR_TXDIS; serial_icr_write(up, UART_ACR, up->acr); } -} -static void serial8250_stop_rx(struct uart_port *port) -{ - struct uart_8250_port *up = - container_of(port, struct uart_8250_port, port); - - up->ier &= ~UART_IER_RLSI; - up->port.read_status_mask &= ~UART_LSR_DR; - serial_out(up, UART_IER, up->ier); + if (!(up->rs485_flags & SER_RS485_RX_DURING_TX)) + serial8250_stop_rx(port); } static void serial8250_enable_ms(struct uart_port *port) -- 1.7.7.3 -- To unsubscribe from this list: send the line "unsubscribe linux-serial" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html