Skip to content

Commit 8b1c82c

Browse files
Jonathan CameronJonathan Cameron
authored andcommitted
iio: core: move @flags from struct iio_dev to struct iio_dev_opaque
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
1 parent 396f723 commit 8b1c82c

3 files changed

Lines changed: 5 additions & 5 deletions

File tree

‎drivers/iio/industrialio-core.c‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1720,15 +1720,15 @@ static int iio_chrdev_open(struct inode *inode, struct file *filp)
17201720
struct iio_dev *indio_dev = &iio_dev_opaque->indio_dev;
17211721
struct iio_dev_buffer_pair *ib;
17221722

1723-
if (test_and_set_bit(IIO_BUSY_BIT_POS, &indio_dev->flags))
1723+
if (test_and_set_bit(IIO_BUSY_BIT_POS, &iio_dev_opaque->flags))
17241724
return -EBUSY;
17251725

17261726
iio_device_get(indio_dev);
17271727

17281728
ib = kmalloc(sizeof(*ib), GFP_KERNEL);
17291729
if (!ib) {
17301730
iio_device_put(indio_dev);
1731-
clear_bit(IIO_BUSY_BIT_POS, &indio_dev->flags);
1731+
clear_bit(IIO_BUSY_BIT_POS, &iio_dev_opaque->flags);
17321732
return -ENOMEM;
17331733
}
17341734

@@ -1754,7 +1754,7 @@ static int iio_chrdev_release(struct inode *inode, struct file *filp)
17541754
container_of(inode->i_cdev, struct iio_dev_opaque, chrdev);
17551755
struct iio_dev *indio_dev = &iio_dev_opaque->indio_dev;
17561756
kfree(ib);
1757-
clear_bit(IIO_BUSY_BIT_POS, &indio_dev->flags);
1757+
clear_bit(IIO_BUSY_BIT_POS, &iio_dev_opaque->flags);
17581758
iio_device_put(indio_dev);
17591759

17601760
return 0;

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
* @legacy_buffer_group: attribute group for legacy buffer attributes group
2626
* @scan_index_timestamp: cache of the index to the timestamp
2727
* @chrdev: associated character device
28+
* @flags: file ops related flags including busy flag.
2829
* @debugfs_dentry: device specific debugfs dentry
2930
* @cached_reg_addr: cached register address for debugfs reads
3031
* @read_buf: read buffer to be used for the initial reg read
@@ -51,6 +52,7 @@ struct iio_dev_opaque {
5152

5253
unsigned int scan_index_timestamp;
5354
struct cdev chrdev;
55+
unsigned long flags;
5456

5557
#if defined(CONFIG_DEBUG_FS)
5658
struct dentry *debugfs_dentry;

‎include/linux/iio/iio.h‎

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -512,7 +512,6 @@ struct iio_buffer_setup_ops {
512512
* @clock_id: [INTERN] timestamping clock posix identifier
513513
* @setup_ops: [DRIVER] callbacks to call before and after buffer
514514
* enable/disable
515-
* @flags: [INTERN] file ops related flags including busy flag.
516515
* @priv: [DRIVER] reference to driver's private information
517516
* **MUST** be accessed **ONLY** via iio_priv() helper
518517
*/
@@ -542,7 +541,6 @@ struct iio_dev {
542541
clockid_t clock_id;
543542
const struct iio_buffer_setup_ops *setup_ops;
544543

545-
unsigned long flags;
546544
void *priv;
547545
};
548546

0 commit comments

Comments
 (0)