Linux IIO development
 help / color / mirror / Atom feed
* [PATCH] iio: light: pa12203001: Poweroff chip  if register fails
@ 2015-11-06  9:10 Adriana Reus
  2015-11-08 15:35 ` Jonathan Cameron
  0 siblings, 1 reply; 2+ messages in thread
From: Adriana Reus @ 2015-11-06  9:10 UTC (permalink / raw)
  To: jic23; +Cc: linux-iio, Adriana Reus

Make sure we poweroff the chip if for any reason iio_register
returns an error.

Signed-off-by: Adriana Reus <adriana.reus@intel.com>
---
 drivers/iio/light/pa12203001.c | 16 +++++++++++-----
 1 file changed, 11 insertions(+), 5 deletions(-)

diff --git a/drivers/iio/light/pa12203001.c b/drivers/iio/light/pa12203001.c
index 45f7bde..76a9e12 100644
--- a/drivers/iio/light/pa12203001.c
+++ b/drivers/iio/light/pa12203001.c
@@ -381,17 +381,23 @@ static int pa12203001_probe(struct i2c_client *client,
 		return ret;
 
 	ret = pm_runtime_set_active(&client->dev);
-	if (ret < 0) {
-		pa12203001_power_chip(indio_dev, PA12203001_CHIP_DISABLE);
-		return ret;
-	}
+	if (ret < 0)
+		goto out_err;
 
 	pm_runtime_enable(&client->dev);
 	pm_runtime_set_autosuspend_delay(&client->dev,
 					 PA12203001_SLEEP_DELAY_MS);
 	pm_runtime_use_autosuspend(&client->dev);
 
-	return iio_device_register(indio_dev);
+	ret = iio_device_register(indio_dev);
+	if (ret < 0)
+		goto out_err;
+
+	return 0;
+
+out_err:
+	pa12203001_power_chip(indio_dev, PA12203001_CHIP_DISABLE);
+	return ret;
 }
 
 static int pa12203001_remove(struct i2c_client *client)
-- 
1.9.1

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

* Re: [PATCH] iio: light: pa12203001: Poweroff chip if register fails
  2015-11-06  9:10 [PATCH] iio: light: pa12203001: Poweroff chip if register fails Adriana Reus
@ 2015-11-08 15:35 ` Jonathan Cameron
  0 siblings, 0 replies; 2+ messages in thread
From: Jonathan Cameron @ 2015-11-08 15:35 UTC (permalink / raw)
  To: Adriana Reus; +Cc: linux-iio

On 06/11/15 09:10, Adriana Reus wrote:
> Make sure we poweroff the chip if for any reason iio_register
> returns an error.
> 
> Signed-off-by: Adriana Reus <adriana.reus@intel.com>
Good spot.

Applied to the togreg branch of iio.git - initially pushed out as
testing etc etc.

Jonathan
> ---
>  drivers/iio/light/pa12203001.c | 16 +++++++++++-----
>  1 file changed, 11 insertions(+), 5 deletions(-)
> 
> diff --git a/drivers/iio/light/pa12203001.c b/drivers/iio/light/pa12203001.c
> index 45f7bde..76a9e12 100644
> --- a/drivers/iio/light/pa12203001.c
> +++ b/drivers/iio/light/pa12203001.c
> @@ -381,17 +381,23 @@ static int pa12203001_probe(struct i2c_client *client,
>  		return ret;
>  
>  	ret = pm_runtime_set_active(&client->dev);
> -	if (ret < 0) {
> -		pa12203001_power_chip(indio_dev, PA12203001_CHIP_DISABLE);
> -		return ret;
> -	}
> +	if (ret < 0)
> +		goto out_err;
>  
>  	pm_runtime_enable(&client->dev);
>  	pm_runtime_set_autosuspend_delay(&client->dev,
>  					 PA12203001_SLEEP_DELAY_MS);
>  	pm_runtime_use_autosuspend(&client->dev);
>  
> -	return iio_device_register(indio_dev);
> +	ret = iio_device_register(indio_dev);
> +	if (ret < 0)
> +		goto out_err;
> +
> +	return 0;
> +
> +out_err:
> +	pa12203001_power_chip(indio_dev, PA12203001_CHIP_DISABLE);
> +	return ret;
>  }
>  
>  static int pa12203001_remove(struct i2c_client *client)
> 


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

end of thread, other threads:[~2015-11-08 15:35 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-11-06  9:10 [PATCH] iio: light: pa12203001: Poweroff chip if register fails Adriana Reus
2015-11-08 15:35 ` Jonathan Cameron

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox