iio: iio_buffer_register: Skip channels with negative scan index
authorLars-Peter Clausen <lars@metafoo.de>
Mon, 18 Jun 2012 16:33:47 +0000 (18:33 +0200)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Tue, 19 Jun 2012 00:26:09 +0000 (17:26 -0700)
It is not always the case that all channels can be used in buffered mode. This
patch allows channels, which can not be used in buffered mode, to set their scan
index to a negative number, which will cause iio_buffer_register to ignore the
channel.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
Acked-by: Jonathan Cameron <jic23@kernel.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/iio/industrialio-buffer.c

index 2f35db93cdb6ef3a8594b74effb93e0f64e971ea..3d8d187eef2acf19b1a625fb48ae188442c49dc3 100644 (file)
@@ -285,6 +285,9 @@ int iio_buffer_register(struct iio_dev *indio_dev,
        if (channels) {
                /* new magic */
                for (i = 0; i < num_channels; i++) {
+                       if (channels[i].scan_index < 0)
+                               continue;
+
                        /* Establish necessary mask length */
                        if (channels[i].scan_index >
                            (int)indio_dev->masklength - 1)