aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/iio/adc
diff options
context:
space:
mode:
authorGreg Kroah-Hartman <gregkh@linuxfoundation.org>2014-07-07 17:59:07 -0700
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2014-07-07 17:59:07 -0700
commitc1a567d31b5488f4593eae7ca215264947b355ca (patch)
tree347b8226a2e92676dc2618d8109b99aa275aa31e /drivers/iio/adc
parentstaging: cxt1e1: remove driver (diff)
parentLinux 3.16-rc4 (diff)
downloadlinux-dev-c1a567d31b5488f4593eae7ca215264947b355ca.tar.xz
linux-dev-c1a567d31b5488f4593eae7ca215264947b355ca.zip
Merge 3.16-rc4 into staging-next
We want the staging tree fixes in here as well. Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'drivers/iio/adc')
-rw-r--r--drivers/iio/adc/ad799x.c8
1 files changed, 6 insertions, 2 deletions
diff --git a/drivers/iio/adc/ad799x.c b/drivers/iio/adc/ad799x.c
index 7e08c601f66e..6cf9ee18a216 100644
--- a/drivers/iio/adc/ad799x.c
+++ b/drivers/iio/adc/ad799x.c
@@ -426,9 +426,12 @@ static int ad799x_write_event_value(struct iio_dev *indio_dev,
int ret;
struct ad799x_state *st = iio_priv(indio_dev);
+ if (val < 0 || val > RES_MASK(chan->scan_type.realbits))
+ return -EINVAL;
+
mutex_lock(&indio_dev->mlock);
ret = ad799x_i2c_write16(st, ad799x_threshold_reg(chan, dir, info),
- val);
+ val << chan->scan_type.shift);
mutex_unlock(&indio_dev->mlock);
return ret;
@@ -451,7 +454,8 @@ static int ad799x_read_event_value(struct iio_dev *indio_dev,
mutex_unlock(&indio_dev->mlock);
if (ret < 0)
return ret;
- *val = valin;
+ *val = (valin >> chan->scan_type.shift) &
+ RES_MASK(chan->scan_type.realbits);
return IIO_VAL_INT;
}