From: "Ilpo Järvinen" <ilpo.jarvinen@linux.intel.com>
To: Lino Sanfilippo <l.sanfilippo@kunbus.com>
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
Jiri Slaby <jirislaby@kernel.org>,
u.kleine-koenig@pengutronix.de, shawnguo@kernel.org,
s.hauer@pengutronix.de, mcoquelin.stm32@gmail.com,
alexandre.torgue@foss.st.com, cniedermaier@dh-electronics.com,
hugo@hugovil.com, m.brock@vanmierlo.com,
LKML <linux-kernel@vger.kernel.org>,
linux-serial <linux-serial@vger.kernel.org>,
LinoSanfilippo@gmx.de, Lukas Wunner <lukas@wunner.de>,
p.rosenberger@kunbus.com, stable@vger.kernel.org
Subject: Re: [PATCH v7 5/7] serial: core, imx: do not set RS485 enabled if it is not supported
Date: Wed, 3 Jan 2024 13:19:43 +0200 (EET) [thread overview]
Message-ID: <75c0cbd4-7cec-a415-bfba-376f035f76@linux.intel.com> (raw)
In-Reply-To: <20240103061818.564-6-l.sanfilippo@kunbus.com>
[-- Attachment #1: Type: text/plain, Size: 3124 bytes --]
On Wed, 3 Jan 2024, Lino Sanfilippo wrote:
> If the imx driver cannot support RS485 it nullifies the ports
> rs485_supported structure. But it still calls uart_get_rs485_mode() which
> may set the RS485_ENABLED flag nevertheless.
>
> This may lead to an attempt to configure RS485 even if it is not supported
> when the flag is evaluated in uart_configure_port() at port startup.
>
> Avoid this by bailing out of uart_get_rs485_mode() if the RS485_ENABLED
> flag is not supported by the caller.
>
> With this fix a check for RTS availability is now obsolete in the imx
> driver, since it can not evaluate to true any more. So remove this check.
>
> Furthermore the explicit nullifcation of rs485_supported is not needed,
> since the memory has already been set to zeros at allocation. So remove
> this, too.
>
> Fixes: 00d7a00e2a6f ("serial: imx: Fill in rs485_supported")
> Cc: Shawn Guo <shawnguo@kernel.org>
> Cc: Sascha Hauer <s.hauer@pengutronix.de>
> Cc: stable@vger.kernel.org
> Suggested-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
> Signed-off-by: Lino Sanfilippo <l.sanfilippo@kunbus.com>
> ---
> drivers/tty/serial/imx.c | 7 -------
> drivers/tty/serial/serial_core.c | 3 +++
> 2 files changed, 3 insertions(+), 7 deletions(-)
>
> diff --git a/drivers/tty/serial/imx.c b/drivers/tty/serial/imx.c
> index 9cffeb23112b..198ce7e7bc8b 100644
> --- a/drivers/tty/serial/imx.c
> +++ b/drivers/tty/serial/imx.c
> @@ -2206,7 +2206,6 @@ static enum hrtimer_restart imx_trigger_stop_tx(struct hrtimer *t)
> return HRTIMER_NORESTART;
> }
>
> -static const struct serial_rs485 imx_no_rs485 = {}; /* No RS485 if no RTS */
> static const struct serial_rs485 imx_rs485_supported = {
> .flags = SER_RS485_ENABLED | SER_RS485_RTS_ON_SEND | SER_RS485_RTS_AFTER_SEND |
> SER_RS485_RX_DURING_TX,
> @@ -2290,8 +2289,6 @@ static int imx_uart_probe(struct platform_device *pdev)
> /* RTS is required to control the RS485 transmitter */
> if (sport->have_rtscts || sport->have_rtsgpio)
> sport->port.rs485_supported = imx_rs485_supported;
> - else
> - sport->port.rs485_supported = imx_no_rs485;
> sport->port.flags = UPF_BOOT_AUTOCONF;
> timer_setup(&sport->timer, imx_uart_timeout, 0);
>
> @@ -2328,10 +2325,6 @@ static int imx_uart_probe(struct platform_device *pdev)
> return ret;
> }
>
> - if (sport->port.rs485.flags & SER_RS485_ENABLED &&
> - (!sport->have_rtscts && !sport->have_rtsgpio))
> - dev_err(&pdev->dev, "no RTS control, disabling rs485\n");
> -
> /*
> * If using the i.MX UART RTS/CTS control then the RTS (CTS_B)
> * signal cannot be set low during transmission in case the
> diff --git a/drivers/tty/serial/serial_core.c b/drivers/tty/serial/serial_core.c
> index 28bcbc686c67..93e4e1693601 100644
> --- a/drivers/tty/serial/serial_core.c
> +++ b/drivers/tty/serial/serial_core.c
> @@ -3600,6 +3600,9 @@ int uart_get_rs485_mode(struct uart_port *port)
> u32 rs485_delay[2];
> int ret;
>
> + if (!(port->rs485_supported.flags & SER_RS485_ENABLED))
> + return 0;
> +
Reviewed-by: Ilpo Järvinen <ilpo.jarvinen@linux.intel.com>
--
i.
next prev parent reply other threads:[~2024-01-03 11:19 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <20240103061818.564-1-l.sanfilippo@kunbus.com>
2024-01-03 6:18 ` [PATCH v7 1/7] serial: Do not hold the port lock when setting rx-during-tx GPIO Lino Sanfilippo
2024-01-03 11:10 ` Ilpo Järvinen
2024-01-05 10:44 ` Lino Sanfilippo
2024-01-03 6:18 ` [PATCH v7 2/7] serial: core: set missing supported flag for RX during TX GPIO Lino Sanfilippo
2024-01-03 6:18 ` [PATCH v7 3/7] serial: core: fix sanitizing check for RTS settings Lino Sanfilippo
2024-01-03 6:18 ` [PATCH v7 4/7] serial: core: make sure RS485 cannot be enabled when it is not supported Lino Sanfilippo
2024-01-03 6:18 ` [PATCH v7 5/7] serial: core, imx: do not set RS485 enabled if " Lino Sanfilippo
2024-01-03 11:19 ` Ilpo Järvinen [this message]
2024-01-03 6:18 ` [PATCH v7 6/7] serial: omap: do not override settings for RS485 support Lino Sanfilippo
2024-01-03 11:36 ` Ilpo Järvinen
2024-01-05 12:42 ` Lino Sanfilippo
2024-01-03 6:18 ` [PATCH v7 7/7] serial: 8250_exar: Set missing rs485_supported flag Lino Sanfilippo
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=75c0cbd4-7cec-a415-bfba-376f035f76@linux.intel.com \
--to=ilpo.jarvinen@linux.intel.com \
--cc=LinoSanfilippo@gmx.de \
--cc=alexandre.torgue@foss.st.com \
--cc=cniedermaier@dh-electronics.com \
--cc=gregkh@linuxfoundation.org \
--cc=hugo@hugovil.com \
--cc=jirislaby@kernel.org \
--cc=l.sanfilippo@kunbus.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-serial@vger.kernel.org \
--cc=lukas@wunner.de \
--cc=m.brock@vanmierlo.com \
--cc=mcoquelin.stm32@gmail.com \
--cc=p.rosenberger@kunbus.com \
--cc=s.hauer@pengutronix.de \
--cc=shawnguo@kernel.org \
--cc=stable@vger.kernel.org \
--cc=u.kleine-koenig@pengutronix.de \
/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