summaryrefslogtreecommitdiffstats
path: root/drivers/iio/temperature
diff options
context:
space:
mode:
authorVianney le Clément de Saint-Marcq <vianney.leclement@essensium.com>2015-03-30 10:35:02 +0200
committerJonathan Cameron <jic23@kernel.org>2015-04-09 15:10:18 +0100
commitd02e0f8f62f786e9291caf4633e20724c2ab7f99 (patch)
tree7afea62206926e3e5be796a980b5c3f66a5a92f7 /drivers/iio/temperature
parenteb4b07dae4d4b7915333f687675209f677f72fc6 (diff)
downloadlinux-d02e0f8f62f786e9291caf4633e20724c2ab7f99.tar.bz2
iio: mlx90614: Check for errors in read values
The device uses the MSB of the returned temperature value as an error flag. Return a read error when this bit is set. Signed-off-by: Vianney le Clément de Saint-Marcq <vianney.leclement@essensium.com> Cc: Arnout Vandecappelle (Essensium/Mind) <arnout@mind.be> Signed-off-by: Jonathan Cameron <jic23@kernel.org>
Diffstat (limited to 'drivers/iio/temperature')
-rw-r--r--drivers/iio/temperature/mlx90614.c5
1 files changed, 5 insertions, 0 deletions
diff --git a/drivers/iio/temperature/mlx90614.c b/drivers/iio/temperature/mlx90614.c
index 73ec7677496f..06b7b9677982 100644
--- a/drivers/iio/temperature/mlx90614.c
+++ b/drivers/iio/temperature/mlx90614.c
@@ -196,6 +196,11 @@ static int mlx90614_read_raw(struct iio_dev *indio_dev,
if (ret < 0)
return ret;
+
+ /* MSB is an error flag */
+ if (ret & 0x8000)
+ return -EIO;
+
*val = ret;
return IIO_VAL_INT;
case IIO_CHAN_INFO_OFFSET: