public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Wenhua Lin <Wenhua.Lin@unisoc.com>
To: Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
	Jiri Slaby <jirislaby@kernel.org>, Rob Herring <robh@kernel.org>,
	Krzysztof Kozlowski <krzk+dt@kernel.org>,
	Conor Dooley <conor+dt@kernel.org>
Cc: Orson Zhai <orsonzhai@gmail.com>,
	Baolin Wang <baolin.wang@linux.alibaba.com>,
	Chunyan Zhang <zhang.lyra@gmail.com>,
	Cixi Geng <cixi.geng@linux.dev>, <linux-kernel@vger.kernel.org>,
	<linux-serial@vger.kernel.org>,
	wenhua lin <wenhua.lin1994@gmail.com>,
	Wenhua Lin <Wenhua.Lin@unisoc.com>,
	Xiongpeng Wu <xiongpeng.wu@unisoc.com>,
	Zhaochen Su <Zhaochen.Su@unisoc.com>,
	Zhirong Qiu <Zhirong.Qiu@unisoc.com>
Subject: [PATCH] serial: sprd: Return -EPROBE_DEFER when uart clock is not ready
Date: Wed, 22 Oct 2025 11:08:40 +0800	[thread overview]
Message-ID: <20251022030840.956589-1-Wenhua.Lin@unisoc.com> (raw)

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>
---
 drivers/tty/serial/sprd_serial.c | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/drivers/tty/serial/sprd_serial.c b/drivers/tty/serial/sprd_serial.c
index 8c9366321f8e..092755f35683 100644
--- a/drivers/tty/serial/sprd_serial.c
+++ b/drivers/tty/serial/sprd_serial.c
@@ -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;
-- 
2.34.1


             reply	other threads:[~2025-10-22  3:42 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-10-22  3:08 Wenhua Lin [this message]
2025-10-22  6:55 ` [PATCH] serial: sprd: Return -EPROBE_DEFER when uart clock is not ready Chunyan Zhang
2025-10-23  2:10   ` wenhua lin
2025-10-24  1:42     ` Chunyan Zhang
2025-11-10  3:05       ` wenhua lin
2025-11-26 12:57 ` Andy Shevchenko
2025-11-27  8:44   ` wenhua lin
2025-11-27  9:05     ` Andy Shevchenko
2025-12-10  6:48       ` wenhua lin

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20251022030840.956589-1-Wenhua.Lin@unisoc.com \
    --to=wenhua.lin@unisoc.com \
    --cc=Zhaochen.Su@unisoc.com \
    --cc=Zhirong.Qiu@unisoc.com \
    --cc=baolin.wang@linux.alibaba.com \
    --cc=cixi.geng@linux.dev \
    --cc=conor+dt@kernel.org \
    --cc=gregkh@linuxfoundation.org \
    --cc=jirislaby@kernel.org \
    --cc=krzk+dt@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-serial@vger.kernel.org \
    --cc=orsonzhai@gmail.com \
    --cc=robh@kernel.org \
    --cc=wenhua.lin1994@gmail.com \
    --cc=xiongpeng.wu@unisoc.com \
    --cc=zhang.lyra@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox