RE: [PATCH] counter: rz-mtu3-cnt: check clk_prepare_enable() return value

Biju Das <[email protected]>
Newsgroups org.kernel.vger.linux-renesas-soc,org.kernel.vger.linux-iio
Message-ID <TYCPR01MB11332D67B5121D22F05E2CAEE86AC2@TYCPR01MB11332.jpnprd01.prod.outlook.com>
Hi Li Youhong,

Thanks for the patch.

> -----Original Message-----
> From: Li Youhong <[email protected]>
> Sent: 28 August 2026 08:11
> Subject: [PATCH] counter: rz-mtu3-cnt: check clk_prepare_enable() return value
> 
> From: Li Youhong <[email protected]>
> 
> 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 <[email protected]>
> ---
>  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);

Maybe also add similar error check in disable() for
Completeness.

>  }
> 
>  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);

This API can return error and same issue will happen.

Cheers,
Biju

>  	pm_runtime_enable(&pdev->dev);
>  	ret = devm_add_action_or_reset(&pdev->dev, rz_mtu3_cnt_pm_disable, dev);
> --
> 2.25.1
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.