diff options
author | Vianney le Clément de Saint-Marcq <vianney.leclement@essensium.com> | 2015-03-30 10:35:02 +0200 |
---|---|---|
committer | Jonathan Cameron <jic23@kernel.org> | 2015-04-09 15:10:18 +0100 |
commit | d02e0f8f62f786e9291caf4633e20724c2ab7f99 (patch) | |
tree | 7afea62206926e3e5be796a980b5c3f66a5a92f7 | |
parent | eb4b07dae4d4b7915333f687675209f677f72fc6 (diff) | |
download | op-kernel-dev-d02e0f8f62f786e9291caf4633e20724c2ab7f99.zip op-kernel-dev-d02e0f8f62f786e9291caf4633e20724c2ab7f99.tar.gz |
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>
-rw-r--r-- | drivers/iio/temperature/mlx90614.c | 5 |
1 files changed, 5 insertions, 0 deletions
diff --git a/drivers/iio/temperature/mlx90614.c b/drivers/iio/temperature/mlx90614.c index 73ec767..06b7b96 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: |