Wlan: Reverting the changes leading to a crash on driver unload.

Revert change to prevent driver crash.

Change-Id: I657e6557d9b91c50563d96393764b189c42e1d8c
CR-Fixed: NA
diff --git a/CORE/MAC/inc/aniGlobal.h b/CORE/MAC/inc/aniGlobal.h
index bd51bcd..716f9e2 100644
--- a/CORE/MAC/inc/aniGlobal.h
+++ b/CORE/MAC/inc/aniGlobal.h
@@ -282,7 +282,6 @@
     tANI_U8               gLim24Band11dScanDone;
     tANI_U8               gLim50Band11dScanDone;
     tANI_U8               gLimReturnUniqueResults;
-    tANI_U8               gSeparateProbeBeacon;
 
     // Background Scan related globals on STA
     tANI_U32               gLimNumOfBackgroundScanSuccess;
diff --git a/CORE/MAC/inc/sirApi.h b/CORE/MAC/inc/sirApi.h
index b5a617e..78eaa9e 100644
--- a/CORE/MAC/inc/sirApi.h
+++ b/CORE/MAC/inc/sirApi.h
@@ -1035,8 +1035,6 @@
     tANI_BOOLEAN         p2pSearch;
     tANI_BOOLEAN         skipDfsChnlInP2pSearch;
 #endif
-    tANI_U8              separateProbeBeacon; //If set to 1, PE scan cache to have separate entry for probe rsp & beacon for same BSSID
-
     tANI_U16             uIEFieldLen;
     tANI_U16             uIEFieldOffset;
 
diff --git a/CORE/MAC/src/pe/lim/limApi.c b/CORE/MAC/src/pe/lim/limApi.c
index 4f46e97..9a0fd9d 100644
--- a/CORE/MAC/src/pe/lim/limApi.c
+++ b/CORE/MAC/src/pe/lim/limApi.c
@@ -87,7 +87,6 @@
     pMac->lim.gLim24Band11dScanDone = 0;
     pMac->lim.gLim50Band11dScanDone = 0;
     pMac->lim.gLimReturnUniqueResults = 0;
-    pMac->lim.gSeparateProbeBeacon = false;
 
     // Background Scan related globals on STA
     pMac->lim.gLimNumOfBackgroundScanSuccess = 0;
@@ -641,7 +640,6 @@
       // By default return unique scan results
       pMac->lim.gLimReturnUniqueResults = true;
       pMac->lim.gLimSmeScanResultLength = 0;
-      pMac->lim.gSeparateProbeBeacon = false;
    }
    else
    {
diff --git a/CORE/MAC/src/pe/lim/limProcessSmeReqMessages.c b/CORE/MAC/src/pe/lim/limProcessSmeReqMessages.c
index 3392ad5..7ade82a 100644
--- a/CORE/MAC/src/pe/lim/limProcessSmeReqMessages.c
+++ b/CORE/MAC/src/pe/lim/limProcessSmeReqMessages.c
@@ -377,7 +377,6 @@
 
         /// By default return unique scan results
         pMac->lim.gLimReturnUniqueResults = true;
-        pMac->lim.gSeparateProbeBeacon = false;
         pMac->lim.gLimSmeScanResultLength = 0;
 
 #if defined(ANI_PRODUCT_TYPE_CLIENT) || defined(ANI_AP_CLIENT_SDK)
@@ -1180,9 +1179,6 @@
 
         pMac->lim.gLimReturnUniqueResults   =
               ((pScanReq->returnUniqueResults) > 0 ? true : false);
-
-        pMac->lim.gSeparateProbeBeacon = ((pScanReq->separateProbeBeacon) > 0 ? true : false);
-
         /* De-activate Heartbeat timers for connected sessions while
          * scan is in progress if the system is in Active mode */
         if((ePMM_STATE_BMPS_WAKEUP == pMac->pmm.gPmmState) ||
diff --git a/CORE/MAC/src/pe/lim/limScanResultUtils.c b/CORE/MAC/src/pe/lim/limScanResultUtils.c
index 06d1a88..511c1f1 100644
--- a/CORE/MAC/src/pe/lim/limScanResultUtils.c
+++ b/CORE/MAC/src/pe/lim/limScanResultUtils.c
@@ -622,9 +622,8 @@
 limLookupNaddHashEntry(tpAniSirGlobal pMac,
                        tLimScanResultNode *pBssDescr, tANI_U8 action)
 {
-    tANI_U8 index, ssidLen = 0;
-    tANI_U8 found = false;
-    tANI_U8 continueSearch = false;
+    tANI_U8                  index, ssidLen = 0;
+    tANI_U8                found = false;
     tLimScanResultNode *ptemp, *pprev;
     tSirMacCapabilityInfo *pSirCap, *pSirCapTemp;
     int idx, len;
@@ -699,35 +698,18 @@
                 }
 
                 // Delete this entry
-                // Delete this entry, if we don't want to keep separate entries for
-                // beacon & probe rsp
-                if(pMac->lim.gSeparateProbeBeacon && 
-                   (pBssDescr->bssDescription.fProbeRsp != ptemp->bssDescription.fProbeRsp))
-                {
-                    continueSearch = true;
-                }
+                if (ptemp == pMac->lim.gLimCachedScanHashTable[index])
+                    pprev = pMac->lim.gLimCachedScanHashTable[index] = ptemp->next;
                 else
-                {
-                    if (ptemp == pMac->lim.gLimCachedScanHashTable[index]) {
-                        pprev = pMac->lim.gLimCachedScanHashTable[index] = ptemp->next;
-                    } else {
-                        pprev->next = ptemp->next;
-                    }
+                    pprev->next = ptemp->next;
 
-                    pMac->lim.gLimMlmScanResultLength -=
-                        ptemp->bssDescription.length + sizeof(tANI_U16);
+                pMac->lim.gLimMlmScanResultLength -=
+                    ptemp->bssDescription.length + sizeof(tANI_U16);
 
-                    palFreeMemory( pMac->hHdd, (tANI_U8 *) ptemp);
-                    continueSearch = false;
-                }
+                palFreeMemory( pMac->hHdd, (tANI_U8 *) ptemp);
             }
-
-            // lets see if there are other entries in the list which can match
-            if(false == continueSearch)
-            {
-                found = true;
-                break;
-            }
+            found = true;
+            break;
         }
     }
 
