Merge branch 'trivial' of git://git.kernel.org/pub/scm/linux/kernel/git/mmarek/kbuild
[deliverable/linux.git] / drivers / iio / industrialio-buffer.c
index cc5db36fb75ab24f6865dd789b32a8ed4e0674c1..4add9bb40eeb32a2cf032775fc7b357085af49c1 100644 (file)
@@ -292,7 +292,7 @@ int iio_buffer_register(struct iio_dev *indio_dev,
                        if (channels[i].scan_index >
                            (int)indio_dev->masklength - 1)
                                indio_dev->masklength
-                                       = indio_dev->channels[i].scan_index + 1;
+                                       = channels[i].scan_index + 1;
 
                        ret = iio_buffer_add_channel_sysfs(indio_dev,
                                                         &channels[i]);
@@ -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)
 {
This page took 0.027581 seconds and 5 git commands to generate.