Skip to contentSkip to conversation

Small mt9m111 fixes

PATCH In review Sakari Ailus 2 participants 5 messages Jun 18, 2019 – Jun 20, 2019

Subsystems (2)
lore
Share & tools
lore

Sakari Ailus

author maintainer
#0 lore raw

cover Small mt9m111 fixes

Hi,

Here are a few simple fixes for the mt9m111 driver.

Sakari Ailus (2):
mt9m111: No need to check for the regulator
mt9m111: Fix error handling in mt9m111_power_on

 drivers/media/i2c/mt9m111.c | 27 ++++++++++++++++-----------
 1 file changed, 16 insertions(+), 11 deletions(-)
Signature · 1 line
2.11.0
author maintainer
#1 lore raw

PATCH 1/2 mt9m111: No need to check for the regulator

The regulator_get() function returns a regulator when it succeeds. There's no need to check whether the regulator is NULL later on.

---
 drivers/media/i2c/mt9m111.c | 11 ++++-------
 1 file changed, 4 insertions(+), 7 deletions(-)
drivers/media/i2c/mt9m111.c +4 -7
index 746d1345b505..bb19f8c346cb 100644
@@ -984,11 +984,9 @@ static int mt9m111_power_on(struct mt9m111 *mt9m111)
 	if (ret < 0)
 		return ret;
 
-	if (mt9m111->regulator) {
-		ret = regulator_enable(mt9m111->regulator);
-		if (ret < 0)
-			return ret;
-	}
+	ret = regulator_enable(mt9m111->regulator);
+	if (ret < 0)
+		return ret;
 
 	ret = mt9m111_resume(mt9m111);
 	if (ret < 0) {
@@ -1002,8 +1000,7 @@ static int mt9m111_power_on(struct mt9m111 *mt9m111)
 static void mt9m111_power_off(struct mt9m111 *mt9m111)
 {
 	mt9m111_suspend(mt9m111);
-	if (mt9m111->regulator)
-		regulator_disable(mt9m111->regulator);
+	regulator_disable(mt9m111->regulator);
 	v4l2_clk_disable(mt9m111->clk);
 }
 
Signature · 1 line
2.11.0
Reviewed-by on v1 1/2
#2 lore raw

Re: [PATCH 1/2] mt9m111: No need to check for the regulator

Hi Sakari,

Quoted 7 lines · Sakari Ailus

The regulator_get() function returns a regulator when it succeeds. There's no need to check whether the regulator is NULL later on.

---
 drivers/media/i2c/mt9m111.c | 11 ++++-------
 1 file changed, 4 insertions(+), 7 deletions(-)

Looks good feel free to add my

Regards,
Marco

Quoted 33 lines
drivers/media/i2c/mt9m111.c +4 -7
index 746d1345b505..bb19f8c346cb 100644
@@ -984,11 +984,9 @@ static int mt9m111_power_on(struct mt9m111 *mt9m111)
 	if (ret < 0)
 		return ret;
 
-	if (mt9m111->regulator) {
-		ret = regulator_enable(mt9m111->regulator);
-		if (ret < 0)
-			return ret;
-	}
+	ret = regulator_enable(mt9m111->regulator);
+	if (ret < 0)
+		return ret;
 
 	ret = mt9m111_resume(mt9m111);
 	if (ret < 0) {
@@ -1002,8 +1000,7 @@ static int mt9m111_power_on(struct mt9m111 *mt9m111)
 static void mt9m111_power_off(struct mt9m111 *mt9m111)
 {
 	mt9m111_suspend(mt9m111);
-	if (mt9m111->regulator)
-		regulator_disable(mt9m111->regulator);
+	regulator_disable(mt9m111->regulator);
 	v4l2_clk_disable(mt9m111->clk);
 }
 
Signature · 1 line
2.11.0
Signature · 4 lines
Pengutronix e.K.                           |                             |
Industrial Linux Solutions                 | http://www.pengutronix.de/  |
Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0    |
Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-5555 |
author maintainer
#3 lore raw

PATCH 2/2 mt9m111: Fix error handling in mt9m111_power_on

In reply to Sakari Ailus

The mt9m111_power_on function did not properly clean up whenever it encountered an error. Do that now.

---
 drivers/media/i2c/mt9m111.c | 18 +++++++++++++-----
 1 file changed, 13 insertions(+), 5 deletions(-)
drivers/media/i2c/mt9m111.c +13 -5
index bb19f8c346cb..593ebe5e2cb6 100644
@@ -986,13 +986,21 @@ static int mt9m111_power_on(struct mt9m111 *mt9m111)
 
 	ret = regulator_enable(mt9m111->regulator);
 	if (ret < 0)
-		return ret;
+		goto out_clk_disable;
 
 	ret = mt9m111_resume(mt9m111);
-	if (ret < 0) {
-		dev_err(&client->dev, "Failed to resume the sensor: %d\n", ret);
-		v4l2_clk_disable(mt9m111->clk);
-	}
+	if (ret < 0)
+		goto out_regulator_disable;
+
+	return 0;
+
+out_regulator_disable:
+	regulator_disable(mt9m111->regulator);
+
+out_clk_disable:
+	v4l2_clk_disable(mt9m111->clk);
+
+	dev_err(&client->dev, "Failed to resume the sensor: %d\n", ret);
 
 	return ret;
 }
Signature · 1 line
2.11.0
Reviewed-by on v1 2/2
#4 lore raw

Re: [PATCH 2/2] mt9m111: Fix error handling in mt9m111_power_on

Hi Sakari,

Quoted 7 lines · Sakari Ailus

The mt9m111_power_on function did not properly clean up whenever it encountered an error. Do that now.

---
 drivers/media/i2c/mt9m111.c | 18 +++++++++++++-----
 1 file changed, 13 insertions(+), 5 deletions(-)

Looks good feel free to add

Regards,
Marco

Quoted 35 lines
drivers/media/i2c/mt9m111.c +13 -5
index bb19f8c346cb..593ebe5e2cb6 100644
@@ -986,13 +986,21 @@ static int mt9m111_power_on(struct mt9m111 *mt9m111)
 
 	ret = regulator_enable(mt9m111->regulator);
 	if (ret < 0)
-		return ret;
+		goto out_clk_disable;
 
 	ret = mt9m111_resume(mt9m111);
-	if (ret < 0) {
-		dev_err(&client->dev, "Failed to resume the sensor: %d\n", ret);
-		v4l2_clk_disable(mt9m111->clk);
-	}
+	if (ret < 0)
+		goto out_regulator_disable;
+
+	return 0;
+
+out_regulator_disable:
+	regulator_disable(mt9m111->regulator);
+
+out_clk_disable:
+	v4l2_clk_disable(mt9m111->clk);
+
+	dev_err(&client->dev, "Failed to resume the sensor: %d\n", ret);
 
 	return ret;
 }
Signature · 1 line
2.11.0
Signature · 4 lines
Pengutronix e.K.                           |                             |
Industrial Linux Solutions                 | http://www.pengutronix.de/  |
Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0    |
Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-5555 |