Skip to content

Commit 7bcfaf2

Browse files
jmberglinvjw
authored andcommitted
cfg80211/mac80211: use debugfs_remove_recursive
We can save a lot of code and pointers in the structs by using debugfs_remove_recursive(). First, change cfg80211 to use debugfs_remove_recursive() so that drivers do not need to clean up any files they added to the per-wiphy debugfs (if and only if they are ok to be accessed until after wiphy_unregister!). Then also make mac80211 use debugfs_remove_recursive() where necessary -- it need not remove per-wiphy files as cfg80211 now removes those, but netdev etc. files still need to be handled but can now be removed without needing struct dentry pointers to all of them. Signed-off-by: Johannes Berg <johannes@sipsolutions.net> Signed-off-by: John W. Linville <linville@tuxdriver.com>
1 parent 2c0d610 commit 7bcfaf2

14 files changed

Lines changed: 51 additions & 462 deletions

File tree

‎net/mac80211/debugfs.c‎

Lines changed: 4 additions & 69 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
12
/*
23
* mac80211 debugfs for wireless PHYs
34
*
@@ -38,16 +39,10 @@ static const struct file_operations name## _ops = { \
3839
};
3940

4041
#define DEBUGFS_ADD(name) \
41-
local->debugfs.name = debugfs_create_file(#name, 0400, phyd, \
42-
local, &name## _ops);
42+
debugfs_create_file(#name, 0400, phyd, local, &name## _ops);
4343

4444
#define DEBUGFS_ADD_MODE(name, mode) \
45-
local->debugfs.name = debugfs_create_file(#name, mode, phyd, \
46-
local, &name## _ops);
47-
48-
#define DEBUGFS_DEL(name) \
49-
debugfs_remove(local->debugfs.name); \
50-
local->debugfs.name = NULL;
45+
debugfs_create_file(#name, mode, phyd, local, &name## _ops);
5146

5247

5348
DEBUGFS_READONLY_FILE(frequency, 20, "%d",
@@ -233,12 +228,7 @@ static const struct file_operations stats_ ##name## _ops = { \
233228
};
234229

235230
#define DEBUGFS_STATS_ADD(name) \
236-
local->debugfs.stats.name = debugfs_create_file(#name, 0400, statsd,\
237-
local, &stats_ ##name## _ops);
238-
239-
#define DEBUGFS_STATS_DEL(name) \
240-
debugfs_remove(local->debugfs.stats.name); \
241-
local->debugfs.stats.name = NULL;
231+
debugfs_create_file(#name, 0400, statsd, local, &stats_ ##name## _ops);
242232

243233
DEBUGFS_STATS_FILE(transmitted_fragment_count, 20, "%u",
244234
local->dot11TransmittedFragmentCount);
@@ -326,7 +316,6 @@ void debugfs_hw_add(struct ieee80211_local *local)
326316
DEBUGFS_ADD(noack);
327317

328318
statsd = debugfs_create_dir("statistics", phyd);
329-
local->debugfs.statistics = statsd;
330319

331320
/* if the dir failed, don't put all the other things into the root! */
332321
if (!statsd)
@@ -367,57 +356,3 @@ void debugfs_hw_add(struct ieee80211_local *local)
367356
DEBUGFS_STATS_ADD(dot11FCSErrorCount);
368357
DEBUGFS_STATS_ADD(dot11RTSSuccessCount);
369358
}
370-
371-
void debugfs_hw_del(struct ieee80211_local *local)
372-
{
373-
DEBUGFS_DEL(frequency);
374-
DEBUGFS_DEL(total_ps_buffered);
375-
DEBUGFS_DEL(wep_iv);
376-
DEBUGFS_DEL(tsf);
377-
DEBUGFS_DEL(queues);
378-
DEBUGFS_DEL(reset);
379-
DEBUGFS_DEL(noack);
380-
381-
DEBUGFS_STATS_DEL(transmitted_fragment_count);
382-
DEBUGFS_STATS_DEL(multicast_transmitted_frame_count);
383-
DEBUGFS_STATS_DEL(failed_count);
384-
DEBUGFS_STATS_DEL(retry_count);
385-
DEBUGFS_STATS_DEL(multiple_retry_count);
386-
DEBUGFS_STATS_DEL(frame_duplicate_count);
387-
DEBUGFS_STATS_DEL(received_fragment_count);
388-
DEBUGFS_STATS_DEL(multicast_received_frame_count);
389-
DEBUGFS_STATS_DEL(transmitted_frame_count);
390-
DEBUGFS_STATS_DEL(num_scans);
391-
#ifdef CONFIG_MAC80211_DEBUG_COUNTERS
392-
DEBUGFS_STATS_DEL(tx_handlers_drop);
393-
DEBUGFS_STATS_DEL(tx_handlers_queued);
394-
DEBUGFS_STATS_DEL(tx_handlers_drop_unencrypted);
395-
DEBUGFS_STATS_DEL(tx_handlers_drop_fragment);
396-
DEBUGFS_STATS_DEL(tx_handlers_drop_wep);
397-
DEBUGFS_STATS_DEL(tx_handlers_drop_not_assoc);
398-
DEBUGFS_STATS_DEL(tx_handlers_drop_unauth_port);
399-
DEBUGFS_STATS_DEL(rx_handlers_drop);
400-
DEBUGFS_STATS_DEL(rx_handlers_queued);
401-
DEBUGFS_STATS_DEL(rx_handlers_drop_nullfunc);
402-
DEBUGFS_STATS_DEL(rx_handlers_drop_defrag);
403-
DEBUGFS_STATS_DEL(rx_handlers_drop_short);
404-
DEBUGFS_STATS_DEL(rx_handlers_drop_passive_scan);
405-
DEBUGFS_STATS_DEL(tx_expand_skb_head);
406-
DEBUGFS_STATS_DEL(tx_expand_skb_head_cloned);
407-
DEBUGFS_STATS_DEL(rx_expand_skb_head);
408-
DEBUGFS_STATS_DEL(rx_expand_skb_head2);
409-
DEBUGFS_STATS_DEL(rx_handlers_fragments);
410-
DEBUGFS_STATS_DEL(tx_status_drop);
411-
#endif
412-
DEBUGFS_STATS_DEL(dot11ACKFailureCount);
413-
DEBUGFS_STATS_DEL(dot11RTSFailureCount);
414-
DEBUGFS_STATS_DEL(dot11FCSErrorCount);
415-
DEBUGFS_STATS_DEL(dot11RTSSuccessCount);
416-
417-
debugfs_remove(local->debugfs.statistics);
418-
local->debugfs.statistics = NULL;
419-
debugfs_remove(local->debugfs.stations);
420-
local->debugfs.stations = NULL;
421-
debugfs_remove(local->debugfs.keys);
422-
local->debugfs.keys = NULL;
423-
}

