iio: imu: drop #ifdef around CONFIG_DEBUG_FS
Subsystems (4)
Nuno Sa
maintainercover iio: imu: drop #ifdef around CONFIG_DEBUG_FS
Hi,
Small series to make the IMUs debugfs code a bit neater. As mentioned in the commit message, let's allow the compiler to drop any unused instead of guarding it with #ifdefs.
---
Nuno Sa (4):
iio: imu: adis16475: drop ifdef around CONFIG_DEBUG_FS
iio: imu: adis16480: drop ifdef around CONFIG_DEBUG_FS
iio: imu: adis16400: drop ifdef around CONFIG_DEBUG_FS
iio: imu: adis16460: drop ifdef around CONFIG_DEBUG_FS
drivers/iio/imu/adis16400.c | 18 ++++-------------- drivers/iio/imu/adis16460.c | 18 ++++-------------- drivers/iio/imu/adis16475.c | 9 +++------ drivers/iio/imu/adis16480.c | 18 ++++-------------- 4 files changed, 15 insertions(+), 48 deletions(-)
---
base-commit: 7cad163c39cb642ed587d3eeb37a5637ee02740f
change-id: 20240809-dev-adis-debugfs-improv-e007579b5262 --
Thanks!
- Nuno Sá
Nuno Sa
maintainerPATCH 1/4 iio: imu: adis16475: drop ifdef around CONFIG_DEBUG_FS
Use IS_ENABLED(CONFIG_DEBUG_FS) to return early in case debugfs is not present. Since this is known at compile time, it allows the compiler to drop any unused code. Therefore no need to wrap the code with #ifdef.
--- drivers/iio/imu/adis16475.c | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-)
drivers/iio/imu/adis16475.c +3 -6
@@ -164,7 +164,6 @@ module_param(low_rate_allow, bool, 0444);MODULE_PARM_DESC (low_rate_allow,"Allow IMU rates below the minimum advisable when external clk is used in SCALED mode (default: N)" ); -#ifdef CONFIG_DEBUG_FS static ssize_t adis16475_show_firmware_revision (struct file *file,char __user *userbuf,size_t count,loff_t *ppos)
@@ -279,6 +278,9 @@ static void adis16475_debugfs_init(struct iio_dev *indio_dev)struct adis16475 *st =iio_priv (indio_dev);struct dentry *d =iio_get_debugfs_dentry (indio_dev); +if (!IS_ENABLED (CONFIG_DEBUG_FS )) +return ; +debugfs_create_file_unsafe ("serial_number" ,0400 , d, st, &adis16475_serial_number_fops); debugfs_create_file_unsafe("product_id", 0400,
@@ -290,11 +292,6 @@ static void adis16475_debugfs_init(struct iio_dev *indio_dev)debugfs_create_file ("firmware_date" ,0400 , d, st, &adis16475_firmware_date_fops); } -#else -static void adis16475_debugfs_init (struct iio_dev *indio_dev) -{ -} -#endif static int adis16475_get_freq (struct adis16475 *st,u32 *freq) {
Signature · 1 line
2.45.2
Nuno Sa
maintainerPATCH 2/4 iio: imu: adis16480: drop ifdef around CONFIG_DEBUG_FS
In reply to Nuno SaUse IS_ENABLED(CONFIG_DEBUG_FS) to return in case debugfs is not present. Since this is known at compile time, it allows the compiler to drop any unused code. Therefore no need to wrap the code with #ifdef.
While at it make adis16480_debugfs_init() void as the return code is ignored.
--- drivers/iio/imu/adis16480.c | 18 ++++-------------- 1 file changed, 4 insertions(+), 14 deletions(-)
drivers/iio/imu/adis16480.c +4 -14
@@ -193,8 +193,6 @@ module_param(low_rate_allow, bool, 0444);MODULE_PARM_DESC (low_rate_allow,"Allow IMU rates below the minimum advisable when external clk is used in PPS mode (default: N)" ); -#ifdef CONFIG_DEBUG_FS -static ssize_t adis16480_show_firmware_revision (struct file *file,char __user *userbuf,size_t count,loff_t *ppos) {
@@ -304,11 +302,14 @@ static int adis16480_show_flash_count(void *arg, u64 *val)DEFINE_DEBUGFS_ATTRIBUTE (adis16480_flash_count_fops, adis16480_show_flash_count,NULL ,"%lld\n" ); -static int adis16480_debugfs_init (struct iio_dev *indio_dev) +static void adis16480_debugfs_init (struct iio_dev *indio_dev) {struct adis16480 *adis16480 =iio_priv (indio_dev);struct dentry *d =iio_get_debugfs_dentry (indio_dev); +if (!IS_ENABLED (CONFIG_DEBUG_FS )) +return ; +debugfs_create_file_unsafe ("firmware_revision" ,0400 , d, adis16480, &adis16480_firmware_revision_fops); debugfs_create_file_unsafe("firmware_date", 0400,
@@ -319,19 +320,8 @@ static int adis16480_debugfs_init(struct iio_dev *indio_dev) d, adis16480, &adis16480_product_id_fops);debugfs_create_file_unsafe ("flash_count" ,0400 , d, adis16480, &adis16480_flash_count_fops); - - return 0; } -#else - -static int adis16480_debugfs_init (struct iio_dev *indio_dev) -{ -return 0 ; -} - -#endif -static int adis16480_set_freq (struct iio_dev *indio_dev,int val,int val2) {struct adis16480 *st =iio_priv (indio_dev);
Signature · 1 line
2.45.2
Nuno Sa
maintainerPATCH 3/4 iio: imu: adis16400: drop ifdef around CONFIG_DEBUG_FS
In reply to Nuno SaUse IS_ENABLED(CONFIG_DEBUG_FS) to return in case debugfs is not present. Since this is known at compile time, it allows the compiler to drop any unused code. Therefore no need to wrap the code with #ifdef.
While at it make adis16400_debugfs_init() void as the return code is ignored.
--- drivers/iio/imu/adis16400.c | 18 ++++-------------- 1 file changed, 4 insertions(+), 14 deletions(-)
drivers/iio/imu/adis16400.c +4 -14
@@ -202,8 +202,6 @@ enum { ADIS16400_SCAN_TIMESTAMP, }; -#ifdef CONFIG_DEBUG_FS -static ssize_t adis16400_show_serial_number (struct file *file,char __user *userbuf,size_t count,loff_t *ppos) {
@@ -273,11 +271,14 @@ static int adis16400_show_flash_count(void *arg, u64 *val)DEFINE_DEBUGFS_ATTRIBUTE (adis16400_flash_count_fops, adis16400_show_flash_count,NULL ,"%lld\n" ); -static int adis16400_debugfs_init (struct iio_dev *indio_dev) +static void adis16400_debugfs_init (struct iio_dev *indio_dev) {struct adis16400_state *st =iio_priv (indio_dev);struct dentry *d =iio_get_debugfs_dentry (indio_dev); +if (!IS_ENABLED (CONFIG_DEBUG_FS )) +return ; +if (st->variant->flags &ADIS16400_HAS_SERIAL_NUMBER )debugfs_create_file_unsafe ("serial_number" ,0400 , d, st, &adis16400_serial_number_fops);
@@ -286,19 +287,8 @@ static int adis16400_debugfs_init(struct iio_dev *indio_dev) d, st, &adis16400_product_id_fops);debugfs_create_file_unsafe ("flash_count" ,0400 , d, st, &adis16400_flash_count_fops); - -return 0 ; } -#else - -static int adis16400_debugfs_init (struct iio_dev *indio_dev) -{ -return 0 ; -} - -#endif -enum adis16400_chip_variant {ADIS16300 ,ADIS16334 ,
Signature · 1 line
2.45.2
Nuno Sa
maintainerPATCH 4/4 iio: imu: adis16460: drop ifdef around CONFIG_DEBUG_FS
In reply to Nuno SaUse IS_ENABLED(CONFIG_DEBUG_FS) to return in case debugfs is not present. Since this is known at compile time, it allows the compiler to drop any unused code. Therefore no need to wrap the code with #ifdef.
While at it make adis16460_debugfs_init() void as the return code is ignored.
--- drivers/iio/imu/adis16460.c | 18 ++++-------------- 1 file changed, 4 insertions(+), 14 deletions(-)
drivers/iio/imu/adis16460.c +4 -14
@@ -69,8 +69,6 @@ struct adis16460 {struct adis adis; }; -#ifdef CONFIG_DEBUG_FS -static int adis16460_show_serial_number (void *arg,u64 *val) {struct adis16460 *adis16460 = arg;
@@ -125,30 +123,22 @@ static int adis16460_show_flash_count(void *arg, u64 *val)DEFINE_DEBUGFS_ATTRIBUTE (adis16460_flash_count_fops, adis16460_show_flash_count,NULL ,"%lld\n" ); -static int adis16460_debugfs_init (struct iio_dev *indio_dev) +static void adis16460_debugfs_init (struct iio_dev *indio_dev) {struct adis16460 *adis16460 =iio_priv (indio_dev);struct dentry *d =iio_get_debugfs_dentry (indio_dev); +if (!IS_ENABLED (CONFIG_DEBUG_FS )) +return ; +debugfs_create_file_unsafe ("serial_number" ,0400 , d, adis16460, &adis16460_serial_number_fops);debugfs_create_file_unsafe ("product_id" ,0400 , d, adis16460, &adis16460_product_id_fops);debugfs_create_file_unsafe ("flash_count" ,0400 , d, adis16460, &adis16460_flash_count_fops); - -return 0 ; } -#else - -static int adis16460_debugfs_init (struct iio_dev *indio_dev) -{ -return 0 ; -} - -#endif -static int adis16460_set_freq (struct iio_dev *indio_dev,int val,int val2) {struct adis16460 *st =iio_priv (indio_dev);
Signature · 1 line
2.45.2
Quoted 5 lines · On Fri, 09 Aug 2024 11:17:05 +0200 Nuno Sa via B4 Relay…
Hi,
Small series to make the IMUs debugfs code a bit neater. As mentioned in the commit message, let's allow the compiler to drop any unused instead of guarding it with #ifdefs.
Applied.
Quoted 22 lines
---
Nuno Sa (4):
iio: imu: adis16475: drop ifdef aroundCONFIG_DEBUG_FS
iio: imu: adis16480: drop ifdef aroundCONFIG_DEBUG_FS
iio: imu: adis16400: drop ifdef aroundCONFIG_DEBUG_FS
iio: imu: adis16460: drop ifdef aroundCONFIG_DEBUG_FSdrivers/iio/imu/adis16400.c | 18 ++++-------------- drivers/iio/imu/adis16460.c | 18 ++++-------------- drivers/iio/imu/adis16475.c | 9 +++------ drivers/iio/imu/adis16480.c | 18 ++++-------------- 4 files changed, 15 insertions(+), 48 deletions(-)---
base-commit:7cad163c39cb642ed587d3eeb37a5637ee02740f
change-id: 20240809-dev-adis-debugfs-improv-e007579b5262 --Thanks!
- Nuno Sá