iio: core: move @clock_id from struct iio_dev to struct iio_dev_opaque
authorJonathan Cameron <Jonathan.Cameron@huawei.com>
Mon, 26 Apr 2021 17:49:11 +0000 (18:49 +0100)
committerJonathan Cameron <Jonathan.Cameron@huawei.com>
Mon, 17 May 2021 12:54:21 +0000 (13:54 +0100)
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
drivers/iio/industrialio-core.c
include/linux/iio/iio-opaque.h
include/linux/iio/iio.h

index 29ff766..bfa20a3 100644 (file)
@@ -271,7 +271,7 @@ int iio_device_set_clock(struct iio_dev *indio_dev, clockid_t clock_id)
                mutex_unlock(&indio_dev->mlock);
                return -EBUSY;
        }
-       indio_dev->clock_id = clock_id;
+       iio_dev_opaque->clock_id = clock_id;
        mutex_unlock(&indio_dev->mlock);
 
        return 0;
@@ -279,6 +279,18 @@ int iio_device_set_clock(struct iio_dev *indio_dev, clockid_t clock_id)
 EXPORT_SYMBOL(iio_device_set_clock);
 
 /**
+ * iio_device_get_clock() - Retrieve current timestamping clock for the device
+ * @indio_dev: IIO device structure containing the device
+ */
+clockid_t iio_device_get_clock(const struct iio_dev *indio_dev)
+{
+       struct iio_dev_opaque *iio_dev_opaque = to_iio_dev_opaque(indio_dev);
+
+       return iio_dev_opaque->clock_id;
+}
+EXPORT_SYMBOL(iio_device_get_clock);
+
+/**
  * iio_get_time_ns() - utility function to get a time stamp for events etc
  * @indio_dev: device
  */
index d7c3036..c9504e9 100644 (file)
@@ -24,6 +24,7 @@
  * @legacy_scan_el_group:      attribute group for legacy scan elements attribute group
  * @legacy_buffer_group:       attribute group for legacy buffer attributes group
  * @scan_index_timestamp:      cache of the index to the timestamp
+ * @clock_id:                  timestamping clock posix identifier
  * @chrdev:                    associated character device
  * @flags:                     file ops related flags including busy flag.
  * @debugfs_dentry:            device specific debugfs dentry
@@ -51,6 +52,7 @@ struct iio_dev_opaque {
        struct attribute_group          legacy_buffer_group;
 
        unsigned int                    scan_index_timestamp;
+       clockid_t                       clock_id;
        struct cdev                     chrdev;
        unsigned long                   flags;
 
index ed05370..5606a3f 100644 (file)
@@ -509,7 +509,6 @@ struct iio_buffer_setup_ops {
  * @name:              [DRIVER] name of the device.
  * @label:              [DRIVER] unique name to identify which device this is
  * @info:              [DRIVER] callbacks and constant info from driver
- * @clock_id:          [INTERN] timestamping clock posix identifier
  * @setup_ops:         [DRIVER] callbacks to call before and after buffer
  *                     enable/disable
  * @priv:              [DRIVER] reference to driver's private information
@@ -538,7 +537,6 @@ struct iio_dev {
        const char                      *name;
        const char                      *label;
        const struct iio_info           *info;
-       clockid_t                       clock_id;
        const struct iio_buffer_setup_ops       *setup_ops;
 
        void                            *priv;
@@ -589,15 +587,7 @@ static inline void iio_device_put(struct iio_dev *indio_dev)
                put_device(&indio_dev->dev);
 }
 
-/**
- * iio_device_get_clock() - Retrieve current timestamping clock for the device
- * @indio_dev: IIO device structure containing the device
- */
-static inline clockid_t iio_device_get_clock(const struct iio_dev *indio_dev)
-{
-       return indio_dev->clock_id;
-}
-
+clockid_t iio_device_get_clock(const struct iio_dev *indio_dev);
 int iio_device_set_clock(struct iio_dev *indio_dev, clockid_t clock_id);
 
 /**