aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorFabien Proriol <fabien.proriol@jdsu.com>2015-01-01 07:46:48 -0500
committerJonathan Cameron <jic23@kernel.org>2015-01-01 07:46:48 -0500
commit65de7654d39c70c2b942f801cea01590cf7e3458 (patch)
treefdb99856165a72ffa2b217c9fddc66e22caa5116
parent2eacc608b3bf3519fc353c558454873f4589146d (diff)
iio: iio: Fix iio_channel_read return if channel havn't info
When xilinx-xadc is used with hwmon driver to read voltage, offset used for temperature is always applied whatever the channel. iio_channel_read must return an error to avoid offset for channel without IIO_CHAN_INFO_OFFSET property. Signed-off-by: Fabien Proriol <fabien.proriol@jdsu.com> Signed-off-by: Jonathan Cameron <jic23@kernel.org>
-rw-r--r--drivers/iio/inkern.c3
1 files changed, 3 insertions, 0 deletions
diff --git a/drivers/iio/inkern.c b/drivers/iio/inkern.c
index f0846108d006..d33590e89337 100644
--- a/drivers/iio/inkern.c
+++ b/drivers/iio/inkern.c
@@ -426,6 +426,9 @@ static int iio_channel_read(struct iio_channel *chan, int *val, int *val2,
426 if (val2 == NULL) 426 if (val2 == NULL)
427 val2 = &unused; 427 val2 = &unused;
428 428
429 if(!iio_channel_has_info(chan->channel, info))
430 return -EINVAL;
431
429 if (chan->indio_dev->info->read_raw_multi) { 432 if (chan->indio_dev->info->read_raw_multi) {
430 ret = chan->indio_dev->info->read_raw_multi(chan->indio_dev, 433 ret = chan->indio_dev->info->read_raw_multi(chan->indio_dev,
431 chan->channel, INDIO_MAX_RAW_ELEMENTS, 434 chan->channel, INDIO_MAX_RAW_ELEMENTS,