From 1167560cee05a428c03cfb0ffedb83eefaac55ed Mon Sep 17 00:00:00 2001 From: Lars-Peter Clausen Date: Mon, 9 Jul 2012 10:00:00 +0100 Subject: [PATCH] --- yaml --- r: 317877 b: refs/heads/master c: 81636632057cc1bece2531220dd5803036f95ea9 h: refs/heads/master i: 317875: 6426ee9814e365533e416ff9aa85ac87771255a9 v: v3 --- [refs] | 2 +- trunk/drivers/iio/industrialio-buffer.c | 16 ++++++++++++++++ trunk/include/linux/iio/buffer.h | 3 +++ 3 files changed, 20 insertions(+), 1 deletion(-) diff --git a/[refs] b/[refs] index 0b31175457f9..765ae66257b3 100644 --- a/[refs] +++ b/[refs] @@ -1,2 +1,2 @@ --- -refs/heads/master: 939546d1a9f47ed169554c711e1e05965b84ffe1 +refs/heads/master: 81636632057cc1bece2531220dd5803036f95ea9 diff --git a/trunk/drivers/iio/industrialio-buffer.c b/trunk/drivers/iio/industrialio-buffer.c index cc5db36fb75a..8c1dc9a683fb 100644 --- a/trunk/drivers/iio/industrialio-buffer.c +++ b/trunk/drivers/iio/industrialio-buffer.c @@ -570,6 +570,22 @@ int iio_sw_buffer_preenable(struct iio_dev *indio_dev) } EXPORT_SYMBOL(iio_sw_buffer_preenable); +/** + * iio_validate_scan_mask_onehot() - Validates that exactly one channel is selected + * @indio_dev: the iio device + * @mask: scan mask to be checked + * + * Return true if exactly one bit is set in the scan mask, false otherwise. It + * can be used for devices where only one channel can be active for sampling at + * a time. + */ +bool iio_validate_scan_mask_onehot(struct iio_dev *indio_dev, + const unsigned long *mask) +{ + return bitmap_weight(mask, indio_dev->masklength) == 1; +} +EXPORT_SYMBOL_GPL(iio_validate_scan_mask_onehot); + static bool iio_validate_scan_mask(struct iio_dev *indio_dev, const unsigned long *mask) { diff --git a/trunk/include/linux/iio/buffer.h b/trunk/include/linux/iio/buffer.h index 2a2b6b4d8d05..8ba516fc2ec6 100644 --- a/trunk/include/linux/iio/buffer.h +++ b/trunk/include/linux/iio/buffer.h @@ -177,6 +177,9 @@ ssize_t iio_buffer_show_enable(struct device *dev, int iio_sw_buffer_preenable(struct iio_dev *indio_dev); +bool iio_validate_scan_mask_onehot(struct iio_dev *indio_dev, + const unsigned long *mask); + #else /* CONFIG_IIO_BUFFER */ static inline int iio_buffer_register(struct iio_dev *indio_dev,