[PATCH] serial: xilinx_uartps: fix rs485 initialization at boot

j.turek posted 1 patch 1 day, 22 hours ago
drivers/tty/serial/xilinx_uartps.c | 5 +++--
1 file changed, 3 insertions(+), 2 deletions(-)
[PATCH] serial: xilinx_uartps: fix rs485 initialization at boot
Posted by j.turek 1 day, 22 hours ago
When 'linux,rs485-enabled-at-boot-time;' property is enabled in device-tree
and there is no rts-gpio defined there is NULL pointer dereference in
function 'cdns_rts_gpio_enable' because 'cdns_uart->port->membase' pointer
is not set at this point

Signed-off-by: Jakub Turek <jakub.turek@elsta.tech>

Fixes: fccc9d9233f9 ("tty: serial: uartps: Add rs485 support to uartps driver")
---
 drivers/tty/serial/xilinx_uartps.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/drivers/tty/serial/xilinx_uartps.c b/drivers/tty/serial/xilinx_uartps.c
index c793fc74c26b..1e4d54fd5762 100644
--- a/drivers/tty/serial/xilinx_uartps.c
+++ b/drivers/tty/serial/xilinx_uartps.c
@@ -1816,8 +1816,6 @@ static int cdns_uart_probe(struct platform_device *pdev)
 		console_port = port;
 	}
 #endif
-	if (cdns_uart_data->port->rs485.flags & SER_RS485_ENABLED)
-		cdns_rs485_rx_setup(cdns_uart_data);
 
 	rc = uart_add_one_port(&cdns_uart_uart_driver, port);
 	if (rc) {
@@ -1826,6 +1824,9 @@ static int cdns_uart_probe(struct platform_device *pdev)
 		goto err_out_pm_disable;
 	}
 
+	if (cdns_uart_data->port->rs485.flags & SER_RS485_ENABLED)
+		cdns_rs485_rx_setup(cdns_uart_data);
+
 #ifdef CONFIG_SERIAL_XILINX_PS_UART_CONSOLE
 	/* This is not port which is used for console that's why clean it up */
 	if (console_port == port &&
-- 
2.34.1
Re: [PATCH] serial: xilinx_uartps: fix rs485 initialization at boot
Posted by Sean Anderson 1 day, 21 hours ago
On 12/16/25 10:26, j.turek wrote:
> When 'linux,rs485-enabled-at-boot-time;' property is enabled in device-tree
> and there is no rts-gpio defined there is NULL pointer dereference in
> function 'cdns_rts_gpio_enable' because 'cdns_uart->port->membase' pointer
> is not set at this point
> 
> Signed-off-by: Jakub Turek <jakub.turek@elsta.tech>
> 
> Fixes: fccc9d9233f9 ("tty: serial: uartps: Add rs485 support to uartps driver")
> ---
>  drivers/tty/serial/xilinx_uartps.c | 5 +++--
>  1 file changed, 3 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/tty/serial/xilinx_uartps.c b/drivers/tty/serial/xilinx_uartps.c
> index c793fc74c26b..1e4d54fd5762 100644
> --- a/drivers/tty/serial/xilinx_uartps.c
> +++ b/drivers/tty/serial/xilinx_uartps.c
> @@ -1816,8 +1816,6 @@ static int cdns_uart_probe(struct platform_device *pdev)
>  		console_port = port;
>  	}
>  #endif
> -	if (cdns_uart_data->port->rs485.flags & SER_RS485_ENABLED)
> -		cdns_rs485_rx_setup(cdns_uart_data);
>  
>  	rc = uart_add_one_port(&cdns_uart_uart_driver, port);
>  	if (rc) {
> @@ -1826,6 +1824,9 @@ static int cdns_uart_probe(struct platform_device *pdev)
>  		goto err_out_pm_disable;
>  	}
>  
> +	if (cdns_uart_data->port->rs485.flags & SER_RS485_ENABLED)
> +		cdns_rs485_rx_setup(cdns_uart_data);
> +
>  #ifdef CONFIG_SERIAL_XILINX_PS_UART_CONSOLE
>  	/* This is not port which is used for console that's why clean it up */
>  	if (console_port == port &&

Is probe the right place to do this configuration? Maybe
cdns_rs485_rx_setup should get moved to cdns_rs485_config.

--Sean