Skip to content

Commit 2ca7382

Browse files
rsarkyjic23
authored andcommitted
iio: imu: adis16460: use DEFINE_DEBUGFS_ATTRIBUTE instead of DEFINE_SIMPLE_ATTRIBUTE
debugfs_create_file_unsafe does not protect the fops handed to it against file removal. DEFINE_DEBUGFS_ATTRIBUTE makes the fops aware of the file lifetime and thus protects it against removal. Signed-off-by: Rohit Sarkar <[email protected]> Tested-by Nuno Sá <[email protected]> Signed-off-by: Jonathan Cameron <[email protected]>
1 parent ae1d37a commit 2ca7382

File tree

1 file changed

+15
-12
lines changed

1 file changed

+15
-12
lines changed

drivers/iio/imu/adis16460.c

Lines changed: 15 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -87,8 +87,8 @@ static int adis16460_show_serial_number(void *arg, u64 *val)
8787

8888
return 0;
8989
}
90-
DEFINE_SIMPLE_ATTRIBUTE(adis16460_serial_number_fops,
91-
adis16460_show_serial_number, NULL, "0x%.4llx\n");
90+
DEFINE_DEBUGFS_ATTRIBUTE(adis16460_serial_number_fops,
91+
adis16460_show_serial_number, NULL, "0x%.4llx\n");
9292

9393
static int adis16460_show_product_id(void *arg, u64 *val)
9494
{
@@ -105,8 +105,8 @@ static int adis16460_show_product_id(void *arg, u64 *val)
105105

106106
return 0;
107107
}
108-
DEFINE_SIMPLE_ATTRIBUTE(adis16460_product_id_fops,
109-
adis16460_show_product_id, NULL, "%llu\n");
108+
DEFINE_DEBUGFS_ATTRIBUTE(adis16460_product_id_fops,
109+
adis16460_show_product_id, NULL, "%llu\n");
110110

111111
static int adis16460_show_flash_count(void *arg, u64 *val)
112112
{
@@ -123,19 +123,22 @@ static int adis16460_show_flash_count(void *arg, u64 *val)
123123

124124
return 0;
125125
}
126-
DEFINE_SIMPLE_ATTRIBUTE(adis16460_flash_count_fops,
127-
adis16460_show_flash_count, NULL, "%lld\n");
126+
DEFINE_DEBUGFS_ATTRIBUTE(adis16460_flash_count_fops,
127+
adis16460_show_flash_count, NULL, "%lld\n");
128128

129129
static int adis16460_debugfs_init(struct iio_dev *indio_dev)
130130
{
131131
struct adis16460 *adis16460 = iio_priv(indio_dev);
132132

133-
debugfs_create_file("serial_number", 0400, indio_dev->debugfs_dentry,
134-
adis16460, &adis16460_serial_number_fops);
135-
debugfs_create_file("product_id", 0400, indio_dev->debugfs_dentry,
136-
adis16460, &adis16460_product_id_fops);
137-
debugfs_create_file("flash_count", 0400, indio_dev->debugfs_dentry,
138-
adis16460, &adis16460_flash_count_fops);
133+
debugfs_create_file_unsafe("serial_number", 0400,
134+
indio_dev->debugfs_dentry, adis16460,
135+
&adis16460_serial_number_fops);
136+
debugfs_create_file_unsafe("product_id", 0400,
137+
indio_dev->debugfs_dentry, adis16460,
138+
&adis16460_product_id_fops);
139+
debugfs_create_file_unsafe("flash_count", 0400,
140+
indio_dev->debugfs_dentry, adis16460,
141+
&adis16460_flash_count_fops);
139142

140143
return 0;
141144
}

0 commit comments

Comments
 (0)