Re: [PATCH] counter: rz-mtu3-cnt: check clk_prepare_enable() return value
Joshua Crofts <[email protected]>
| Newsgroups | org.kernel.vger.linux-renesas-soc,org.kernel.vger.linux-iio |
|---|---|
| Message-ID | <[email protected]> |
On Fri, 28 Aug 2026 15:11:23 +0800 "Li Youhong" <[email protected]> wrote: > 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); > } > > 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