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>
This commit is contained in:
Vianney le Clément de Saint-Marcq 2015-03-30 10:35:02 +02:00 committed by Jonathan Cameron
parent eb4b07dae4
commit d02e0f8f62

View File

@ -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: