wl1251: improve PS report handling
[pandora-kernel.git] / drivers / net / wireless / wl1251 / event.c
index 9f15cca..8c70b14 100644 (file)
@@ -67,29 +67,21 @@ 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->station_mode != STATION_ACTIVE_MODE) {
-                       ret = wl1251_ps_set_mode(wl, STATION_ACTIVE_MODE);
-                       if (ret < 0)
-                               return ret;
-               }
+               wl->bss_lost = 1;
+               ieee80211_queue_delayed_work(wl->hw, &wl->ps_work, 0);
        }
 
-       if (vector & SYNCHRONIZATION_TIMEOUT_EVENT_ID &&
-           wl->station_mode != STATION_ACTIVE_MODE) {
+       if (vector & SYNCHRONIZATION_TIMEOUT_EVENT_ID) {
                wl1251_debug(DEBUG_EVENT, "SYNCHRONIZATION_TIMEOUT_EVENT");
 
                /* indicate to the stack, that beacons have been lost */
-               ieee80211_beacon_loss(wl->vif);
+               if (wl->vif && wl->vif->type == NL80211_IFTYPE_STATION)
+                       ieee80211_beacon_loss(wl->vif);
        }
 
        if (vector & REGAINED_BSS_EVENT_ID) {
-               if (wl->psm_requested) {
-                       ret = wl1251_ps_set_mode(wl, STATION_POWER_SAVE_MODE);
-                       if (ret < 0)
-                               return ret;
-               }
+               wl->bss_lost = 0;
+               ieee80211_queue_delayed_work(wl->hw, &wl->ps_work, 0);
        }
 
        if (wl->vif && wl->rssi_thold) {
@@ -110,6 +102,27 @@ static int wl1251_event_process(struct wl1251 *wl, struct event_mailbox *mbox)
                }
        }
 
+       if (vector & PS_REPORT_EVENT_ID) {
+               if (mbox->ps_status == ENTER_POWER_SAVE_SUCCESS) {
+                       /* enable beacon filtering */
+                       ret = wl1251_acx_beacon_filter_opt(wl, true);
+                       if (ret < 0)
+                               wl1251_error("beacon filter enable failed");
+
+               } else if (wl->ps_transitioning) {
+                       if (mbox->ps_status == ENTER_POWER_SAVE_FAIL)
+                               wl->station_mode = STATION_ACTIVE_MODE;
+                       /* always happens on exit from idle - ignore for now
+                       else if (mbox->ps_status == EXIT_POWER_SAVE_FAIL)
+                               wl->station_mode = STATION_POWER_SAVE_MODE;
+                       */
+               }
+
+               //wl1251_error("ps_status %d, mode %d",
+               //      mbox->ps_status, wl->station_mode);
+               wl->ps_transitioning = false;
+       }
+
        return 0;
 }