[PATCH v2 7/7] iio: mlx90614: Check for errors in read values

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



The device uses the MSB of the returned temperature values 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@xxxxxxxxxxxxx>
Cc: Arnout Vandecappelle (Essensium/Mind) <arnout@xxxxxxx>

---

v2: new patch
---
 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 6b9bfcd..6cb1e81 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 -EREMOTEIO;
+
 		*val = ret;
 		return IIO_VAL_INT;
 	case IIO_CHAN_INFO_OFFSET:
-- 
2.3.3

--
To unsubscribe from this list: send the line "unsubscribe linux-iio" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html




[Index of Archives]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Yosemite News]     [Linux Input]     [Linux Kernel]     [Linux SCSI]     [X.org]

  Powered by Linux