From: Shawn Lin <shawn.lin@rock-chips.com>
To: "ping.gao" <ping.gao@samsung.com>
Cc: shawn.lin@rock-chips.com, jh80.chung@samsung.com,
sebastian.reichel@collabora.com, linux-mmc@vger.kernel.org,
ulf.hansson@linaro.org, linux-kernel@vger.kernel.org,
hy50.seo@samsung.com, kwangwon.min@samsung.com
Subject: Re: [PATCH] drivers: mmc: Replace manual devm_clk_get/clk_prepare_enable with devm_clk_get_optional_enabled
Date: Fri, 23 Jan 2026 14:48:14 +0800 [thread overview]
Message-ID: <2531d1ef-2450-4479-b32e-b9c861ffadd1@rock-chips.com> (raw)
In-Reply-To: <20260123054527.4151947-1-ping.gao@samsung.com>
在 2026/01/23 星期五 13:45, ping.gao 写道:
> By using , we:
> - Automatically handle optional clocks (return NULL if not present).
> - Ensure the clock is enabled upon acquisition.
> This change reduces code complexity and improves reliability.
>
The commit tile should be:
mmc: dw_mmc: Replace....
> before biu_clk in dwmmc driver devm_clk_get fail, but it's ERR_PTR,
> not null,it will panic when call clk_prepare
> log is below:
----8<----
>
> diff --git a/drivers/mmc/host/dw_mmc.c b/drivers/mmc/host/dw_mmc.c
> index 61f6986f15ef..18981d010b62 100644
> --- a/drivers/mmc/host/dw_mmc.c
> +++ b/drivers/mmc/host/dw_mmc.c
> @@ -3375,20 +3375,10 @@ int dw_mci_probe(struct dw_mci *host)
> "platform data not available\n");
> }
>
> - host->biu_clk = devm_clk_get(host->dev, "biu");
> - if (IS_ERR(host->biu_clk)) {
> - dev_dbg(host->dev, "biu clock not available\n");
> - ret = PTR_ERR(host->biu_clk);
> - if (ret == -EPROBE_DEFER)
> - return ret;
> -
> - } else {
> - ret = clk_prepare_enable(host->biu_clk);
> - if (ret) {
> - dev_err(host->dev, "failed to enable biu clock\n");
> - return ret;
> - }
> - }
> + host->biu_clk = devm_clk_get_optional_enabled(host->dev, "biu");
This won't work, as biu_clk will automatically be disabled, unprepared
and freed when dwmmc host is unbound from the bus. Given we need to
control biu_clk in runtime, you could just use devm_clk_get_optional,
it will return NULL which serves as a dummy clk, if biu isn't present.
Then clk_prepare_enable/clk_disable_unprepare for biu_clk is safe to
bail out internally.
> + ret = PTR_ERR_OR_ZERO(host->biu_clk);
> + if (ret)
> + return dev_err_probe(host->dev, ret, "failed to get biu clock\n");
>
> host->ciu_clk = devm_clk_get(host->dev, "ciu");
> if (IS_ERR(host->ciu_clk)) {
prev parent reply other threads:[~2026-01-23 6:53 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <CGME20260123054113epcas5p26e6418eb49d2caa8e3ad048d14386189@epcas5p2.samsung.com>
2026-01-23 5:45 ` ping.gao
2026-01-23 6:48 ` Shawn Lin [this message]
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=2531d1ef-2450-4479-b32e-b9c861ffadd1@rock-chips.com \
--to=shawn.lin@rock-chips.com \
--cc=hy50.seo@samsung.com \
--cc=jh80.chung@samsung.com \
--cc=kwangwon.min@samsung.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mmc@vger.kernel.org \
--cc=ping.gao@samsung.com \
--cc=sebastian.reichel@collabora.com \
--cc=ulf.hansson@linaro.org \
/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
all inboxes | Powered by JetHome®