wlan: Exit BMPS during wlan resume

Wlan firmware locks interrupt during exit & enter BMPS.
During wlan resume, host sends multiple commands to firmware and
While processing of each smd commands, it exit/enter bmps mode.
Because of much interrupt locking, BT thread get delayed and user
experiences glitches during  a2dp streaming.

As a part of this fix, Host exit BMP during starting of resume.
Later once resume gets complete, host enter again in bmps.

Change-Id: I00dac523755bcb1c3ade407cb2840a9060e23ed6
CRs-Fixed: 2069225
diff --git a/CORE/HDD/src/wlan_hdd_early_suspend.c b/CORE/HDD/src/wlan_hdd_early_suspend.c
index 1ebcf4d..7078900 100644
--- a/CORE/HDD/src/wlan_hdd_early_suspend.c
+++ b/CORE/HDD/src/wlan_hdd_early_suspend.c
@@ -1983,6 +1983,8 @@
    hdd_adapter_list_node_t *pAdapterNode = NULL, *pNext = NULL;
    VOS_STATUS status;
    v_CONTEXT_t pVosContext = NULL;
+   tPmcState pmc_state;
+   hdd_adapter_t *first_adapter = NULL;
 
    hddLog(VOS_TRACE_LEVEL_INFO, "%s: WLAN being resumed by Android OS",__func__);
 
@@ -2017,6 +2019,26 @@
 
    pHddCtx->hdd_wlan_suspended = FALSE;
    hdd_wlan_suspend_resume_event(HDD_WLAN_EARLY_RESUME);
+
+   /* Get first valid adapter for disable/enable  bmps purpose */
+   status = hdd_get_front_adapter ( pHddCtx, &pAdapterNode );
+   while ( NULL != pAdapterNode && VOS_STATUS_SUCCESS == status )
+   {
+       first_adapter = pAdapterNode->pAdapter;
+       if (first_adapter != NULL)
+           break;
+       status = hdd_get_next_adapter ( pHddCtx, pAdapterNode, &pNext );
+       pAdapterNode = pNext;
+   }
+   pmc_state = pmcGetPmcState(pHddCtx->hHal);
+   if (BMPS == pmc_state && first_adapter)
+   {
+       /* put the device into full power */
+       hddLog(VOS_TRACE_LEVEL_INFO,
+             "%s: Disaling bmps during resume", __func__);
+       wlan_hdd_enter_bmps(first_adapter, DRIVER_POWER_MODE_ACTIVE);
+   }
+
    /*loop through all adapters. Concurrency */
    status = hdd_get_front_adapter ( pHddCtx, &pAdapterNode );
 
@@ -2064,14 +2086,8 @@
                         "Switch to DTIM%d",powerRequest.uListenInterval);
          sme_SetPowerParams( WLAN_HDD_GET_HAL_CTX(pAdapter), &powerRequest, FALSE);
 
-         if (BMPS == pmcGetPmcState(pHddCtx->hHal))
+         if (BMPS == pmc_state)
          {
-             /* put the device into full power */
-             wlan_hdd_enter_bmps(pAdapter, DRIVER_POWER_MODE_ACTIVE);
-
-             /* put the device back into BMPS */
-             wlan_hdd_enter_bmps(pAdapter, DRIVER_POWER_MODE_AUTO);
-
              pHddCtx->hdd_ignore_dtim_enabled = FALSE;
          }
       }
@@ -2081,6 +2097,15 @@
       pAdapterNode = pNext;
    }
 
+   if (BMPS == pmc_state && first_adapter)
+   {
+       /* put the device into full power */
+       hddLog(VOS_TRACE_LEVEL_INFO,
+             "%s: Enable bmps during resume", __func__);
+      /* put the device back into BMPS */
+      wlan_hdd_enter_bmps(first_adapter, DRIVER_POWER_MODE_AUTO);
+   }
+
 #ifdef SUPPORT_EARLY_SUSPEND_STANDBY_DEEPSLEEP   
    if(pHddCtx->hdd_ps_state == eHDD_SUSPEND_STANDBY) 
    {