lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <20200318142640.982763-6-heiko@sntech.de>
Date:   Wed, 18 Mar 2020 15:26:38 +0100
From:   Heiko Stuebner <heiko@...ech.de>
To:     gregkh@...uxfoundation.org
Cc:     jslaby@...e.com, andriy.shevchenko@...ux.intel.com,
        matwey.kornilov@...il.com, linux-serial@...r.kernel.org,
        linux-kernel@...r.kernel.org, heiko@...ech.de,
        Heiko Stuebner <heiko.stuebner@...obroma-systems.com>
Subject: [PATCH 5/7] serial: 8250: handle DTR in rs485 emulation

From: Heiko Stuebner <heiko.stuebner@...obroma-systems.com>

While in a lot of cases only RTS is needed as DE signal, sometimes the
RE signals is to be controlled separately, as DTR pin.

So add necessary control functions for it.

Signed-off-by: Heiko Stuebner <heiko.stuebner@...obroma-systems.com>
---
 drivers/tty/serial/8250/8250_port.c | 13 +++++++++++++
 1 file changed, 13 insertions(+)

diff --git a/drivers/tty/serial/8250/8250_port.c b/drivers/tty/serial/8250/8250_port.c
index 3d1d8490bc42..f8e5c096ed51 100644
--- a/drivers/tty/serial/8250/8250_port.c
+++ b/drivers/tty/serial/8250/8250_port.c
@@ -572,6 +572,10 @@ static inline void serial8250_em485_rts_after_send(struct uart_8250_port *p)
 		mcr &= ~UART_MCR_RTS;
 		p->port.mctrl &= ~TIOCM_RTS;
 	}
+
+	mcr |= UART_MCR_DTR;
+	p->port.mctrl |= TIOCM_DTR;
+
 	serial8250_out_MCR(p, mcr);
 }
 
@@ -1558,6 +1562,13 @@ static inline void start_tx_rs485(struct uart_port *port)
 	em485->active_timer = NULL;
 
 	mcr = serial8250_in_MCR(up);
+
+	/* in rx_during_tx mode keep DTR active, to receive data */
+	if (up->port.rs485.flags & SER_RS485_RX_DURING_TX)
+		mcr |= UART_MCR_DTR;
+	else
+		mcr &= ~UART_MCR_DTR;
+
 	if (!!(up->port.rs485.flags & SER_RS485_RTS_ON_SEND) !=
 	    !!(mcr & UART_MCR_RTS)) {
 		if (up->port.rs485.flags & SER_RS485_RTS_ON_SEND)
@@ -1572,6 +1583,8 @@ static inline void start_tx_rs485(struct uart_port *port)
 					 up->port.rs485.delay_rts_before_send);
 			return;
 		}
+	} else {
+		serial8250_out_MCR(up, mcr);
 	}
 
 	__start_tx(port);
-- 
2.24.1

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