diff options
-rw-r--r-- | drivers/iio/inkern.c | 25 | ||||
-rw-r--r-- | include/linux/iio/consumer.h | 10 |
2 files changed, 35 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: | |||
631 | return ret; | 631 | return ret; |
632 | } | 632 | } |
633 | EXPORT_SYMBOL_GPL(iio_get_channel_type); | 633 | EXPORT_SYMBOL_GPL(iio_get_channel_type); |
634 | |||
635 | static int iio_channel_write(struct iio_channel *chan, int val, int val2, | ||
636 | enum iio_chan_info_enum info) | ||
637 | { | ||
638 | return chan->indio_dev->info->write_raw(chan->indio_dev, | ||
639 | chan->channel, val, val2, info); | ||
640 | } | ||
641 | |||
642 | int iio_write_channel_raw(struct iio_channel *chan, int val) | ||
643 | { | ||
644 | int ret; | ||
645 | |||
646 | mutex_lock(&chan->indio_dev->info_exist_lock); | ||
647 | if (chan->indio_dev->info == NULL) { | ||
648 | ret = -ENODEV; | ||
649 | goto err_unlock; | ||
650 | } | ||
651 | |||
652 | ret = iio_channel_write(chan, val, 0, IIO_CHAN_INFO_RAW); | ||
653 | err_unlock: | ||
654 | mutex_unlock(&chan->indio_dev->info_exist_lock); | ||
655 | |||
656 | return ret; | ||
657 | } | ||
658 | EXPORT_SYMBOL_GPL(iio_write_channel_raw); | ||
diff --git a/include/linux/iio/consumer.h b/include/linux/iio/consumer.h index 651f9a0e2765..6f64624f329b 100644 --- a/include/linux/iio/consumer.h +++ b/include/linux/iio/consumer.h | |||
@@ -151,6 +151,16 @@ int iio_read_channel_average_raw(struct iio_channel *chan, int *val); | |||
151 | int iio_read_channel_processed(struct iio_channel *chan, int *val); | 151 | int iio_read_channel_processed(struct iio_channel *chan, int *val); |
152 | 152 | ||
153 | /** | 153 | /** |
154 | * iio_write_channel_raw() - write to a given channel | ||
155 | * @chan: The channel being queried. | ||
156 | * @val: Value being written. | ||
157 | * | ||
158 | * Note raw writes to iio channels are in dac counts and hence | ||
159 | * scale will need to be applied if standard units required. | ||
160 | */ | ||
161 | int iio_write_channel_raw(struct iio_channel *chan, int val); | ||
162 | |||
163 | /** | ||
154 | * iio_get_channel_type() - get the type of a channel | 164 | * iio_get_channel_type() - get the type of a channel |
155 | * @channel: The channel being queried. | 165 | * @channel: The channel being queried. |
156 | * @type: The type of the channel. | 166 | * @type: The type of the channel. |