iio: use DEFINE_DEBUGFS_ATTRIBUTE to define debugfs fops
Subsystems (3)
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
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
@@ -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
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_ATTRIBUTEto define debugfs file operation rather thanDEFINE_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
Signed-off-by zhong jiang <[email protected]>--- drivers/iio/imu/adis16460.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)drivers/iio/imu/adis16460.c +1
-1@@ -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)
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_ATTRIBUTEto define debugfs file operation rather thanDEFINE_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:Reviewed-by Alexandru Ardelean <[email protected]>Quoted 39 lines
Signed-off-by zhong jiang <[email protected]>--- drivers/iio/imu/adis16460.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)drivers/iio/imu/adis16460.c +1
-1@@ -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)
Jonathan Cameron
maintainerRe: [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_ATTRIBUTEto define debugfs file operation rather thanDEFINE_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:Reviewed-by Alexandru Ardelean <[email protected]>Quoted 1 line
Signed-off-by zhong jiang <[email protected]>
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@@ -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)
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_ATTRIBUTEto define debugfs file
operation rather thanDEFINE_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
Reviewed-by Alexandru Ardelean <[email protected]>Quoted 1 line
Signed-off-by zhong jiang <[email protected]>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/144The 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@@ -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
-2return 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)
PATCH 2/2 iio: imu: adis16400: use DEFINE_DEBUGFS_ATTRIBUTE to define debugfs fops
In reply to zhong jiangIt 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
@@ -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
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_ATTRIBUTEto define debugfs file operation rather thanDEFINE_SIMPLE_ATTRIBUTE.
Quoted 30 lines
Signed-off-by zhong jiang <[email protected]>--- drivers/iio/imu/adis16400.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)drivers/iio/imu/adis16400.c +1
-1@@ -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)
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: useDEFINE_DEBUGFS_ATTRIBUTEto define debugfs
fops
iio: imu: adis16400: useDEFINE_DEBUGFS_ATTRIBUTEto define debugfs
fopsdrivers/iio/imu/adis16400.c | 4 ++-- drivers/iio/imu/adis16460.c | 6 +++--- 2 files changed, 5 insertions(+), 5 deletions(-)