Skip to contentSkip to conversation

media: ov7251: add missing clk_disable_unprepare() on error in ov7251_set_power_on()

PATCH In review Yang Yingliang 3 participants 5 messages Jun 17, 2022 – Jun 20, 2022

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

PATCH 1/1 media: ov7251: add missing clk_disable_unprepare() on error in ov7251_set_power_on()

Add the missing clk_disable_unprepare() before return from ov7251_set_power_on() in the error handling case.

Fixes 9e1d3012cc10 ("media: i2c: Remove .s_power() from ov7251")
---
 drivers/media/i2c/ov7251.c | 1 +
 1 file changed, 1 insertion(+)
drivers/media/i2c/ov7251.c +1 -0
index 0e7be15bc20a..40c207d1d7af 100644
@@ -934,6 +934,7 @@ static int ov7251_set_power_on(struct device *dev)
 					ARRAY_SIZE(ov7251_global_init_setting));
 	if (ret < 0) {
 		dev_err(ov7251->dev, "error during global init\n");
+		clk_disable_unprepare(ov7251->xclk);
 		ov7251_regulators_disable(ov7251);
 		return ret;
 	}
Signature · 1 line
2.25.1
#1 lore raw
Quoted 2 lines · Yang Yingliang

Add the missing clk_disable_unprepare() before return from ov7251_set_power_on() in the error handling case.

...

drivers/media/i2c/ov7251.c static int ov7251_set_power_on(struct device *dev) · line 938

Quoted 4 lines
drivers/media/i2c/ov7251.c +1 -0
 	if (ret < 0) {
 		dev_err(ov7251->dev, "error during global init\n");
+		clk_disable_unprepare(ov7251->xclk);
 		ov7251_regulators_disable(ov7251);

Logically it should go here. Please, read a code above this check.

Quoted 2 lines
drivers/media/i2c/ov7251.c +0 -0
 		return ret;
 	}
Signature · 2 lines
With Best Regards,
Andy Shevchenko
#2 lore raw

Hi,

Quoted 10 lines · Andy Shevchenko
Quoted 2 lines · Yang Yingliang

Add the missing clk_disable_unprepare() before return from ov7251_set_power_on() in the error handling case.

...

drivers/media/i2c/ov7251.c static int ov7251_set_power_on(struct device *dev) · line 938

Quoted 4 lines
  	if (ret < 0) {
  		dev_err(ov7251->dev, "error during global init\n");
drivers/media/i2c/ov7251.c +1 -0
+		clk_disable_unprepare(ov7251->xclk);
  		ov7251_regulators_disable(ov7251);

Logically it should go here. Please, read a code above this check.

Do you mean print the error code on error path ?

Thanks,
Yang

Quoted 3 lines
Quoted 3 lines
  		return ret;
  	}
#3 lore raw
Quoted 2 lines · Yang Yingliang
Quoted 1 line · Andy Shevchenko

On Fri, Jun 17, 2022 at 09:39:43AM +0800, Yang Yingliang wrote:

...

Quoted 6 lines
Quoted 5 lines

drivers/media/i2c/ov7251.c static int ov7251_set_power_on(struct device *dev) · line 938

Quoted 4 lines
  	if (ret < 0) {
  		dev_err(ov7251->dev, "error during global init\n");
drivers/media/i2c/ov7251.c +1 -0
+		clk_disable_unprepare(ov7251->xclk);
  		ov7251_regulators_disable(ov7251);

Logically it should go here. Please, read a code above this check.

Do you mean print the error code on error path ?

The new code, you added, should be in correct order (reversed in comparison to resource allocation / registration).

Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
  		return ret;
  	}
Signature · 2 lines
With Best Regards,
Andy Shevchenko
Reviewed-by on v1 1/1
#4 lore raw
In reply to Yang Yingliang

Hello

Quoted 6 lines · Yang Yingliang

Add the missing clk_disable_unprepare() before return from ov7251_set_power_on() in the error handling case.

Fixes 9e1d3012cc10 ("media: i2c: Remove .s_power() from ov7251")

Thanks for spotting this - with Andy's comment addressed:

Quoted 16 lines
---
 drivers/media/i2c/ov7251.c | 1 +
 1 file changed, 1 insertion(+)
drivers/media/i2c/ov7251.c +1 -0
index 0e7be15bc20a..40c207d1d7af 100644
@@ -934,6 +934,7 @@ static int ov7251_set_power_on(struct device *dev)
 					ARRAY_SIZE(ov7251_global_init_setting));
 	if (ret < 0) {
 		dev_err(ov7251->dev, "error during global init\n");
+		clk_disable_unprepare(ov7251->xclk);
 		ov7251_regulators_disable(ov7251);
 		return ret;
 	}