From: Lino Sanfilippo <l.sanfilippo@kunbus.com>
If the imx driver cannot support RS485 it sets the UARTS rs485_supported
structure to NULL. But it still calls uart_get_rs485_mode() which may set
the RS485_ENABLED flag.
The flag however is evaluated by the serial core in uart_configure_port()
at port startup and thus may lead to an attempt to configure RS485 even if
it is not supported.
Avoid this by calling uart_get_rs485_mode() only if RS485 is actually
supported by the driver. Remove also a check for an error condition
that is not possible any more now.
Signed-off-by: Lino Sanfilippo <l.sanfilippo@kunbus.com>
---
drivers/tty/serial/imx.c | 14 ++++++--------
1 file changed, 6 insertions(+), 8 deletions(-)
diff --git a/drivers/tty/serial/imx.c b/drivers/tty/serial/imx.c
index edb2ec6a5567..87689abc21bd 100644
--- a/drivers/tty/serial/imx.c
+++ b/drivers/tty/serial/imx.c
@@ -2326,16 +2326,14 @@ static int imx_uart_probe(struct platform_device *pdev)
return ret;
}
- ret = uart_get_rs485_mode(&sport->port);
- if (ret) {
- clk_disable_unprepare(sport->clk_ipg);
- return ret;
+ if (sport->port.rs485_supported.flags & SER_RS485_ENABLED) {
+ ret = uart_get_rs485_mode(&sport->port);
+ if (ret) {
+ clk_disable_unprepare(sport->clk_ipg);
+ 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
--
2.40.1
On Fri, Sep 29, 2023 at 12:12:46AM +0200, Lino Sanfilippo wrote: > From: Lino Sanfilippo <l.sanfilippo@kunbus.com> > > If the imx driver cannot support RS485 it sets the UARTS rs485_supported > structure to NULL. But it still calls uart_get_rs485_mode() which may set > the RS485_ENABLED flag. > The flag however is evaluated by the serial core in uart_configure_port() I wonder if this is the code location where this problem should be addressed. Or alternatively don't let uart_get_rs485_mode() set RS485_ENABLED (and other flags) if rs485_supported doesn't suggest that this works? > [...] > > Signed-off-by: Lino Sanfilippo <l.sanfilippo@kunbus.com> I don't know how picky Greg is here, but formally you missed to add an S-o-b line for the sender of this patch (i.e. you with your gmx address). Best regards Uwe -- Pengutronix e.K. | Uwe Kleine-König | Industrial Linux Solutions | https://www.pengutronix.de/ |
Hi, On 29.09.23 08:39, Uwe Kleine-König wrote: > On Fri, Sep 29, 2023 at 12:12:46AM +0200, Lino Sanfilippo wrote: >> From: Lino Sanfilippo <l.sanfilippo@kunbus.com> >> >> If the imx driver cannot support RS485 it sets the UARTS rs485_supported >> structure to NULL. But it still calls uart_get_rs485_mode() which may set >> the RS485_ENABLED flag. >> The flag however is evaluated by the serial core in uart_configure_port() > > I wonder if this is the code location where this problem should be > addressed. Or alternatively don't let uart_get_rs485_mode() set > RS485_ENABLED (and other flags) if rs485_supported doesn't suggest that > this works? > This is indeed the better solution. Especially since the check is then in the serial core and all RS485 supporting drivers benefit from it. I will change this for v2, thanks! >> [...] >> >> Signed-off-by: Lino Sanfilippo <l.sanfilippo@kunbus.com> > > I don't know how picky Greg is here, but formally you missed to add an > S-o-b line for the sender of this patch (i.e. you with your gmx > address). > Hm, until now there have never been complaints about this. Is this really an issue? Of course I can also S-o-b with my gmx address but adding two S-o-b's for the same person seems a bit odd to me... BR, Lino > Best regards > Uwe >
Hello Lino, On Fri, Sep 29, 2023 at 03:46:52PM +0200, Lino Sanfilippo wrote: > On 29.09.23 08:39, Uwe Kleine-König wrote: > > On Fri, Sep 29, 2023 at 12:12:46AM +0200, Lino Sanfilippo wrote: > >> Signed-off-by: Lino Sanfilippo <l.sanfilippo@kunbus.com> > > > > I don't know how picky Greg is here, but formally you missed to add an > > S-o-b line for the sender of this patch (i.e. you with your gmx > > address). > > > > Hm, until now there have never been complaints about this. Is this really an issue? Of > course I can also S-o-b with my gmx address but adding two S-o-b's for the same person seems > a bit odd to me... The obvious and easy fix is of course to use the author address to send the patches. :-) Best regards Uwe -- Pengutronix e.K. | Uwe Kleine-König | Industrial Linux Solutions | https://www.pengutronix.de/ |
On Fri, Sep 29, 2023 at 12:12:46AM +0200, Lino Sanfilippo wrote: > From: Lino Sanfilippo <l.sanfilippo@kunbus.com> > > If the imx driver cannot support RS485 it sets the UARTS rs485_supported > structure to NULL. But it still calls uart_get_rs485_mode() which may set > the RS485_ENABLED flag. > The flag however is evaluated by the serial core in uart_configure_port() > at port startup and thus may lead to an attempt to configure RS485 even if > it is not supported. > > Avoid this by calling uart_get_rs485_mode() only if RS485 is actually > supported by the driver. Remove also a check for an error condition > that is not possible any more now. > > Signed-off-by: Lino Sanfilippo <l.sanfilippo@kunbus.com> > --- > drivers/tty/serial/imx.c | 14 ++++++-------- > 1 file changed, 6 insertions(+), 8 deletions(-) Why is this patch not marked for stable? thanks, greg k-h
On 29.09.23 07:51, Greg KH wrote: > On Fri, Sep 29, 2023 at 12:12:46AM +0200, Lino Sanfilippo wrote: >> From: Lino Sanfilippo <l.sanfilippo@kunbus.com> >> >> If the imx driver cannot support RS485 it sets the UARTS rs485_supported >> structure to NULL. But it still calls uart_get_rs485_mode() which may set >> the RS485_ENABLED flag. >> The flag however is evaluated by the serial core in uart_configure_port() >> at port startup and thus may lead to an attempt to configure RS485 even if >> it is not supported. >> >> Avoid this by calling uart_get_rs485_mode() only if RS485 is actually >> supported by the driver. Remove also a check for an error condition >> that is not possible any more now. >> >> Signed-off-by: Lino Sanfilippo <l.sanfilippo@kunbus.com> >> --- >> drivers/tty/serial/imx.c | 14 ++++++-------- >> 1 file changed, 6 insertions(+), 8 deletions(-) > > Why is this patch not marked for stable? > Right, it should be, I will correct this, thanks!
© 2016 - 2025 Red Hat, Inc.