/* * We need to differentiate between the surprise and planned removal of the * device because of the following consideration: * * - In case of surprise removal, the hcd already frees up the pending * for the device and hence there is no need to unregister the function * driver inorder to get these requests. For planned removal, the function * driver has to explicitly unregister itself to have the hcd return all the * pending requests before the data structures for the devices are freed up. * Note that as per the current implementation, the function driver will * end up releasing all the devices since there is no API to selectively * release a particular device. * * - Certain commands issued to the target can be skipped for surprise * removal since they will anyway not go through. */ void ath6kl_destroy(struct net_device *dev, unsigned int unregister) { struct ath6kl *ar; if (!dev || !ath6kl_priv(dev)) { ath6kl_err("failed to get device structure\n"); return; } ar = ath6kl_priv(dev); destroy_workqueue(ar->ath6kl_wq); if (ar->htc_target) htc_cleanup(ar->htc_target); aggr_module_destroy(ar->aggr_cntxt); ath6kl_cookie_cleanup(ar); ath6kl_cleanup_amsdu_rxbufs(ar); ath6kl_bmi_cleanup(ar); if (unregister && test_bit(NETDEV_REGISTERED, &ar->flag)) { unregister_netdev(dev); clear_bit(NETDEV_REGISTERED, &ar->flag); } free_netdev(dev); ath6kl_cfg80211_deinit(ar); }
struct ath6kl *ath6kl_core_alloc(struct device *sdev) { struct net_device *dev; struct ath6kl *ar; struct wireless_dev *wdev; wdev = ath6kl_cfg80211_init(sdev); if (!wdev) { ath6kl_err("ath6kl_cfg80211_init failed\n"); return NULL; } ar = wdev_priv(wdev); ar->dev = sdev; ar->wdev = wdev; wdev->iftype = NL80211_IFTYPE_STATION; dev = alloc_netdev(0, "wlan%d", ether_setup); if (!dev) { ath6kl_err("no memory for network device instance\n"); ath6kl_cfg80211_deinit(ar); return NULL; } dev->ieee80211_ptr = wdev; SET_NETDEV_DEV(dev, wiphy_dev(wdev->wiphy)); wdev->netdev = dev; ar->sme_state = SME_DISCONNECTED; ar->auto_auth_stage = AUTH_IDLE; init_netdev(dev); ar->net_dev = dev; set_bit(WLAN_ENABLED, &ar->flag); ar->wlan_pwr_state = WLAN_POWER_STATE_ON; spin_lock_init(&ar->lock); ath6kl_init_control_info(ar); init_waitqueue_head(&ar->event_wq); sema_init(&ar->sem, 1); clear_bit(DESTROY_IN_PROGRESS, &ar->flag); INIT_LIST_HEAD(&ar->amsdu_rx_buffer_queue); setup_timer(&ar->disconnect_timer, disconnect_timer_handler, (unsigned long) dev); return ar; }