From: Andy Shevchenko <andriy.shevchenko@intel.com>
To: wenhua lin <wenhua.lin1994@gmail.com>
Cc: Wenhua Lin <Wenhua.Lin@unisoc.com>,
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>,
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,
Xiongpeng Wu <xiongpeng.wu@unisoc.com>,
Zhaochen Su <Zhaochen.Su@unisoc.com>,
Zhirong Qiu <Zhirong.Qiu@unisoc.com>
Subject: Re: [PATCH] serial: sprd: Return -EPROBE_DEFER when uart clock is not ready
Date: Thu, 27 Nov 2025 11:05:06 +0200 [thread overview]
Message-ID: <aSgUQvExNY2lCpYT@smile.fi.intel.com> (raw)
In-Reply-To: <CAB9BWhfkkssUK7inD1gQA7DJ0YFuXKzboYFQjvZgT9jKSmyZFA@mail.gmail.com>
On Thu, Nov 27, 2025 at 04:44:08PM +0800, wenhua lin wrote:
> On Wed, Nov 26, 2025 at 8:57 PM Andy Shevchenko
> <andriy.shevchenko@intel.com> wrote:
> > On Wed, Oct 22, 2025 at 11:08:40AM +0800, Wenhua Lin wrote:
...
> > > 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;
> >
> > AFAICS this still ignores other issues, what should be done here is to
> > replace devm_clk_get() by devm_clk_get_optional() and drop this NULL
> > assignment.
> The main reason for this change is that the UART driver is
> built-in, while the CLK driver is loaded as a module (ko).
> There may be a situation where the UART driver is loaded first. If
> an EPROBE_DEFER error occurs, the driver will return directly
> and continue waiting for the CLK driver to complete loading.
> If this interface is changed to devm_clk_get_optional, in scenarios
> where dependent components are not yet loaded,
> it will no longer return EPROBE_DEFER but instead return null. This
> behavior may not align with the desired outcome.
No, the _optional does exactly what your code does with the better approach
that may return other errors _in addition to_ the current state of affairs.
So, please switch to _optional variant and drop all that unneeded dances.
clk_uart = devm_clk_get_optional(uport->dev, "uart");
if (IS_ERR(clk_uart)) {
return dev_err_probe(uport->dev, PTR_ERR(clk_uart),
"uart%d can't get uart clock\n", uport->line);
this will return an error when clock is present, but can't be retrieved.
When there is no clock provided at all, it will return NULL.
> > > 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;
Ditto.
--
With Best Regards,
Andy Shevchenko
next prev parent reply other threads:[~2025-11-27 9:05 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-10-22 3:08 [PATCH] serial: sprd: Return -EPROBE_DEFER when uart clock is not ready Wenhua Lin
2025-10-22 6:55 ` 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 [this message]
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=aSgUQvExNY2lCpYT@smile.fi.intel.com \
--to=andriy.shevchenko@intel.com \
--cc=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