wext: refactor
[linux-2.6.git] / net / wireless / core.c
index 154e1e2..eb0bb24 100644 (file)
@@ -294,69 +294,17 @@ static void cfg80211_rfkill_sync_work(struct work_struct *work)
        cfg80211_rfkill_set_block(rdev, rfkill_blocked(rdev->rfkill));
 }
 
-static void cfg80211_process_events(struct wireless_dev *wdev)
-{
-       struct cfg80211_event *ev;
-       unsigned long flags;
-
-       spin_lock_irqsave(&wdev->event_lock, flags);
-       while (!list_empty(&wdev->event_list)) {
-               ev = list_first_entry(&wdev->event_list,
-                                     struct cfg80211_event, list);
-               list_del(&ev->list);
-               spin_unlock_irqrestore(&wdev->event_lock, flags);
-
-               wdev_lock(wdev);
-               switch (ev->type) {
-               case EVENT_CONNECT_RESULT:
-                       __cfg80211_connect_result(
-                               wdev->netdev, is_zero_ether_addr(ev->cr.bssid) ?
-                               NULL : ev->cr.bssid,
-                               ev->cr.req_ie, ev->cr.req_ie_len,
-                               ev->cr.resp_ie, ev->cr.resp_ie_len,
-                               ev->cr.status,
-                               ev->cr.status == WLAN_STATUS_SUCCESS,
-                               NULL);
-                       break;
-               case EVENT_ROAMED:
-                       __cfg80211_roamed(wdev, ev->rm.bssid,
-                                         ev->rm.req_ie, ev->rm.req_ie_len,
-                                         ev->rm.resp_ie, ev->rm.resp_ie_len);
-                       break;
-               case EVENT_DISCONNECTED:
-                       __cfg80211_disconnected(wdev->netdev,
-                                               ev->dc.ie, ev->dc.ie_len,
-                                               ev->dc.reason, true);
-                       break;
-               case EVENT_IBSS_JOINED:
-                       __cfg80211_ibss_joined(wdev->netdev, ev->ij.bssid);
-                       break;
-               }
-               wdev_unlock(wdev);
-
-               kfree(ev);
-
-               spin_lock_irqsave(&wdev->event_lock, flags);
-       }
-       spin_unlock_irqrestore(&wdev->event_lock, flags);
-}
-
 static void cfg80211_event_work(struct work_struct *work)
 {
        struct cfg80211_registered_device *rdev;
-       struct wireless_dev *wdev;
 
        rdev = container_of(work, struct cfg80211_registered_device,
                            event_work);
 
        rtnl_lock();
        cfg80211_lock_rdev(rdev);
-       mutex_lock(&rdev->devlist_mtx);
 
-       list_for_each_entry(wdev, &rdev->netdev_list, list)
-               cfg80211_process_events(wdev);
-
-       mutex_unlock(&rdev->devlist_mtx);
+       cfg80211_process_rdev_events(rdev);
        cfg80211_unlock_rdev(rdev);
        rtnl_unlock();
 }
@@ -410,6 +358,10 @@ struct wiphy *wiphy_new(const struct cfg80211_ops *ops, int sizeof_priv)
        INIT_LIST_HEAD(&rdev->bss_list);
        INIT_WORK(&rdev->scan_done_wk, __cfg80211_scan_done);
 
+#ifdef CONFIG_CFG80211_WEXT
+       rdev->wiphy.wext = &cfg80211_wext_handler;
+#endif
+
        device_initialize(&rdev->wiphy.dev);
        rdev->wiphy.dev.class = &ieee80211_class;
        rdev->wiphy.dev.platform_data = rdev;
@@ -664,7 +616,7 @@ static void wdev_cleanup_work(struct work_struct *work)
 
        if (WARN_ON(rdev->scan_req && rdev->scan_req->dev == wdev->netdev)) {
                rdev->scan_req->aborted = true;
-               ___cfg80211_scan_done(rdev);
+               ___cfg80211_scan_done(rdev, true);
        }
 
        cfg80211_unlock_rdev(rdev);
@@ -677,6 +629,10 @@ static void wdev_cleanup_work(struct work_struct *work)
        dev_put(wdev->netdev);
 }
 
+static struct device_type wiphy_type = {
+       .name   = "wlan",
+};
+
 static int cfg80211_netdev_notifier_call(struct notifier_block * nb,
                                         unsigned long state,
                                         void *ndev)
@@ -693,6 +649,9 @@ static int cfg80211_netdev_notifier_call(struct notifier_block * nb,
        WARN_ON(wdev->iftype == NL80211_IFTYPE_UNSPECIFIED);
 
        switch (state) {
+       case NETDEV_POST_INIT:
+               SET_NETDEV_DEVTYPE(dev, &wiphy_type);
+               break;
        case NETDEV_REGISTER:
                /*
                 * NB: cannot take rdev->mtx here because this may be
@@ -717,9 +676,7 @@ static int cfg80211_netdev_notifier_call(struct notifier_block * nb,
                wdev->netdev = dev;
                wdev->sme_state = CFG80211_SME_IDLE;
                mutex_unlock(&rdev->devlist_mtx);
-#ifdef CONFIG_WIRELESS_EXT
-               if (!dev->wireless_handlers)
-                       dev->wireless_handlers = &cfg80211_wext_handler;
+#ifdef CONFIG_CFG80211_WEXT
                wdev->wext.default_key = -1;
                wdev->wext.default_mgmt_key = -1;
                wdev->wext.connect.auth_type = NL80211_AUTHTYPE_AUTOMATIC;
@@ -741,7 +698,7 @@ static int cfg80211_netdev_notifier_call(struct notifier_block * nb,
                        break;
                case NL80211_IFTYPE_STATION:
                        wdev_lock(wdev);
-#ifdef CONFIG_WIRELESS_EXT
+#ifdef CONFIG_CFG80211_WEXT
                        kfree(wdev->wext.ie);
                        wdev->wext.ie = NULL;
                        wdev->wext.ie_len = 0;
@@ -755,6 +712,8 @@ static int cfg80211_netdev_notifier_call(struct notifier_block * nb,
                default:
                        break;
                }
+               break;
+       case NETDEV_DOWN:
                dev_hold(dev);
                schedule_work(&wdev->cleanup_work);
                break;
@@ -771,7 +730,7 @@ static int cfg80211_netdev_notifier_call(struct notifier_block * nb,
                        mutex_unlock(&rdev->devlist_mtx);
                        dev_put(dev);
                }
-#ifdef CONFIG_WIRELESS_EXT
+#ifdef CONFIG_CFG80211_WEXT
                cfg80211_lock_rdev(rdev);
                mutex_lock(&rdev->devlist_mtx);
                wdev_lock(wdev);
@@ -809,7 +768,7 @@ static int cfg80211_netdev_notifier_call(struct notifier_block * nb,
                        sysfs_remove_link(&dev->dev.kobj, "phy80211");
                        list_del_init(&wdev->list);
                        rdev->devlist_generation++;
-#ifdef CONFIG_WIRELESS_EXT
+#ifdef CONFIG_CFG80211_WEXT
                        kfree(wdev->wext.keys);
 #endif
                }