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]
Date:   Wed, 22 Jun 2022 17:46:52 +0200
From:   Lino Sanfilippo <LinoSanfilippo@....de>
To:     gregkh@...uxfoundation.org, jirislaby@...nel.org
Cc:     ilpo.jarvinen@...ux.intel.com, robh+dt@...nel.org,
        krzysztof.kozlowski+dt@...aro.org,
        andriy.shevchenko@...ux.intel.com, vz@...ia.com,
        linux-arm-kernel@...ts.infradead.org, devicetree@...r.kernel.org,
        linux-serial@...r.kernel.org, linux-kernel@...r.kernel.org,
        lukas@...ner.de, p.rosenberger@...bus.com,
        Lino Sanfilippo <l.sanfilippo@...bus.com>
Subject: [PATCH 1/8] serial: core: only get RS485 termination gpio if supported

From: Lino Sanfilippo <l.sanfilippo@...bus.com>

In uart_get_rs485_mode() only try to get a termination GPIO if RS485 bus
termination is supported by the driver.

Signed-off-by: Lino Sanfilippo <l.sanfilippo@...bus.com>
---
 drivers/tty/serial/serial_core.c | 25 ++++++++++++++-----------
 1 file changed, 14 insertions(+), 11 deletions(-)

diff --git a/drivers/tty/serial/serial_core.c b/drivers/tty/serial/serial_core.c
index 1368b0ef7d7f..015f4e1da647 100644
--- a/drivers/tty/serial/serial_core.c
+++ b/drivers/tty/serial/serial_core.c
@@ -3384,17 +3384,20 @@ int uart_get_rs485_mode(struct uart_port *port)
 		rs485conf->flags |= SER_RS485_RTS_AFTER_SEND;
 	}
 
-	/*
-	 * Disabling termination by default is the safe choice:  Else if many
-	 * bus participants enable it, no communication is possible at all.
-	 * Works fine for short cables and users may enable for longer cables.
-	 */
-	port->rs485_term_gpio = devm_gpiod_get_optional(dev, "rs485-term",
-							GPIOD_OUT_LOW);
-	if (IS_ERR(port->rs485_term_gpio)) {
-		ret = PTR_ERR(port->rs485_term_gpio);
-		port->rs485_term_gpio = NULL;
-		return dev_err_probe(dev, ret, "Cannot get rs485-term-gpios\n");
+	if (port->rs485_supported->flags & SER_RS485_TERMINATE_BUS) {
+		/*
+		 * Disabling termination by default is the safe choice:  Else if
+		 * many bus participants enable it, no communication is possible
+		 * at all. Works fine for short cables and users may enable for
+		 * longer cables.
+		 */
+		port->rs485_term_gpio = devm_gpiod_get_optional(dev, "rs485-term",
+								GPIOD_OUT_LOW);
+		if (IS_ERR(port->rs485_term_gpio)) {
+			ret = PTR_ERR(port->rs485_term_gpio);
+			port->rs485_term_gpio = NULL;
+			return dev_err_probe(dev, ret, "Cannot get rs485-term-gpios\n");
+		}
 	}
 
 	return 0;
-- 
2.36.1

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