On 11/17/2014 09:53 AM, Fabien Proriol wrote:
From bdeab2d72a00587eac15eb91ec0820ff6d11bfe8 Mon Sep 17 00:00:00 2001 From: Fabien Proriol <fabien.proriol@xxxxxxxx> Date: Mon, 17 Nov 2014 09:46:02 +0100 Subject: [PATCH] iio: Fix iio_channel_read return if channel havn't info 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@xxxxxxxx>
Reviewed-by: Lars-Peter Clausen <lars@xxxxxxxxxx> Thanks.
--- drivers/iio/inkern.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/drivers/iio/inkern.c b/drivers/iio/inkern.c index 1e8e94d..917eb00 100644 --- a/drivers/iio/inkern.c +++ b/drivers/iio/inkern.c @@ -423,6 +423,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; + return chan->indio_dev->info->read_raw(chan->indio_dev, chan->channel, val, val2, info); }
-- To unsubscribe from this list: send the line "unsubscribe linux-iio" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html