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>
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,
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) ==