From: Jonathan Cameron Date: Mon, 5 Dec 2011 21:37:11 +0000 (+0000) Subject: staging:iio:buffer add a cache of the timestamp scan index. X-Git-Tag: next-20111209~13^2~74 X-Git-Url: https://git.karo-electronics.de/?a=commitdiff_plain;h=beb80600b017ff4c407e9e72eb7f9a884fed4210;p=karo-tx-linux.git staging:iio:buffer add a cache of the timestamp scan index. Basically avoids looking it up lots of times. Signed-off-by: Jonathan Cameron Signed-off-by: Greg Kroah-Hartman --- diff --git a/drivers/staging/iio/buffer.h b/drivers/staging/iio/buffer.h index 9de581e2d764..4b8f6190a5b0 100644 --- a/drivers/staging/iio/buffer.h +++ b/drivers/staging/iio/buffer.h @@ -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; diff --git a/drivers/staging/iio/industrialio-buffer.c b/drivers/staging/iio/industrialio-buffer.c index 8c5598081b60..b2cf3e33e39b 100644 --- a/drivers/staging/iio/industrialio-buffer.c +++ b/drivers/staging/iio/industrialio-buffer.c @@ -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),