wl1251: Prepare for idle mode support
[pandora-wifi.git] / drivers / net / wireless / wl12xx / wl1251_event.c
index e093a1c..070cd44 100644 (file)
@@ -72,18 +72,23 @@ static int wl1251_event_process(struct wl1251 *wl, struct event_mailbox *mbox)
        if (vector & BSS_LOSE_EVENT_ID) {
                wl1251_debug(DEBUG_EVENT, "BSS_LOSE_EVENT");
 
-               if (wl->psm_requested && wl->psm) {
+               if (wl->psm_requested &&
+                   wl->station_mode != STATION_ACTIVE_MODE) {
                        ret = wl1251_ps_set_mode(wl, STATION_ACTIVE_MODE);
                        if (ret < 0)
                                return ret;
                }
        }
 
-       if (vector & SYNCHRONIZATION_TIMEOUT_EVENT_ID && wl->psm) {
+       if (vector & SYNCHRONIZATION_TIMEOUT_EVENT_ID &&
+           wl->station_mode != STATION_ACTIVE_MODE) {
                wl1251_debug(DEBUG_EVENT, "SYNCHRONIZATION_TIMEOUT_EVENT");
+               /* need to unlock mutex to avoid deadlocking with rtnl */
+               mutex_unlock(&wl->mutex);
 
                /* indicate to the stack, that beacons have been lost */
                ieee80211_beacon_loss(wl->vif);
+               mutex_lock(&wl->mutex);
        }
 
        if (vector & REGAINED_BSS_EVENT_ID) {
@@ -94,6 +99,13 @@ static int wl1251_event_process(struct wl1251 *wl, struct event_mailbox *mbox)
                }
        }
 
+       /* log rare events to help debugging some issues */
+       if (vector & ~(SCAN_COMPLETE_EVENT_ID | PS_REPORT_EVENT_ID |
+                       SYNCHRONIZATION_TIMEOUT_EVENT_ID | JOIN_EVENT_COMPLETE_ID |
+                       BSS_LOSE_EVENT_ID | RESET_BSS_EVENT_ID |
+                       BT_PTA_PREDICTION_EVENT_ID))
+               wl1251_info("rare event: %08x", vector);
+
        return 0;
 }