staging:iio:buffer add a cache of the timestamp scan index.
authorJonathan Cameron <jic23@cam.ac.uk>
Mon, 5 Dec 2011 21:37:11 +0000 (21:37 +0000)
committerGreg Kroah-Hartman <gregkh@suse.de>
Thu, 8 Dec 2011 19:36:11 +0000 (11:36 -0800)
Basically avoids looking it up lots of times.

Signed-off-by: Jonathan Cameron <jic23@cam.ac.uk>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
drivers/staging/iio/buffer.h
drivers/staging/iio/industrialio-buffer.c

index 9de581e2d7648b61d1e49805dd66d5fcabde1f11..4b8f6190a5b0acd855dc6f57114a15e0ab8218a9 100644 (file)
@@ -106,6 +106,7 @@ struct iio_buffer {
        int                                     scan_count;
        long                                    *scan_mask;
        bool                                    scan_timestamp;
+       unsigned                                scan_index_timestamp;
        const struct iio_buffer_access_funcs    *access;
        const struct iio_buffer_setup_ops               *setup_ops;
        struct list_head                        scan_el_dev_attr_list;
index 8c5598081b608fe6677bb1ff1b1184b46d87ed9b..b2cf3e33e39b2d27321c85131eead4d56509d3bd 100644 (file)
@@ -313,6 +313,9 @@ int iio_buffer_register(struct iio_dev *indio_dev,
                        if (ret < 0)
                                goto error_cleanup_dynamic;
                        attrcount += ret;
+                       if (channels[i].type == IIO_TIMESTAMP)
+                               buffer->scan_index_timestamp =
+                                       channels[i].scan_index;
                }
                if (indio_dev->masklength && buffer->scan_mask == NULL) {
                        buffer->scan_mask = kcalloc(BITS_TO_LONGS(indio_dev->masklength),