linux-media.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 0/2] Small mt9m111 fixes
@ 2019-06-18 11:59 Sakari Ailus
  2019-06-18 11:59 ` [PATCH 1/2] mt9m111: No need to check for the regulator Sakari Ailus
  2019-06-18 11:59 ` [PATCH 2/2] mt9m111: Fix error handling in mt9m111_power_on Sakari Ailus
  0 siblings, 2 replies; 5+ messages in thread
From: Sakari Ailus @ 2019-06-18 11:59 UTC (permalink / raw)
  To: linux-media
  Cc: Robert Jarzmik, Akinobu Mita, Marco Felsch, Michael Grzeschik,
	Enrico Scholz, Mauro Carvalho Chehab

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(-)

-- 
2.11.0


^ permalink raw reply	[flat|nested] 5+ messages in thread

* [PATCH 1/2] mt9m111: No need to check for the regulator
  2019-06-18 11:59 [PATCH 0/2] Small mt9m111 fixes Sakari Ailus
@ 2019-06-18 11:59 ` Sakari Ailus
  2019-06-20  9:15   ` Marco Felsch
  2019-06-18 11:59 ` [PATCH 2/2] mt9m111: Fix error handling in mt9m111_power_on Sakari Ailus
  1 sibling, 1 reply; 5+ messages in thread
From: Sakari Ailus @ 2019-06-18 11:59 UTC (permalink / raw)
  To: linux-media
  Cc: Robert Jarzmik, Akinobu Mita, Marco Felsch, Michael Grzeschik,
	Enrico Scholz, Mauro Carvalho Chehab

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

Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
---
 drivers/media/i2c/mt9m111.c | 11 ++++-------
 1 file changed, 4 insertions(+), 7 deletions(-)

diff --git a/drivers/media/i2c/mt9m111.c b/drivers/media/i2c/mt9m111.c
index 746d1345b505..bb19f8c346cb 100644
--- a/drivers/media/i2c/mt9m111.c
+++ b/drivers/media/i2c/mt9m111.c
@@ -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);
 }
 
-- 
2.11.0


^ permalink raw reply related	[flat|nested] 5+ messages in thread

* [PATCH 2/2] mt9m111: Fix error handling in mt9m111_power_on
  2019-06-18 11:59 [PATCH 0/2] Small mt9m111 fixes Sakari Ailus
  2019-06-18 11:59 ` [PATCH 1/2] mt9m111: No need to check for the regulator Sakari Ailus
@ 2019-06-18 11:59 ` Sakari Ailus
  2019-06-20  9:13   ` Marco Felsch
  1 sibling, 1 reply; 5+ messages in thread
From: Sakari Ailus @ 2019-06-18 11:59 UTC (permalink / raw)
  To: linux-media
  Cc: Robert Jarzmik, Akinobu Mita, Marco Felsch, Michael Grzeschik,
	Enrico Scholz, Mauro Carvalho Chehab

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

Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
---
 drivers/media/i2c/mt9m111.c | 18 +++++++++++++-----
 1 file changed, 13 insertions(+), 5 deletions(-)

diff --git a/drivers/media/i2c/mt9m111.c b/drivers/media/i2c/mt9m111.c
index bb19f8c346cb..593ebe5e2cb6 100644
--- a/drivers/media/i2c/mt9m111.c
+++ b/drivers/media/i2c/mt9m111.c
@@ -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;
 }
-- 
2.11.0


^ permalink raw reply related	[flat|nested] 5+ messages in thread

* Re: [PATCH 2/2] mt9m111: Fix error handling in mt9m111_power_on
  2019-06-18 11:59 ` [PATCH 2/2] mt9m111: Fix error handling in mt9m111_power_on Sakari Ailus
@ 2019-06-20  9:13   ` Marco Felsch
  0 siblings, 0 replies; 5+ messages in thread
From: Marco Felsch @ 2019-06-20  9:13 UTC (permalink / raw)
  To: Sakari Ailus
  Cc: linux-media, Robert Jarzmik, Akinobu Mita, Michael Grzeschik,
	Enrico Scholz, Mauro Carvalho Chehab

Hi Sakari,

On 19-06-18 14:59, Sakari Ailus wrote:
> The mt9m111_power_on function did not properly clean up whenever it
> encountered an error. Do that now.
> 
> Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
> ---
>  drivers/media/i2c/mt9m111.c | 18 +++++++++++++-----
>  1 file changed, 13 insertions(+), 5 deletions(-)

Looks good feel free to add

Reviewed-by: Marco Felsch <m.felsch@pengutronix.de>

Regards,
  Marco

> diff --git a/drivers/media/i2c/mt9m111.c b/drivers/media/i2c/mt9m111.c
> index bb19f8c346cb..593ebe5e2cb6 100644
> --- a/drivers/media/i2c/mt9m111.c
> +++ b/drivers/media/i2c/mt9m111.c
> @@ -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;
>  }
> -- 
> 2.11.0
> 
> 

-- 
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 |

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH 1/2] mt9m111: No need to check for the regulator
  2019-06-18 11:59 ` [PATCH 1/2] mt9m111: No need to check for the regulator Sakari Ailus
@ 2019-06-20  9:15   ` Marco Felsch
  0 siblings, 0 replies; 5+ messages in thread
From: Marco Felsch @ 2019-06-20  9:15 UTC (permalink / raw)
  To: Sakari Ailus
  Cc: linux-media, Robert Jarzmik, Akinobu Mita, Michael Grzeschik,
	Enrico Scholz, Mauro Carvalho Chehab

Hi Sakari,

On 19-06-18 14:59, Sakari Ailus wrote:
> The regulator_get() function returns a regulator when it succeeds. There's
> no need to check whether the regulator is NULL later on.
> 
> Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
> ---
>  drivers/media/i2c/mt9m111.c | 11 ++++-------
>  1 file changed, 4 insertions(+), 7 deletions(-)

Looks good feel free to add my

Reviewed-by: Marco Felsch <m.felsch@pengutronix.de>

Regards,
  Marco

> diff --git a/drivers/media/i2c/mt9m111.c b/drivers/media/i2c/mt9m111.c
> index 746d1345b505..bb19f8c346cb 100644
> --- a/drivers/media/i2c/mt9m111.c
> +++ b/drivers/media/i2c/mt9m111.c
> @@ -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);
>  }
>  
> -- 
> 2.11.0
> 
> 

-- 
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 |

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2019-06-20  9:15 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-06-18 11:59 [PATCH 0/2] Small mt9m111 fixes Sakari Ailus
2019-06-18 11:59 ` [PATCH 1/2] mt9m111: No need to check for the regulator Sakari Ailus
2019-06-20  9:15   ` Marco Felsch
2019-06-18 11:59 ` [PATCH 2/2] mt9m111: Fix error handling in mt9m111_power_on Sakari Ailus
2019-06-20  9:13   ` Marco Felsch

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).