Re: [PATCH 10/12] iio: ad7192: return len and fix out of range checking

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

 



On 08/31/11 11:57, michael.hennerich@xxxxxxxxxx wrote:
> From: Michael Hennerich <michael.hennerich@xxxxxxxxxx>
> 
> 
Is 4096 a valid value?  I thought we only had 12 bits (hence the 0xFFF)
That would make maximum 4095
> Signed-off-by: Michael Hennerich <michael.hennerich@xxxxxxxxxx>
> ---
>  drivers/staging/iio/adc/ad7291.c |   10 +++++++---
>  1 files changed, 7 insertions(+), 3 deletions(-)
> 
> diff --git a/drivers/staging/iio/adc/ad7291.c b/drivers/staging/iio/adc/ad7291.c
> index 1a2fa66..334951c 100644
> --- a/drivers/staging/iio/adc/ad7291.c
> +++ b/drivers/staging/iio/adc/ad7291.c
> @@ -240,10 +240,14 @@ static inline ssize_t ad7291_set_hyst(struct device *dev,
>  
>  	if (ret < 0)
>  		return ret;
> -	if (data < 4096)
> +	if (data > AD7291_VALUE_MASK)
>  		return -EINVAL;
>  
> -	return ad7291_i2c_write(chip, this_attr->address, data);
> +	ret = ad7291_i2c_write(chip, this_attr->address, data);
> +	if (ret < 0)
> +		return ret;
> +
> +	return len;
>  }
>  
>  static IIO_DEVICE_ATTR(in_temp0_thresh_both_hyst_raw,
> @@ -351,7 +355,7 @@ static int ad7291_write_event_value(struct iio_dev *indio_dev,
>  
>  	switch (IIO_EVENT_CODE_EXTRACT_CHAN_TYPE(event_code)) {
>  	case IIO_VOLTAGE:
> -		if (val > 0xFFF || val < 0)
> +		if (val > AD7291_VALUE_MASK || val < 0)
>  			return -EINVAL;
>  		reg = ad7291_limit_regs[IIO_EVENT_CODE_EXTRACT_NUM(event_code)]
>  			[!(IIO_EVENT_CODE_EXTRACT_DIR(event_code) ==

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


[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