Skip to content

Commit

Permalink
cfg80211/mac80211: use debugfs_remove_recursive
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
jmberg authored and linvjw committed Oct 30, 2009
1 parent 2c0d610 commit 7bcfaf2
Show file tree
Hide file tree
Showing 14 changed files with 51 additions and 462 deletions.
73 changes: 4 additions & 69 deletions net/mac80211/debugfs.c
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@

/*
* mac80211 debugfs for wireless PHYs
*
Expand Down Expand Up @@ -38,16 +39,10 @@ static const struct file_operations name## _ops = { \
};

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

#define DEBUGFS_ADD_MODE(name, mode) \
local->debugfs.name = debugfs_create_file(#name, mode, phyd, \
local, &name## _ops);

#define DEBUGFS_DEL(name) \
debugfs_remove(local->debugfs.name); \
local->debugfs.name = NULL;
debugfs_create_file(#name, mode, phyd, local, &name## _ops);


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

#define DEBUGFS_STATS_ADD(name) \
local->debugfs.stats.name = debugfs_create_file(#name, 0400, statsd,\
local, &stats_ ##name## _ops);

#define DEBUGFS_STATS_DEL(name) \
debugfs_remove(local->debugfs.stats.name); \
local->debugfs.stats.name = NULL;
debugfs_create_file(#name, 0400, statsd, local, &stats_ ##name## _ops);

DEBUGFS_STATS_FILE(transmitted_fragment_count, 20, "%u",
local->dot11TransmittedFragmentCount);
Expand Down Expand Up @@ -326,7 +316,6 @@ void debugfs_hw_add(struct ieee80211_local *local)
DEBUGFS_ADD(noack);

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

/* if the dir failed, don't put all the other things into the root! */
if (!statsd)
Expand Down Expand Up @@ -367,57 +356,3 @@ void debugfs_hw_add(struct ieee80211_local *local)
DEBUGFS_STATS_ADD(dot11FCSErrorCount);
DEBUGFS_STATS_ADD(dot11RTSSuccessCount);
}

void debugfs_hw_del(struct ieee80211_local *local)
{
DEBUGFS_DEL(frequency);
DEBUGFS_DEL(total_ps_buffered);
DEBUGFS_DEL(wep_iv);
DEBUGFS_DEL(tsf);
DEBUGFS_DEL(queues);
DEBUGFS_DEL(reset);
DEBUGFS_DEL(noack);

DEBUGFS_STATS_DEL(transmitted_fragment_count);
DEBUGFS_STATS_DEL(multicast_transmitted_frame_count);
DEBUGFS_STATS_DEL(failed_count);
DEBUGFS_STATS_DEL(retry_count);
DEBUGFS_STATS_DEL(multiple_retry_count);
DEBUGFS_STATS_DEL(frame_duplicate_count);
DEBUGFS_STATS_DEL(received_fragment_count);
DEBUGFS_STATS_DEL(multicast_received_frame_count);
DEBUGFS_STATS_DEL(transmitted_frame_count);
DEBUGFS_STATS_DEL(num_scans);
#ifdef CONFIG_MAC80211_DEBUG_COUNTERS
DEBUGFS_STATS_DEL(tx_handlers_drop);
DEBUGFS_STATS_DEL(tx_handlers_queued);
DEBUGFS_STATS_DEL(tx_handlers_drop_unencrypted);
DEBUGFS_STATS_DEL(tx_handlers_drop_fragment);
DEBUGFS_STATS_DEL(tx_handlers_drop_wep);
DEBUGFS_STATS_DEL(tx_handlers_drop_not_assoc);
DEBUGFS_STATS_DEL(tx_handlers_drop_unauth_port);
DEBUGFS_STATS_DEL(rx_handlers_drop);
DEBUGFS_STATS_DEL(rx_handlers_queued);
DEBUGFS_STATS_DEL(rx_handlers_drop_nullfunc);
DEBUGFS_STATS_DEL(rx_handlers_drop_defrag);
DEBUGFS_STATS_DEL(rx_handlers_drop_short);
DEBUGFS_STATS_DEL(rx_handlers_drop_passive_scan);
DEBUGFS_STATS_DEL(tx_expand_skb_head);
DEBUGFS_STATS_DEL(tx_expand_skb_head_cloned);
DEBUGFS_STATS_DEL(rx_expand_skb_head);
DEBUGFS_STATS_DEL(rx_expand_skb_head2);
DEBUGFS_STATS_DEL(rx_handlers_fragments);
DEBUGFS_STATS_DEL(tx_status_drop);
#endif
DEBUGFS_STATS_DEL(dot11ACKFailureCount);
DEBUGFS_STATS_DEL(dot11RTSFailureCount);
DEBUGFS_STATS_DEL(dot11FCSErrorCount);
DEBUGFS_STATS_DEL(dot11RTSSuccessCount);

debugfs_remove(local->debugfs.statistics);
local->debugfs.statistics = NULL;
debugfs_remove(local->debugfs.stations);
local->debugfs.stations = NULL;
debugfs_remove(local->debugfs.keys);
local->debugfs.keys = NULL;
}
2 changes: 0 additions & 2 deletions net/mac80211/debugfs.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,12 @@

