From: Vianney le Clément de Saint-Marcq Date: Mon, 30 Mar 2015 08:35:02 +0000 (+0200) Subject: iio: mlx90614: Check for errors in read values X-Git-Url: http://git.lede-project.org./?a=commitdiff_plain;h=d02e0f8f62f786e9291caf4633e20724c2ab7f99;p=openwrt%2Fstaging%2Fblogic.git 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 Cc: Arnout Vandecappelle (Essensium/Mind) Signed-off-by: Jonathan Cameron --- 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: