]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
serial: sprd: Return -EPROBE_DEFER when uart clock is not ready
authorWenhua Lin <Wenhua.Lin@unisoc.com>
Wed, 22 Oct 2025 03:08:40 +0000 (11:08 +0800)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Wed, 26 Nov 2025 12:12:19 +0000 (13:12 +0100)
In sprd_clk_init(), when devm_clk_get() returns -EPROBE_DEFER
for either uart or source clock, we should propagate the
error instead of just warning and continuing with NULL clocks.

Currently the driver only emits a warning when clock acquisition
fails and proceeds with NULL clock pointers. This can lead to
issues later when the clocks are actually needed. More importantly,
when the clock provider is not ready yet and returns -EPROBE_DEFER,
we should return this error to allow deferred probing.

This change adds explicit checks for -EPROBE_DEFER after both:
1. devm_clk_get(uport->dev, uart)
2. devm_clk_get(uport->dev, source)

When -EPROBE_DEFER is encountered, the function now returns
-EPROBE_DEFER to let the driver framework retry probing
later when the clock dependencies are resolved.

Signed-off-by: Wenhua Lin <Wenhua.Lin@unisoc.com>
Link: https://patch.msgid.link/20251022030840.956589-1-Wenhua.Lin@unisoc.com
Reviewed-by: Cixi Geng <cixi.geng@linux.dev>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/tty/serial/sprd_serial.c

index 8c9366321f8e734fa65d09e0448f24855759d5de..092755f356836ae75fa9d49a66866a36877a92a1 100644 (file)
@@ -1133,6 +1133,9 @@ static int sprd_clk_init(struct uart_port *uport)
 
        clk_uart = devm_clk_get(uport->dev, "uart");
        if (IS_ERR(clk_uart)) {
+               if (PTR_ERR(clk_uart) == -EPROBE_DEFER)
+                       return -EPROBE_DEFER;
+
                dev_warn(uport->dev, "uart%d can't get uart clock\n",
                         uport->line);
                clk_uart = NULL;
@@ -1140,6 +1143,9 @@ static int sprd_clk_init(struct uart_port *uport)
 
        clk_parent = devm_clk_get(uport->dev, "source");
        if (IS_ERR(clk_parent)) {
+               if (PTR_ERR(clk_parent) == -EPROBE_DEFER)
+                       return -EPROBE_DEFER;
+
                dev_warn(uport->dev, "uart%d can't get source clock\n",
                         uport->line);
                clk_parent = NULL;