diff options
author | Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com> | 2014-04-29 00:51:00 +0100 |
---|---|---|
committer | Jonathan Cameron <jic23@kernel.org> | 2014-04-29 22:05:32 +0100 |
commit | 9fbfb4b37ed23f71aa9484484266381c6c6964cb (patch) | |
tree | 441b1f942d51a1729d10a3237c7a28853f482ff9 /drivers/iio/inkern.c | |
parent | 3046365bb470f0ec2f7cf5cb07a8ee7e4b490103 (diff) | |
download | linux-9fbfb4b37ed23f71aa9484484266381c6c6964cb.tar.gz linux-9fbfb4b37ed23f71aa9484484266381c6c6964cb.tar.bz2 linux-9fbfb4b37ed23f71aa9484484266381c6c6964cb.zip |
IIO: core: Introduce read_raw_multi
This callback is introduced to overcome some limitations of existing
read_raw callback. The functionality of both existing read_raw and
read_raw_multi is similar, both are used to request values from the
device. The current read_raw callback allows only two return values.
The new read_raw_multi allows returning multiple values. Instead of
passing just address of val and val2, it passes length and pointer
to values. Depending on the type and length of passed buffer, iio
client drivers can return multiple values.
Signed-off-by: Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com>
Signed-off-by: Jonathan Cameron <jic23@kernel.org>
Diffstat (limited to 'drivers/iio/inkern.c')
-rw-r--r-- | drivers/iio/inkern.c | 16 |
1 files changed, 14 insertions, 2 deletions
diff --git a/drivers/iio/inkern.c b/drivers/iio/inkern.c index adeba5a0ecf7..d833d55052ea 100644 --- a/drivers/iio/inkern.c +++ b/drivers/iio/inkern.c @@ -417,12 +417,24 @@ static int iio_channel_read(struct iio_channel *chan, int *val, int *val2, enum iio_chan_info_enum info) { int unused; + int vals[INDIO_MAX_RAW_ELEMENTS]; + int ret; + int val_len = 2; if (val2 == NULL) val2 = &unused; - return chan->indio_dev->info->read_raw(chan->indio_dev, chan->channel, - val, val2, info); + 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, + vals, &val_len, info); + *val = vals[0]; + *val2 = vals[1]; + } else + ret = chan->indio_dev->info->read_raw(chan->indio_dev, + chan->channel, val, val2, info); + + return ret; } int iio_read_channel_raw(struct iio_channel *chan, int *val) |