Skip to content

Commit

Permalink
iio: iio: Fix iio_channel_read return if channel havn't info
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Fabien Proriol authored and jic23 committed Jan 1, 2015
1 parent 2eacc60 commit 65de765
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions drivers/iio/inkern.c
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down

0 comments on commit 65de765

Please sign in to comment.