‎net/mac80211/debugfs.h‎

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,12 @@
33

44
#ifdef CONFIG_MAC80211_DEBUGFS
55
extern void debugfs_hw_add(struct ieee80211_local *local);
6-
extern void debugfs_hw_del(struct ieee80211_local *local);
76
extern int mac80211_open_file_generic(struct inode *inode, struct file *file);
87
#else
98
static inline void debugfs_hw_add(struct ieee80211_local *local)
109
{
1110
return;
1211
}
13-
static inline void debugfs_hw_del(struct ieee80211_local *local) {}
1412
#endif
1513

1614
#endif /* __MAC80211_DEBUGFS_H */

‎net/mac80211/debugfs_key.c‎

Lines changed: 13 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -225,8 +225,8 @@ static ssize_t key_key_read(struct file *file, char __user *userbuf,
225225
KEY_OPS(key);
226226

227227
#define DEBUGFS_ADD(name) \
228-
key->debugfs.name = debugfs_create_file(#name, 0400,\
229-
key->debugfs.dir, key, &key_##name##_ops);
228+
debugfs_create_file(#name, 0400, key->debugfs.dir, \
229+
key, &key_##name##_ops);
230230

231231
void ieee80211_debugfs_key_add(struct ieee80211_key *key)
232232
{
@@ -271,48 +271,30 @@ void ieee80211_debugfs_key_add(struct ieee80211_key *key)
271271
DEBUGFS_ADD(ifindex);
272272
};
273273

274-
#define DEBUGFS_DEL(name) \
275-
debugfs_remove(key->debugfs.name); key->debugfs.name = NULL;
276-
277274
void ieee80211_debugfs_key_remove(struct ieee80211_key *key)
278275
{
279276
if (!key)
280277
return;
281278

282-
DEBUGFS_DEL(keylen);
283-
DEBUGFS_DEL(flags);
284-
DEBUGFS_DEL(keyidx);
285-
DEBUGFS_DEL(hw_key_idx);
286-
DEBUGFS_DEL(tx_rx_count);
287-
DEBUGFS_DEL(algorithm);
288-
DEBUGFS_DEL(tx_spec);
289-
DEBUGFS_DEL(rx_spec);
290-
DEBUGFS_DEL(replays);
291-
DEBUGFS_DEL(icverrors);
292-
DEBUGFS_DEL(key);
293-
DEBUGFS_DEL(ifindex);
294-
295-
debugfs_remove(key->debugfs.stalink);
296-
key->debugfs.stalink = NULL;
297-
debugfs_remove(key->debugfs.dir);
279+
debugfs_remove_recursive(key->debugfs.dir);
298280
key->debugfs.dir = NULL;
299281
}
300282
void ieee80211_debugfs_key_add_default(struct ieee80211_sub_if_data *sdata)
301283
{
302284
char buf[50];
303285
struct ieee80211_key *key;
304286

305-
if (!sdata->debugfsdir)
287+
if (!sdata->debugfs.dir)
306288
return;
307289

308290
/* this is running under the key lock */
309291

310292
key = sdata->default_key;
311293
if (key) {
312294
sprintf(buf, "../keys/%d", key->debugfs.cnt);
313-
sdata->common_debugfs.default_key =
295+
sdata->debugfs.default_key =
314296
debugfs_create_symlink("default_key",
315-
sdata->debugfsdir, buf);
297+
sdata->debugfs.dir, buf);
316298
} else
317299
ieee80211_debugfs_key_remove_default(sdata);
318300
}
@@ -322,26 +304,26 @@ void ieee80211_debugfs_key_remove_default(struct ieee80211_sub_if_data *sdata)
322304
if (!sdata)
323305
return;
324306

325-
debugfs_remove(sdata->common_debugfs.default_key);
326-
sdata->common_debugfs.default_key = NULL;
307+
debugfs_remove(sdata->debugfs.default_key);
308+
sdata->debugfs.default_key = NULL;
327309
}
328310

329311
void ieee80211_debugfs_key_add_mgmt_default(struct ieee80211_sub_if_data *sdata)
330312
{
331313
char buf[50];
332314
struct ieee80211_key *key;
333315

334-
if (!sdata->debugfsdir)
316+
if (!sdata->debugfs.dir)
335317
return;
336318

337319
/* this is running under the key lock */
338320

339321
key = sdata->default_mgmt_key;
340322
if (key) {
341323
sprintf(buf, "../keys/%d", key->debugfs.cnt);
342-
sdata->common_debugfs.default_mgmt_key =
324+
sdata->debugfs.default_mgmt_key =
343325
debugfs_create_symlink("default_mgmt_key",
344-
sdata->debugfsdir, buf);
326+
sdata->debugfs.dir, buf);
345327
} else
346328
ieee80211_debugfs_key_remove_mgmt_default(sdata);
347329
}
@@ -351,8 +333,8 @@ void ieee80211_debugfs_key_remove_mgmt_default(struct ieee80211_sub_if_data *sda
351333
if (!sdata)
352334
return;
353335

354-
debugfs_remove(sdata->common_debugfs.default_mgmt_key);
355-
sdata->common_debugfs.default_mgmt_key = NULL;
336+
debugfs_remove(sdata->debugfs.default_mgmt_key);
337+
sdata->debugfs.default_mgmt_key = NULL;
356338
}
357339

358340
void ieee80211_debugfs_key_sta_del(struct ieee80211_key *key,

0 commit comments

Comments
 (0)