Skip to content

Commit 62f4f36

Browse files
Jonathan CameronJonathan Cameron
authored andcommitted
iio: core: move @scan_index_timestamp to struct iio_dev_opaque
No reason for this cached value to be exposed to drivers so move it to the opaque structure. Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com> Reviewed-by: Alexandru Ardelean <ardeleanalex@gmail.com> Link: https://lore.kernel.org/r/20210426174911.397061-6-jic23@kernel.org
1 parent 3028e0c commit 62f4f36

3 files changed

Lines changed: 9 additions & 4 deletions

File tree

‎drivers/iio/industrialio-buffer.c‎

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -601,8 +601,10 @@ static unsigned int iio_storage_bytes_for_si(struct iio_dev *indio_dev,
601601

602602
static unsigned int iio_storage_bytes_for_timestamp(struct iio_dev *indio_dev)
603603
{
604+
struct iio_dev_opaque *iio_dev_opaque = to_iio_dev_opaque(indio_dev);
605+
604606
return iio_storage_bytes_for_si(indio_dev,
605-
indio_dev->scan_index_timestamp);
607+
iio_dev_opaque->scan_index_timestamp);
606608
}
607609

608610
static int iio_compute_scan_bytes(struct iio_dev *indio_dev,
@@ -1469,6 +1471,7 @@ static int __iio_buffer_alloc_sysfs_and_mask(struct iio_buffer *buffer,
14691471
struct iio_dev *indio_dev,
14701472
int index)
14711473
{
1474+
struct iio_dev_opaque *iio_dev_opaque = to_iio_dev_opaque(indio_dev);
14721475
struct iio_dev_attr *p;
14731476
struct attribute **attr;
14741477
int ret, i, attrn, scan_el_attrcount, buffer_attrcount;
@@ -1495,7 +1498,7 @@ static int __iio_buffer_alloc_sysfs_and_mask(struct iio_buffer *buffer,
14951498
goto error_cleanup_dynamic;
14961499
scan_el_attrcount += ret;
14971500
if (channels[i].type == IIO_TIMESTAMP)
1498-
indio_dev->scan_index_timestamp =
1501+
iio_dev_opaque->scan_index_timestamp =
14991502
channels[i].scan_index;
15001503
}
15011504
if (indio_dev->masklength && buffer->scan_mask == NULL) {

‎include/linux/iio/iio-opaque.h‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
* @groupcounter: index of next attribute group
2323
* @legacy_scan_el_group: attribute group for legacy scan elements attribute group
2424
* @legacy_buffer_group: attribute group for legacy buffer attributes group
25+
* @scan_index_timestamp: cache of the index to the timestamp
2526
* @debugfs_dentry: device specific debugfs dentry
2627
* @cached_reg_addr: cached register address for debugfs reads
2728
* @read_buf: read buffer to be used for the initial reg read
@@ -44,6 +45,9 @@ struct iio_dev_opaque {
4445
int groupcounter;
4546
struct attribute_group legacy_scan_el_group;
4647
struct attribute_group legacy_buffer_group;
48+
49+
unsigned int scan_index_timestamp;
50+
4751
#if defined(CONFIG_DEBUG_FS)
4852
struct dentry *debugfs_dentry;
4953
unsigned cached_reg_addr;

‎include/linux/iio/iio.h‎

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -501,7 +501,6 @@ struct iio_buffer_setup_ops {
501501
* channels
502502
* @active_scan_mask: [INTERN] union of all scan masks requested by buffers
503503
* @scan_timestamp: [INTERN] set if any buffers have requested timestamp
504-
* @scan_index_timestamp:[INTERN] cache of the index to the timestamp
505504
* @trig: [INTERN] current device trigger (buffer modes)
506505
* @pollfunc: [DRIVER] function run on trigger being received
507506
* @pollfunc_event: [DRIVER] function run on events trigger being received
@@ -532,7 +531,6 @@ struct iio_dev {
532531
unsigned masklength;
533532
const unsigned long *active_scan_mask;
534533
bool scan_timestamp;
535-
unsigned scan_index_timestamp;
536534
struct iio_trigger *trig;
537535
struct iio_poll_func *pollfunc;
538536
struct iio_poll_func *pollfunc_event;

0 commit comments

Comments
 (0)