core.c 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678
  1. /*
  2. * This is the linux wireless configuration interface.
  3. *
  4. * Copyright 2006-2009 Johannes Berg <johannes@sipsolutions.net>
  5. */
  6. #include <linux/if.h>
  7. #include <linux/module.h>
  8. #include <linux/err.h>
  9. #include <linux/list.h>
  10. #include <linux/nl80211.h>
  11. #include <linux/debugfs.h>
  12. #include <linux/notifier.h>
  13. #include <linux/device.h>
  14. #include <linux/rtnetlink.h>
  15. #include <net/genetlink.h>
  16. #include <net/cfg80211.h>
  17. #include "nl80211.h"
  18. #include "core.h"
  19. #include "sysfs.h"
  20. #include "debugfs.h"
  21. /* name for sysfs, %d is appended */
  22. #define PHY_NAME "phy"
  23. MODULE_AUTHOR("Johannes Berg");
  24. MODULE_LICENSE("GPL");
  25. MODULE_DESCRIPTION("wireless configuration support");
  26. /* RCU might be appropriate here since we usually
  27. * only read the list, and that can happen quite
  28. * often because we need to do it for each command */
  29. LIST_HEAD(cfg80211_drv_list);
  30. /*
  31. * This is used to protect the cfg80211_drv_list, cfg80211_regdomain,
  32. * country_ie_regdomain, the reg_beacon_list and the the last regulatory
  33. * request receipt (last_request).
  34. */
  35. DEFINE_MUTEX(cfg80211_mutex);
  36. /* for debugfs */
  37. static struct dentry *ieee80211_debugfs_dir;
  38. /* requires cfg80211_mutex to be held! */
  39. struct cfg80211_registered_device *cfg80211_drv_by_wiphy_idx(int wiphy_idx)
  40. {
  41. struct cfg80211_registered_device *result = NULL, *drv;
  42. if (!wiphy_idx_valid(wiphy_idx))
  43. return NULL;
  44. assert_cfg80211_lock();
  45. list_for_each_entry(drv, &cfg80211_drv_list, list) {
  46. if (drv->wiphy_idx == wiphy_idx) {
  47. result = drv;
  48. break;
  49. }
  50. }
  51. return result;
  52. }
  53. int get_wiphy_idx(struct wiphy *wiphy)
  54. {
  55. struct cfg80211_registered_device *drv;
  56. if (!wiphy)
  57. return WIPHY_IDX_STALE;
  58. drv = wiphy_to_dev(wiphy);
  59. return drv->wiphy_idx;
  60. }
  61. /* requires cfg80211_drv_mutex to be held! */
  62. struct wiphy *wiphy_idx_to_wiphy(int wiphy_idx)
  63. {
  64. struct cfg80211_registered_device *drv;
  65. if (!wiphy_idx_valid(wiphy_idx))
  66. return NULL;
  67. assert_cfg80211_lock();
  68. drv = cfg80211_drv_by_wiphy_idx(wiphy_idx);
  69. if (!drv)
  70. return NULL;
  71. return &drv->wiphy;
  72. }
  73. /* requires cfg80211_mutex to be held! */
  74. struct cfg80211_registered_device *
  75. __cfg80211_drv_from_info(struct genl_info *info)
  76. {
  77. int ifindex;
  78. struct cfg80211_registered_device *bywiphyidx = NULL, *byifidx = NULL;
  79. struct net_device *dev;
  80. int err = -EINVAL;
  81. assert_cfg80211_lock();
  82. if (info->attrs[NL80211_ATTR_WIPHY]) {
  83. bywiphyidx = cfg80211_drv_by_wiphy_idx(
  84. nla_get_u32(info->attrs[NL80211_ATTR_WIPHY]));
  85. err = -ENODEV;
  86. }
  87. if (info->attrs[NL80211_ATTR_IFINDEX]) {
  88. ifindex = nla_get_u32(info->attrs[NL80211_ATTR_IFINDEX]);
  89. dev = dev_get_by_index(&init_net, ifindex);
  90. if (dev) {
  91. if (dev->ieee80211_ptr)
  92. byifidx =
  93. wiphy_to_dev(dev->ieee80211_ptr->wiphy);
  94. dev_put(dev);
  95. }
  96. err = -ENODEV;
  97. }
  98. if (bywiphyidx && byifidx) {
  99. if (bywiphyidx != byifidx)
  100. return ERR_PTR(-EINVAL);
  101. else
  102. return bywiphyidx; /* == byifidx */
  103. }
  104. if (bywiphyidx)
  105. return bywiphyidx;
  106. if (byifidx)
  107. return byifidx;
  108. return ERR_PTR(err);
  109. }
  110. struct cfg80211_registered_device *
  111. cfg80211_get_dev_from_info(struct genl_info *info)
  112. {
  113. struct cfg80211_registered_device *drv;
  114. mutex_lock(&cfg80211_mutex);
  115. drv = __cfg80211_drv_from_info(info);
  116. /* if it is not an error we grab the lock on
  117. * it to assure it won't be going away while
  118. * we operate on it */
  119. if (!IS_ERR(drv))
  120. mutex_lock(&drv->mtx);
  121. mutex_unlock(&cfg80211_mutex);
  122. return drv;
  123. }
  124. struct cfg80211_registered_device *
  125. cfg80211_get_dev_from_ifindex(int ifindex)
  126. {
  127. struct cfg80211_registered_device *drv = ERR_PTR(-ENODEV);
  128. struct net_device *dev;
  129. mutex_lock(&cfg80211_mutex);
  130. dev = dev_get_by_index(&init_net, ifindex);
  131. if (!dev)
  132. goto out;
  133. if (dev->ieee80211_ptr) {
  134. drv = wiphy_to_dev(dev->ieee80211_ptr->wiphy);
  135. mutex_lock(&drv->mtx);
  136. } else
  137. drv = ERR_PTR(-ENODEV);
  138. dev_put(dev);
  139. out:
  140. mutex_unlock(&cfg80211_mutex);
  141. return drv;
  142. }
  143. void cfg80211_put_dev(struct cfg80211_registered_device *drv)
  144. {
  145. BUG_ON(IS_ERR(drv));
  146. mutex_unlock(&drv->mtx);
  147. }
  148. /* requires cfg80211_mutex to be held */
  149. int cfg80211_dev_rename(struct cfg80211_registered_device *rdev,
  150. char *newname)
  151. {
  152. struct cfg80211_registered_device *drv;
  153. int wiphy_idx, taken = -1, result, digits;
  154. assert_cfg80211_lock();
  155. /* prohibit calling the thing phy%d when %d is not its number */
  156. sscanf(newname, PHY_NAME "%d%n", &wiphy_idx, &taken);
  157. if (taken == strlen(newname) && wiphy_idx != rdev->wiphy_idx) {
  158. /* count number of places needed to print wiphy_idx */
  159. digits = 1;
  160. while (wiphy_idx /= 10)
  161. digits++;
  162. /*
  163. * deny the name if it is phy<idx> where <idx> is printed
  164. * without leading zeroes. taken == strlen(newname) here
  165. */
  166. if (taken == strlen(PHY_NAME) + digits)
  167. return -EINVAL;
  168. }
  169. /* Ignore nop renames */
  170. if (strcmp(newname, dev_name(&rdev->wiphy.dev)) == 0)
  171. return 0;
  172. /* Ensure another device does not already have this name. */
  173. list_for_each_entry(drv, &cfg80211_drv_list, list)
  174. if (strcmp(newname, dev_name(&drv->wiphy.dev)) == 0)
  175. return -EINVAL;
  176. result = device_rename(&rdev->wiphy.dev, newname);
  177. if (result)
  178. return result;
  179. if (rdev->wiphy.debugfsdir &&
  180. !debugfs_rename(rdev->wiphy.debugfsdir->d_parent,
  181. rdev->wiphy.debugfsdir,
  182. rdev->wiphy.debugfsdir->d_parent,
  183. newname))
  184. printk(KERN_ERR "cfg80211: failed to rename debugfs dir to %s!\n",
  185. newname);
  186. nl80211_notify_dev_rename(rdev);
  187. return 0;
  188. }
  189. static void cfg80211_rfkill_poll(struct rfkill *rfkill, void *data)
  190. {
  191. struct cfg80211_registered_device *drv = data;
  192. drv->ops->rfkill_poll(&drv->wiphy);
  193. }
  194. static int cfg80211_rfkill_set_block(void *data, bool blocked)
  195. {
  196. struct cfg80211_registered_device *drv = data;
  197. struct wireless_dev *wdev;
  198. if (!blocked)
  199. return 0;
  200. rtnl_lock();
  201. mutex_lock(&drv->devlist_mtx);
  202. list_for_each_entry(wdev, &drv->netdev_list, list)
  203. dev_close(wdev->netdev);
  204. mutex_unlock(&drv->devlist_mtx);
  205. rtnl_unlock();
  206. return 0;
  207. }
  208. static void cfg80211_rfkill_sync_work(struct work_struct *work)
  209. {
  210. struct cfg80211_registered_device *drv;
  211. drv = container_of(work, struct cfg80211_registered_device, rfkill_sync);
  212. cfg80211_rfkill_set_block(drv, rfkill_blocked(drv->rfkill));
  213. }
  214. /* exported functions */
  215. struct wiphy *wiphy_new(const struct cfg80211_ops *ops, int sizeof_priv)
  216. {
  217. static int wiphy_counter;
  218. struct cfg80211_registered_device *drv;
  219. int alloc_size;
  220. WARN_ON(!ops->add_key && ops->del_key);
  221. WARN_ON(ops->add_key && !ops->del_key);
  222. alloc_size = sizeof(*drv) + sizeof_priv;
  223. drv = kzalloc(alloc_size, GFP_KERNEL);
  224. if (!drv)
  225. return NULL;
  226. drv->ops = ops;
  227. mutex_lock(&cfg80211_mutex);
  228. drv->wiphy_idx = wiphy_counter++;
  229. if (unlikely(!wiphy_idx_valid(drv->wiphy_idx))) {
  230. wiphy_counter--;
  231. mutex_unlock(&cfg80211_mutex);
  232. /* ugh, wrapped! */
  233. kfree(drv);
  234. return NULL;
  235. }
  236. mutex_unlock(&cfg80211_mutex);
  237. /* give it a proper name */
  238. dev_set_name(&drv->wiphy.dev, PHY_NAME "%d", drv->wiphy_idx);
  239. mutex_init(&drv->mtx);
  240. mutex_init(&drv->devlist_mtx);
  241. INIT_LIST_HEAD(&drv->netdev_list);
  242. spin_lock_init(&drv->bss_lock);
  243. INIT_LIST_HEAD(&drv->bss_list);
  244. device_initialize(&drv->wiphy.dev);
  245. drv->wiphy.dev.class = &ieee80211_class;
  246. drv->wiphy.dev.platform_data = drv;
  247. drv->rfkill_ops.set_block = cfg80211_rfkill_set_block;
  248. drv->rfkill = rfkill_alloc(dev_name(&drv->wiphy.dev),
  249. &drv->wiphy.dev, RFKILL_TYPE_WLAN,
  250. &drv->rfkill_ops, drv);
  251. if (!drv->rfkill) {
  252. kfree(drv);
  253. return NULL;
  254. }
  255. INIT_WORK(&drv->rfkill_sync, cfg80211_rfkill_sync_work);
  256. INIT_WORK(&drv->conn_work, cfg80211_conn_work);
  257. /*
  258. * Initialize wiphy parameters to IEEE 802.11 MIB default values.
  259. * Fragmentation and RTS threshold are disabled by default with the
  260. * special -1 value.
  261. */
  262. drv->wiphy.retry_short = 7;
  263. drv->wiphy.retry_long = 4;
  264. drv->wiphy.frag_threshold = (u32) -1;
  265. drv->wiphy.rts_threshold = (u32) -1;
  266. return &drv->wiphy;
  267. }
  268. EXPORT_SYMBOL(wiphy_new);
  269. int wiphy_register(struct wiphy *wiphy)
  270. {
  271. struct cfg80211_registered_device *drv = wiphy_to_dev(wiphy);
  272. int res;
  273. enum ieee80211_band band;
  274. struct ieee80211_supported_band *sband;
  275. bool have_band = false;
  276. int i;
  277. u16 ifmodes = wiphy->interface_modes;
  278. /* sanity check ifmodes */
  279. WARN_ON(!ifmodes);
  280. ifmodes &= ((1 << __NL80211_IFTYPE_AFTER_LAST) - 1) & ~1;
  281. if (WARN_ON(ifmodes != wiphy->interface_modes))
  282. wiphy->interface_modes = ifmodes;
  283. /* sanity check supported bands/channels */
  284. for (band = 0; band < IEEE80211_NUM_BANDS; band++) {
  285. sband = wiphy->bands[band];
  286. if (!sband)
  287. continue;
  288. sband->band = band;
  289. if (WARN_ON(!sband->n_channels || !sband->n_bitrates))
  290. return -EINVAL;
  291. /*
  292. * Since we use a u32 for rate bitmaps in
  293. * ieee80211_get_response_rate, we cannot
  294. * have more than 32 legacy rates.
  295. */
  296. if (WARN_ON(sband->n_bitrates > 32))
  297. return -EINVAL;
  298. for (i = 0; i < sband->n_channels; i++) {
  299. sband->channels[i].orig_flags =
  300. sband->channels[i].flags;
  301. sband->channels[i].orig_mag =
  302. sband->channels[i].max_antenna_gain;
  303. sband->channels[i].orig_mpwr =
  304. sband->channels[i].max_power;
  305. sband->channels[i].band = band;
  306. }
  307. have_band = true;
  308. }
  309. if (!have_band) {
  310. WARN_ON(1);
  311. return -EINVAL;
  312. }
  313. /* check and set up bitrates */
  314. ieee80211_set_bitrate_flags(wiphy);
  315. res = device_add(&drv->wiphy.dev);
  316. if (res)
  317. return res;
  318. res = rfkill_register(drv->rfkill);
  319. if (res)
  320. goto out_rm_dev;
  321. mutex_lock(&cfg80211_mutex);
  322. /* set up regulatory info */
  323. wiphy_update_regulatory(wiphy, NL80211_REGDOM_SET_BY_CORE);
  324. list_add(&drv->list, &cfg80211_drv_list);
  325. mutex_unlock(&cfg80211_mutex);
  326. /* add to debugfs */
  327. drv->wiphy.debugfsdir =
  328. debugfs_create_dir(wiphy_name(&drv->wiphy),
  329. ieee80211_debugfs_dir);
  330. if (IS_ERR(drv->wiphy.debugfsdir))
  331. drv->wiphy.debugfsdir = NULL;
  332. if (wiphy->custom_regulatory) {
  333. struct regulatory_request request;
  334. request.wiphy_idx = get_wiphy_idx(wiphy);
  335. request.initiator = NL80211_REGDOM_SET_BY_DRIVER;
  336. request.alpha2[0] = '9';
  337. request.alpha2[1] = '9';
  338. nl80211_send_reg_change_event(&request);
  339. }
  340. cfg80211_debugfs_drv_add(drv);
  341. return 0;
  342. out_rm_dev:
  343. device_del(&drv->wiphy.dev);
  344. return res;
  345. }
  346. EXPORT_SYMBOL(wiphy_register);
  347. void wiphy_rfkill_start_polling(struct wiphy *wiphy)
  348. {
  349. struct cfg80211_registered_device *drv = wiphy_to_dev(wiphy);
  350. if (!drv->ops->rfkill_poll)
  351. return;
  352. drv->rfkill_ops.poll = cfg80211_rfkill_poll;
  353. rfkill_resume_polling(drv->rfkill);
  354. }
  355. EXPORT_SYMBOL(wiphy_rfkill_start_polling);
  356. void wiphy_rfkill_stop_polling(struct wiphy *wiphy)
  357. {
  358. struct cfg80211_registered_device *drv = wiphy_to_dev(wiphy);
  359. rfkill_pause_polling(drv->rfkill);
  360. }
  361. EXPORT_SYMBOL(wiphy_rfkill_stop_polling);
  362. void wiphy_unregister(struct wiphy *wiphy)
  363. {
  364. struct cfg80211_registered_device *drv = wiphy_to_dev(wiphy);
  365. rfkill_unregister(drv->rfkill);
  366. /* protect the device list */
  367. mutex_lock(&cfg80211_mutex);
  368. BUG_ON(!list_empty(&drv->netdev_list));
  369. /*
  370. * Try to grab drv->mtx. If a command is still in progress,
  371. * hopefully the driver will refuse it since it's tearing
  372. * down the device already. We wait for this command to complete
  373. * before unlinking the item from the list.
  374. * Note: as codified by the BUG_ON above we cannot get here if
  375. * a virtual interface is still associated. Hence, we can only
  376. * get to lock contention here if userspace issues a command
  377. * that identified the hardware by wiphy index.
  378. */
  379. mutex_lock(&drv->mtx);
  380. /* unlock again before freeing */
  381. mutex_unlock(&drv->mtx);
  382. cancel_work_sync(&drv->conn_work);
  383. cfg80211_debugfs_drv_del(drv);
  384. /* If this device got a regulatory hint tell core its
  385. * free to listen now to a new shiny device regulatory hint */
  386. reg_device_remove(wiphy);
  387. list_del(&drv->list);
  388. device_del(&drv->wiphy.dev);
  389. debugfs_remove(drv->wiphy.debugfsdir);
  390. mutex_unlock(&cfg80211_mutex);
  391. }
  392. EXPORT_SYMBOL(wiphy_unregister);
  393. void cfg80211_dev_free(struct cfg80211_registered_device *drv)
  394. {
  395. struct cfg80211_internal_bss *scan, *tmp;
  396. rfkill_destroy(drv->rfkill);
  397. mutex_destroy(&drv->mtx);
  398. mutex_destroy(&drv->devlist_mtx);
  399. list_for_each_entry_safe(scan, tmp, &drv->bss_list, list)
  400. cfg80211_put_bss(&scan->pub);
  401. kfree(drv);
  402. }
  403. void wiphy_free(struct wiphy *wiphy)
  404. {
  405. put_device(&wiphy->dev);
  406. }
  407. EXPORT_SYMBOL(wiphy_free);
  408. void wiphy_rfkill_set_hw_state(struct wiphy *wiphy, bool blocked)
  409. {
  410. struct cfg80211_registered_device *drv = wiphy_to_dev(wiphy);
  411. if (rfkill_set_hw_state(drv->rfkill, blocked))
  412. schedule_work(&drv->rfkill_sync);
  413. }
  414. EXPORT_SYMBOL(wiphy_rfkill_set_hw_state);
  415. static int cfg80211_netdev_notifier_call(struct notifier_block * nb,
  416. unsigned long state,
  417. void *ndev)
  418. {
  419. struct net_device *dev = ndev;
  420. struct wireless_dev *wdev = dev->ieee80211_ptr;
  421. struct cfg80211_registered_device *rdev;
  422. if (!wdev)
  423. return NOTIFY_DONE;
  424. rdev = wiphy_to_dev(wdev->wiphy);
  425. WARN_ON(wdev->iftype == NL80211_IFTYPE_UNSPECIFIED);
  426. switch (state) {
  427. case NETDEV_REGISTER:
  428. mutex_lock(&rdev->devlist_mtx);
  429. list_add(&wdev->list, &rdev->netdev_list);
  430. if (sysfs_create_link(&dev->dev.kobj, &rdev->wiphy.dev.kobj,
  431. "phy80211")) {
  432. printk(KERN_ERR "wireless: failed to add phy80211 "
  433. "symlink to netdev!\n");
  434. }
  435. wdev->netdev = dev;
  436. wdev->sme_state = CFG80211_SME_IDLE;
  437. mutex_unlock(&rdev->devlist_mtx);
  438. #ifdef CONFIG_WIRELESS_EXT
  439. wdev->wext.default_key = -1;
  440. wdev->wext.default_mgmt_key = -1;
  441. wdev->wext.connect.auth_type = NL80211_AUTHTYPE_AUTOMATIC;
  442. wdev->wext.ps = CONFIG_CFG80211_DEFAULT_PS_VALUE;
  443. wdev->wext.ps_timeout = 500;
  444. if (rdev->ops->set_power_mgmt)
  445. if (rdev->ops->set_power_mgmt(wdev->wiphy, dev,
  446. wdev->wext.ps,
  447. wdev->wext.ps_timeout)) {
  448. /* assume this means it's off */
  449. wdev->wext.ps = false;
  450. }
  451. #endif
  452. break;
  453. case NETDEV_GOING_DOWN:
  454. if (!wdev->ssid_len)
  455. break;
  456. switch (wdev->iftype) {
  457. case NL80211_IFTYPE_ADHOC:
  458. cfg80211_leave_ibss(rdev, dev, true);
  459. break;
  460. case NL80211_IFTYPE_STATION:
  461. #ifdef CONFIG_WIRELESS_EXT
  462. kfree(wdev->wext.ie);
  463. wdev->wext.ie = NULL;
  464. wdev->wext.ie_len = 0;
  465. wdev->wext.connect.auth_type = NL80211_AUTHTYPE_AUTOMATIC;
  466. #endif
  467. cfg80211_disconnect(rdev, dev,
  468. WLAN_REASON_DEAUTH_LEAVING, true);
  469. break;
  470. default:
  471. break;
  472. }
  473. break;
  474. case NETDEV_DOWN:
  475. kfree(wdev->conn);
  476. wdev->conn = NULL;
  477. break;
  478. case NETDEV_UP:
  479. #ifdef CONFIG_WIRELESS_EXT
  480. switch (wdev->iftype) {
  481. case NL80211_IFTYPE_ADHOC:
  482. if (wdev->wext.ibss.ssid_len)
  483. cfg80211_join_ibss(rdev, dev,
  484. &wdev->wext.ibss);
  485. break;
  486. case NL80211_IFTYPE_STATION:
  487. if (wdev->wext.connect.ssid_len)
  488. cfg80211_connect(rdev, dev,
  489. &wdev->wext.connect);
  490. break;
  491. default:
  492. break;
  493. }
  494. #endif
  495. break;
  496. case NETDEV_UNREGISTER:
  497. mutex_lock(&rdev->devlist_mtx);
  498. if (!list_empty(&wdev->list)) {
  499. sysfs_remove_link(&dev->dev.kobj, "phy80211");
  500. list_del_init(&wdev->list);
  501. }
  502. mutex_unlock(&rdev->devlist_mtx);
  503. break;
  504. case NETDEV_PRE_UP:
  505. if (rfkill_blocked(rdev->rfkill))
  506. return notifier_from_errno(-ERFKILL);
  507. break;
  508. }
  509. return NOTIFY_DONE;
  510. }
  511. static struct notifier_block cfg80211_netdev_notifier = {
  512. .notifier_call = cfg80211_netdev_notifier_call,
  513. };
  514. static int cfg80211_init(void)
  515. {
  516. int err;
  517. err = wiphy_sysfs_init();
  518. if (err)
  519. goto out_fail_sysfs;
  520. err = register_netdevice_notifier(&cfg80211_netdev_notifier);
  521. if (err)
  522. goto out_fail_notifier;
  523. err = nl80211_init();
  524. if (err)
  525. goto out_fail_nl80211;
  526. ieee80211_debugfs_dir = debugfs_create_dir("ieee80211", NULL);
  527. err = regulatory_init();
  528. if (err)
  529. goto out_fail_reg;
  530. return 0;
  531. out_fail_reg:
  532. debugfs_remove(ieee80211_debugfs_dir);
  533. out_fail_nl80211:
  534. unregister_netdevice_notifier(&cfg80211_netdev_notifier);
  535. out_fail_notifier:
  536. wiphy_sysfs_exit();
  537. out_fail_sysfs:
  538. return err;
  539. }
  540. subsys_initcall(cfg80211_init);
  541. static void cfg80211_exit(void)
  542. {
  543. debugfs_remove(ieee80211_debugfs_dir);
  544. nl80211_exit();
  545. unregister_netdevice_notifier(&cfg80211_netdev_notifier);
  546. wiphy_sysfs_exit();
  547. regulatory_exit();
  548. }
  549. module_exit(cfg80211_exit);