#ifdef CONFIG_MAC80211_DEBUGFS
extern void debugfs_hw_add(struct ieee80211_local *local);
extern void debugfs_hw_del(struct ieee80211_local *local);
extern int mac80211_open_file_generic(struct inode *inode, struct file *file);
#else
static inline void debugfs_hw_add(struct ieee80211_local *local)
{
return;
}
static inline void debugfs_hw_del(struct ieee80211_local *local) {}
#endif

#endif /* __MAC80211_DEBUGFS_H */
44 changes: 13 additions & 31 deletions net/mac80211/debugfs_key.c
Original file line number Diff line number Diff line change
Expand Up @@ -225,8 +225,8 @@ static ssize_t key_key_read(struct file *file, char __user *userbuf,
KEY_OPS(key);

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

void ieee80211_debugfs_key_add(struct ieee80211_key *key)
{
Expand Down Expand Up @@ -271,48 +271,30 @@ void ieee80211_debugfs_key_add(struct ieee80211_key *key)
DEBUGFS_ADD(ifindex);
};

#define DEBUGFS_DEL(name) \
debugfs_remove(key->debugfs.name); key->debugfs.name = NULL;

void ieee80211_debugfs_key_remove(struct ieee80211_key *key)
{
if (!key)
return;

DEBUGFS_DEL(keylen);
DEBUGFS_DEL(flags);
DEBUGFS_DEL(keyidx);
DEBUGFS_DEL(hw_key_idx);
DEBUGFS_DEL(tx_rx_count);
DEBUGFS_DEL(algorithm);
DEBUGFS_DEL(tx_spec);
DEBUGFS_DEL(rx_spec);
DEBUGFS_DEL(replays);
DEBUGFS_DEL(icverrors);
DEBUGFS_DEL(key);
DEBUGFS_DEL(ifindex);

debugfs_remove(key->debugfs.stalink);
key->debugfs.stalink = NULL;
debugfs_remove(key->debugfs.dir);
debugfs_remove_recursive(key->debugfs.dir);
key->debugfs.dir = NULL;
}
void ieee80211_debugfs_key_add_default(struct ieee80211_sub_if_data *sdata)
{
char buf[50];
struct ieee80211_key *key;

if (!sdata->debugfsdir)
if (!sdata->debugfs.dir)
return;

/* this is running under the key lock */

key = sdata->default_key;
if (key) {
sprintf(buf, "../keys/%d", key->debugfs.cnt);
sdata->common_debugfs.default_key =
sdata->debugfs.default_key =
debugfs_create_symlink("default_key",
sdata->debugfsdir, buf);
sdata->debugfs.dir, buf);
} else
ieee80211_debugfs_key_remove_default(sdata);
}
Expand All @@ -322,26 +304,26 @@ void ieee80211_debugfs_key_remove_default(struct ieee80211_sub_if_data *sdata)
if (!sdata)
return;

debugfs_remove(sdata->common_debugfs.default_key);
sdata->common_debugfs.default_key = NULL;
debugfs_remove(sdata->debugfs.default_key);
sdata->debugfs.default_key = NULL;
}

void ieee80211_debugfs_key_add_mgmt_default(struct ieee80211_sub_if_data *sdata)
{
char buf[50];
struct ieee80211_key *key;

if (!sdata->debugfsdir)
if (!sdata->debugfs.dir)
return;

/* this is running under the key lock */

key = sdata->default_mgmt_key;
if (key) {
sprintf(buf, "../keys/%d", key->debugfs.cnt);
sdata->common_debugfs.default_mgmt_key =
sdata->debugfs.default_mgmt_key =
debugfs_create_symlink("default_mgmt_key",
sdata->debugfsdir, buf);
sdata->debugfs.dir, buf);
} else
ieee80211_debugfs_key_remove_mgmt_default(sdata);
}
Expand All @@ -351,8 +333,8 @@ void ieee80211_debugfs_key_remove_mgmt_default(struct ieee80211_sub_if_data *sda
if (!sdata)
return;

debugfs_remove(sdata->common_debugfs.default_mgmt_key);
sdata->common_debugfs.default_mgmt_key = NULL;
debugfs_remove(sdata->debugfs.default_mgmt_key);
sdata->debugfs.default_mgmt_key = NULL;
}

void ieee80211_debugfs_key_sta_del(struct ieee80211_key *key,
Expand Down
Loading

0 comments on commit 7bcfaf2

Please sign in to comment.