summaryrefslogtreecommitdiffstats
path: root/drivers/iio/inkern.c
diff options
context:
space:
mode:
authorSebastian Reichel <sre@debian.org>2014-10-03 18:25:00 +0200
committerJonathan Cameron <jic23@kernel.org>2014-03-16 19:00:33 +0100
commit476d4af22cec8a9ebc90137712e5ab7070b7379d (patch)
tree3da0d92e3e37b9a37e0184d5bf8d10a9e2a7d60c /drivers/iio/inkern.c
parentiio: documentation: Add ABI documentation for *_mean_raw (diff)
downloadlinux-476d4af22cec8a9ebc90137712e5ab7070b7379d.tar.xz
linux-476d4af22cec8a9ebc90137712e5ab7070b7379d.zip
iio: inkern: add iio_read_channel_average_raw
Add iio_read_channel_average_raw to support reading averaged raw values in consumer drivers. Signed-off-by: Sebastian Reichel <sre@debian.org> Signed-off-by: Jonathan Cameron <jic23@kernel.org>
Diffstat (limited to 'drivers/iio/inkern.c')
-rw-r--r--drivers/iio/inkern.c18
1 files changed, 18 insertions, 0 deletions
diff --git a/drivers/iio/inkern.c b/drivers/iio/inkern.c
index 0cf5f8e06cfc..adeba5a0ecf7 100644
--- a/drivers/iio/inkern.c
+++ b/drivers/iio/inkern.c
@@ -443,6 +443,24 @@ err_unlock:
}
EXPORT_SYMBOL_GPL(iio_read_channel_raw);
+int iio_read_channel_average_raw(struct iio_channel *chan, int *val)
+{
+ int ret;
+
+ mutex_lock(&chan->indio_dev->info_exist_lock);
+ if (chan->indio_dev->info == NULL) {
+ ret = -ENODEV;
+ goto err_unlock;
+ }
+
+ ret = iio_channel_read(chan, val, NULL, IIO_CHAN_INFO_AVERAGE_RAW);
+err_unlock:
+ mutex_unlock(&chan->indio_dev->info_exist_lock);
+
+ return ret;
+}
+EXPORT_SYMBOL_GPL(iio_read_channel_average_raw);
+
static int iio_convert_raw_to_processed_unlocked(struct iio_channel *chan,
int raw, int *processed, unsigned int scale)
{