Skip to content

Commit 74eab89

Browse files
linosanfilippo-kunbusgregkh
authored andcommitted
serial: core, imx: do not set RS485 enabled if it is not supported
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: 00d7a00 ("serial: imx: Fill in rs485_supported") Cc: Shawn Guo <[email protected]> Cc: Sascha Hauer <[email protected]> Cc: <[email protected]> Suggested-by: Uwe Kleine-König <[email protected]> Signed-off-by: Lino Sanfilippo <[email protected]> Reviewed-by: Ilpo Järvinen <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Greg Kroah-Hartman <[email protected]>
1 parent c739869 commit 74eab89

File tree

2 files changed

+3
-7
lines changed

2 files changed

+3
-7
lines changed

drivers/tty/serial/imx.c

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2211,7 +2211,6 @@ static enum hrtimer_restart imx_trigger_stop_tx(struct hrtimer *t)
22112211
return HRTIMER_NORESTART;
22122212
}
22132213

2214-
static const struct serial_rs485 imx_no_rs485 = {}; /* No RS485 if no RTS */
22152214
static const struct serial_rs485 imx_rs485_supported = {
22162215
.flags = SER_RS485_ENABLED | SER_RS485_RTS_ON_SEND | SER_RS485_RTS_AFTER_SEND |
22172216
SER_RS485_RX_DURING_TX,
@@ -2295,8 +2294,6 @@ static int imx_uart_probe(struct platform_device *pdev)
22952294
/* RTS is required to control the RS485 transmitter */
22962295
if (sport->have_rtscts || sport->have_rtsgpio)
22972296
sport->port.rs485_supported = imx_rs485_supported;
2298-
else
2299-
sport->port.rs485_supported = imx_no_rs485;
23002297
sport->port.flags = UPF_BOOT_AUTOCONF;
23012298
timer_setup(&sport->timer, imx_uart_timeout, 0);
23022299

@@ -2331,10 +2328,6 @@ static int imx_uart_probe(struct platform_device *pdev)
23312328
if (ret)
23322329
goto err_clk;
23332330

2334-
if (sport->port.rs485.flags & SER_RS485_ENABLED &&
2335-
(!sport->have_rtscts && !sport->have_rtsgpio))
2336-
dev_err(&pdev->dev, "no RTS control, disabling rs485\n");
2337-
23382331
/*
23392332
* If using the i.MX UART RTS/CTS control then the RTS (CTS_B)
23402333
* signal cannot be set low during transmission in case the

drivers/tty/serial/serial_core.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3607,6 +3607,9 @@ int uart_get_rs485_mode(struct uart_port *port)
36073607
u32 rs485_delay[2];
36083608
int ret;
36093609

3610+
if (!(port->rs485_supported.flags & SER_RS485_ENABLED))
3611+
return 0;
3612+
36103613
ret = device_property_read_u32_array(dev, "rs485-rts-delay",
36113614
rs485_delay, 2);
36123615
if (!ret) {

0 commit comments

Comments
 (0)