aboutsummaryrefslogtreecommitdiffstats
path: root/include/linux/iio/consumer.h
diff options
context:
space:
mode:
authorPeter Rosin <peda@axentia.se>2016-11-08 12:58:52 +0100
committerJonathan Cameron <jic23@kernel.org>2016-11-13 11:40:26 +0000
commit00c5f80c2fad5368cd5bfa6c9d90e75a9041ac16 (patch)
tree87425443e5163ef59ab05fbc378d293c34e465d9 /include/linux/iio/consumer.h
parentiio:core: add a callback to allow drivers to provide _available attributes (diff)
downloadlinux-dev-00c5f80c2fad5368cd5bfa6c9d90e75a9041ac16.tar.xz
linux-dev-00c5f80c2fad5368cd5bfa6c9d90e75a9041ac16.zip
iio: inkern: add helpers to query available values from channels
Specifically a helper for reading the available maximum raw value of a channel and a helper for forwarding read_avail requests for raw values from one iio driver to an iio channel that is consumed. These rather specific helpers are in turn built with generic helpers making it easy to build more helpers for available values as needed. Signed-off-by: Peter Rosin <peda@axentia.se> Signed-off-by: Jonathan Cameron <jic23@kernel.org>
Diffstat (limited to 'include/linux/iio/consumer.h')
-rw-r--r--include/linux/iio/consumer.h28
1 files changed, 28 insertions, 0 deletions
diff --git a/include/linux/iio/consumer.h b/include/linux/iio/consumer.h
index 638157234357..47eeec3218b5 100644
--- a/include/linux/iio/consumer.h
+++ b/include/linux/iio/consumer.h
@@ -226,6 +226,34 @@ int iio_read_channel_processed(struct iio_channel *chan, int *val);
int iio_write_channel_raw(struct iio_channel *chan, int val);
/**
+ * iio_read_max_channel_raw() - read maximum available raw value from a given
+ * channel, i.e. the maximum possible value.
+ * @chan: The channel being queried.
+ * @val: Value read back.
+ *
+ * Note raw reads from iio channels are in adc counts and hence
+ * scale will need to be applied if standard units are required.
+ */
+int iio_read_max_channel_raw(struct iio_channel *chan, int *val);
+
+/**
+ * iio_read_avail_channel_raw() - read available raw values from a given channel
+ * @chan: The channel being queried.
+ * @vals: Available values read back.
+ * @length: Number of entries in vals.
+ *
+ * Returns an error code, IIO_AVAIL_RANGE or IIO_AVAIL_LIST.
+ *
+ * For ranges, three vals are always returned; min, step and max.
+ * For lists, all the possible values are enumerated.
+ *
+ * Note raw available values from iio channels are in adc counts and
+ * hence scale will need to be applied if standard units are required.
+ */
+int iio_read_avail_channel_raw(struct iio_channel *chan,
+ const int **vals, int *length);
+
+/**
* iio_get_channel_type() - get the type of a channel
* @channel: The channel being queried.
* @type: The type of the channel.