iio: mlx90614: Check for errors in read values
authorVianney le Clément de Saint-Marcq <vianney.leclement@essensium.com>
Mon, 30 Mar 2015 08:35:02 +0000 (10:35 +0200)
committerJonathan Cameron <jic23@kernel.org>
Thu, 9 Apr 2015 14:10:18 +0000 (15:10 +0100)
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>
drivers/iio/temperature/mlx90614.c

index 73ec767..06b7b96 100644 (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: