Message ID | 20241121202506.37602-1-jiashengjiangcool@gmail.com |
---|---|
State | Superseded |
Headers | show |
Series | media: marvell: Add check for clk_enable() | expand |
Hi Jiasheng, On 21/11/2024 21:25, Jiasheng Jiang wrote: > Add check for the return value of clk_enable() to gurantee the success. > > Fixes: 81a409bfd551 ("media: marvell-ccic: provide a clock for the sensor") > Signed-off-by: Jiasheng Jiang <jiashengjiangcool@gmail.com> > --- > drivers/media/platform/marvell/mcam-core.c | 4 +++- > 1 file changed, 3 insertions(+), 1 deletion(-) > > diff --git a/drivers/media/platform/marvell/mcam-core.c b/drivers/media/platform/marvell/mcam-core.c > index 9ec01228f907..47023e701e12 100644 > --- a/drivers/media/platform/marvell/mcam-core.c > +++ b/drivers/media/platform/marvell/mcam-core.c > @@ -935,7 +935,9 @@ static int mclk_enable(struct clk_hw *hw) > ret = pm_runtime_resume_and_get(cam->dev); > if (ret < 0) > return ret; > - clk_enable(cam->clk[0]); > + ret = clk_enable(cam->clk[0]); > + if (ret) > + return ret; If clk_enable returns an error, doesn't this also require a call to pm_runtime_put() to balance the pm_runtime_resume_and_get() call? Regards, Hans > mcam_reg_write(cam, REG_CLKCTRL, (mclk_src << 29) | mclk_div); > mcam_ctlr_power_up(cam); >
Hi Hans, On Tue, Dec 3, 2024 at 2:14 AM Hans Verkuil <hverkuil@xs4all.nl> wrote: > > Hi Jiasheng, > > On 21/11/2024 21:25, Jiasheng Jiang wrote: > > Add check for the return value of clk_enable() to gurantee the success. > > > > Fixes: 81a409bfd551 ("media: marvell-ccic: provide a clock for the sensor") > > Signed-off-by: Jiasheng Jiang <jiashengjiangcool@gmail.com> > > --- > > drivers/media/platform/marvell/mcam-core.c | 4 +++- > > 1 file changed, 3 insertions(+), 1 deletion(-) > > > > diff --git a/drivers/media/platform/marvell/mcam-core.c b/drivers/media/platform/marvell/mcam-core.c > > index 9ec01228f907..47023e701e12 100644 > > --- a/drivers/media/platform/marvell/mcam-core.c > > +++ b/drivers/media/platform/marvell/mcam-core.c > > @@ -935,7 +935,9 @@ static int mclk_enable(struct clk_hw *hw) > > ret = pm_runtime_resume_and_get(cam->dev); > > if (ret < 0) > > return ret; > > - clk_enable(cam->clk[0]); > > + ret = clk_enable(cam->clk[0]); > > + if (ret) > > + return ret; > > If clk_enable returns an error, doesn't this also require a call to pm_runtime_put() to > balance the pm_runtime_resume_and_get() call? Thanks. I will submit a v2 to add error handling. -Jiasheng > Regards, > > Hans > > > mcam_reg_write(cam, REG_CLKCTRL, (mclk_src << 29) | mclk_div); > > mcam_ctlr_power_up(cam); > > >
diff --git a/drivers/media/platform/marvell/mcam-core.c b/drivers/media/platform/marvell/mcam-core.c index 9ec01228f907..47023e701e12 100644 --- a/drivers/media/platform/marvell/mcam-core.c +++ b/drivers/media/platform/marvell/mcam-core.c @@ -935,7 +935,9 @@ static int mclk_enable(struct clk_hw *hw) ret = pm_runtime_resume_and_get(cam->dev); if (ret < 0) return ret; - clk_enable(cam->clk[0]); + ret = clk_enable(cam->clk[0]); + if (ret) + return ret; mcam_reg_write(cam, REG_CLKCTRL, (mclk_src << 29) | mclk_div); mcam_ctlr_power_up(cam);
Add check for the return value of clk_enable() to gurantee the success. Fixes: 81a409bfd551 ("media: marvell-ccic: provide a clock for the sensor") Signed-off-by: Jiasheng Jiang <jiashengjiangcool@gmail.com> --- drivers/media/platform/marvell/mcam-core.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)