summaryrefslogtreecommitdiffstats
path: root/drivers/iio/inkern.c
diff options
context:
space:
mode:
authorDmitry Eremin-Solenikov <dbaryshkov@gmail.com>2014-11-27 01:42:45 +0300
committerJonathan Cameron <jic23@kernel.org>2014-12-12 12:28:27 +0000
commitf9380e7123863a4cb0627d940533be954a0a15df (patch)
treec85e2a56d3c30e6380314acb2179f773dfd1420d /drivers/iio/inkern.c
parentc75b8dc84fd28511224a4cd2bfa791bb56a06172 (diff)
downloadlinux-f9380e7123863a4cb0627d940533be954a0a15df.tar.gz
linux-f9380e7123863a4cb0627d940533be954a0a15df.tar.bz2
linux-f9380e7123863a4cb0627d940533be954a0a15df.zip
iio: inkern: add iio_write_channel_raw
Introduce API for easy in-kernel setting of DAC values. Signed-off-by: Dmitry Eremin-Solenikov <dbaryshkov@gmail.com> Signed-off-by: Jonathan Cameron <jic23@kernel.org>
Diffstat (limited to 'drivers/iio/inkern.c')
-rw-r--r--drivers/iio/inkern.c25
1 files changed, 25 insertions, 0 deletions
diff --git a/drivers/iio/inkern.c b/drivers/iio/inkern.c
index 866fe904cba2..21655fd1465c 100644
--- a/drivers/iio/inkern.c
+++ b/drivers/iio/inkern.c
@@ -631,3 +631,28 @@ err_unlock:
return ret;
}
EXPORT_SYMBOL_GPL(iio_get_channel_type);
+
+static int iio_channel_write(struct iio_channel *chan, int val, int val2,
+ enum iio_chan_info_enum info)
+{
+ return chan->indio_dev->info->write_raw(chan->indio_dev,
+ chan->channel, val, val2, info);
+}
+
+int iio_write_channel_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_write(chan, val, 0, IIO_CHAN_INFO_RAW);
+err_unlock:
+ mutex_unlock(&chan->indio_dev->info_exist_lock);
+
+ return ret;
+}
+EXPORT_SYMBOL_GPL(iio_write_channel_raw);