Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1520593

Re: [PATCH v4 01/26] staging: iio: tsl2583: check if chip is in a working state in in_illuminance_calibrate_store

From Jonathan Cameron <jic23@kernel.org>
Newsgroups linux.kernel
Subject Re: [PATCH v4 01/26] staging: iio: tsl2583: check if chip is in a working state in in_illuminance_calibrate_store
Date 2016-11-13 13:00 +0100
Message-ID <sD1C2-89M-15@gated-at.bofh.it> (permalink)
References <sCLdT-5L4-5@gated-at.bofh.it> <sCLdV-5L4-65@gated-at.bofh.it>
Organization linux.* mail to news gateway

Show all headers | View raw


On 12/11/16 18:19, Brian Masney wrote:
> in_illuminance_calibrate_store() did not check to see if the chip is
> in a working state. This patch adds the proper check. The return value
> from taos_als_calibrate() was also not checked in this function, so the
> proper check was also added while changes are being made here.
> 
> Signed-off-by: Brian Masney <masneyb@onstation.org>
Applied
> ---
>  drivers/staging/iio/light/tsl2583.c | 17 ++++++++++++++---
>  1 file changed, 14 insertions(+), 3 deletions(-)
> 
> diff --git a/drivers/staging/iio/light/tsl2583.c b/drivers/staging/iio/light/tsl2583.c
> index 1a7be12..de54e74 100644
> --- a/drivers/staging/iio/light/tsl2583.c
> +++ b/drivers/staging/iio/light/tsl2583.c
> @@ -501,16 +501,27 @@ static ssize_t in_illuminance_calibrate_store(struct device *dev,
>  {
>  	struct iio_dev *indio_dev = dev_to_iio_dev(dev);
>  	struct tsl2583_chip *chip = iio_priv(indio_dev);
> -	int value;
> +	int value, ret;
>  
>  	if (kstrtoint(buf, 0, &value) || value != 1)
>  		return -EINVAL;
>  
>  	mutex_lock(&chip->als_mutex);
> -	taos_als_calibrate(indio_dev);
> +
> +	if (chip->taos_chip_status != TSL258X_CHIP_WORKING) {
> +		ret = -EBUSY;
> +		goto done;
> +	}
> +
> +	ret = taos_als_calibrate(indio_dev);
> +	if (ret < 0)
> +		goto done;
> +
> +	ret = len;
> +done:
>  	mutex_unlock(&chip->als_mutex);
>  
> -	return len;
> +	return ret;
>  }
>  
>  static ssize_t in_illuminance_lux_table_show(struct device *dev,
> 

Back to linux.kernel | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

[PATCH v4 00/26] staging: iio: tsl2583: move out of staging Brian Masney <masneyb@onstation.org> - 2016-11-12 19:30 +0100
  [PATCH v4 14/26] staging: iio: tsl2583: updated code comment to match what the code does Brian Masney <masneyb@onstation.org> - 2016-11-12 19:30 +0100
  [PATCH v4 24/26] staging: iio: tsl2583: remove unnecessary variable initialization Brian Masney <masneyb@onstation.org> - 2016-11-12 19:30 +0100
  [PATCH v4 08/26] staging: iio: tsl2583: unify function and variable prefix to tsl2583_ Brian Masney <masneyb@onstation.org> - 2016-11-12 19:30 +0100
  [PATCH v4 22/26] staging: iio: tsl2583: remove comment for tsl2583_probe() Brian Masney <masneyb@onstation.org> - 2016-11-12 19:30 +0100
    Re: [PATCH v4 22/26] staging: iio: tsl2583: remove comment for  tsl2583_probe() Jonathan Cameron <jic23@kernel.org> - 2016-11-13 13:30 +0100
  [PATCH v4 21/26] staging: iio: tsl2583: clarified comment about clearing interrupts Brian Masney <masneyb@onstation.org> - 2016-11-12 19:30 +0100
  [PATCH v4 10/26] staging: iio: tsl2583: fix comparison between signed and unsigned integers Brian Masney <masneyb@onstation.org> - 2016-11-12 19:30 +0100
  [PATCH v4 01/26] staging: iio: tsl2583: check if chip is in a working state in in_illuminance_calibrate_store Brian Masney <masneyb@onstation.org> - 2016-11-12 19:30 +0100
    Re: [PATCH v4 01/26] staging: iio: tsl2583: check if chip is in a  working state in in_illuminance_calibrate_store Jonathan Cameron <jic23@kernel.org> - 2016-11-13 13:00 +0100
  [PATCH v4 03/26] staging: iio: tsl2583: remove unnecessary chip status checks in suspend/resume Brian Masney <masneyb@onstation.org> - 2016-11-12 19:30 +0100
    Re: [PATCH v4 03/26] staging: iio: tsl2583: remove unnecessary chip  status checks in suspend/resume Jonathan Cameron <jic23@kernel.org> - 2016-11-13 13:00 +0100
  Re: [PATCH v4 26/26] staging: iio: tsl2583: move out of staging Brian Masney <masneyb@onstation.org> - 2016-11-13 17:20 +0100

csiph-web