Skip to contentSkip to conversation

iio: use DEFINE_DEBUGFS_ATTRIBUTE to define debugfs fops

PATCH In review zhong jiang 3 participants 9 messages Oct 30, 2019 – Nov 4, 2019

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

cover iio: use DEFINE_DEBUGFS_ATTRIBUTE to define debugfs fops

The issue is detected with the help of coccinelle.

zhong jiang (2):
iio: imu: adis16460: use DEFINE_DEBUGFS_ATTRIBUTE to define debugfs
fops
iio: imu: adis16400: use DEFINE_DEBUGFS_ATTRIBUTE to define debugfs
fops

 drivers/iio/imu/adis16400.c | 4 ++--
 drivers/iio/imu/adis16460.c | 6 +++---
 2 files changed, 5 insertions(+), 5 deletions(-)
Signature · 1 line
1.7.12.4
#1 lore raw

PATCH 1/2 iio: imu: adis16460: use DEFINE_DEBUGFS_ATTRIBUTE to define debugfs fops

It is more clear to use DEFINE_DEBUGFS_ATTRIBUTE to define debugfs file operation rather than DEFINE_SIMPLE_ATTRIBUTE.

---
 drivers/iio/imu/adis16460.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)
drivers/iio/imu/adis16460.c +3 -3
index 6aed9e8..2e7a582 100644
@@ -87,7 +87,7 @@ static int adis16460_show_serial_number(void *arg, u64 *val)
 
 	return 0;
 }
-DEFINE_SIMPLE_ATTRIBUTE(adis16460_serial_number_fops,
+DEFINE_DEBUGFS_ATTRIBUTE(adis16460_serial_number_fops,
 	adis16460_show_serial_number, NULL, "0x%.4llx\n");
 
 static int adis16460_show_product_id(void *arg, u64 *val)
@@ -105,7 +105,7 @@ static int adis16460_show_product_id(void *arg, u64 *val)
 
 	return 0;
 }
-DEFINE_SIMPLE_ATTRIBUTE(adis16460_product_id_fops,
+DEFINE_DEBUGFS_ATTRIBUTE(adis16460_product_id_fops,
 	adis16460_show_product_id, NULL, "%llu\n");
 
 static int adis16460_show_flash_count(void *arg, u64 *val)
@@ -123,7 +123,7 @@ static int adis16460_show_flash_count(void *arg, u64 *val)
 
 	return 0;
 }
-DEFINE_SIMPLE_ATTRIBUTE(adis16460_flash_count_fops,
+DEFINE_DEBUGFS_ATTRIBUTE(adis16460_flash_count_fops,
 	adis16460_show_flash_count, NULL, "%lld\n");
 
 static int adis16460_debugfs_init(struct iio_dev *indio_dev)
Signature · 1 line
1.7.12.4
Reviewed-by on v1 1/2
#2 lore raw

Re: [PATCH 1/2] iio: imu: adis16460: use DEFINE_DEBUGFS_ATTRIBUTE to define debugfs fops

Quoted 4 lines · zhong jiang

[External]

It is more clear to use DEFINE_DEBUGFS_ATTRIBUTE to define debugfs file operation rather than DEFINE_SIMPLE_ATTRIBUTE.

Not sure if "more clear" is the word.
But it is more correct to use DEFINE_DEBUGFS_ATTRIBUTE(), since they are debugfs attrs.

In any case, this is no big deal.
So:

Quoted 40 lines
---
 drivers/iio/imu/adis16460.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)
drivers/iio/imu/adis16460.c +1 -1
index 6aed9e8..2e7a582 100644
@@ -87,7 +87,7 @@ static int adis16460_show_serial_number(void *arg, u64
 *val)
 
 	return 0;
 }
-DEFINE_SIMPLE_ATTRIBUTE(adis16460_serial_number_fops,
+DEFINE_DEBUGFS_ATTRIBUTE(adis16460_serial_number_fops,
 	adis16460_show_serial_number, NULL, "0x%.4llx\n");
 

static int adis16460_show_product_id(void *arg, u64 *val)

drivers/iio/imu/adis16460.c +1 -1
@@ -105,7 +105,7 @@ static int adis16460_show_product_id(void *arg, u64
 *val)
 
 	return 0;
 }
