linux-serial.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Lukas Wunner <lukas@wunner.de>
To: Gerhard Engleder <gerhard@engleder-embedded.com>
Cc: linux-serial@vger.kernel.org, gregkh@linuxfoundation.org,
	jirislaby@kernel.org, Gerhard Engleder <eg@keba.com>
Subject: Re: [PATCH v2 1/2] serial: Keep rs485 settings for devices without firmware node
Date: Sun, 19 Oct 2025 10:50:01 +0200	[thread overview]
Message-ID: <aPSmOcbprjf0EoAq@wunner.de> (raw)
In-Reply-To: <20251017144209.2662-2-gerhard@engleder-embedded.com>

On Fri, Oct 17, 2025 at 04:42:08PM +0200, Gerhard Engleder wrote:
> Commit fe7f0fa43cef ("serial: 8250: Support rs485 devicetree properties")
> retrieves rs485 properties for 8250 drivers. These properties are read
> from the firmware node of the device. If the firmware node does not
> exist, then the rs485 flags are still reset. Thus, 8250 driver cannot
> set rs485 flags to enable a defined rs485 mode during driver loading.
> This is no problem so far, as no 8250 driver sets the rs485 flags.
> 
> If no firmware node exist, then it should be possible for the driver to
> set a reasonable default rs485 mode. Therefore, reset rs485 flags only
> if a firmware node exists.
[...]
> +++ b/drivers/tty/serial/serial_core.c
> @@ -3533,7 +3533,13 @@ int uart_get_rs485_mode(struct uart_port *port)
>  	u32 rs485_delay[2];
>  	int ret;
>  
> -	if (!(port->rs485_supported.flags & SER_RS485_ENABLED))
> +	/*
> +	 * Retrieve properties only if rs485 is supported and if a firmware node
> +	 * exist. If no firmware node exist, then don't touch rs485 config and
> +	 * keep initial rs485 properties set by driver.
> +	 */
> +	if (!(port->rs485_supported.flags & SER_RS485_ENABLED) ||
> +	    !dev_fwnode(dev))
>  		return 0;
>  
>  	ret = device_property_read_u32_array(dev, "rs485-rts-delay",

Hm, this will also skip the call to uart_sanitize_serial_rs485_delays().

I'm wondering if a better approach might be to move the check for
!dev_fwnode(dev) further down, after the invocation of
uart_sanitize_serial_rs485_delays()?

It may be necessary then to change the else-branch for the delays to
"else if (ret != -EINVAL)" because -EINVAL is returned from
device_property_read_u32_array() if there's no fw_node.

If you decide to keep the check at the top of the function, then
style-wise it would seem cleaner to not insert it into the existing
if-condition, but add a separate if-condition.  It doesn't matter
IMO that they both return 0.  The way the patch is now, it creates
a little confusion to which of the two if-conditions the code
comment pertains.

Thanks,

Lukas

  reply	other threads:[~2025-10-19  8:50 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-10-17 14:42 [PATCH v2 0/2] serial: add KEBA UART driver Gerhard Engleder
2025-10-17 14:42 ` [PATCH v2 1/2] serial: Keep rs485 settings for devices without firmware node Gerhard Engleder
2025-10-19  8:50   ` Lukas Wunner [this message]
2025-10-19 14:10     ` Gerhard Engleder
2025-10-19 14:42       ` Lukas Wunner
2025-10-19 15:21         ` Gerhard Engleder
2025-10-19 17:02           ` Lukas Wunner
2025-10-19 19:06             ` Gerhard Engleder
2025-10-19 17:20           ` Lukas Wunner
2025-10-19 19:19             ` Gerhard Engleder
2025-10-17 14:42 ` [PATCH v2 2/2] serial: 8250: add driver for KEBA UART Gerhard Engleder
2025-11-27 16:05 ` [PATCH v2 0/2] serial: add KEBA UART driver Andy Shevchenko
2025-11-27 19:26   ` Gerhard Engleder
2025-11-27 19:56     ` Andy Shevchenko
2025-11-27 20:07       ` Gerhard Engleder
2025-11-27 20:56         ` Andy Shevchenko

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=aPSmOcbprjf0EoAq@wunner.de \
    --to=lukas@wunner.de \
    --cc=eg@keba.com \
    --cc=gerhard@engleder-embedded.com \
    --cc=gregkh@linuxfoundation.org \
    --cc=jirislaby@kernel.org \
    --cc=linux-serial@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).