Commit e4afb603 authored by Johannes Berg's avatar Johannes Berg

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: default avatarJohannes Berg <johannes.berg@intel.com>
parent f39c2bfa
...@@ -1623,25 +1623,29 @@ static const struct ieee80211_ops mac80211_hwsim_ops = { ...@@ -1623,25 +1623,29 @@ static const struct ieee80211_ops mac80211_hwsim_ops = {
static struct ieee80211_ops mac80211_hwsim_mchan_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; debugfs_remove_recursive(data->debugfs);
struct mac80211_hwsim_data *data, *tmpdata; 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); spin_lock_bh(&hwsim_radio_lock);
list_for_each_safe(i, tmp, &hwsim_radios) while ((data = list_first_entry_or_null(&hwsim_radios,
list_move(i, &tmplist); struct mac80211_hwsim_data,
spin_unlock_bh(&hwsim_radio_lock); list))) {
list_del(&data->list);
list_for_each_entry_safe(data, tmpdata, &tmplist, list) { spin_unlock_bh(&hwsim_radio_lock);
debugfs_remove_recursive(data->debugfs); mac80211_hwsim_destroy_radio(data);
ieee80211_unregister_hw(data->hw); spin_lock_bh(&hwsim_radio_lock);
device_release_driver(data->dev);
device_unregister(data->dev);
ieee80211_free_hw(data->hw);
} }
spin_unlock_bh(&hwsim_radio_lock);
class_destroy(hwsim_class); class_destroy(hwsim_class);
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment