Commit 85dd3da4 authored by Johannes Berg's avatar Johannes Berg

cfg80211: combine wdev/netdev unregister code

We currently have two places that do similar things, depending
on whether it's a wdev with or without netdev.

Combine the code to avoid having to duplicate all new additions.
Signed-off-by: default avatarJohannes Berg <johannes.berg@intel.com>
parent 49f9cf0e
...@@ -1019,36 +1019,49 @@ void cfg80211_cqm_config_free(struct wireless_dev *wdev) ...@@ -1019,36 +1019,49 @@ void cfg80211_cqm_config_free(struct wireless_dev *wdev)
wdev->cqm_config = NULL; wdev->cqm_config = NULL;
} }
void cfg80211_unregister_wdev(struct wireless_dev *wdev) static void __cfg80211_unregister_wdev(struct wireless_dev *wdev, bool sync)
{ {
struct cfg80211_registered_device *rdev = wiphy_to_rdev(wdev->wiphy); struct cfg80211_registered_device *rdev = wiphy_to_rdev(wdev->wiphy);
ASSERT_RTNL(); ASSERT_RTNL();
if (WARN_ON(wdev->netdev))
return;
nl80211_notify_iface(rdev, wdev, NL80211_CMD_DEL_INTERFACE); nl80211_notify_iface(rdev, wdev, NL80211_CMD_DEL_INTERFACE);
list_del_rcu(&wdev->list); list_del_rcu(&wdev->list);
synchronize_rcu(); if (sync)
synchronize_rcu();
rdev->devlist_generation++; rdev->devlist_generation++;
cfg80211_mlme_purge_registrations(wdev);
switch (wdev->iftype) { switch (wdev->iftype) {
case NL80211_IFTYPE_P2P_DEVICE: case NL80211_IFTYPE_P2P_DEVICE:
cfg80211_mlme_purge_registrations(wdev);
cfg80211_stop_p2p_device(rdev, wdev); cfg80211_stop_p2p_device(rdev, wdev);
break; break;
case NL80211_IFTYPE_NAN: case NL80211_IFTYPE_NAN:
cfg80211_stop_nan(rdev, wdev); cfg80211_stop_nan(rdev, wdev);
break; break;
default: default:
WARN_ON_ONCE(1);
break; break;
} }
#ifdef CONFIG_CFG80211_WEXT
kzfree(wdev->wext.keys);
#endif
/* only initialized if we have a netdev */
if (wdev->netdev)
flush_work(&wdev->disconnect_wk);
cfg80211_cqm_config_free(wdev); cfg80211_cqm_config_free(wdev);
} }
void cfg80211_unregister_wdev(struct wireless_dev *wdev)
{
if (WARN_ON(wdev->netdev))
return;
__cfg80211_unregister_wdev(wdev, true);
}
EXPORT_SYMBOL(cfg80211_unregister_wdev); EXPORT_SYMBOL(cfg80211_unregister_wdev);
static const struct device_type wiphy_type = { static const struct device_type wiphy_type = {
...@@ -1308,17 +1321,8 @@ static int cfg80211_netdev_notifier_call(struct notifier_block *nb, ...@@ -1308,17 +1321,8 @@ static int cfg80211_netdev_notifier_call(struct notifier_block *nb,
* remove and clean it up. * remove and clean it up.
*/ */
if (!list_empty(&wdev->list)) { if (!list_empty(&wdev->list)) {
nl80211_notify_iface(rdev, wdev, __cfg80211_unregister_wdev(wdev, false);
NL80211_CMD_DEL_INTERFACE);
sysfs_remove_link(&dev->dev.kobj, "phy80211"); sysfs_remove_link(&dev->dev.kobj, "phy80211");
list_del_rcu(&wdev->list);
rdev->devlist_generation++;
cfg80211_mlme_purge_registrations(wdev);
#ifdef CONFIG_CFG80211_WEXT
kzfree(wdev->wext.keys);
#endif
flush_work(&wdev->disconnect_wk);
cfg80211_cqm_config_free(wdev);
} }
/* /*
* synchronise (so that we won't find this netdev * synchronise (so that we won't find this netdev
......
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