iio:ad7923: Return error if we didn't get the expected result
authorLars-Peter Clausen <lars@metafoo.de>
Mon, 4 Mar 2013 19:30:00 +0000 (19:30 +0000)
committerJonathan Cameron <jic23@kernel.org>
Sun, 17 Mar 2013 20:16:40 +0000 (20:16 +0000)
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@metafoo.de>
Cc: Patrick Vasseur <patrick.vasseur@c-s.fr>
Cc: Christophe Leroy <christophe.leroy@c-s.fr>
Signed-off-by: Jonathan Cameron <jic23@kernel.org>
drivers/iio/adc/ad7923.c

index 766c74026be208ff6316026ef991204c4971d634..36eee248a9f6bddda205905c1ef8a5884221cb32 100644 (file)
@@ -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;
        }