summaryrefslogtreecommitdiffstats
path: root/include/linux/iio/iio.h
diff options
context:
space:
mode:
authorPeter Rosin2016-11-08 12:58:52 +0100
committerJonathan Cameron2016-11-13 12:40:26 +0100
commit00c5f80c2fad5368cd5bfa6c9d90e75a9041ac16 (patch)
tree87425443e5163ef59ab05fbc378d293c34e465d9 /include/linux/iio/iio.h
parentiio:core: add a callback to allow drivers to provide _available attributes (diff)
downloadkernel-qcow2-linux-00c5f80c2fad5368cd5bfa6c9d90e75a9041ac16.tar.gz
kernel-qcow2-linux-00c5f80c2fad5368cd5bfa6c9d90e75a9041ac16.tar.xz
kernel-qcow2-linux-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/iio.h')
-rw-r--r--include/linux/iio/iio.h17
1 files changed, 17 insertions, 0 deletions
diff --git a/include/linux/iio/iio.h b/include/linux/iio/iio.h
index 849d524645e8..3f5ea2e9a39e 100644
--- a/include/linux/iio/iio.h
+++ b/include/linux/iio/iio.h
@@ -315,6 +315,23 @@ static inline bool iio_channel_has_info(const struct iio_chan_spec *chan,
(chan->info_mask_shared_by_all & BIT(type));
}
+/**
+ * iio_channel_has_available() - Checks if a channel has an available attribute
+ * @chan: The channel to be queried
+ * @type: Type of the available attribute to be checked
+ *
+ * Returns true if the channel supports reporting available values for the
+ * given attribute type, false otherwise.
+ */
+static inline bool iio_channel_has_available(const struct iio_chan_spec *chan,
+ enum iio_chan_info_enum type)
+{
+ return (chan->info_mask_separate_available & BIT(type)) |
+ (chan->info_mask_shared_by_type_available & BIT(type)) |
+ (chan->info_mask_shared_by_dir_available & BIT(type)) |
+ (chan->info_mask_shared_by_all_available & BIT(type));
+}
+
#define IIO_CHAN_SOFT_TIMESTAMP(_si) { \
.type = IIO_TIMESTAMP, \
.channel = -1, \