-DEFINE_SIMPLE_ATTRIBUTE(adis16460_product_id_fops,
+DEFINE_DEBUGFS_ATTRIBUTE(adis16460_product_id_fops,
 	adis16460_show_product_id, NULL, "%llu\n");
 

static int adis16460_show_flash_count(void *arg, u64 *val)

drivers/iio/imu/adis16460.c +1 -1
@@ -123,7 +123,7 @@ static int adis16460_show_flash_count(void *arg, u64
 *val)
 
 	return 0;
 }
-DEFINE_SIMPLE_ATTRIBUTE(adis16460_flash_count_fops,
+DEFINE_DEBUGFS_ATTRIBUTE(adis16460_flash_count_fops,
 	adis16460_show_flash_count, NULL, "%lld\n");
 

static int adis16460_debugfs_init(struct iio_dev *indio_dev)

#3 lore raw

Re: [PATCH 1/2] iio: imu: adis16460: use DEFINE_DEBUGFS_ATTRIBUTE to define debugfs fops

Quoted 6 lines · Alexandru
Quoted 4 lines · zhong jiang

[External]

It is more clear to use DEFINE_DEBUGFS_ATTRIBUTE to define debugfs file operation rather than DEFINE_SIMPLE_ATTRIBUTE.

Not sure if "more clear" is the word.

Should be more clearly. :-)

Quoted 47 lines

But it is more correct to use DEFINE_DEBUGFS_ATTRIBUTE(), since they are debugfs attrs.

In any case, this is no big deal.
So:

Quoted 39 lines
---
 drivers/iio/imu/adis16460.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)
drivers/iio/imu/adis16460.c +1 -1
index 6aed9e8..2e7a582 100644
@@ -87,7 +87,7 @@ static int adis16460_show_serial_number(void *arg, u64
 *val)
 
 	return 0;
 }
-DEFINE_SIMPLE_ATTRIBUTE(adis16460_serial_number_fops,
+DEFINE_DEBUGFS_ATTRIBUTE(adis16460_serial_number_fops,
 	adis16460_show_serial_number, NULL, "0x%.4llx\n");
 

static int adis16460_show_product_id(void *arg, u64 *val)

drivers/iio/imu/adis16460.c +1 -1
@@ -105,7 +105,7 @@ static int adis16460_show_product_id(void *arg, u64
 *val)
 
 	return 0;
 }
-DEFINE_SIMPLE_ATTRIBUTE(adis16460_product_id_fops,
+DEFINE_DEBUGFS_ATTRIBUTE(adis16460_product_id_fops,
 	adis16460_show_product_id, NULL, "%llu\n");
 

static int adis16460_show_flash_count(void *arg, u64 *val)

drivers/iio/imu/adis16460.c +1 -1
@@ -123,7 +123,7 @@ static int adis16460_show_flash_count(void *arg, u64
 *val)
 
 	return 0;
 }
-DEFINE_SIMPLE_ATTRIBUTE(adis16460_flash_count_fops,
+DEFINE_DEBUGFS_ATTRIBUTE(adis16460_flash_count_fops,
 	adis16460_show_flash_count, NULL, "%lld\n");
 

static int adis16460_debugfs_init(struct iio_dev *indio_dev)

maintainer
#4 lore raw

Re: [PATCH 1/2] iio: imu: adis16460: use DEFINE_DEBUGFS_ATTRIBUTE to define debugfs fops

Quoted 17 lines · On Wed, 30 Oct 2019 17:33:14 +0800 zhong jiang <[email protected]> wrote:
Quoted 6 lines · Alexandru
Quoted 4 lines · zhong jiang

[External]

It is more clear to use DEFINE_DEBUGFS_ATTRIBUTE to define debugfs file operation rather than DEFINE_SIMPLE_ATTRIBUTE.

Not sure if "more clear" is the word.

Should be more clearly. :-)

Quoted 9 lines

But it is more correct to use DEFINE_DEBUGFS_ATTRIBUTE(), since they are debugfs attrs.

In any case, this is no big deal.
So:

Quoted 1 line

I started looking into why this attributes were introduced. There are potential issues, so Alex can you confirm you've tested this series. Whilst it looks right, it seems some other patches making this change have had to switch over to the unsafe registration functions.

https://patchwork.kernel.org/patch/11051725/
https://lkml.org/lkml/2019/10/30/144

The reference counting is subtly different between the two versions. Seems you are getting some push back on similar patches.

Perhaps a v2 with reference to the other threads if those get resolved to say it is sensible to make this change.

