summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorArtur Rojek <contact@artur-rojek.eu>2019-03-23 13:28:06 -0400
committerJonathan Cameron <Jonathan.Cameron@huawei.com>2019-04-14 06:11:00 -0400
commit9f421096a16e75d22e69f766206f1bb0dc8fcf90 (patch)
treeb9cd33e7f4491e2a5e661b1023dbeb0d180949af
parent1c163f4c7b3f621efff9b28a47abb36f7378d783 (diff)
iio: inkern: API for reading available iio channel attribute values
Extend the inkern API with a function for reading available attribute values of iio channels. Signed-off-by: Artur Rojek <contact@artur-rojek.eu> Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
-rw-r--r--drivers/iio/inkern.c20
-rw-r--r--include/linux/iio/consumer.h14
2 files changed, 34 insertions, 0 deletions
diff --git a/drivers/iio/inkern.c b/drivers/iio/inkern.c
index 06ca3f7fcc44..f19dbde3c945 100644
--- a/drivers/iio/inkern.c
+++ b/drivers/iio/inkern.c
@@ -733,6 +733,26 @@ static int iio_channel_read_avail(struct iio_channel *chan,
733 vals, type, length, info); 733 vals, type, length, info);
734} 734}
735 735
736int iio_read_avail_channel_attribute(struct iio_channel *chan,
737 const int **vals, int *type, int *length,
738 enum iio_chan_info_enum attribute)
739{
740 int ret;
741
742 mutex_lock(&chan->indio_dev->info_exist_lock);
743 if (!chan->indio_dev->info) {
744 ret = -ENODEV;
745 goto err_unlock;
746 }
747
748 ret = iio_channel_read_avail(chan, vals, type, length, attribute);
749err_unlock:
750 mutex_unlock(&chan->indio_dev->info_exist_lock);
751
752 return ret;
753}
754EXPORT_SYMBOL_GPL(iio_read_avail_channel_attribute);
755
736int iio_read_avail_channel_raw(struct iio_channel *chan, 756int iio_read_avail_channel_raw(struct iio_channel *chan,
737 const int **vals, int *length) 757 const int **vals, int *length)
738{ 758{
diff --git a/include/linux/iio/consumer.h b/include/linux/iio/consumer.h
index 9887f4f8e2a8..b2d34831ed7c 100644
--- a/include/linux/iio/consumer.h
+++ b/include/linux/iio/consumer.h
@@ -291,6 +291,20 @@ int iio_read_avail_channel_raw(struct iio_channel *chan,
291 const int **vals, int *length); 291 const int **vals, int *length);
292 292
293/** 293/**
294 * iio_read_avail_channel_attribute() - read available channel attribute values
295 * @chan: The channel being queried.
296 * @vals: Available values read back.
297 * @type: Type of values read back.
298 * @length: Number of entries in vals.
299 * @attribute: info attribute to be read back.
300 *
301 * Returns an error code, IIO_AVAIL_RANGE or IIO_AVAIL_LIST.
302 */
303int iio_read_avail_channel_attribute(struct iio_channel *chan,
304 const int **vals, int *type, int *length,
305 enum iio_chan_info_enum attribute);
306
307/**
294 * iio_get_channel_type() - get the type of a channel 308 * iio_get_channel_type() - get the type of a channel
295 * @channel: The channel being queried. 309 * @channel: The channel being queried.
296 * @type: The type of the channel. 310 * @type: The type of the channel.