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
6/**6/**
7 * struct iio_dev_opaque - industrial I/O device opaque information7 * struct iio_dev_opaque - industrial I/O device opaque information
8 * @indio_dev: public industrial I/O device information8 * @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
9 */13 */
10struct iio_dev_opaque {14struct iio_dev_opaque {
11 struct iio_dev indio_dev;15 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
12};22};
13 23
14#define to_iio_dev_opaque(indio_dev) \24#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
520 * @groups: [INTERN] attribute groups520 * @groups: [INTERN] attribute groups
521 * @groupcounter: [INTERN] index of next attribute group521 * @groupcounter: [INTERN] index of next attribute group
522 * @flags: [INTERN] file ops related flags including busy flag.522 * @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.
525 * @priv: [DRIVER] reference to driver's private information523 * @priv: [DRIVER] reference to driver's private information
526 * **MUST** be accessed **ONLY** via iio_priv() helper524 * **MUST** be accessed **ONLY** via iio_priv() helper
527 */525 */
@@ -567,12 +565,6 @@ struct iio_dev { · 39 unmodified lines
567 int groupcounter;565 int groupcounter;
568 566
569 unsigned long flags;567 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
576 void *priv;568 void *priv;
577};569};
578 570
@@ -733,10 +725,7 @@ static inline bool iio_buffer_enabled(struct iio_dev *indio_dev) · 154 unmodified lines
733 * @indio_dev: IIO device structure for device725 * @indio_dev: IIO device structure for device
734 **/726 **/
735#if defined(CONFIG_DEBUG_FS)727#if defined(CONFIG_DEBUG_FS)
736static inline struct dentry *iio_get_debugfs_dentry(struct iio_dev *indio_dev)728struct dentry *iio_get_debugfs_dentry(struct iio_dev *indio_dev);
737{
738 return indio_dev->debugfs_dentry;
739}
740#else729#else
741static inline struct dentry *iio_get_debugfs_dentry(struct iio_dev *indio_dev)730static inline struct dentry *iio_get_debugfs_dentry(struct iio_dev *indio_dev)
742{731{