Thanks,

Jonathan

Quoted 40 lines
Quoted 38 lines
Quoted 38 lines
---
 drivers/iio/imu/adis16460.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)
drivers/iio/imu/adis16460.c +1 -1
index 6aed9e8..2e7a582 100644
@@ -87,7 +87,7 @@ static int adis16460_show_serial_number(void *arg, u64
 *val)
 
 	return 0;
 }
-DEFINE_SIMPLE_ATTRIBUTE(adis16460_serial_number_fops,
+DEFINE_DEBUGFS_ATTRIBUTE(adis16460_serial_number_fops,
 	adis16460_show_serial_number, NULL, "0x%.4llx\n");
 

static int adis16460_show_product_id(void *arg, u64 *val)

drivers/iio/imu/adis16460.c +1 -1
@@ -105,7 +105,7 @@ static int adis16460_show_product_id(void *arg, u64
 *val)
 
 	return 0;
 }
-DEFINE_SIMPLE_ATTRIBUTE(adis16460_product_id_fops,
+DEFINE_DEBUGFS_ATTRIBUTE(adis16460_product_id_fops,
 	adis16460_show_product_id, NULL, "%llu\n");
 

static int adis16460_show_flash_count(void *arg, u64 *val)

drivers/iio/imu/adis16460.c +1 -1
@@ -123,7 +123,7 @@ static int adis16460_show_flash_count(void *arg, u64
 *val)
 
 	return 0;
 }
-DEFINE_SIMPLE_ATTRIBUTE(adis16460_flash_count_fops,
+DEFINE_DEBUGFS_ATTRIBUTE(adis16460_flash_count_fops,
 	adis16460_show_flash_count, NULL, "%lld\n");
 

static int adis16460_debugfs_init(struct iio_dev *indio_dev)

#5 lore raw

Re: [PATCH 1/2] iio: imu: adis16460: use DEFINE_DEBUGFS_ATTRIBUTE to define debugfs fops

Quoted 19 lines · Jonathan Cameron
Quoted 16 lines · On Wed, 30 Oct 2019 17:33:14 +0800 zhong jiang <[email protected]> wrote:
Quoted 7 lines · Alexandru
Quoted 5 lines · zhong jiang

[External]

It is more clear to use DEFINE_DEBUGFS_ATTRIBUTE to define debugfs file
operation rather than DEFINE_SIMPLE_ATTRIBUTE.

Not sure if "more clear" is the word.

Should be more clearly. :-)

Quoted 7 lines

But it is more correct to use DEFINE_DEBUGFS_ATTRIBUTE(), since they are
debugfs attrs.

In any case, this is no big deal.
So:

Quoted 7 lines
Quoted 3 lines
Quoted 3 lines
Quoted 1 line

I started looking into why this attributes were introduced. There are potential issues, so Alex can you confirm you've tested this series. Whilst it looks right, it seems some other patches making this change have had to switch over to the unsafe registration functions.

I haven't tested this locally yet.
Will try to alloc some time for this.

Quoted 57 lines

https://patchwork.kernel.org/patch/11051725/
https://lkml.org/lkml/2019/10/30/144

The reference counting is subtly different between the two versions. Seems you are getting some push back on similar patches.

Perhaps a v2 with reference to the other threads if those get resolved to say it is sensible to make this change.

Thanks,

Jonathan

Quoted 42 lines
Quoted 42 lines
Quoted 42 lines
---
 drivers/iio/imu/adis16460.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)
drivers/iio/imu/adis16460.c +1 -1
index 6aed9e8..2e7a582 100644
@@ -87,7 +87,7 @@ static int adis16460_show_serial_number(void
 *arg, u64
 *val)
 
 	return 0;
 }
-DEFINE_SIMPLE_ATTRIBUTE(adis16460_serial_number_fops,
+DEFINE_DEBUGFS_ATTRIBUTE(adis16460_serial_number_fops,
 	adis16460_show_serial_number, NULL, "0x%.4llx\n");

static int adis16460_show_product_id(void *arg, u64 *val)

drivers/iio/imu/adis16460.c +0 -0
@@ -105,7 +105,7 @@ static int adis16460_show_product_id(void *arg,

u64
*val)

drivers/iio/imu/adis16460.c +2 -2
 	return 0;
 }
