Re: [PATCH v1 1/8] iio: accel: bma220: Fix returned codes from bma220_init(), bma220_deinit()

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Mon, 31 Aug 2020 12:08:06 +0300
Andy Shevchenko <andriy.shevchenko@xxxxxxxxxxxxxxx> wrote:

> Potentially bma220_init() and bma220_deinit() may return positive codes.
> Fix the logic to return proper error codes instead.
> 
> Signed-off-by: Andy Shevchenko <andriy.shevchenko@xxxxxxxxxxxxxxx>
Hi Andy

A nice straight forward set and I suspect we aren't going to get any other
reviews, hence...

Series applied to the togreg branch of iio.git and pushed out as testing for
the autobuilders to poke at it.

Thanks,

Jonathan

> ---
>  drivers/iio/accel/bma220_spi.c | 14 +++++++++-----
>  1 file changed, 9 insertions(+), 5 deletions(-)
> 
> diff --git a/drivers/iio/accel/bma220_spi.c b/drivers/iio/accel/bma220_spi.c
> index da8b36cc8628..3247b9c8abcb 100644
> --- a/drivers/iio/accel/bma220_spi.c
> +++ b/drivers/iio/accel/bma220_spi.c
> @@ -198,10 +198,12 @@ static int bma220_init(struct spi_device *spi)
>  
>  	/* Make sure the chip is powered on */
>  	ret = bma220_read_reg(spi, BMA220_REG_SUSPEND);
> +	if (ret == BMA220_SUSPEND_WAKE)
> +		ret = bma220_read_reg(spi, BMA220_REG_SUSPEND);
>  	if (ret < 0)
>  		return ret;
> -	else if (ret == BMA220_SUSPEND_WAKE)
> -		return bma220_read_reg(spi, BMA220_REG_SUSPEND);
> +	if (ret == BMA220_SUSPEND_WAKE)
> +		return -EBUSY;
>  
>  	return 0;
>  }
> @@ -212,10 +214,12 @@ static int bma220_deinit(struct spi_device *spi)
>  
>  	/* Make sure the chip is powered off */
>  	ret = bma220_read_reg(spi, BMA220_REG_SUSPEND);
> +	if (ret == BMA220_SUSPEND_SLEEP)
> +		ret = bma220_read_reg(spi, BMA220_REG_SUSPEND);
>  	if (ret < 0)
>  		return ret;
> -	else if (ret == BMA220_SUSPEND_SLEEP)
> -		return bma220_read_reg(spi, BMA220_REG_SUSPEND);
> +	if (ret == BMA220_SUSPEND_SLEEP)
> +		return -EBUSY;
>  
>  	return 0;
>  }
> @@ -245,7 +249,7 @@ static int bma220_probe(struct spi_device *spi)
>  	indio_dev->available_scan_masks = bma220_accel_scan_masks;
>  
>  	ret = bma220_init(data->spi_device);
> -	if (ret < 0)
> +	if (ret)
>  		return ret;
>  
>  	ret = iio_triggered_buffer_setup(indio_dev, iio_pollfunc_store_time,




[Index of Archives]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Yosemite News]     [Linux Input]     [Linux Kernel]     [Linux SCSI]     [X.org]

  Powered by Linux