wl12xx: make WL1271_FLAG_IF_INITIALIZED per-vif
Make the initialization flag per-vif, and add some checks for it.
Signed-off-by: Eliad Peller <eliad@wizery.com>
Signed-off-by: Luciano Coelho <coelho@ti.com>
diff --git a/drivers/net/wireless/wl12xx/main.c b/drivers/net/wireless/wl12xx/main.c
index 9042445..fb5951c 100644
--- a/drivers/net/wireless/wl12xx/main.c
+++ b/drivers/net/wireless/wl12xx/main.c
@@ -1817,14 +1817,20 @@
wl1271_debug(DEBUG_MAC80211, "mac80211 stop");
- mutex_lock(&wl_list_mutex);
- list_del(&wl->list);
-
+ mutex_lock(&wl->mutex);
+ if (wl->state == WL1271_STATE_OFF) {
+ mutex_unlock(&wl->mutex);
+ return;
+ }
/*
* this must be before the cancel_work calls below, so that the work
* functions don't perform further work.
*/
wl->state = WL1271_STATE_OFF;
+ mutex_unlock(&wl->mutex);
+
+ mutex_lock(&wl_list_mutex);
+ list_del(&wl->list);
mutex_unlock(&wl_list_mutex);
wl1271_disable_interrupts(wl);
@@ -1971,7 +1977,6 @@
setup_timer(&wlvif->rx_streaming_timer, wl1271_rx_streaming_timer,
(unsigned long) wlvif);
-
return 0;
}
@@ -2069,7 +2074,8 @@
* get here before __wl1271_op_remove_interface is complete, so
* opt out if that is the case.
*/
- if (test_bit(WL1271_FLAG_IF_INITIALIZED, &wl->flags)) {
+ if (test_bit(WL1271_FLAG_RECOVERY_IN_PROGRESS, &wl->flags) ||
+ test_bit(WLVIF_FLAG_INITIALIZED, &wlvif->flags)) {
ret = -EBUSY;
goto out;
}
@@ -2129,7 +2135,7 @@
wl->vif = vif;
list_add(&wlvif->list, &wl->wlvif_list);
- set_bit(WL1271_FLAG_IF_INITIALIZED, &wl->flags);
+ set_bit(WLVIF_FLAG_INITIALIZED, &wlvif->flags);
if (wlvif->bss_type == BSS_TYPE_AP_BSS)
wl->ap_count++;
@@ -2155,6 +2161,9 @@
wl1271_debug(DEBUG_MAC80211, "mac80211 remove interface");
+ if (!test_and_clear_bit(WLVIF_FLAG_INITIALIZED, &wlvif->flags))
+ return;
+
/* because of hardware recovery, we may get here twice */
if (wl->state != WL1271_STATE_ON)
return;
@@ -2224,8 +2233,14 @@
struct ieee80211_vif *vif)
{
struct wl1271 *wl = hw->priv;
+ struct wl12xx_vif *wlvif = wl12xx_vif_to_data(vif);
mutex_lock(&wl->mutex);
+
+ if (wl->state == WL1271_STATE_OFF ||
+ !test_bit(WLVIF_FLAG_INITIALIZED, &wlvif->flags))
+ goto out;
+
/*
* wl->vif can be null here if someone shuts down the interface
* just when hardware recovery has been started.
@@ -2234,7 +2249,7 @@
WARN_ON(wl->vif != vif);
__wl1271_op_remove_interface(wl, vif, true);
}
-
+out:
mutex_unlock(&wl->mutex);
cancel_work_sync(&wl->recovery_work);
}
@@ -3843,6 +3858,9 @@
if (unlikely(wl->state == WL1271_STATE_OFF))
goto out;
+ if (unlikely(!test_bit(WLVIF_FLAG_INITIALIZED, &wlvif->flags)))
+ goto out;
+
ret = wl1271_ps_elp_wakeup(wl);
if (ret < 0)
goto out;