diff mbox

[v4,4/4] iio: imu: inv_mpu6050: clean read channel data error path

Message ID 1524479613-23954-4-git-send-email-jmaneyrol@invensense.com (mailing list archive)
State New, archived
Headers show

Commit Message

Jean-Baptiste Maneyrol April 23, 2018, 10:33 a.m. UTC
Delete the useless ored result and give a second chance to turn
the chip back off at the end.

Signed-off-by: Jean-Baptiste Maneyrol <jmaneyrol@invensense.com>
---
 drivers/iio/imu/inv_mpu6050/inv_mpu_core.c | 16 ++++++++++------
 1 file changed, 10 insertions(+), 6 deletions(-)

Comments

Jonathan Cameron April 28, 2018, 3:57 p.m. UTC | #1
On Mon, 23 Apr 2018 12:33:33 +0200
Jean-Baptiste Maneyrol <jmaneyrol@invensense.com> wrote:

> Delete the useless ored result and give a second chance to turn
> the chip back off at the end.
> 
> Signed-off-by: Jean-Baptiste Maneyrol <jmaneyrol@invensense.com>
Hmm. I'm not totally sold on the 'try powering down' again
option.  That seems somewhat inelegant.  Ah well, it's a minor
thing as all sorts of horrible things will happen if we fail the second
powerdown anyway.

Applied to the togreg branch of iio.git and pushed out as testing
for the autobuilders to play with it.

Thanks,

Jonathan

> ---
>  drivers/iio/imu/inv_mpu6050/inv_mpu_core.c | 16 ++++++++++------
>  1 file changed, 10 insertions(+), 6 deletions(-)
> 
> diff --git a/drivers/iio/imu/inv_mpu6050/inv_mpu_core.c b/drivers/iio/imu/inv_mpu6050/inv_mpu_core.c
> index 79b44fd..aafa777 100644
> --- a/drivers/iio/imu/inv_mpu6050/inv_mpu_core.c
> +++ b/drivers/iio/imu/inv_mpu6050/inv_mpu_core.c
> @@ -338,7 +338,7 @@ static int inv_mpu6050_read_channel_data(struct iio_dev *indio_dev,
>  {
>  	struct inv_mpu6050_state *st = iio_priv(indio_dev);
>  	int result;
> -	int ret = IIO_VAL_INT;
> +	int ret;
>  
>  	result = iio_device_claim_direct_mode(indio_dev);
>  	if (result)
> @@ -383,14 +383,18 @@ static int inv_mpu6050_read_channel_data(struct iio_dev *indio_dev,
>  		break;
>  	}
>  
> -error_power_off:
> -	result |= inv_mpu6050_set_power_itg(st, false);
> -error_release:
> -	iio_device_release_direct_mode(indio_dev);
> +	result = inv_mpu6050_set_power_itg(st, false);
>  	if (result)
> -		return result;
> +		goto error_power_off;
> +	iio_device_release_direct_mode(indio_dev);
>  
>  	return ret;
> +
> +error_power_off:
> +	inv_mpu6050_set_power_itg(st, false);
> +error_release:
> +	iio_device_release_direct_mode(indio_dev);
> +	return result;
>  }
>  
>  static int

--
To unsubscribe from this list: send the line "unsubscribe linux-iio" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
diff mbox

Patch

diff --git a/drivers/iio/imu/inv_mpu6050/inv_mpu_core.c b/drivers/iio/imu/inv_mpu6050/inv_mpu_core.c
index 79b44fd..aafa777 100644
--- a/drivers/iio/imu/inv_mpu6050/inv_mpu_core.c
+++ b/drivers/iio/imu/inv_mpu6050/inv_mpu_core.c
@@ -338,7 +338,7 @@  static int inv_mpu6050_read_channel_data(struct iio_dev *indio_dev,
 {
 	struct inv_mpu6050_state *st = iio_priv(indio_dev);
 	int result;
-	int ret = IIO_VAL_INT;
+	int ret;
 
 	result = iio_device_claim_direct_mode(indio_dev);
 	if (result)
@@ -383,14 +383,18 @@  static int inv_mpu6050_read_channel_data(struct iio_dev *indio_dev,
 		break;
 	}
 
-error_power_off:
-	result |= inv_mpu6050_set_power_itg(st, false);
-error_release:
-	iio_device_release_direct_mode(indio_dev);
+	result = inv_mpu6050_set_power_itg(st, false);
 	if (result)
-		return result;
+		goto error_power_off;
+	iio_device_release_direct_mode(indio_dev);
 
 	return ret;
+
+error_power_off:
+	inv_mpu6050_set_power_itg(st, false);
+error_release:
+	iio_device_release_direct_mode(indio_dev);
+	return result;
 }
 
 static int