aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/iio/inkern.c
diff options
context:
space:
mode:
authorSrinivas Pandruvada <srinivas.pandruvada@linux.intel.com>2014-04-28 19:51:00 -0400
committerJonathan Cameron <jic23@kernel.org>2014-04-29 17:05:32 -0400
commit9fbfb4b37ed23f71aa9484484266381c6c6964cb (patch)
tree441b1f942d51a1729d10a3237c7a28853f482ff9 /drivers/iio/inkern.c
parent3046365bb470f0ec2f7cf5cb07a8ee7e4b490103 (diff)
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.c16
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,
417 enum iio_chan_info_enum info) 417 enum iio_chan_info_enum info)
418{ 418{
419 int unused; 419 int unused;
420 int vals[INDIO_MAX_RAW_ELEMENTS];
421 int ret;
422 int val_len = 2;
420 423
421 if (val2 == NULL) 424 if (val2 == NULL)
422 val2 = &unused; 425 val2 = &unused;
423 426
424 return chan->indio_dev->info->read_raw(chan->indio_dev, chan->channel, 427 if (chan->indio_dev->info->read_raw_multi) {
425 val, val2, info); 428 ret = chan->indio_dev->info->read_raw_multi(chan->indio_dev,
429 chan->channel, INDIO_MAX_RAW_ELEMENTS,
430 vals, &val_len, info);
431 *val = vals[0];
432 *val2 = vals[1];
433 } else
434 ret = chan->indio_dev->info->read_raw(chan->indio_dev,
435 chan->channel, val, val2, info);
436
437 return ret;
426} 438}
427 439
428int iio_read_channel_raw(struct iio_channel *chan, int *val) 440int iio_read_channel_raw(struct iio_channel *chan, int *val)