From d02e0f8f62f786e9291caf4633e20724c2ab7f99 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Vianney=20le=20Cl=C3=A9ment=20de=20Saint-Marcq?= Date: Mon, 30 Mar 2015 10:35:02 +0200 Subject: [PATCH] iio: mlx90614: Check for errors in read values MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit 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 Cc: Arnout Vandecappelle (Essensium/Mind) Signed-off-by: Jonathan Cameron --- drivers/iio/temperature/mlx90614.c | 5 +++++ 1 file changed, 5 insertions(+) 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: -- 2.20.1