Skip to contentSkip to conversation

media: marvell: Add check for clk_enable()

PATCH In review Jiasheng Jiang 2 participants 3 messages Nov 21, 2024 – Dec 3, 2024

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 media: marvell: Add check for clk_enable()

Add check for the return value of clk_enable() to gurantee the success.

Fixes 81a409bfd551 ("media: marvell-ccic: provide a clock for the sensor")
---
 drivers/media/platform/marvell/mcam-core.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
drivers/media/platform/marvell/mcam-core.c +3 -1
index 9ec01228f907..47023e701e12 100644
@@ -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);
 
Signature · 1 line
2.25.1
#1 lore raw

Hi Jiasheng,

Quoted 13 lines · Jiasheng Jiang

Add check for the return value of clk_enable() to gurantee the success.

Fixes 81a409bfd551 ("media: marvell-ccic: provide a clock for the sensor")
---
 drivers/media/platform/marvell/mcam-core.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
drivers/media/platform/marvell/mcam-core.c +0 -0
index 9ec01228f907..47023e701e12 100644

drivers/media/platform/marvell/mcam-core.c static int mclk_enable(struct clk_hw *hw) · line 940

Quoted 7 lines
drivers/media/platform/marvell/mcam-core.c +3 -1
@@ -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

Quoted 3 lines
drivers/media/platform/marvell/mcam-core.c +0 -0
 	mcam_reg_write(cam, REG_CLKCTRL, (mclk_src << 29) | mclk_div);
 	mcam_ctlr_power_up(cam);
 
#2 lore raw

Hi Hans,

Quoted 12 lines · Hans Verkuil

Hi Jiasheng,

Quoted 8 lines · Jiasheng Jiang

Add check for the return value of clk_enable() to gurantee the success.

Fixes 81a409bfd551 ("media: marvell-ccic: provide a clock for the sensor")
---
 drivers/media/platform/marvell/mcam-core.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
Quoted 15 lines

drivers/media/platform/marvell/mcam-core.c static int mclk_enable(struct clk_hw *hw) · line 940

Quoted 12 lines
drivers/media/platform/marvell/mcam-core.c +3 -1
index 9ec01228f907..47023e701e12 100644
@@ -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

Quoted 8 lines

Regards,

Hans

Quoted 3 lines
drivers/media/platform/marvell/mcam-core.c +0 -0
      mcam_reg_write(cam, REG_CLKCTRL, (mclk_src << 29) | mclk_div);
      mcam_ctlr_power_up(cam);