WorkStruct: make allyesconfig
[deliverable/linux.git] / net / ieee80211 / softmac / ieee80211softmac_scan.c
index 30e79d45af6bebb074eaa158f255c0b9844a5ad9..a8326076581aa0a596c6f7a5330c55a5dcf28637 100644 (file)
@@ -2,6 +2,28 @@
  * Scanning routines.
  *
  * These are not exported because they're assigned to the function pointers.
+ *
+ * Copyright (c) 2005, 2006 Johannes Berg <johannes@sipsolutions.net>
+ *                          Joseph Jezak <josejx@gentoo.org>
+ *                          Larry Finger <Larry.Finger@lwfinger.net>
+ *                          Danny van Dyk <kugelfang@gentoo.org>
+ *                          Michael Buesch <mbuesch@freenet.de>
+ *
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms of version 2 of the GNU General Public License as
+ * published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for
+ * more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301 USA
+ *
+ * The full GNU General Public License is included in this distribution in the
+ * file called COPYING.
  */
 
 #include <linux/completion.h>
@@ -25,6 +47,7 @@ ieee80211softmac_start_scan(struct ieee80211softmac_device *sm)
        sm->scanning = 1;
        spin_unlock_irqrestore(&sm->lock, flags);
 
+       netif_tx_disable(sm->ieee->dev);
        ret = sm->start_scan(sm->dev);
        if (ret) {
                spin_lock_irqsave(&sm->lock, flags);
@@ -68,12 +91,14 @@ ieee80211softmac_wait_for_scan(struct ieee80211softmac_device *sm)
 
 
 /* internal scanning implementation follows */
-void ieee80211softmac_scan(void *d)
+void ieee80211softmac_scan(struct work_struct *work)
 {
        int invalid_channel;
        u8 current_channel_idx;
-       struct ieee80211softmac_device *sm = (struct ieee80211softmac_device *)d;
-       struct ieee80211softmac_scaninfo *si = sm->scaninfo;
+       struct ieee80211softmac_scaninfo *si =
+               container_of(work, struct ieee80211softmac_scaninfo,
+                            softmac_scan.work);
+       struct ieee80211softmac_device *sm = si->mac;
        unsigned long flags;
 
        while (!(si->stop) && (si->current_channel_idx < si->number_channels)) {
@@ -92,7 +117,15 @@ void ieee80211softmac_scan(void *d)
                        // TODO: is this if correct, or should we do this only if scanning from assoc request?
                        if (sm->associnfo.req_essid.len)
                                ieee80211softmac_send_mgt_frame(sm, &sm->associnfo.req_essid, IEEE80211_STYPE_PROBE_REQ, 0);
+
+                       spin_lock_irqsave(&sm->lock, flags);
+                       if (unlikely(!sm->running)) {
+                               /* Prevent reschedule on workqueue flush */
+                               spin_unlock_irqrestore(&sm->lock, flags);
+                               break;
+                       }
                        schedule_delayed_work(&si->softmac_scan, IEEE80211SOFTMAC_PROBE_DELAY);
+                       spin_unlock_irqrestore(&sm->lock, flags);
                        return;
                } else {
                        dprintk(PFX "Not probing Channel %d (not allowed here)\n", si->channels[current_channel_idx].channel);
@@ -115,7 +148,8 @@ static inline struct ieee80211softmac_scaninfo *allocate_scaninfo(struct ieee802
        struct ieee80211softmac_scaninfo *info = kmalloc(sizeof(struct ieee80211softmac_scaninfo), GFP_ATOMIC);
        if (unlikely(!info))
                return NULL;
-       INIT_WORK(&info->softmac_scan, ieee80211softmac_scan, mac);
+       INIT_DELAYED_WORK(&info->softmac_scan, ieee80211softmac_scan);
+       info->mac = mac;
        init_completion(&info->finished);
        return info;
 }
@@ -156,8 +190,9 @@ int ieee80211softmac_start_scan_implementation(struct net_device *dev)
        dprintk(PFX "Scanning %d channels\n", sm->scaninfo->number_channels);
        sm->scaninfo->current_channel_idx = 0;
        sm->scaninfo->started = 1;
+       sm->scaninfo->stop = 0;
        INIT_COMPLETION(sm->scaninfo->finished);
-       schedule_work(&sm->scaninfo->softmac_scan);
+       schedule_delayed_work(&sm->scaninfo->softmac_scan, 0);
        spin_unlock_irqrestore(&sm->lock, flags);
        return 0;
 }
@@ -209,7 +244,14 @@ void ieee80211softmac_scan_finished(struct ieee80211softmac_device *sm)
        sm->scanning = 0;
        spin_unlock_irqrestore(&sm->lock, flags);
        
+       if (sm->associnfo.bssvalid) {
+               struct ieee80211softmac_network *net;
+
+               net = ieee80211softmac_get_network_by_bssid(sm, sm->associnfo.bssid);
+               if (net)
+                       sm->set_channel(sm->dev, net->channel);
+       }
+       netif_wake_queue(sm->ieee->dev);
        ieee80211softmac_call_events(sm, IEEE80211SOFTMAC_EVENT_SCAN_FINISHED, NULL);
 }
-
 EXPORT_SYMBOL_GPL(ieee80211softmac_scan_finished);
This page took 0.024394 seconds and 5 git commands to generate.