Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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: Johannes Berg <johannes.berg@intel.com>

+21 -17
+21 -17
net/wireless/core.c
··· 1019 1019 wdev->cqm_config = NULL; 1020 1020 } 1021 1021 1022 - void cfg80211_unregister_wdev(struct wireless_dev *wdev) 1022 + static void __cfg80211_unregister_wdev(struct wireless_dev *wdev, bool sync) 1023 1023 { 1024 1024 struct cfg80211_registered_device *rdev = wiphy_to_rdev(wdev->wiphy); 1025 1025 1026 1026 ASSERT_RTNL(); 1027 1027 1028 - if (WARN_ON(wdev->netdev)) 1029 - return; 1030 - 1031 1028 nl80211_notify_iface(rdev, wdev, NL80211_CMD_DEL_INTERFACE); 1032 1029 1033 1030 list_del_rcu(&wdev->list); 1034 - synchronize_rcu(); 1031 + if (sync) 1032 + synchronize_rcu(); 1035 1033 rdev->devlist_generation++; 1034 + 1035 + cfg80211_mlme_purge_registrations(wdev); 1036 1036 1037 1037 switch (wdev->iftype) { 1038 1038 case NL80211_IFTYPE_P2P_DEVICE: 1039 - cfg80211_mlme_purge_registrations(wdev); 1040 1039 cfg80211_stop_p2p_device(rdev, wdev); 1041 1040 break; 1042 1041 case NL80211_IFTYPE_NAN: 1043 1042 cfg80211_stop_nan(rdev, wdev); 1044 1043 break; 1045 1044 default: 1046 - WARN_ON_ONCE(1); 1047 1045 break; 1048 1046 } 1049 1047 1048 + #ifdef CONFIG_CFG80211_WEXT 1049 + kzfree(wdev->wext.keys); 1050 + #endif 1051 + /* only initialized if we have a netdev */ 1052 + if (wdev->netdev) 1053 + flush_work(&wdev->disconnect_wk); 1054 + 1050 1055 cfg80211_cqm_config_free(wdev); 1056 + } 1057 + 1058 + void cfg80211_unregister_wdev(struct wireless_dev *wdev) 1059 + { 1060 + if (WARN_ON(wdev->netdev)) 1061 + return; 1062 + 1063 + __cfg80211_unregister_wdev(wdev, true); 1051 1064 } 1052 1065 EXPORT_SYMBOL(cfg80211_unregister_wdev); 1053 1066 ··· 1321 1308 * remove and clean it up. 1322 1309 */ 1323 1310 if (!list_empty(&wdev->list)) { 1324 - nl80211_notify_iface(rdev, wdev, 1325 - NL80211_CMD_DEL_INTERFACE); 1311 + __cfg80211_unregister_wdev(wdev, false); 1326 1312 sysfs_remove_link(&dev->dev.kobj, "phy80211"); 1327 - list_del_rcu(&wdev->list); 1328 - rdev->devlist_generation++; 1329 - cfg80211_mlme_purge_registrations(wdev); 1330 - #ifdef CONFIG_CFG80211_WEXT 1331 - kzfree(wdev->wext.keys); 1332 - #endif 1333 - flush_work(&wdev->disconnect_wk); 1334 - cfg80211_cqm_config_free(wdev); 1335 1313 } 1336 1314 /* 1337 1315 * synchronise (so that we won't find this netdev