]> Git Repo - linux.git/commitdiff
iio: iio: Fix iio_channel_read return if channel havn't info
authorFabien Proriol <[email protected]>
Thu, 1 Jan 2015 12:46:48 +0000 (12:46 +0000)
committerJonathan Cameron <[email protected]>
Thu, 1 Jan 2015 12:46:48 +0000 (12:46 +0000)
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 <[email protected]>
Signed-off-by: Jonathan Cameron <[email protected]>
drivers/iio/inkern.c

index f0846108d0067b4a979f3c3b86624b6e211cfa76..d33590e89337e500569fac35e1341b0f695e5e7f 100644 (file)
@@ -426,6 +426,9 @@ static int iio_channel_read(struct iio_channel *chan, int *val, int *val2,
        if (val2 == NULL)
                val2 = &unused;
 
+       if(!iio_channel_has_info(chan->channel, info))
+               return -EINVAL;
+
        if (chan->indio_dev->info->read_raw_multi) {
                ret = chan->indio_dev->info->read_raw_multi(chan->indio_dev,
                                        chan->channel, INDIO_MAX_RAW_ELEMENTS,
This page took 0.058524 seconds and 4 git commands to generate.