Linux IIO development
 help / color / mirror / Atom feed
* [PATCH 0/4] iio: imu: drop #ifdef around CONFIG_DEBUG_FS
@ 2024-08-09  9:17 Nuno Sa via B4 Relay
  2024-08-09  9:17 ` [PATCH 1/4] iio: imu: adis16475: drop ifdef " Nuno Sa via B4 Relay
                   ` (4 more replies)
  0 siblings, 5 replies; 6+ messages in thread
From: Nuno Sa via B4 Relay @ 2024-08-09  9:17 UTC (permalink / raw)
  To: linux-iio
  Cc: Lars-Peter Clausen, Michael Hennerich, Jonathan Cameron,
	Dragos Bogdan

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á



^ permalink raw reply	[flat|nested] 6+ messages in thread

* [PATCH 1/4] iio: imu: adis16475: drop ifdef around CONFIG_DEBUG_FS
  2024-08-09  9:17 [PATCH 0/4] iio: imu: drop #ifdef around CONFIG_DEBUG_FS Nuno Sa via B4 Relay
@ 2024-08-09  9:17 ` Nuno Sa via B4 Relay
  2024-08-09  9:17 ` [PATCH 2/4] iio: imu: adis16480: " Nuno Sa via B4 Relay
                   ` (3 subsequent siblings)
  4 siblings, 0 replies; 6+ messages in thread
From: Nuno Sa via B4 Relay @ 2024-08-09  9:17 UTC (permalink / raw)
  To: linux-iio
  Cc: Lars-Peter Clausen, Michael Hennerich, Jonathan Cameron,
	Dragos Bogdan

From: Nuno Sa <nuno.sa@analog.com>

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.

Signed-off-by: Nuno Sa <nuno.sa@analog.com>
---
 drivers/iio/imu/adis16475.c | 9 +++------
 1 file changed, 3 insertions(+), 6 deletions(-)

diff --git a/drivers/iio/imu/adis16475.c b/drivers/iio/imu/adis16475.c
index c094ae4ffcb2..88efe728b61b 100644
--- a/drivers/iio/imu/adis16475.c
+++ b/drivers/iio/imu/adis16475.c
@@ -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)
 {

-- 
2.45.2



^ permalink raw reply related	[flat|nested] 6+ messages in thread

* [PATCH 2/4] iio: imu: adis16480: drop ifdef around CONFIG_DEBUG_FS
  2024-08-09  9:17 [PATCH 0/4] iio: imu: drop #ifdef around CONFIG_DEBUG_FS Nuno Sa via B4 Relay
  2024-08-09  9:17 ` [PATCH 1/4] iio: imu: adis16475: drop ifdef " Nuno Sa via B4 Relay
@ 2024-08-09  9:17 ` Nuno Sa via B4 Relay
  2024-08-09  9:17 ` [PATCH 3/4] iio: imu: adis16400: " Nuno Sa via B4 Relay
                   ` (2 subsequent siblings)
  4 siblings, 0 replies; 6+ messages in thread
From: Nuno Sa via B4 Relay @ 2024-08-09  9:17 UTC (permalink / raw)
  To: linux-iio
  Cc: Lars-Peter Clausen, Michael Hennerich, Jonathan Cameron,
	Dragos Bogdan

From: Nuno Sa <nuno.sa@analog.com>

Use 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.

Signed-off-by: Nuno Sa <nuno.sa@analog.com>
---
 drivers/iio/imu/adis16480.c | 18 ++++--------------
 1 file changed, 4 insertions(+), 14 deletions(-)

diff --git a/drivers/iio/imu/adis16480.c b/drivers/iio/imu/adis16480.c
index 4e31503d512e..294181f2fcb3 100644
--- a/drivers/iio/imu/adis16480.c
+++ b/drivers/iio/imu/adis16480.c
@@ -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);

-- 
2.45.2



^ permalink raw reply related	[flat|nested] 6+ messages in thread

* [PATCH 3/4] iio: imu: adis16400: drop ifdef around CONFIG_DEBUG_FS
  2024-08-09  9:17 [PATCH 0/4] iio: imu: drop #ifdef around CONFIG_DEBUG_FS Nuno Sa via B4 Relay
  2024-08-09  9:17 ` [PATCH 1/4] iio: imu: adis16475: drop ifdef " Nuno Sa via B4 Relay
  2024-08-09  9:17 ` [PATCH 2/4] iio: imu: adis16480: " Nuno Sa via B4 Relay
@ 2024-08-09  9:17 ` Nuno Sa via B4 Relay
  2024-08-09  9:17 ` [PATCH 4/4] iio: imu: adis16460: " Nuno Sa via B4 Relay
  2024-08-10 10:41 ` [PATCH 0/4] iio: imu: drop #ifdef " Jonathan Cameron
  4 siblings, 0 replies; 6+ messages in thread
