diff mbox

[2/3] smiapp: Check for GPIO validity using gpio_is_valid()

Message ID 1399163517-5220-3-git-send-email-sakari.ailus@iki.fi (mailing list archive)
State New, archived
Headers show

Commit Message

Sakari Ailus May 4, 2014, 12:31 a.m. UTC
Do not use our special value, SMIAPP_NO_XSHUTDOWN.

Signed-off-by: Sakari Ailus <sakari.ailus@iki.fi>
---
 drivers/media/i2c/smiapp/smiapp-core.c |   10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)

Comments

Laurent Pinchart May 9, 2014, 12:18 p.m. UTC | #1
Hi Sakari,

Thank you for the patch.

On Sunday 04 May 2014 03:31:56 Sakari Ailus wrote:
> Do not use our special value, SMIAPP_NO_XSHUTDOWN.
> 
> Signed-off-by: Sakari Ailus <sakari.ailus@iki.fi>

Wouldn't it make sense to switch to the gpiod API ? That change could then 
replace this patch. If you would like to do so in an incremental patch 
instead,

Acked-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>

> ---
>  drivers/media/i2c/smiapp/smiapp-core.c |   10 +++++-----
>  1 file changed, 5 insertions(+), 5 deletions(-)
> 
> diff --git a/drivers/media/i2c/smiapp/smiapp-core.c
> b/drivers/media/i2c/smiapp/smiapp-core.c index c1d6d1d..e4037c8 100644
> --- a/drivers/media/i2c/smiapp/smiapp-core.c
> +++ b/drivers/media/i2c/smiapp/smiapp-core.c
> @@ -1128,7 +1128,7 @@ static int smiapp_power_on(struct smiapp_sensor
> *sensor) }
>  	usleep_range(1000, 1000);
> 
> -	if (sensor->platform_data->xshutdown != SMIAPP_NO_XSHUTDOWN)
> +	if (gpio_is_valid(sensor->platform_data->xshutdown))
>  		gpio_set_value(sensor->platform_data->xshutdown, 1);
> 
>  	sleep = SMIAPP_RESET_DELAY(sensor->platform_data->ext_clk);
> @@ -1238,7 +1238,7 @@ static int smiapp_power_on(struct smiapp_sensor
> *sensor) return 0;
> 
>  out_cci_addr_fail:
> -	if (sensor->platform_data->xshutdown != SMIAPP_NO_XSHUTDOWN)
> +	if (gpio_is_valid(sensor->platform_data->xshutdown))
>  		gpio_set_value(sensor->platform_data->xshutdown, 0);
>  	if (sensor->platform_data->set_xclk)
>  		sensor->platform_data->set_xclk(&sensor->src->sd, 0);
> @@ -1264,7 +1264,7 @@ static void smiapp_power_off(struct smiapp_sensor
> *sensor) SMIAPP_REG_U8_SOFTWARE_RESET,
>  			     SMIAPP_SOFTWARE_RESET);
> 
> -	if (sensor->platform_data->xshutdown != SMIAPP_NO_XSHUTDOWN)
> +	if (gpio_is_valid(sensor->platform_data->xshutdown))
>  		gpio_set_value(sensor->platform_data->xshutdown, 0);
>  	if (sensor->platform_data->set_xclk)
>  		sensor->platform_data->set_xclk(&sensor->src->sd, 0);
> @@ -2378,7 +2378,7 @@ static int smiapp_registered(struct v4l2_subdev
> *subdev) }
>  	}
> 
> -	if (sensor->platform_data->xshutdown != SMIAPP_NO_XSHUTDOWN) {
> +	if (gpio_is_valid(sensor->platform_data->xshutdown)) {
>  		if (devm_gpio_request_one(&client->dev,
>  					  sensor->platform_data->xshutdown, 0,
>  					  "SMIA++ xshutdown") != 0) {
> @@ -2830,7 +2830,7 @@ static int smiapp_remove(struct i2c_client *client)
>  	unsigned int i;
> 
>  	if (sensor->power_count) {
> -		if (sensor->platform_data->xshutdown != SMIAPP_NO_XSHUTDOWN)
> +		if (gpio_is_valid(sensor->platform_data->xshutdown))
>  			gpio_set_value(sensor->platform_data->xshutdown, 0);
>  		if (sensor->platform_data->set_xclk)
>  			sensor->platform_data->set_xclk(&sensor->src->sd, 0);
Sakari Ailus May 9, 2014, 12:38 p.m. UTC | #2
Hi Laurent,

On Fri, May 09, 2014 at 02:18:24PM +0200, Laurent Pinchart wrote:
> On Sunday 04 May 2014 03:31:56 Sakari Ailus wrote:
> > Do not use our special value, SMIAPP_NO_XSHUTDOWN.
> > 
> > Signed-off-by: Sakari Ailus <sakari.ailus@iki.fi>
> 
> Wouldn't it make sense to switch to the gpiod API ? That change could then 
> replace this patch. If you would like to do so in an incremental patch 
> instead,

I'll do that a little later.

> Acked-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>

Thanks!
diff mbox

Patch

diff --git a/drivers/media/i2c/smiapp/smiapp-core.c b/drivers/media/i2c/smiapp/smiapp-core.c
index c1d6d1d..e4037c8 100644
--- a/drivers/media/i2c/smiapp/smiapp-core.c
+++ b/drivers/media/i2c/smiapp/smiapp-core.c
@@ -1128,7 +1128,7 @@  static int smiapp_power_on(struct smiapp_sensor *sensor)
 	}
 	usleep_range(1000, 1000);
 
-	if (sensor->platform_data->xshutdown != SMIAPP_NO_XSHUTDOWN)
+	if (gpio_is_valid(sensor->platform_data->xshutdown))
 		gpio_set_value(sensor->platform_data->xshutdown, 1);
 
 	sleep = SMIAPP_RESET_DELAY(sensor->platform_data->ext_clk);
@@ -1238,7 +1238,7 @@  static int smiapp_power_on(struct smiapp_sensor *sensor)
 	return 0;
 
 out_cci_addr_fail:
-	if (sensor->platform_data->xshutdown != SMIAPP_NO_XSHUTDOWN)
+	if (gpio_is_valid(sensor->platform_data->xshutdown))
 		gpio_set_value(sensor->platform_data->xshutdown, 0);
 	if (sensor->platform_data->set_xclk)
 		sensor->platform_data->set_xclk(&sensor->src->sd, 0);
@@ -1264,7 +1264,7 @@  static void smiapp_power_off(struct smiapp_sensor *sensor)
 			     SMIAPP_REG_U8_SOFTWARE_RESET,
 			     SMIAPP_SOFTWARE_RESET);
 
-	if (sensor->platform_data->xshutdown != SMIAPP_NO_XSHUTDOWN)
+	if (gpio_is_valid(sensor->platform_data->xshutdown))
 		gpio_set_value(sensor->platform_data->xshutdown, 0);
 	if (sensor->platform_data->set_xclk)
 		sensor->platform_data->set_xclk(&sensor->src->sd, 0);
@@ -2378,7 +2378,7 @@  static int smiapp_registered(struct v4l2_subdev *subdev)
 		}
 	}
 
-	if (sensor->platform_data->xshutdown != SMIAPP_NO_XSHUTDOWN) {
+	if (gpio_is_valid(sensor->platform_data->xshutdown)) {
 		if (devm_gpio_request_one(&client->dev,
 					  sensor->platform_data->xshutdown, 0,
 					  "SMIA++ xshutdown") != 0) {
@@ -2830,7 +2830,7 @@  static int smiapp_remove(struct i2c_client *client)
 	unsigned int i;
 
 	if (sensor->power_count) {
-		if (sensor->platform_data->xshutdown != SMIAPP_NO_XSHUTDOWN)
+		if (gpio_is_valid(sensor->platform_data->xshutdown))
 			gpio_set_value(sensor->platform_data->xshutdown, 0);
 		if (sensor->platform_data->set_xclk)
 			sensor->platform_data->set_xclk(&sensor->src->sd, 0);