History

iio: core: move debugfs data on the private iio dev info

This change moves all iio_dev debugfs fields to the iio_dev_priv object. It's not the biggest advantage yet (to the whole thing of abstractization) but it's a start. The iio_get_debugfs_dentry() function (which is moved in industrialio-core.c) needs to also be guarded against the CONFIG_DEBUG_FS symbol, when it isn't defined. We do want to keep the inline definition in the iio.h header, so that the compiler can better infer when to compile out debugfs code that is related to the IIO debugfs directory.

Alexandru Ardelean committed 6 years ago

Commit 96fb1b61 parent 09673d53 files · +44 −25Browse files

Showing the changes to include/linux (2 of 3 files). Show all

Unified · Split

2 files
  1. include/linux/iio/iio-opaque.h +10 −0
  2. include/linux/iio/iio.h +1 −12
include/linux/iio/iio-opaque.h+10−0
@@ -6,9 +6,19 @@ · 5 unmodified lines
66 /**
77 * struct iio_dev_opaque - industrial I/O device opaque information
88 * @indio_dev: public industrial I/O device information
9+ * @debugfs_dentry: device specific debugfs dentry
10+ * @cached_reg_addr: cached register address for debugfs reads
11+ * @read_buf: read buffer to be used for the initial reg read
12+ * @read_buf_len: data length in @read_buf
913 */
1014 struct iio_dev_opaque {
1115 struct iio_dev indio_dev;
16+#if defined(CONFIG_DEBUG_FS)
17+ struct dentry *debugfs_dentry;
18+ unsigned cached_reg_addr;
19+ char read_buf[20];
20+ unsigned int read_buf_len;
21+#endif
1222 };
1323
1424 #define to_iio_dev_opaque(indio_dev) \
include/linux/iio/iio.h+1−12
@@ -520,8 +520,6 @@ struct iio_buffer_setup_ops { · 519 unmodified lines
520520 * @groups: [INTERN] attribute groups
521521 * @groupcounter: [INTERN] index of next attribute group
522522 * @flags: [INTERN] file ops related flags including busy flag.
523− * @debugfs_dentry: [INTERN] device specific debugfs dentry.
524− * @cached_reg_addr: [INTERN] cached register address for debugfs reads.
525523 * @priv: [DRIVER] reference to driver's private information
526524 * **MUST** be accessed **ONLY** via iio_priv() helper
527525 */
@@ -567,12 +565,6 @@ struct iio_dev { · 39 unmodified lines
567565 int groupcounter;
568566
569567 unsigned long flags;
570−#if defined(CONFIG_DEBUG_FS)
571− struct dentry *debugfs_dentry;
572− unsigned cached_reg_addr;
573− char read_buf[20];
574− unsigned int read_buf_len;
575−#endif
576568 void *priv;
577569 };
578570
@@ -733,10 +725,7 @@ static inline bool iio_buffer_enabled(struct iio_dev *indio_dev) · 154 unmodified lines
733725 * @indio_dev: IIO device structure for device
734726 **/
735727 #if defined(CONFIG_DEBUG_FS)
736−static inline struct dentry *iio_get_debugfs_dentry(struct iio_dev *indio_dev)
737−{
738− return indio_dev->debugfs_dentry;
739−}
728+struct dentry *iio_get_debugfs_dentry(struct iio_dev *indio_dev);
740729 #else
741730 static inline struct dentry *iio_get_debugfs_dentry(struct iio_dev *indio_dev)
742731 {