]> git.karo-electronics.de Git - karo-tx-linux.git/blobdiff - drivers/net/wireless/mac80211_hwsim.c
Merge branch 'master' of git://git.kernel.org/pub/scm/linux/kernel/git/linville/wirel...
[karo-tx-linux.git] / drivers / net / wireless / mac80211_hwsim.c
index 6ea77e95277ba52d4b04fe58ef38bf76ff16bba6..dfff02f5c86dd1985593add2f3bc202d7ab63c1a 100644 (file)
@@ -14,6 +14,7 @@
  */
 
 #include <linux/list.h>
+#include <linux/slab.h>
 #include <linux/spinlock.h>
 #include <net/dst.h>
 #include <net/xfrm.h>
@@ -290,7 +291,8 @@ struct mac80211_hwsim_data {
        struct ieee80211_channel *channel;
        unsigned long beacon_int; /* in jiffies unit */
        unsigned int rx_filter;
-       bool started, idle;
+       bool started, idle, scanning;
+       struct mutex mutex;
        struct timer_list beacon_timer;
        enum ps_mode {
                PS_DISABLED, PS_ENABLED, PS_AUTO_POLL, PS_MANUAL_POLL
@@ -956,9 +958,9 @@ static int mac80211_hwsim_hw_scan(struct ieee80211_hw *hw,
        hsd->hw = hw;
        INIT_DELAYED_WORK(&hsd->w, hw_scan_done);
 
-       printk(KERN_DEBUG "hwsim scan request\n");
+       printk(KERN_DEBUG "hwsim hw_scan request\n");
        for (i = 0; i < req->n_channels; i++)
-               printk(KERN_DEBUG "hwsim scan freq %d\n",
+               printk(KERN_DEBUG "hwsim hw_scan freq %d\n",
                        req->channels[i]->center_freq);
 
        ieee80211_queue_delayed_work(hw, &hsd->w, 2 * HZ);
@@ -966,6 +968,36 @@ static int mac80211_hwsim_hw_scan(struct ieee80211_hw *hw,
        return 0;
 }
 
+static void mac80211_hwsim_sw_scan(struct ieee80211_hw *hw)
+{
+       struct mac80211_hwsim_data *hwsim = hw->priv;
+
+       mutex_lock(&hwsim->mutex);
+
+       if (hwsim->scanning) {
+               printk(KERN_DEBUG "two hwsim sw_scans detected!\n");
+               goto out;
+       }
+
+       printk(KERN_DEBUG "hwsim sw_scan request, prepping stuff\n");
+       hwsim->scanning = true;
+
+out:
+       mutex_unlock(&hwsim->mutex);
+}
+
+static void mac80211_hwsim_sw_scan_complete(struct ieee80211_hw *hw)
+{
+       struct mac80211_hwsim_data *hwsim = hw->priv;
+
+       mutex_lock(&hwsim->mutex);
+
+       printk(KERN_DEBUG "hwsim sw_scan_complete\n");
+       hwsim->scanning = true;
+
+       mutex_unlock(&hwsim->mutex);
+}
+
 static struct ieee80211_ops mac80211_hwsim_ops =
 {
        .tx = mac80211_hwsim_tx,
@@ -983,6 +1015,8 @@ static struct ieee80211_ops mac80211_hwsim_ops =
        .conf_tx = mac80211_hwsim_conf_tx,
        CFG80211_TESTMODE_CMD(mac80211_hwsim_testmode_cmd)
        .ampdu_action = mac80211_hwsim_ampdu_action,
+       .sw_scan_start = mac80211_hwsim_sw_scan,
+       .sw_scan_complete = mac80211_hwsim_sw_scan_complete,
        .flush = mac80211_hwsim_flush,
 };
 
@@ -1178,8 +1212,11 @@ static int __init init_mac80211_hwsim(void)
        if (radios < 1 || radios > 100)
                return -EINVAL;
 
-       if (fake_hw_scan)
+       if (fake_hw_scan) {
                mac80211_hwsim_ops.hw_scan = mac80211_hwsim_hw_scan;
+               mac80211_hwsim_ops.sw_scan_start = NULL;
+               mac80211_hwsim_ops.sw_scan_complete = NULL;
+       }
 
        spin_lock_init(&hwsim_radio_lock);
        INIT_LIST_HEAD(&hwsim_radios);
@@ -1284,6 +1321,7 @@ static int __init init_mac80211_hwsim(void)
                }
                /* By default all radios are belonging to the first group */
                data->group = 1;
+               mutex_init(&data->mutex);
 
                /* Work to be done prior to ieee80211_register_hw() */
                switch (regtest) {