-DEFINE_SIMPLE_ATTRIBUTE(adis16460_product_id_fops,
+DEFINE_DEBUGFS_ATTRIBUTE(adis16460_product_id_fops,
 	adis16460_show_product_id, NULL, "%llu\n");
 
 static int adis16460_show_flash_count(void *arg, u64 *val)
@@ -123,7 +123,7 @@ static int adis16460_show_flash_count(void
 *arg, u64
 *val)
 
 	return 0;
 }
-DEFINE_SIMPLE_ATTRIBUTE(adis16460_flash_count_fops,
+DEFINE_DEBUGFS_ATTRIBUTE(adis16460_flash_count_fops,
 	adis16460_show_flash_count, NULL, "%lld\n");

static int adis16460_debugfs_init(struct iio_dev *indio_dev)

#6 lore raw

PATCH 2/2 iio: imu: adis16400: use DEFINE_DEBUGFS_ATTRIBUTE to define debugfs fops

In reply to zhong jiang

It is more clear to use DEFINE_DEBUGFS_ATTRIBUTE to define debugfs file operation rather than DEFINE_SIMPLE_ATTRIBUTE.

---
 drivers/iio/imu/adis16400.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/iio/imu/adis16400.c +2 -2
index 0575ff7..8195bc9 100644
@@ -256,7 +256,7 @@ static int adis16400_show_product_id(void *arg, u64 *val)
 
 	return 0;
 }
-DEFINE_SIMPLE_ATTRIBUTE(adis16400_product_id_fops,
+DEFINE_DEBUGFS_ATTRIBUTE(adis16400_product_id_fops,
 	adis16400_show_product_id, NULL, "%lld\n");
 
 static int adis16400_show_flash_count(void *arg, u64 *val)
@@ -273,7 +273,7 @@ static int adis16400_show_flash_count(void *arg, u64 *val)
 
 	return 0;
 }
-DEFINE_SIMPLE_ATTRIBUTE(adis16400_flash_count_fops,
+DEFINE_DEBUGFS_ATTRIBUTE(adis16400_flash_count_fops,
 	adis16400_show_flash_count, NULL, "%lld\n");
 
 static int adis16400_debugfs_init(struct iio_dev *indio_dev)
Signature · 1 line
1.7.12.4
Reviewed-by on v1 2/2
#7 lore raw

Re: [PATCH 2/2] iio: imu: adis16400: use DEFINE_DEBUGFS_ATTRIBUTE to define debugfs fops

Quoted 4 lines · zhong jiang

[External]

It is more clear to use DEFINE_DEBUGFS_ATTRIBUTE to define debugfs file operation rather than DEFINE_SIMPLE_ATTRIBUTE.

Quoted 30 lines
---
 drivers/iio/imu/adis16400.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/iio/imu/adis16400.c +1 -1
index 0575ff7..8195bc9 100644
@@ -256,7 +256,7 @@ static int adis16400_show_product_id(void *arg, u64
 *val)
 
 	return 0;
 }
-DEFINE_SIMPLE_ATTRIBUTE(adis16400_product_id_fops,
+DEFINE_DEBUGFS_ATTRIBUTE(adis16400_product_id_fops,
 	adis16400_show_product_id, NULL, "%lld\n");
 

static int adis16400_show_flash_count(void *arg, u64 *val)

drivers/iio/imu/adis16400.c +1 -1
@@ -273,7 +273,7 @@ static int adis16400_show_flash_count(void *arg, u64
 *val)
 
 	return 0;
 }
-DEFINE_SIMPLE_ATTRIBUTE(adis16400_flash_count_fops,
+DEFINE_DEBUGFS_ATTRIBUTE(adis16400_flash_count_fops,
 	adis16400_show_flash_count, NULL, "%lld\n");
 

static int adis16400_debugfs_init(struct iio_dev *indio_dev)

#8 lore raw
In reply to zhong jiang
Quoted 2 lines · zhong jiang

[External]

Thanks for the patches.
They look good.

Quoted 12 lines

The issue is detected with the help of coccinelle.

zhong jiang (2):
iio: imu: adis16460: use DEFINE_DEBUGFS_ATTRIBUTE to define debugfs
fops
iio: imu: adis16400: use DEFINE_DEBUGFS_ATTRIBUTE to define debugfs
fops

 drivers/iio/imu/adis16400.c | 4 ++--
 drivers/iio/imu/adis16460.c | 6 +++---
 2 files changed, 5 insertions(+), 5 deletions(-)