iio: core: move @flags from struct iio_dev to struct iio_dev_opaque
authorJonathan Cameron <Jonathan.Cameron@huawei.com>
Mon, 26 Apr 2021 17:49:10 +0000 (18:49 +0100)
committerJonathan Cameron <Jonathan.Cameron@huawei.com>
Mon, 17 May 2021 12:54:21 +0000 (13:54 +0100)
No reason any driver should ever need access to this field, so hide it.

Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
Reviewed-by: Alexandru Ardelean <ardeleanalex@gmail.com>
Link: https://lore.kernel.org/r/20210426174911.397061-9-jic23@kernel.org
drivers/iio/industrialio-core.c
include/linux/iio/iio-opaque.h
include/linux/iio/iio.h

index 0aba0a0..29ff766 100644 (file)
@@ -1720,7 +1720,7 @@ static int iio_chrdev_open(struct inode *inode, struct file *filp)
        struct iio_dev *indio_dev = &iio_dev_opaque->indio_dev;
        struct iio_dev_buffer_pair *ib;
 
-       if (test_and_set_bit(IIO_BUSY_BIT_POS, &indio_dev->flags))
+       if (test_and_set_bit(IIO_BUSY_BIT_POS, &iio_dev_opaque->flags))
                return -EBUSY;
 
        iio_device_get(indio_dev);
@@ -1728,7 +1728,7 @@ static int iio_chrdev_open(struct inode *inode, struct file *filp)
        ib = kmalloc(sizeof(*ib), GFP_KERNEL);
        if (!ib) {
                iio_device_put(indio_dev);
-               clear_bit(IIO_BUSY_BIT_POS, &indio_dev->flags);
+               clear_bit(IIO_BUSY_BIT_POS, &iio_dev_opaque->flags);
                return -ENOMEM;
        }
 
@@ -1754,7 +1754,7 @@ static int iio_chrdev_release(struct inode *inode, struct file *filp)
                container_of(inode->i_cdev, struct iio_dev_opaque, chrdev);
        struct iio_dev *indio_dev = &iio_dev_opaque->indio_dev;
        kfree(ib);
-       clear_bit(IIO_BUSY_BIT_POS, &indio_dev->flags);
+       clear_bit(IIO_BUSY_BIT_POS, &iio_dev_opaque->flags);
        iio_device_put(indio_dev);
 
        return 0;
index 2f8ef5d..d7c3036 100644 (file)
@@ -25,6 +25,7 @@
  * @legacy_buffer_group:       attribute group for legacy buffer attributes group
  * @scan_index_timestamp:      cache of the index to the timestamp
  * @chrdev:                    associated character device
+ * @flags:                     file ops related flags including busy flag.
  * @debugfs_dentry:            device specific debugfs dentry
  * @cached_reg_addr:           cached register address for debugfs reads
  * @read_buf:                  read buffer to be used for the initial reg read
@@ -51,6 +52,7 @@ struct iio_dev_opaque {
 
        unsigned int                    scan_index_timestamp;
        struct cdev                     chrdev;
+       unsigned long                   flags;
 
 #if defined(CONFIG_DEBUG_FS)
        struct dentry                   *debugfs_dentry;
index 586e2dc..ed05370 100644 (file)
@@ -512,7 +512,6 @@ struct iio_buffer_setup_ops {
  * @clock_id:          [INTERN] timestamping clock posix identifier
  * @setup_ops:         [DRIVER] callbacks to call before and after buffer
  *                     enable/disable
- * @flags:             [INTERN] file ops related flags including busy flag.
  * @priv:              [DRIVER] reference to driver's private information
  *                     **MUST** be accessed **ONLY** via iio_priv() helper
  */
@@ -542,7 +541,6 @@ struct iio_dev {
        clockid_t                       clock_id;
        const struct iio_buffer_setup_ops       *setup_ops;
 
-       unsigned long                   flags;
        void                            *priv;
 };