All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] counter: rz-mtu3-cnt: check clk_prepare_enable() return value
@ 2026-08-28  7:11 Li Youhong
  2026-08-28  9:24 ` Vidhu Sarwal
                   ` (2 more replies)
  0 siblings, 3 replies; 6+ messages in thread
From: Li Youhong @ 2026-08-28  7:11 UTC (permalink / raw)
  To: biju.das.jz, wbg; +Cc: linux-iio, linux-renesas-soc, Li Youhong

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


^ permalink raw reply related	[flat|nested] 6+ messages in thread

* Re: [PATCH] counter: rz-mtu3-cnt: check clk_prepare_enable() return value
  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
  2026-08-28  9:39 ` Biju Das
  2 siblings, 1 reply; 6+ messages in thread
From: Vidhu Sarwal @ 2026-08-28  9:24 UTC (permalink / raw)
  To: Li Youhong; +Cc: biju.das.jz, wbg, linux-iio, linux-renesas-soc, Li Youhong

On Fri, Aug 28, 2026 at 12:46 PM 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>
> ---

This is a bug fix, so I think it should carry a Fixes: tag. Both call
sites look like they date back to the original driver.

Thanks,
Vidhu

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re:Re: [PATCH] counter: rz-mtu3-cnt: check clk_prepare_enable() return value
  2026-08-28  9:24 ` Vidhu Sarwal
@ 2026-08-28  9:32   ` 李佑鸿 
  0 siblings, 0 replies; 6+ messages in thread
From: 李佑鸿  @ 2026-08-28  9:32 UTC (permalink / raw)
  To: Vidhu Sarwal; +Cc: biju.das.jz, wbg, linux-iio, linux-renesas-soc, Li Youhong


















At 2026-08-28 17:24:54, "Vidhu Sarwal" <vidhu.linux@gmail.com> wrote:
>On Fri, Aug 28, 2026 at 12:46 PM 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>
>> ---
>
>This is a bug fix, so I think it should carry a Fixes: tag. Both call
>sites look like they date back to the original driver.
>
>Thanks,

>Vidhu


Thanks for the review. I'll add a Fixes: tag and send a v2.

Thanks,
Li Youhong

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH] counter: rz-mtu3-cnt: check clk_prepare_enable() return value
  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:35 ` Joshua Crofts
  2026-08-28  9:39 ` Biju Das
  2 siblings, 0 replies; 6+ messages in thread
From: Joshua Crofts @ 2026-08-28  9:35 UTC (permalink / raw)
  To: Li Youhong; +Cc: biju.das.jz, wbg, linux-iio, linux-renesas-soc, Li Youhong

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

^ permalink raw reply	[flat|nested] 6+ messages in thread

* RE: [PATCH] counter: rz-mtu3-cnt: check clk_prepare_enable() return value
  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:35 ` Joshua Crofts
@ 2026-08-28  9:39 ` Biju Das
  2026-08-28  9:43   ` Biju Das
  2 siblings, 1 reply; 6+ messages in thread
From: Biju Das @ 2026-08-28  9:39 UTC (permalink / raw)
  To: Li Youhong, wbg@kernel.org
  Cc: linux-iio@vger.kernel.org, linux-renesas-soc@vger.kernel.org,
	Li Youhong

Hi Li Youhong,

Thanks for the patch.

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

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


^ permalink raw reply	[flat|nested] 6+ messages in thread

* RE: [PATCH] counter: rz-mtu3-cnt: check clk_prepare_enable() return value
  2026-08-28  9:39 ` Biju Das
@ 2026-08-28  9:43   ` Biju Das
  0 siblings, 0 replies; 6+ messages in thread
From: Biju Das @ 2026-08-28  9:43 UTC (permalink / raw)
  To: Biju Das, Li Youhong, wbg@kernel.org
  Cc: linux-iio@vger.kernel.org, linux-renesas-soc@vger.kernel.org,
	Li Youhong



> -----Original Message-----
> From: Biju Das <biju.das.jz@bp.renesas.com>
> Sent: 28 August 2026 10:39
> To: Li Youhong <dayou5941@163.com>; wbg@kernel.org
> Cc: 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
> 
> Hi Li Youhong,
> 
> Thanks for the patch.
> 
> > -----Original Message-----
> > From: Li Youhong <dayou5941@163.com>
> > Sent: 28 August 2026 08:11
> > Subject: [PATCH] counter: rz-mtu3-cnt: check clk_prepare_enable()
> > return value
> >
> > 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);
> 
> Maybe also add similar error check in disable() for Completeness.

Oops ignore me, disable is void function

Cheers,
Biju

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2026-08-28  9:43 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
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
2026-08-28  9:39 ` Biju Das
2026-08-28  9:43   ` Biju Das

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.