[PATCH 1/3] iio:ad7923: Return error if we didn't get the expected result

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

 



Instead of leaving 'val' uninitialized return an error if the result's address
did not match that of the channel we were trying to read.

Signed-off-by: Lars-Peter Clausen <lars@xxxxxxxxxx>
Cc: Patrick Vasseur <patrick.vasseur@xxxxxx>
Cc: Christophe Leroy <christophe.leroy@xxxxxx>
---
 drivers/iio/adc/ad7923.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/drivers/iio/adc/ad7923.c b/drivers/iio/adc/ad7923.c
index 766c740..36eee24 100644
--- a/drivers/iio/adc/ad7923.c
+++ b/drivers/iio/adc/ad7923.c
@@ -199,6 +199,8 @@ static int ad7923_read_raw(struct iio_dev *indio_dev,
 
 		if (chan->address == EXTRACT(ret, 12, 4))
 			*val = EXTRACT(ret, 0, 12);
+		else
+			return -EIO;
 
 		return IIO_VAL_INT;
 	}
-- 
1.8.0

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