On 11.12.23 12:00, Ilpo Järvinen wrote:
On Sat, 9 Dec 2023, Lino Sanfilippo wrote:
If the imx driver cannot support RS485 it sets the ports rs485_supported structure to NULL.
No, an embedded struct inside struct uart_port cannot be set to NULL, it's always there.
Hmm, ok. What I meant was that the structure is nullified. "set to NULL" is maybe a bit misleading. I will correct this.
Looking into the code, that setting of rs485_supported from imx_no_rs485 is actually superfluous as it should be already cleared to zeros on alloc.
Yes. BTW: Another "no_rs485" configuration setting can be found in the ar933x driver. If we do not want to keep those assignments I can remove the one for the imx driver with the next version of this patch...
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. Remove this check, 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