diff --git a/CORE/MAC/src/pe/lim/limSendSmeRspMessages.c b/CORE/MAC/src/pe/lim/limSendSmeRspMessages.c
index e432fa5..3aa403b 100644
--- a/CORE/MAC/src/pe/lim/limSendSmeRspMessages.c
+++ b/CORE/MAC/src/pe/lim/limSendSmeRspMessages.c
@@ -797,8 +797,6 @@
         PELOG2(limLog(pMac, LOG2, FL("statusCode : eSIR_SME_SUCCESS\n"));)
     }
 
-    //reset the flag, to be set again by new scan request from SME
-    pMac->lim.gSeparateProbeBeacon = false;
     return;
 
 } /*** end limSendSmeScanRsp() ***/
diff --git a/CORE/SME/inc/csrInternal.h b/CORE/SME/inc/csrInternal.h
index 65ba29d..504f9dc 100644
--- a/CORE/SME/inc/csrInternal.h
+++ b/CORE/SME/inc/csrInternal.h
@@ -607,7 +607,7 @@
 {
     tScanProfile scanProfile;
     tANI_U32 nextScanID;
-    tDblLinkList scanResultList[CSR_ROAM_SESSION_MAX];
+    tDblLinkList scanResultList;
     tDblLinkList tempScanResults;
     tANI_BOOLEAN fScanEnable;
     tANI_BOOLEAN fFullScanIssued;
@@ -1033,7 +1033,6 @@
 tANI_BOOLEAN csrIsConnStateDisconnectedWds( tpAniSirGlobal pMac, tANI_U32 sessionId );
 tANI_BOOLEAN csrIsAnySessionInConnectState( tpAniSirGlobal pMac );
 tANI_BOOLEAN csrIsAllSessionDisconnected( tpAniSirGlobal pMac );
-tANI_BOOLEAN csrIsAnySessionConnected( tpAniSirGlobal pMac );
 tANI_BOOLEAN csrIsInfraConnected( tpAniSirGlobal pMac );
 tANI_BOOLEAN csrIsConcurrentInfraConnected( tpAniSirGlobal pMac );
 tANI_BOOLEAN csrIsConcurrentSessionRunning( tpAniSirGlobal pMac );
diff --git a/CORE/SME/src/csr/csrInsideApi.h b/CORE/SME/src/csr/csrInsideApi.h
index 426026a..fdd7f12 100644
--- a/CORE/SME/src/csr/csrInsideApi.h
+++ b/CORE/SME/src/csr/csrInsideApi.h
@@ -138,7 +138,6 @@
     tANI_U8 fUniqueResult;
     tANI_U8 freshScan;
     tANI_U8 hiddenSsid;
-    tANI_U8 separateProbeBeacon; //If set to 1, PE scan cache to have separate entry for probe rsp & beacon for same BSSID
     tANI_U8 reserved;
 }tScanReqParam;
 
