From: Joshua Crofts <joshua.crofts1@gmail.com>
To: "Li Youhong" <dayou5941@163.com>
Cc: biju.das.jz@bp.renesas.com, wbg@kernel.org,
linux-iio@vger.kernel.org, linux-renesas-soc@vger.kernel.org,
Li Youhong <liyouhong@kylinos.cn>
Subject: Re: [PATCH] counter: rz-mtu3-cnt: check clk_prepare_enable() return value
Date: Fri, 28 Aug 2026 11:35:44 +0200 [thread overview]
Message-ID: <20260828113544.00000aa4@gmail.com> (raw)
In-Reply-To: <20260828071123.179670-1-dayou5941@163.com>
On Fri, 28 Aug 2026 15:11:23 +0800
"Li Youhong" <dayou5941@163.com> wrote:
> From: Li Youhong <liyouhong@kylinos.cn>
>
> The driver ignored clk_prepare_enable() failures during probe and
> runtime resume. Propagate the error so probe does not continue with
> the clock disabled and resume does not report success falsely.
>
> Signed-off-by: Li Youhong <liyouhong@kylinos.cn>
> ---
> drivers/counter/rz-mtu3-cnt.c | 9 +++++----
> 1 file changed, 5 insertions(+), 4 deletions(-)
>
> diff --git a/drivers/counter/rz-mtu3-cnt.c b/drivers/counter/rz-mtu3-cnt.c
> index 7bfb6979193c..6f746cf598c0 100644
> --- a/drivers/counter/rz-mtu3-cnt.c
> +++ b/drivers/counter/rz-mtu3-cnt.c
> @@ -817,9 +817,7 @@ static int rz_mtu3_cnt_pm_runtime_resume(struct device *dev)
> {
> struct clk *const clk = dev_get_drvdata(dev);
>
> - clk_prepare_enable(clk);
> -
> - return 0;
> + return clk_prepare_enable(clk);
> }
>
> static DEFINE_RUNTIME_DEV_PM_OPS(rz_mtu3_cnt_pm_ops,
> @@ -861,7 +859,10 @@ static int rz_mtu3_cnt_probe(struct platform_device *pdev)
>
> mutex_init(&priv->lock);
> platform_set_drvdata(pdev, priv->clk);
> - clk_prepare_enable(priv->clk);
> + ret = clk_prepare_enable(priv->clk);
> + if (ret)
> + return ret;
> +
> pm_runtime_set_active(&pdev->dev);
> pm_runtime_enable(&pdev->dev);
> ret = devm_add_action_or_reset(&pdev->dev, rz_mtu3_cnt_pm_disable, dev);
This is fine, but any pm_runtime_get*() function called in this driver
would return a negative error code if clk_prepare_enable() fails. You
should definitely add checks whether any pm_runtime_get*() functions
succeeded, otherwise subsequent reads/writes will produce garbage.
--
Kind regards,
Joshua Crofts
next prev parent reply other threads:[~2026-08-28 9:35 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-08-28 7:11 [PATCH] counter: rz-mtu3-cnt: check clk_prepare_enable() return value Li Youhong
2026-08-28 9:24 ` Vidhu Sarwal
2026-08-28 9:32 ` 李佑鸿
2026-08-28 9:35 ` Joshua Crofts [this message]
2026-08-28 9:39 ` Biju Das
2026-08-28 9:43 ` Biju Das
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=20260828113544.00000aa4@gmail.com \
--to=joshua.crofts1@gmail.com \
--cc=biju.das.jz@bp.renesas.com \
--cc=dayou5941@163.com \
--cc=linux-iio@vger.kernel.org \
--cc=linux-renesas-soc@vger.kernel.org \
--cc=liyouhong@kylinos.cn \
--cc=wbg@kernel.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.