diff options
author | Michael Hennerich <michael.hennerich@analog.com> | 2011-09-02 17:25:46 +0100 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@suse.de> | 2011-09-06 16:03:37 -0700 |
commit | a3ef65d3225f1ff378da4798b9c0c68f13265900 (patch) | |
tree | eea87067a5e689a79e54b037a75b11df0e2a20d7 /drivers/staging/iio/adc/ad7291.c | |
parent | e68b1db1b573ddb5b9d793df01ddd9aaa3d120c3 (diff) |
staging:iio:adc:ad7192: return len and fix out of range checking
Signed-off-by: Michael Hennerich <michael.hennerich@analog.com>
Signed-off-by: Jonathan Cameron <jic23@cam.ac.uk>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
Diffstat (limited to 'drivers/staging/iio/adc/ad7291.c')
-rw-r--r-- | 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 4697ebbfd08d..c486d72167b1 100644 --- a/drivers/staging/iio/adc/ad7291.c +++ b/drivers/staging/iio/adc/ad7291.c @@ -241,10 +241,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, @@ -352,7 +356,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) == |