浏览代码

iio:ad7923: Return error if we didn't get the expected result

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>
Lars-Peter Clausen 12 年之前
父节点
当前提交
135f06465d
共有 1 个文件被更改,包括 2 次插入0 次删除
  1. 2 0
      drivers/iio/adc/ad7923.c

+ 2 - 0
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))
 		if (chan->address == EXTRACT(ret, 12, 4))
 			*val = EXTRACT(ret, 0, 12);
 			*val = EXTRACT(ret, 0, 12);
+		else
+			return -EIO;
 
 
 		return IIO_VAL_INT;
 		return IIO_VAL_INT;
 	}
 	}