From: Nuno Sa via B4 Relay @ 2024-08-09  9:17 UTC (permalink / raw)
  To: linux-iio
  Cc: Lars-Peter Clausen, Michael Hennerich, Jonathan Cameron,
	Dragos Bogdan

From: Nuno Sa <nuno.sa@analog.com>

Use 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.

Signed-off-by: Nuno Sa <nuno.sa@analog.com>
---
 drivers/iio/imu/adis16400.c | 18 ++++--------------
 1 file changed, 4 insertions(+), 14 deletions(-)

diff --git a/drivers/iio/imu/adis16400.c b/drivers/iio/imu/adis16400.c
index 0bfd6205f5f6..6484ab8aff55 100644
--- a/drivers/iio/imu/adis16400.c
+++ b/drivers/iio/imu/adis16400.c
@@ -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,

-- 
2.45.2



^ permalink raw reply related	[flat|nested] 6+ messages in thread

* [PATCH 4/4] iio: imu: adis16460: drop ifdef around CONFIG_DEBUG_FS
  2024-08-09  9:17 [PATCH 0/4] iio: imu: drop #ifdef around CONFIG_DEBUG_FS Nuno Sa via B4 Relay
                   ` (2 preceding siblings ...)
  2024-08-09  9:17 ` [PATCH 3/4] iio: imu: adis16400: " Nuno Sa via B4 Relay
@ 2024-08-09  9:17 ` Nuno Sa via B4 Relay
  2024-08-10 10:41 ` [PATCH 0/4] iio: imu: drop #ifdef " Jonathan Cameron
  4 siblings, 0 replies; 6+ messages in thread
From: Nuno Sa via B4 Relay @ 2024-08-09  9:17 UTC (permalink / raw)
  To: linux-iio
  Cc: Lars-Peter Clausen, Michael Hennerich, Jonathan Cameron,
	Dragos Bogdan

From: Nuno Sa <nuno.sa@analog.com>

Use 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.

Signed-off-by: Nuno Sa <nuno.sa@analog.com>
---
 drivers/iio/imu/adis16460.c | 18 ++++--------------
 1 file changed, 4 insertions(+), 14 deletions(-)

diff --git a/drivers/iio/imu/adis16460.c b/drivers/iio/imu/adis16460.c
index 69facd72bd7d..eaa38dd6201f 100644
--- a/drivers/iio/imu/adis16460.c
+++ b/drivers/iio/imu/adis16460.c
@@ -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);

-- 
2.45.2



^ permalink raw reply related	[flat|nested] 6+ messages in thread

* Re: [PATCH 0/4] iio: imu: drop #ifdef around CONFIG_DEBUG_FS
  2024-08-09  9:17 [PATCH 0/4] iio: imu: drop #ifdef around CONFIG_DEBUG_FS Nuno Sa via B4 Relay
                   ` (3 preceding siblings ...)
  2024-08-09  9:17 ` [PATCH 4/4] iio: imu: adis16460: " Nuno Sa via B4 Relay
@ 2024-08-10 10:41 ` Jonathan Cameron
  4 siblings, 0 replies; 6+ messages in thread
From: Jonathan Cameron @ 2024-08-10 10:41 UTC (permalink / raw)
  To: Nuno Sa via B4 Relay
  Cc: nuno.sa, linux-iio, Lars-Peter Clausen, Michael Hennerich,
	Dragos Bogdan

On Fri, 09 Aug 2024 11:17:05 +0200
Nuno Sa via B4 Relay <devnull+nuno.sa.analog.com@kernel.org> wrote:

> 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.
> 
> ---
> 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á
> 
> 


^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2024-08-10 10:41 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-08-09  9:17 [PATCH 0/4] iio: imu: drop #ifdef around CONFIG_DEBUG_FS Nuno Sa via B4 Relay
2024-08-09  9:17 ` [PATCH 1/4] iio: imu: adis16475: drop ifdef " Nuno Sa via B4 Relay
2024-08-09  9:17 ` [PATCH 2/4] iio: imu: adis16480: " Nuno Sa via B4 Relay
2024-08-09  9:17 ` [PATCH 3/4] iio: imu: adis16400: " Nuno Sa via B4 Relay
2024-08-09  9:17 ` [PATCH 4/4] iio: imu: adis16460: " Nuno Sa via B4 Relay
2024-08-10 10:41 ` [PATCH 0/4] iio: imu: drop #ifdef " Jonathan Cameron

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox