sh: convert /proc/cpu/aligmnent, /proc/cpu/kernel_alignment to seq_file
[safe/jmp/linux-2.6] / net / mac80211 / scan.c
index d56b9da..71e10ca 100644 (file)
@@ -18,7 +18,6 @@
 #include <linux/if_arp.h>
 #include <linux/rtnetlink.h>
 #include <net/mac80211.h>
-#include <net/iw_handler.h>
 
 #include "ieee80211_i.h"
 #include "driver-ops.h"
@@ -91,8 +90,8 @@ ieee80211_bss_info_update(struct ieee80211_local *local,
                bss->dtim_period = tim_ie->dtim_period;
        }
 
-       /* set default value for buggy APs */
-       if (!elems->tim || bss->dtim_period == 0)
+       /* set default value for buggy AP/no TIM element */
+       if (bss->dtim_period == 0)
                bss->dtim_period = 1;
 
        bss->supp_rates_len = 0;
@@ -278,9 +277,10 @@ void ieee80211_scan_completed(struct ieee80211_hw *hw, bool aborted)
        if (test_bit(SCAN_HW_SCANNING, &local->scanning))
                ieee80211_restore_scan_ies(local);
 
-       if (local->scan_req != &local->int_scan_req)
+       if (local->scan_req != local->int_scan_req)
                cfg80211_scan_done(local->scan_req, aborted);
        local->scan_req = NULL;
+       local->scan_sdata = NULL;
 
        was_hw_scan = test_bit(SCAN_HW_SCANNING, &local->scanning);
        local->scanning = 0;
@@ -293,13 +293,7 @@ void ieee80211_scan_completed(struct ieee80211_hw *hw, bool aborted)
        if (was_hw_scan)
                goto done;
 
-       spin_lock_bh(&local->filter_lock);
-       local->filter_flags &= ~FIF_BCN_PRBRESP_PROMISC;
-       drv_configure_filter(local, FIF_BCN_PRBRESP_PROMISC,
-                            &local->filter_flags,
-                            local->mc_count,
-                            local->mc_list);
-       spin_unlock_bh(&local->filter_lock);
+       ieee80211_configure_filter(local);
 
        drv_sw_scan_complete(local);
 
@@ -374,20 +368,15 @@ static int ieee80211_start_sw_scan(struct ieee80211_local *local)
        }
        mutex_unlock(&local->iflist_mtx);
 
-       local->scan_state = SCAN_DECISION;
+       local->next_scan_state = SCAN_DECISION;
        local->scan_channel_idx = 0;
 
-       spin_lock_bh(&local->filter_lock);
-       local->filter_flags |= FIF_BCN_PRBRESP_PROMISC;
-       drv_configure_filter(local, FIF_BCN_PRBRESP_PROMISC,
-                            &local->filter_flags,
-                            local->mc_count,
-                            local->mc_list);
-       spin_unlock_bh(&local->filter_lock);
+       ieee80211_configure_filter(local);
 
        /* TODO: start scan as soon as all nullfunc frames are ACKed */
-       queue_delayed_work(local->hw.workqueue, &local->scan_work,
-                          IEEE80211_CHANNEL_TIME);
+       ieee80211_queue_delayed_work(&local->hw,
+                                    &local->scan_work,
+                                    IEEE80211_CHANNEL_TIME);
 
        return 0;
 }
@@ -423,7 +412,7 @@ static int __ieee80211_start_scan(struct ieee80211_sub_if_data *sdata,
        local->scan_req = req;
        local->scan_sdata = sdata;
 
-       if (req != &local->int_scan_req &&
+       if (req != local->int_scan_req &&
            sdata->vif.type == NL80211_IFTYPE_STATION &&
            !list_empty(&ifmgd->work_list)) {
                /* actually wait for the work it's doing to finish/time out */
@@ -505,15 +494,15 @@ static int ieee80211_scan_state_decision(struct ieee80211_local *local,
                 * next channel
                 */
                if (associated)
-                       local->scan_state = SCAN_ENTER_OPER_CHANNEL;
+                       local->next_scan_state = SCAN_ENTER_OPER_CHANNEL;
                else
-                       local->scan_state = SCAN_SET_CHANNEL;
+                       local->next_scan_state = SCAN_SET_CHANNEL;
        } else {
                /*
                 * we're on the operating channel currently, let's
                 * leave that channel now to scan another one
                 */
-               local->scan_state = SCAN_LEAVE_OPER_CHANNEL;
+               local->next_scan_state = SCAN_LEAVE_OPER_CHANNEL;
        }
 
        *next_delay = 0;
@@ -545,7 +534,7 @@ static void ieee80211_scan_state_leave_oper_channel(struct ieee80211_local *loca
 
        /* advance to the next channel to be scanned */
        *next_delay = HZ / 10;
-       local->scan_state = SCAN_SET_CHANNEL;
+       local->next_scan_state = SCAN_SET_CHANNEL;
 }
 
 static void ieee80211_scan_state_enter_oper_channel(struct ieee80211_local *local,
@@ -577,7 +566,7 @@ static void ieee80211_scan_state_enter_oper_channel(struct ieee80211_local *loca
        __clear_bit(SCAN_OFF_CHANNEL, &local->scanning);
 
        *next_delay = HZ / 5;
-       local->scan_state = SCAN_DECISION;
+       local->next_scan_state = SCAN_DECISION;
 }
 
 static void ieee80211_scan_state_set_channel(struct ieee80211_local *local,
@@ -605,8 +594,11 @@ static void ieee80211_scan_state_set_channel(struct ieee80211_local *local,
        /* advance state machine to next channel/band */
        local->scan_channel_idx++;
 
-       if (skip)
+       if (skip) {
+               /* if we skip this channel return to the decision state */
+               local->next_scan_state = SCAN_DECISION;
                return;
+       }
 
        /*
         * Probe delay is used to update the NAV, cf. 11.1.3.2.2
@@ -621,13 +613,13 @@ static void ieee80211_scan_state_set_channel(struct ieee80211_local *local,
        if (chan->flags & IEEE80211_CHAN_PASSIVE_SCAN ||
            !local->scan_req->n_ssids) {
                *next_delay = IEEE80211_PASSIVE_CHANNEL_TIME;
-               local->scan_state = SCAN_DECISION;
+               local->next_scan_state = SCAN_DECISION;
                return;
        }
 
        /* active scan, send probes */
        *next_delay = IEEE80211_PROBE_DELAY;
-       local->scan_state = SCAN_SEND_PROBE;
+       local->next_scan_state = SCAN_SEND_PROBE;
 }
 
 static void ieee80211_scan_state_send_probe(struct ieee80211_local *local,
@@ -648,7 +640,7 @@ static void ieee80211_scan_state_send_probe(struct ieee80211_local *local,
         * on the channel.
         */
        *next_delay = IEEE80211_CHANNEL_TIME;
-       local->scan_state = SCAN_DECISION;
+       local->next_scan_state = SCAN_DECISION;
 }
 
 void ieee80211_scan_work(struct work_struct *work)
@@ -669,6 +661,7 @@ void ieee80211_scan_work(struct work_struct *work)
                int rc;
 
                local->scan_req = NULL;
+               local->scan_sdata = NULL;
 
                rc = __ieee80211_start_scan(sdata, req);
                mutex_unlock(&local->scan_mtx);
@@ -693,7 +686,7 @@ void ieee80211_scan_work(struct work_struct *work)
         * without scheduling a new work
         */
        do {
-               switch (local->scan_state) {
+               switch (local->next_scan_state) {
                case SCAN_DECISION:
                        if (ieee80211_scan_state_decision(local, &next_delay))
                                return;
@@ -713,8 +706,7 @@ void ieee80211_scan_work(struct work_struct *work)
                }
        } while (next_delay == 0);
 
-       queue_delayed_work(local->hw.workqueue, &local->scan_work,
-                          next_delay);
+       ieee80211_queue_delayed_work(&local->hw, &local->scan_work, next_delay);
 }
 
 int ieee80211_request_scan(struct ieee80211_sub_if_data *sdata,
@@ -741,10 +733,10 @@ int ieee80211_request_internal_scan(struct ieee80211_sub_if_data *sdata,
        if (local->scan_req)
                goto unlock;
 
-       memcpy(local->int_scan_req.ssids[0].ssid, ssid, IEEE80211_MAX_SSID_LEN);
-       local->int_scan_req.ssids[0].ssid_len = ssid_len;
+       memcpy(local->int_scan_req->ssids[0].ssid, ssid, IEEE80211_MAX_SSID_LEN);
+       local->int_scan_req->ssids[0].ssid_len = ssid_len;
 
-       ret = __ieee80211_start_scan(sdata, &sdata->local->int_scan_req);
+       ret = __ieee80211_start_scan(sdata, sdata->local->int_scan_req);
  unlock:
        mutex_unlock(&local->scan_mtx);
        return ret;
@@ -752,7 +744,7 @@ int ieee80211_request_internal_scan(struct ieee80211_sub_if_data *sdata,
 
 void ieee80211_scan_cancel(struct ieee80211_local *local)
 {
-       bool swscan;
+       bool abortscan;
 
        cancel_delayed_work_sync(&local->scan_work);
 
@@ -761,9 +753,10 @@ void ieee80211_scan_cancel(struct ieee80211_local *local)
         * queued -- mostly at suspend under RTNL.
         */
        mutex_lock(&local->scan_mtx);
-       swscan = test_bit(SCAN_SW_SCANNING, &local->scanning);
+       abortscan = test_bit(SCAN_SW_SCANNING, &local->scanning) ||
+                   (!local->scanning && local->scan_req);
        mutex_unlock(&local->scan_mtx);
 
-       if (swscan)
+       if (abortscan)
                ieee80211_scan_completed(&local->hw, true);
 }