Skip to content

Commit 62a486c

Browse files
Jonathan CameronJonathan Cameron
authored andcommitted
iio: core: move @clock_id from struct iio_dev to struct iio_dev_opaque
There is already an acessor function used to access it, making this move straight forward. Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com> Reviewed-by: Alexandru Ardelean <ardeleanalex@gmail.com> Link: https://lore.kernel.org/r/20210426174911.397061-10-jic23@kernel.org
1 parent 8b1c82c commit 62a486c

3 files changed

Lines changed: 16 additions & 12 deletions

File tree

‎drivers/iio/industrialio-core.c‎

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -271,13 +271,25 @@ int iio_device_set_clock(struct iio_dev *indio_dev, clockid_t clock_id)
271271
mutex_unlock(&indio_dev->mlock);
272272
return -EBUSY;
273273
}
274-
indio_dev->clock_id = clock_id;
274+
iio_dev_opaque->clock_id = clock_id;
275275
mutex_unlock(&indio_dev->mlock);
276276

277277
return 0;
278278
}
279279
EXPORT_SYMBOL(iio_device_set_clock);
280280

281+
/**
282+
* iio_device_get_clock() - Retrieve current timestamping clock for the device
283+
* @indio_dev: IIO device structure containing the device
284+
*/
285+
clockid_t iio_device_get_clock(const struct iio_dev *indio_dev)
286+
{
287+
struct iio_dev_opaque *iio_dev_opaque = to_iio_dev_opaque(indio_dev);
288+
289+
return iio_dev_opaque->clock_id;
290+
}
291+
EXPORT_SYMBOL(iio_device_get_clock);
292+
281293
/**
282294
* iio_get_time_ns() - utility function to get a time stamp for events etc
283295
* @indio_dev: device

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
* @legacy_scan_el_group: attribute group for legacy scan elements attribute group
2525
* @legacy_buffer_group: attribute group for legacy buffer attributes group
2626
* @scan_index_timestamp: cache of the index to the timestamp
27+
* @clock_id: timestamping clock posix identifier
2728
* @chrdev: associated character device
2829
* @flags: file ops related flags including busy flag.
2930
* @debugfs_dentry: device specific debugfs dentry
@@ -51,6 +52,7 @@ struct iio_dev_opaque {
5152
struct attribute_group legacy_buffer_group;
5253

5354
unsigned int scan_index_timestamp;
55+
clockid_t clock_id;
5456
struct cdev chrdev;
5557
unsigned long flags;
5658

‎include/linux/iio/iio.h‎

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -509,7 +509,6 @@ struct iio_buffer_setup_ops {
509509
* @name: [DRIVER] name of the device.
510510
* @label: [DRIVER] unique name to identify which device this is
511511
* @info: [DRIVER] callbacks and constant info from driver
512-
* @clock_id: [INTERN] timestamping clock posix identifier
513512
* @setup_ops: [DRIVER] callbacks to call before and after buffer
514513
* enable/disable
515514
* @priv: [DRIVER] reference to driver's private information
@@ -538,7 +537,6 @@ struct iio_dev {
538537
const char *name;
539538
const char *label;
540539
const struct iio_info *info;
541-
clockid_t clock_id;
542540
const struct iio_buffer_setup_ops *setup_ops;
543541

544542
void *priv;
@@ -589,15 +587,7 @@ static inline void iio_device_put(struct iio_dev *indio_dev)
589587
put_device(&indio_dev->dev);
590588
}
591589

592-
/**
593-
* iio_device_get_clock() - Retrieve current timestamping clock for the device
594-
* @indio_dev: IIO device structure containing the device
595-
*/
596-
static inline clockid_t iio_device_get_clock(const struct iio_dev *indio_dev)
597-
{
598-
return indio_dev->clock_id;
599-
}
600-
590+
clockid_t iio_device_get_clock(const struct iio_dev *indio_dev);
601591
int iio_device_set_clock(struct iio_dev *indio_dev, clockid_t clock_id);
602592

603593
/**

0 commit comments

Comments
 (0)