This flag should be set per-vif, rather than globally.
Rename the flag to indicate IN_USE (rather than IDLE), as
in the default configuration (i.e. flag is clear) the vif
should be idle.
Change all the bit operations (and elp conditions) appropriately.
Signed-off-by: Eliad Peller <eliad@wizery.com>
Signed-off-by: Luciano Coelho <coelho@ti.com>
                                  bool idle)
 {
        int ret;
+       bool cur_idle = !test_bit(WLVIF_FLAG_IN_USE, &wlvif->flags);
+
+       if (idle == cur_idle)
+               return 0;
 
        if (idle) {
                /* no need to croc if we weren't busy (e.g. during boot) */
                        ACX_KEEP_ALIVE_TPL_INVALID);
                if (ret < 0)
                        goto out;
-               set_bit(WL1271_FLAG_IDLE, &wl->flags);
+               clear_bit(WLVIF_FLAG_IN_USE, &wlvif->flags);
        } else {
                /* The current firmware only supports sched_scan in idle */
                if (wl->sched_scanning) {
                ret = wl12xx_start_dev(wl, wlvif);
                if (ret < 0)
                        goto out;
-               clear_bit(WL1271_FLAG_IDLE, &wl->flags);
+               set_bit(WLVIF_FLAG_IN_USE, &wlvif->flags);
        }
 
 out:
 
                goto out;
 
        wl12xx_for_each_wlvif(wl, wlvif) {
+               if (wlvif->bss_type == BSS_TYPE_AP_BSS)
+                       goto out;
+
                if (!test_bit(WLVIF_FLAG_PSM, &wlvif->flags) &&
-                   !test_bit(WL1271_FLAG_IDLE, &wl->flags))
+                   test_bit(WLVIF_FLAG_IN_USE, &wlvif->flags))
                        goto out;
        }
 
                return;
 
        wl12xx_for_each_wlvif(wl, wlvif) {
+               if (wlvif->bss_type == BSS_TYPE_AP_BSS)
+                       return;
+
                if (!test_bit(WLVIF_FLAG_PSM, &wlvif->flags) &&
-                   !test_bit(WL1271_FLAG_IDLE, &wl->flags))
+                   test_bit(WLVIF_FLAG_IN_USE, &wlvif->flags))
                        return;
        }
 
 
        if (wlvif->bss_type != BSS_TYPE_STA_BSS)
                return -EOPNOTSUPP;
 
-       if (!test_bit(WL1271_FLAG_IDLE, &wl->flags))
+       if (test_bit(WLVIF_FLAG_IN_USE, &wlvif->flags))
                return -EBUSY;
 
        start = kzalloc(sizeof(*start), GFP_KERNEL);
 
        WL1271_FLAG_IN_ELP,
        WL1271_FLAG_ELP_REQUESTED,
        WL1271_FLAG_IRQ_RUNNING,
-       WL1271_FLAG_IDLE,
        WL1271_FLAG_FW_TX_BUSY,
        WL1271_FLAG_DUMMY_PACKET_PENDING,
        WL1271_FLAG_SUSPENDED,
        WLVIF_FLAG_PSPOLL_FAILURE,
        WLVIF_FLAG_CS_PROGRESS,
        WLVIF_FLAG_AP_PROBE_RESP_SET,
+       WLVIF_FLAG_IN_USE,
 };
 
 struct wl1271_link {