summaryrefslogtreecommitdiff
path: root/drivers/net
diff options
context:
space:
mode:
authorJohannes Berg <johannes.berg@intel.com>2014-01-06 22:43:11 +0100
committerJohannes Berg <johannes.berg@intel.com>2014-01-10 20:12:57 +0100
commite4afb603c0799fbca3351320180ec3c8fbeefa6d (patch)
tree41452e6bb332b7e117b8b4656a2738c5c61aa700 /drivers/net
parentf39c2bfa9a1e2bae726cce65d2d328652e81f0c2 (diff)
mac80211_hwsim: refactor radio cleanup
Refactor the radio cleanup into a new function to later allow deleting a single radio from the list. Signed-off-by: Johannes Berg <johannes.berg@intel.com>
Diffstat (limited to 'drivers/net')
-rw-r--r--drivers/net/wireless/mac80211_hwsim.c32
1 files changed, 18 insertions, 14 deletions
diff --git a/drivers/net/wireless/mac80211_hwsim.c b/drivers/net/wireless/mac80211_hwsim.c
index 23fa6ee8eefe..cca5b3ffb22c 100644
--- a/drivers/net/wireless/mac80211_hwsim.c
+++ b/drivers/net/wireless/mac80211_hwsim.c
@@ -1623,25 +1623,29 @@ static const struct ieee80211_ops mac80211_hwsim_ops = {
static struct ieee80211_ops mac80211_hwsim_mchan_ops;
-static void mac80211_hwsim_free(void)
+static void mac80211_hwsim_destroy_radio(struct mac80211_hwsim_data *data)
{
- struct list_head tmplist, *i, *tmp;
- struct mac80211_hwsim_data *data, *tmpdata;
+ debugfs_remove_recursive(data->debugfs);
+ ieee80211_unregister_hw(data->hw);
+ device_release_driver(data->dev);
+ device_unregister(data->dev);
+ ieee80211_free_hw(data->hw);
+}
- INIT_LIST_HEAD(&tmplist);
+static void mac80211_hwsim_free(void)
+{
+ struct mac80211_hwsim_data *data;
spin_lock_bh(&hwsim_radio_lock);
- list_for_each_safe(i, tmp, &hwsim_radios)
- list_move(i, &tmplist);
- spin_unlock_bh(&hwsim_radio_lock);
-
- list_for_each_entry_safe(data, tmpdata, &tmplist, list) {
- debugfs_remove_recursive(data->debugfs);
- ieee80211_unregister_hw(data->hw);
- device_release_driver(data->dev);
- device_unregister(data->dev);
- ieee80211_free_hw(data->hw);
+ while ((data = list_first_entry_or_null(&hwsim_radios,
+ struct mac80211_hwsim_data,
+ list))) {
+ list_del(&data->list);
+ spin_unlock_bh(&hwsim_radio_lock);
+ mac80211_hwsim_destroy_radio(data);
+ spin_lock_bh(&hwsim_radio_lock);
}
+ spin_unlock_bh(&hwsim_radio_lock);
class_destroy(hwsim_class);
}