diff options
author | Lars-Peter Clausen <lars@metafoo.de> | 2012-09-17 08:17:00 -0400 |
---|---|---|
committer | Jonathan Cameron <jic23@kernel.org> | 2012-09-17 16:48:51 -0400 |
commit | 48e44ce0f8810b530fc83a4f5eb67149280d9b82 (patch) | |
tree | ce32b7a0917edb95fe5b4c3de1edd33e8d0f7ed6 /include/linux/iio/iio.h | |
parent | 45f010baa0292c367168b1f62d5494965b905b5d (diff) |
iio:inkern: Add function to read the processed value
Add a function to read a processed value from a channel. The function will first
attempt to read the IIO_CHAN_INFO_PROCESSED attribute. If that fails it will
read the IIO_CHAN_INFO_RAW attribute and convert the result from a raw value to
a processed value.
The patch also introduces a function to convert raw value to a processed value
and exports it, in case a user needs or wants to do the conversion by itself.
Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
Signed-off-by: Jonathan Cameron <jic23@kernel.org>
Diffstat (limited to 'include/linux/iio/iio.h')
-rw-r--r-- | include/linux/iio/iio.h | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/include/linux/iio/iio.h b/include/linux/iio/iio.h index 30affa533a1f..c0ae76ac4e0b 100644 --- a/include/linux/iio/iio.h +++ b/include/linux/iio/iio.h | |||
@@ -40,6 +40,8 @@ enum iio_chan_info_enum { | |||
40 | 40 | ||
41 | #define IIO_CHAN_INFO_SHARED_BIT(type) BIT(type*2) | 41 | #define IIO_CHAN_INFO_SHARED_BIT(type) BIT(type*2) |
42 | #define IIO_CHAN_INFO_SEPARATE_BIT(type) BIT(type*2 + 1) | 42 | #define IIO_CHAN_INFO_SEPARATE_BIT(type) BIT(type*2 + 1) |
43 | #define IIO_CHAN_INFO_BITS(type) (IIO_CHAN_INFO_SHARED_BIT(type) | \ | ||
44 | IIO_CHAN_INFO_SEPARATE_BIT(type)) | ||
43 | 45 | ||
44 | #define IIO_CHAN_INFO_RAW_SEPARATE_BIT \ | 46 | #define IIO_CHAN_INFO_RAW_SEPARATE_BIT \ |
45 | IIO_CHAN_INFO_SEPARATE_BIT(IIO_CHAN_INFO_RAW) | 47 | IIO_CHAN_INFO_SEPARATE_BIT(IIO_CHAN_INFO_RAW) |
@@ -261,6 +263,21 @@ struct iio_chan_spec { | |||
261 | unsigned differential:1; | 263 | unsigned differential:1; |
262 | }; | 264 | }; |
263 | 265 | ||
266 | |||
267 | /** | ||
268 | * iio_channel_has_info() - Checks whether a channel supports a info attribute | ||
269 | * @chan: The channel to be queried | ||
270 | * @type: Type of the info attribute to be checked | ||
271 | * | ||
272 | * Returns true if the channels supports reporting values for the given info | ||
273 | * attribute type, false otherwise. | ||
274 | */ | ||
275 | static inline bool iio_channel_has_info(const struct iio_chan_spec *chan, | ||
276 | enum iio_chan_info_enum type) | ||
277 | { | ||
278 | return chan->info_mask & IIO_CHAN_INFO_BITS(type); | ||
279 | } | ||
280 | |||
264 | #define IIO_ST(si, rb, sb, sh) \ | 281 | #define IIO_ST(si, rb, sb, sh) \ |
265 | { .sign = si, .realbits = rb, .storagebits = sb, .shift = sh } | 282 | { .sign = si, .realbits = rb, .storagebits = sb, .shift = sh } |
266 | 283 | ||