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: <9bc128a9-7ce3-d1e-dad6-ca91a5564ea8@linux.intel.com>
Date:   Mon, 4 Jul 2022 12:55:59 +0300 (EEST)
From:   Ilpo Järvinen <ilpo.jarvinen@...ux.intel.com>
To:     Lino Sanfilippo <LinoSanfilippo@....de>
cc:     Greg Kroah-Hartman <gregkh@...uxfoundation.org>,
        Jiri Slaby <jirislaby@...nel.org>, robh+dt@...nel.org,
        krzysztof.kozlowski+dt@...aro.org,
        Andy Shevchenko <andriy.shevchenko@...ux.intel.com>,
        vz@...ia.com, linux-arm-kernel@...ts.infradead.org,
        devicetree@...r.kernel.org,
        linux-serial <linux-serial@...r.kernel.org>,
        LKML <linux-kernel@...r.kernel.org>,
        Lukas Wunner <lukas@...ner.de>, p.rosenberger@...bus.com,
        Lino Sanfilippo <l.sanfilippo@...bus.com>
Subject: Re: [PATCH v2 1/9] serial: core: only get RS485 termination GPIO if
 supported

On Sun, 3 Jul 2022, Lino Sanfilippo wrote:

> 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. This prevents from allocating
> and holding a GPIO descriptor for the drivers lifetimg that will never be
> used.
> 
> Signed-off-by: Lino Sanfilippo <l.sanfilippo@...bus.com>
> ---
> 
> NOTE: 
> This patch follows the design decision that "rs485_supported" is
> set by the driver at initialization and cannot be modified
> afterwards. However the better approach would be to let the serial
> core modify the termination GPIO support setting based on the
> existence of a termination GPIO. If "rs485_supported" is not a 
> read-only value any more in future the logic implemented in this
> patch should be adjusted accordingly.
> 
>  drivers/tty/serial/serial_core.c | 10 ++++++++++
>  1 file changed, 10 insertions(+)
> 
> diff --git a/drivers/tty/serial/serial_core.c b/drivers/tty/serial/serial_core.c
> index 85ef7ef00b82..3768663dfa4d 100644
> --- a/drivers/tty/serial/serial_core.c
> +++ b/drivers/tty/serial/serial_core.c
> @@ -3404,6 +3404,16 @@ int uart_get_rs485_mode(struct uart_port *port)
>  	 */
>  	port->rs485_term_gpio = devm_gpiod_get_optional(dev, "rs485-term",
>  							GPIOD_OUT_LOW);
> +
> +	if (port->rs485_term_gpio &&
> +	    !(port->rs485_supported->flags & SER_RS485_TERMINATE_BUS)) {
> +		dev_warn(port->dev,
> +			"%s (%d): RS485 termination gpio not supported by driver\n",
> +			port->name, port->line);
> +		devm_gpiod_put(dev, port->rs485_term_gpio);
> +		port->rs485_term_gpio = NULL;
> +	}
> +
>  	if (IS_ERR(port->rs485_term_gpio)) {
>  		ret = PTR_ERR(port->rs485_term_gpio);
>  		port->rs485_term_gpio = NULL;

I sent a series to embed supported_rs485 to uart_port and manage 
SER_RS485_TERMINATE_BUS properly so I think this won't be necessary 
with that?


-- 
 i.

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