@@ -220,13 +219,13 @@
 eHalStatus csrScanHandleFailedLostlink1(tpAniSirGlobal pMac, tANI_U32 sessionId);
 eHalStatus csrScanHandleFailedLostlink2(tpAniSirGlobal pMac, tANI_U32 sessionId);
 eHalStatus csrScanHandleFailedLostlink3(tpAniSirGlobal pMac, tANI_U32 sessionId);
-tCsrScanResult *csrScanAppendBssDescription( tpAniSirGlobal pMac, tANI_U32 sessionId, 
+tCsrScanResult *csrScanAppendBssDescription( tpAniSirGlobal pMac, 
                                              tSirBssDescription *pSirBssDescription,
                                              tDot11fBeaconIEs *pIes);
 void csrScanCallCallback(tpAniSirGlobal pMac, tSmeCmd *pCommand, eCsrScanStatus scanStatus);
 eHalStatus csrScanCopyRequest(tpAniSirGlobal pMac, tCsrScanRequest *pDstReq, tCsrScanRequest *pSrcReq);
 eHalStatus csrScanFreeRequest(tpAniSirGlobal pMac, tCsrScanRequest *pReq);
-eHalStatus csrScanCopyResultList(tpAniSirGlobal pMac, tANI_U32 sessionId, tScanResultHandle hIn, tScanResultHandle *phResult);
+eHalStatus csrScanCopyResultList(tpAniSirGlobal pMac, tScanResultHandle hIn, tScanResultHandle *phResult);
 void csrInitBGScanChannelList(tpAniSirGlobal pMac);
 eHalStatus csrScanForSSID(tpAniSirGlobal pMac, tANI_U32 sessionId, tCsrRoamProfile *pProfile, tANI_U32 roamId);
 eHalStatus csrScanForCapabilityChange(tpAniSirGlobal pMac, tSirSmeApNewCaps *pNewCaps);
@@ -258,13 +257,13 @@
 //The logic is that whenever CSR add a BSS to scan result, it set the age count to
 //a value. This function deduct the age count if channelId matches the BSS' channelId
 //The BSS is remove if the count reaches 0.
-eHalStatus csrScanAgeResults(tpAniSirGlobal pMac, tANI_U32 sessionId, tSmeGetScanChnRsp *pScanChnInfo);
+eHalStatus csrScanAgeResults(tpAniSirGlobal pMac, tSmeGetScanChnRsp *pScanChnInfo);
 
 //If fForce is TRUE we will save the new String that is learn't.
 //Typically it will be true in case of Join or user initiated ioctl
 tANI_BOOLEAN csrLearnCountryInformation( tpAniSirGlobal pMac, tSirBssDescription *pSirBssDesc,
                                          tDot11fBeaconIEs *pIes, tANI_BOOLEAN fForce );
-void csrApplyCountryInformation( tpAniSirGlobal pMac, tANI_U32 sessionId, tANI_BOOLEAN fForce );
+void csrApplyCountryInformation( tpAniSirGlobal pMac, tANI_BOOLEAN fForce );
 void csrSetCfgScanControlList( tpAniSirGlobal pMac, tANI_U8 *countryCode, tCsrChannel *pChannelList  );
 void csrReinitScanCmd(tpAniSirGlobal pMac, tSmeCmd *pCommand);
 void csrFreeScanResultEntry( tpAniSirGlobal pMac, tCsrScanResult *pResult );
@@ -359,7 +358,7 @@
 void csrAssignRssiForCategory(tpAniSirGlobal pMac, tANI_U8 catOffset);
 tANI_BOOLEAN csrIsMacAddressZero( tpAniSirGlobal pMac, tCsrBssid *pMacAddr );
 tANI_BOOLEAN csrIsMacAddressBroadcast( tpAniSirGlobal pMac, tCsrBssid *pMacAddr );
-eHalStatus csrRoamRemoveConnectedBssFromScanCache(tpAniSirGlobal pMac, tANI_U32 sessionId, tCsrRoamConnectedProfile *pConnProfile);
+eHalStatus csrRoamRemoveConnectedBssFromScanCache(tpAniSirGlobal pMac, tCsrRoamConnectedProfile *pConnProfile);
 eHalStatus csrRoamStartRoaming(tpAniSirGlobal pMac, tANI_U32 sessionId, eCsrRoamingReason roamingReason);
 //return a boolean to indicate whether roaming completed or continue.
 tANI_BOOLEAN csrRoamCompleteRoaming(tpAniSirGlobal pMac, tANI_U32 sessionId,
@@ -440,14 +439,14 @@
     \param phResult - an object for the result.
     \return eHalStatus     
   -------------------------------------------------------------------------------*/
-eHalStatus csrScanGetResult(tpAniSirGlobal, tANI_U32 sessionId, tCsrScanResultFilter *pFilter, tScanResultHandle *phResult);
+eHalStatus csrScanGetResult(tpAniSirGlobal, tCsrScanResultFilter *pFilter, tScanResultHandle *phResult);
 
 /* ---------------------------------------------------------------------------
     \fn csrScanFlushResult
     \brief Clear scan results.
     \return eHalStatus     
   -------------------------------------------------------------------------------*/
-eHalStatus csrScanFlushResult(tpAniSirGlobal, tANI_U32 sessionId);
+eHalStatus csrScanFlushResult(tpAniSirGlobal);
 
 /* ---------------------------------------------------------------------------
     \fn csrScanBGScanGetParam
diff --git a/CORE/SME/src/p2p/p2p_Api.c b/CORE/SME/src/p2p/p2p_Api.c
index 3776ffd..8b45b1d 100644
--- a/CORE/SME/src/p2p/p2p_Api.c
+++ b/CORE/SME/src/p2p/p2p_Api.c
@@ -1256,7 +1256,7 @@
       filter.bWPSAssociation = TRUE;
       filter.BSSType = eCSR_BSS_TYPE_ANY;
 
-      status = csrScanGetResult(pMac, pP2pContext->SMEsessionId, &filter, &hScanResult);
+      status = csrScanGetResult(pMac, &filter, &hScanResult);
 
       if (hScanResult)
       {
@@ -1298,7 +1298,7 @@
             filter.SSIDs.SSIDList->SSID.length = ssIdLen;
             vos_mem_copy(&filter.SSIDs.SSIDList[0].SSID.ssId, &ssId, ssIdLen);
             filter.SSIDs.numOfSSIDs = 1;
-            status = csrScanGetResult(pMac, pP2pContext->SMEsessionId, &filter, &hScanResult);
+            status = csrScanGetResult(pMac, &filter, &hScanResult);
             if (hScanResult)
             {
                pScanResult = csrScanResultGetFirst(pMac, hScanResult );
@@ -1852,7 +1852,7 @@
             }
          }//if(NULL != pDeviceFilters)
 
-         status = csrScanGetResult(pMac, SessionID, &filter, &hScanResult);
+         status = csrScanGetResult(pMac, &filter, &hScanResult);
          if (hScanResult)
          {
             VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR, 
@@ -2162,13 +2162,12 @@
 {
    eHalStatus status = eHAL_STATUS_FAILURE;
    tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
-   tp2pContext *pP2pContext = &pMac->p2pContext[HDDSessionId];
 
    smsLog(pMac, LOG2, FL("enter"));
    status = sme_AcquireGlobalLock( &pMac->sme );
    if ( HAL_STATUS_SUCCESS( status ) )
    {
-      status = p2pPurgeDeviceList(pMac, &pMac->scan.scanResultList[pP2pContext->SMEsessionId]);
+      status = p2pPurgeDeviceList(pMac, &pMac->scan.scanResultList);
       sme_ReleaseGlobalLock( &pMac->sme );
    }
 
diff --git a/CORE/SME/src/sme_common/sme_Api.c b/CORE/SME/src/sme_common/sme_Api.c
index 2950024..1538df4 100644
--- a/CORE/SME/src/sme_common/sme_Api.c
+++ b/CORE/SME/src/sme_common/sme_Api.c
@@ -1932,7 +1932,7 @@
    status = sme_AcquireGlobalLock( &pMac->sme );
    if ( HAL_STATUS_SUCCESS( status ) )
    {
-       status = csrScanGetResult( pMac, sessionId, pFilter, phResult );
+       status = csrScanGetResult( hHal, pFilter, phResult );
        sme_ReleaseGlobalLock( &pMac->sme );
    }
    smsLog(pMac, LOG2, FL("exit status %d"), status);
@@ -1955,7 +1955,7 @@
    status = sme_AcquireGlobalLock( &pMac->sme );
    if ( HAL_STATUS_SUCCESS( status ) )
    {
-       status = csrScanFlushResult( hHal, sessionId );
+       status = csrScanFlushResult( hHal );
        sme_ReleaseGlobalLock( &pMac->sme );
    }
 
@@ -5976,8 +5976,7 @@
     if i don't do this than I still get old ap's (of different country code) as available (even if they are powered off). 
     Looks like a bug in current scan sequence. 
    */
-   //Is it ok to assume infra session here - TBD
-   csrScanFlushResult(pMac, 0);
+   csrScanFlushResult(pMac);
 
    /* overwrite the defualt country code */
    palCopyMemory(pMac->hHdd, pMac->scan.countryCodeDefault, pMac->scan.countryCodeCurrent, WNI_CFG_COUNTRY_CODE_LEN);