Skip to content

Commit 5e05353

Browse files
YueHaibingholtmann
authored andcommitted
6lowpan: fix debugfs_simple_attr.cocci warnings
Use DEFINE_DEBUGFS_ATTRIBUTE rather than DEFINE_SIMPLE_ATTRIBUTE for debugfs files. Semantic patch information: Rationale: DEFINE_SIMPLE_ATTRIBUTE + debugfs_create_file() imposes some significant overhead as compared to DEFINE_DEBUGFS_ATTRIBUTE + debugfs_create_file_unsafe(). Generated by: scripts/coccinelle/api/debugfs/debugfs_simple_attr.cocci Signed-off-by: YueHaibing <[email protected]> Signed-off-by: Marcel Holtmann <[email protected]>
1 parent e250fab commit 5e05353

File tree

1 file changed

+21
-21
lines changed

1 file changed

+21
-21
lines changed

net/6lowpan/debugfs.c

Lines changed: 21 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -41,9 +41,9 @@ static int lowpan_ctx_flag_active_get(void *data, u64 *val)
4141
return 0;
4242
}
4343

44-
DEFINE_SIMPLE_ATTRIBUTE(lowpan_ctx_flag_active_fops,
45-
lowpan_ctx_flag_active_get,
46-
lowpan_ctx_flag_active_set, "%llu\n");
44+
DEFINE_DEBUGFS_ATTRIBUTE(lowpan_ctx_flag_active_fops,
45+
lowpan_ctx_flag_active_get,
46+
lowpan_ctx_flag_active_set, "%llu\n");
4747

4848
static int lowpan_ctx_flag_c_set(void *data, u64 val)
4949
{
@@ -66,8 +66,8 @@ static int lowpan_ctx_flag_c_get(void *data, u64 *val)
6666
return 0;
6767
}
6868

69-
DEFINE_SIMPLE_ATTRIBUTE(lowpan_ctx_flag_c_fops, lowpan_ctx_flag_c_get,
70-
lowpan_ctx_flag_c_set, "%llu\n");
69+
DEFINE_DEBUGFS_ATTRIBUTE(lowpan_ctx_flag_c_fops, lowpan_ctx_flag_c_get,
70+
lowpan_ctx_flag_c_set, "%llu\n");
7171

7272
static int lowpan_ctx_plen_set(void *data, u64 val)
7373
{
@@ -97,8 +97,8 @@ static int lowpan_ctx_plen_get(void *data, u64 *val)
9797
return 0;
9898
}
9999

100-
DEFINE_SIMPLE_ATTRIBUTE(lowpan_ctx_plen_fops, lowpan_ctx_plen_get,
101-
lowpan_ctx_plen_set, "%llu\n");
100+
DEFINE_DEBUGFS_ATTRIBUTE(lowpan_ctx_plen_fops, lowpan_ctx_plen_get,
101+
lowpan_ctx_plen_set, "%llu\n");
102102

103103
static int lowpan_ctx_pfx_show(struct seq_file *file, void *offset)
104104
{
@@ -184,15 +184,15 @@ static int lowpan_dev_debugfs_ctx_init(struct net_device *dev,
184184
if (!root)
185185
return -EINVAL;
186186

187-
dentry = debugfs_create_file("active", 0644, root,
188-
&ldev->ctx.table[id],
189-
&lowpan_ctx_flag_active_fops);
187+
dentry = debugfs_create_file_unsafe("active", 0644, root,
188+
&ldev->ctx.table[id],
189+
&lowpan_ctx_flag_active_fops);
190190
if (!dentry)
191191
return -EINVAL;
192192

193-
dentry = debugfs_create_file("compression", 0644, root,
194-
&ldev->ctx.table[id],
195-
&lowpan_ctx_flag_c_fops);
193+
dentry = debugfs_create_file_unsafe("compression", 0644, root,
194+
&ldev->ctx.table[id],
195+
&lowpan_ctx_flag_c_fops);
196196
if (!dentry)
197197
return -EINVAL;
198198

@@ -202,9 +202,9 @@ static int lowpan_dev_debugfs_ctx_init(struct net_device *dev,
202202
if (!dentry)
203203
return -EINVAL;
204204

205-
dentry = debugfs_create_file("prefix_len", 0644, root,
206-
&ldev->ctx.table[id],
207-
&lowpan_ctx_plen_fops);
205+
dentry = debugfs_create_file_unsafe("prefix_len", 0644, root,
206+
&ldev->ctx.table[id],
207+
&lowpan_ctx_plen_fops);
208208
if (!dentry)
209209
return -EINVAL;
210210

@@ -245,8 +245,8 @@ static int lowpan_short_addr_get(void *data, u64 *val)
245245
return 0;
246246
}
247247

248-
DEFINE_SIMPLE_ATTRIBUTE(lowpan_short_addr_fops, lowpan_short_addr_get,
249-
NULL, "0x%04llx\n");
248+
DEFINE_DEBUGFS_ATTRIBUTE(lowpan_short_addr_fops, lowpan_short_addr_get, NULL,
249+
"0x%04llx\n");
250250

251251
static int lowpan_dev_debugfs_802154_init(const struct net_device *dev,
252252
struct lowpan_dev *ldev)
@@ -260,9 +260,9 @@ static int lowpan_dev_debugfs_802154_init(const struct net_device *dev,
260260
if (!root)
261261
return -EINVAL;
262262

263-
dentry = debugfs_create_file("short_addr", 0444, root,
264-
lowpan_802154_dev(dev)->wdev->ieee802154_ptr,
265-
&lowpan_short_addr_fops);
263+
dentry = debugfs_create_file_unsafe("short_addr", 0444, root,
264+
lowpan_802154_dev(dev)->wdev->ieee802154_ptr,
265+
&lowpan_short_addr_fops);
266266
if (!dentry)
267267
return -EINVAL;
268268

0 commit comments

Comments
 (0)