wlan: Driver should serve only one scan request in concurrent scenarios.

Moving scan_info structure from hdd_adapter_t to hdd_context_t to detect
simultaneous scan request on different interfaces.

Change-Id: I355ce5a28017f5c74986a1c4f653119c63aa7ee8
CR-Fixed: 407901
diff --git a/CORE/HDD/inc/wlan_hdd_main.h b/CORE/HDD/inc/wlan_hdd_main.h
index 3b6f97d..bd917c3 100644
--- a/CORE/HDD/inc/wlan_hdd_main.h
+++ b/CORE/HDD/inc/wlan_hdd_main.h
@@ -718,7 +718,6 @@
 #endif
    }sessionCtx;
 
-   hdd_scaninfo_t scan_info;
 #ifdef CONFIG_CFG80211
    hdd_cfg80211_state_t cfg80211State;
 #endif
@@ -906,6 +905,7 @@
    atomic_t isRestartInProgress;
    u_int8_t hdd_restart_retries;
    
+   hdd_scaninfo_t scan_info;
 };
 
 
diff --git a/CORE/HDD/src/wlan_hdd_cfg80211.c b/CORE/HDD/src/wlan_hdd_cfg80211.c
index ca7d19c..6c3cb8c 100644
--- a/CORE/HDD/src/wlan_hdd_cfg80211.c
+++ b/CORE/HDD/src/wlan_hdd_cfg80211.c
@@ -1704,18 +1704,6 @@
     hdd_adapter_t  *staAdapter = NULL;
     VOS_STATUS status = 0;
 
-    staAdapter = hdd_get_adapter(pAdapter->pHddCtx, WLAN_HDD_INFRA_STATION);
-
-    if (!staAdapter)
-    {
-        staAdapter = hdd_get_adapter(pAdapter->pHddCtx, WLAN_HDD_P2P_CLIENT);
-    }
-
-    if (staAdapter != NULL)
-    {
-        pScanInfo =  &staAdapter->scan_info;
-    }
-
     ENTER();
 
     if (NULL == pAdapter)
@@ -1724,6 +1712,29 @@
                    "%s: HDD adapter context is Null", __FUNCTION__);
         return -ENODEV;
     }
+
+    pHddCtx  =  (hdd_context_t*)pAdapter->pHddCtx;
+    if (NULL == pHddCtx)
+    {
+        VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
+                "%s: HDD context is Null", __FUNCTION__);
+        return -ENODEV;
+    }
+
+    staAdapter = hdd_get_adapter(pAdapter->pHddCtx, WLAN_HDD_INFRA_STATION);
+    if (NULL == staAdapter)
+    {
+        staAdapter = hdd_get_adapter(pAdapter->pHddCtx, WLAN_HDD_P2P_CLIENT);
+        if (NULL == staAdapter)
+        {
+            VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
+                    "%s: HDD adapter context is Null", __FUNCTION__);
+            return -ENODEV;
+        }
+    }
+
+    pScanInfo =  &pHddCtx->scan_info;
+
     if ((WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress)
     {
         VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL, "%s:LOGP in Progress. Ignore!!!",__func__);
@@ -3463,7 +3474,8 @@
     struct net_device *dev = (struct net_device *) pContext;
     //struct wireless_dev *wdev = dev->ieee80211_ptr;    
     hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR( dev );
-    hdd_scaninfo_t *pScanInfo = &pAdapter->scan_info;
+    hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
+    hdd_scaninfo_t *pScanInfo = &pHddCtx->scan_info;
     struct cfg80211_scan_request *req = NULL;
     int ret = 0;
 
@@ -3508,16 +3520,16 @@
 
     /* If any client wait scan result through WEXT
      * send scan done event to client */
-    if (pAdapter->scan_info.waitScanResult)
+    if (pHddCtx->scan_info.waitScanResult)
     {
         /* The other scan request waiting for current scan finish
          * Send event to notify current scan finished */
-        if(WEXT_SCAN_PENDING_DELAY == pAdapter->scan_info.scan_pending_option)
+        if(WEXT_SCAN_PENDING_DELAY == pHddCtx->scan_info.scan_pending_option)
         {
-            vos_event_set(&pAdapter->scan_info.scan_finished_event);
+            vos_event_set(&pHddCtx->scan_info.scan_finished_event);
         }
         /* Send notify to WEXT client */
-        else if(WEXT_SCAN_PENDING_PIGGYBACK == pAdapter->scan_info.scan_pending_option)
+        else if(WEXT_SCAN_PENDING_PIGGYBACK == pHddCtx->scan_info.scan_pending_option)
         {
             struct net_device *dev = pAdapter->dev;
             union iwreq_data wrqu;
@@ -3530,7 +3542,7 @@
             wireless_send_event(dev, we_event, &wrqu, msg);
         }
     }
-    pAdapter->scan_info.waitScanResult = FALSE;
+    pHddCtx->scan_info.waitScanResult = FALSE;
 
     /* Get the Scan Req */
     req = pAdapter->request;
@@ -3599,7 +3611,7 @@
     tANI_U8 *channelList = NULL, i;
     v_U32_t scanId = 0;
     int status = 0;
-    hdd_scaninfo_t *pScanInfo = &pAdapter->scan_info;
+    hdd_scaninfo_t *pScanInfo = &pHddCtx->scan_info;
 #ifdef WLAN_FEATURE_P2P
     v_U8_t* pP2pIe = NULL;
 #endif
diff --git a/CORE/HDD/src/wlan_hdd_hostapd.c b/CORE/HDD/src/wlan_hdd_hostapd.c
index 8550092..f388cde 100644
--- a/CORE/HDD/src/wlan_hdd_hostapd.c
+++ b/CORE/HDD/src/wlan_hdd_hostapd.c
@@ -2782,8 +2782,6 @@
         init_completion(&pHostapdAdapter->offchannel_tx_event);
 #endif
 
-        init_completion(&pHostapdAdapter->scan_info.scan_req_completion_event);
-
         SET_NETDEV_DEV(pWlanHostapdDev, pHddCtx->parent_dev);
     }
     return pHostapdAdapter;
diff --git a/CORE/HDD/src/wlan_hdd_main.c b/CORE/HDD/src/wlan_hdd_main.c
index 1ab6a95..3b8ab3e 100644
--- a/CORE/HDD/src/wlan_hdd_main.c
+++ b/CORE/HDD/src/wlan_hdd_main.c
@@ -180,7 +180,8 @@
                                          void *ndev)
 {
    struct net_device *dev = ndev;
-   hdd_adapter_t *pAdapter = NULL;
+   hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
+   hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX( pAdapter );
 #ifdef WLAN_BTAMP_FEATURE
    VOS_STATUS status;
    hdd_context_t *pHddCtx;
@@ -197,7 +198,6 @@
        return NOTIFY_DONE;
 #endif
 
-   pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
 
    if(NULL == pAdapter)
    {
@@ -227,7 +227,7 @@
         break;
 
    case NETDEV_GOING_DOWN:
-        if( pAdapter->scan_info.mScanPending != FALSE )
+        if( pHddCtx->scan_info.mScanPending != FALSE )
         { 
            int result;
            INIT_COMPLETION(pAdapter->abortscan_event_var);
@@ -249,7 +249,6 @@
         }
 #ifdef WLAN_BTAMP_FEATURE
         VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,"%s: disabling AMP", __FUNCTION__);
-        pHddCtx = WLAN_HDD_GET_CTX( pAdapter );
         status = WLANBAP_StopAmp();
         if(VOS_STATUS_SUCCESS != status )
         {
@@ -1133,8 +1132,6 @@
       init_completion(&pHddCtx->mc_sus_event_var);
       init_completion(&pHddCtx->tx_sus_event_var);
 
-      init_completion(&pAdapter->scan_info.scan_req_completion_event);
-
       pAdapter->isLinkUpSvcNeeded = FALSE; 
       pAdapter->higherDtimTransition = eANI_BOOLEAN_TRUE;
       //Init the net_device structure
@@ -2084,8 +2081,8 @@
             hdd_init_station_mode(pAdapter);
             /* Open the gates for HDD to receive Wext commands */
             pAdapter->isLinkUpSvcNeeded = FALSE; 
-            pAdapter->scan_info.mScanPending = FALSE;
-            pAdapter->scan_info.waitScanResult = FALSE;
+            pHddCtx->scan_info.mScanPending = FALSE;
+            pHddCtx->scan_info.waitScanResult = FALSE;
 
             //Trigger the initial scan
             hdd_wlan_initial_scan(pAdapter);
@@ -3403,7 +3400,7 @@
    init_completion(&pHddCtx->full_pwr_comp_var);
    init_completion(&pHddCtx->standby_comp_var);
    init_completion(&pHddCtx->req_bmps_comp_var);
-
+   init_completion(&pHddCtx->scan_info.scan_req_completion_event);
 
    hdd_list_init( &pHddCtx->hddAdapters, MAX_NUMBER_OF_ADAPTERS );
 
@@ -3876,8 +3873,8 @@
            "qcom_rx_wakelock");
 #endif
 
-   vos_event_init(&pAdapter->scan_info.scan_finished_event);
-   pAdapter->scan_info.scan_pending_option = WEXT_SCAN_PENDING_GIVEUP;
+   vos_event_init(&pHddCtx->scan_info.scan_finished_event);
+   pHddCtx->scan_info.scan_pending_option = WEXT_SCAN_PENDING_GIVEUP;
 
    vos_set_load_unload_in_progress(VOS_MODULE_ID_VOSS, FALSE);
    hdd_allow_suspend();
diff --git a/CORE/HDD/src/wlan_hdd_scan.c b/CORE/HDD/src/wlan_hdd_scan.c
index 6f6bb50..ea0fee7 100644
--- a/CORE/HDD/src/wlan_hdd_scan.c
+++ b/CORE/HDD/src/wlan_hdd_scan.c
@@ -548,6 +548,7 @@
 {
     struct net_device *dev = (struct net_device *) pContext;
     hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev) ;
+    hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
     union iwreq_data wrqu;
     int we_event;
     char *msg;
@@ -570,15 +571,15 @@
     }
 
     /* Check the scanId */
-    if (pAdapter->scan_info.scanId != scanId)
+    if (pHddCtx->scan_info.scanId != scanId)
     {
-        hddLog(LOGW, "%s called with mismatched scanId pAdapter->scan_info.scanId = %d "
-               "scanId = %d ", __FUNCTION__, (int) pAdapter->scan_info.scanId,
+        hddLog(LOGW, "%s called with mismatched scanId pHddCtx->scan_info.scanId = %d "
+               "scanId = %d ", __FUNCTION__, (int) pHddCtx->scan_info.scanId,
                 (int) scanId);
     }
 
     /* Scan is no longer pending */
-    pAdapter->scan_info.mScanPending = VOS_FALSE;
+    pHddCtx->scan_info.mScanPending = VOS_FALSE;
 
     // notify any applications that may be interested
     memset(&wrqu, '\0', sizeof(wrqu));
@@ -613,6 +614,7 @@
                  union iwreq_data *wrqu, char *extra)
 {
    hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev) ;
+   hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
    hdd_wext_state_t *pwextBuf = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
    tCsrScanRequest scanRequest;
    v_U32_t scanId = 0;
@@ -631,7 +633,7 @@
        return eHAL_STATUS_SUCCESS;
    }
 #endif
-   if(pAdapter->scan_info.mScanPending == TRUE)
+   if(pHddCtx->scan_info.mScanPending == TRUE)
    {
        VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL, "%s:mScanPending is TRUE !!!",__func__);
        return eHAL_STATUS_SUCCESS;
@@ -646,7 +648,7 @@
    if (NULL != wrqu->data.pointer)
    {
        /* set scanType, active or passive */
-       if ((IW_SCAN_TYPE_ACTIVE ==  scanReq->scan_type) || (eSIR_ACTIVE_SCAN == pAdapter->scan_info.scan_mode))
+       if ((IW_SCAN_TYPE_ACTIVE ==  scanReq->scan_type) || (eSIR_ACTIVE_SCAN == pHddCtx->scan_info.scan_mode))
        {
            scanRequest.scanType = eSIR_ACTIVE_SCAN;
        }
@@ -684,7 +686,7 @@
    }
    else
    {
-       if(pAdapter->scan_info.scan_mode == eSIR_ACTIVE_SCAN) {
+       if(pHddCtx->scan_info.scan_mode == eSIR_ACTIVE_SCAN) {
            /* set the scan type to active */
            scanRequest.scanType = eSIR_ACTIVE_SCAN;
        } else {
@@ -712,24 +714,24 @@
    /* if previous genIE is not NULL, update ScanIE */
    if (0 != pwextBuf->genIE.length)
    {
-       memset( &pAdapter->scan_info.scanAddIE, 0, sizeof(pAdapter->scan_info.scanAddIE) );
-       memcpy( pAdapter->scan_info.scanAddIE.addIEdata, pwextBuf->genIE.addIEdata, 
+       memset( &pHddCtx->scan_info.scanAddIE, 0, sizeof(pHddCtx->scan_info.scanAddIE) );
+       memcpy( pHddCtx->scan_info.scanAddIE.addIEdata, pwextBuf->genIE.addIEdata, 
            pwextBuf->genIE.length );
-       pAdapter->scan_info.scanAddIE.length = pwextBuf->genIE.length;
+       pHddCtx->scan_info.scanAddIE.length = pwextBuf->genIE.length;
 
-       pwextBuf->roamProfile.pAddIEScan = pAdapter->scan_info.scanAddIE.addIEdata;
-       pwextBuf->roamProfile.nAddIEScanLength = pAdapter->scan_info.scanAddIE.length;
+       pwextBuf->roamProfile.pAddIEScan = pHddCtx->scan_info.scanAddIE.addIEdata;
+       pwextBuf->roamProfile.nAddIEScanLength = pHddCtx->scan_info.scanAddIE.length;
    
        /* clear previous genIE after use it */
        memset( &pwextBuf->genIE, 0, sizeof(pwextBuf->genIE) );
    }
 
    /* push addIEScan in scanRequset if exist */
-   if (pAdapter->scan_info.scanAddIE.addIEdata && 
-       pAdapter->scan_info.scanAddIE.length)
+   if (pHddCtx->scan_info.scanAddIE.addIEdata && 
+       pHddCtx->scan_info.scanAddIE.length)
    { 
-       scanRequest.uIEFieldLen = pAdapter->scan_info.scanAddIE.length;
-       scanRequest.pIEField = pAdapter->scan_info.scanAddIE.addIEdata;
+       scanRequest.uIEFieldLen = pHddCtx->scan_info.scanAddIE.length;
+       scanRequest.pIEField = pHddCtx->scan_info.scanAddIE.addIEdata;
    }
 
    status = sme_ScanRequest( (WLAN_HDD_GET_CTX(pAdapter))->hHal, pAdapter->sessionId,&scanRequest, &scanId, &hdd_ScanRequestCallback, dev ); 
@@ -739,9 +741,9 @@
        goto error;
    }
 
-   pAdapter->scan_info.mScanPending = TRUE;
+   pHddCtx->scan_info.mScanPending = TRUE;
 
-   pAdapter->scan_info.scanId = scanId;
+   pHddCtx->scan_info.scanId = scanId;
 
 error:
    if ((wrqu->data.flags & IW_SCAN_THIS_ESSID) && (scanReq->essid_len))
@@ -773,6 +775,7 @@
                          union iwreq_data *wrqu, char *extra)
 {
    hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev) ;
+   hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
    tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
    tCsrScanResultInfo *pScanResult;
    eHalStatus status = eHAL_STATUS_SUCCESS;
@@ -784,7 +787,7 @@
        __func__, (wrqu->data.length)?wrqu->data.length:IW_SCAN_MAX_DATA);
    ENTER();
 
-   if (TRUE == pAdapter->scan_info.mScanPending)
+   if (TRUE == pHddCtx->scan_info.mScanPending)
    {
        VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL, "%s:mScanPending is TRUE !!!",__func__);
        return -EAGAIN;
@@ -890,6 +893,7 @@
                  union iwreq_data *wrqu, char *extra)
 {
     hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev) ;
+    hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
     hdd_wext_state_t *pwextBuf = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
     tCsrScanRequest scanRequest;
     v_U32_t scanId = 0;
@@ -933,24 +937,24 @@
             scanPendingOption = (hdd_scan_pending_option_e)str_ptr[++i];
             ++i;
         }
-        pAdapter->scan_info.scan_pending_option = scanPendingOption;
+        pHddCtx->scan_info.scan_pending_option = scanPendingOption;
 
-        if(pAdapter->scan_info.mScanPending == TRUE)
+        if(pHddCtx->scan_info.mScanPending == TRUE)
         {
             hddLog(LOG1,"%s: mScanPending is TRUE",__func__);
             /* If any scan is pending, just giveup this scan request */
             if(WEXT_SCAN_PENDING_GIVEUP == scanPendingOption)
             {
-                pAdapter->scan_info.waitScanResult = FALSE;
+                pHddCtx->scan_info.waitScanResult = FALSE;
                 return eHAL_STATUS_SUCCESS; 
             }
             /* If any scan pending, wait till finish current scan,
                and try this scan request when previous scan finish */
             else if(WEXT_SCAN_PENDING_DELAY == scanPendingOption)
             {
-                pAdapter->scan_info.waitScanResult = TRUE;
-                vos_event_reset(&pAdapter->scan_info.scan_finished_event);
-                if(vos_wait_single_event(&pAdapter->scan_info.scan_finished_event,
+                pHddCtx->scan_info.waitScanResult = TRUE;
+                vos_event_reset(&pHddCtx->scan_info.scan_finished_event);
+                if(vos_wait_single_event(&pHddCtx->scan_info.scan_finished_event,
                                           WEXT_CSCAN_SCAN_DONE_WAIT_TIME))
                 {
                     hddLog(LOG1,"%s: Previous SCAN does not finished on time",__func__);
@@ -960,11 +964,11 @@
             /* Piggyback previous scan result */
             else if(WEXT_SCAN_PENDING_PIGGYBACK == scanPendingOption)
             {
-                pAdapter->scan_info.waitScanResult = TRUE;
+                pHddCtx->scan_info.waitScanResult = TRUE;
                 return eHAL_STATUS_SUCCESS; 
             }
         }
-        pAdapter->scan_info.waitScanResult = FALSE;
+        pHddCtx->scan_info.waitScanResult = FALSE;
 
         /* Check for scan IE */
         while( WEXT_CSCAN_SSID_SECTION == str_ptr[i] ) 
@@ -1055,7 +1059,7 @@
         if( WEXT_CSCAN_PASV_DWELL_SECTION == (str_ptr[i]) ) 
         {
             /* No SSID specified, num_ssid == 0, then start paasive scan */
-            if (!num_ssid || (eSIR_PASSIVE_SCAN == pAdapter->scan_info.scan_mode))
+            if (!num_ssid || (eSIR_PASSIVE_SCAN == pHddCtx->scan_info.scan_mode))
             {
                 scanRequest.scanType = eSIR_PASSIVE_SCAN;
                 scanRequest.minChnTime = (v_U8_t)str_ptr[++i];//scanReq->min_channel_time;
@@ -1071,7 +1075,7 @@
         /* H indicates active channel time */
         if( WEXT_CSCAN_HOME_DWELL_SECTION == (str_ptr[i]) ) 
         {
-            if (num_ssid || (eSIR_ACTIVE_SCAN == pAdapter->scan_info.scan_mode))
+            if (num_ssid || (eSIR_ACTIVE_SCAN == pHddCtx->scan_info.scan_mode))
             {
                 scanRequest.scanType = eSIR_ACTIVE_SCAN;
                 scanRequest.minChnTime = str_ptr[++i];//scanReq->min_channel_time;
@@ -1086,29 +1090,29 @@
         scanRequest.BSSType = eCSR_BSS_TYPE_ANY;
         /* set requestType to full scan */
         scanRequest.requestType = eCSR_SCAN_REQUEST_FULL_SCAN;
-        pAdapter->scan_info.mScanPending = TRUE;
+        pHddCtx->scan_info.mScanPending = TRUE;
 
         /* if previous genIE is not NULL, update ScanIE */
         if(0 != pwextBuf->genIE.length)
         {
-            memset( &pAdapter->scan_info.scanAddIE, 0, sizeof(pAdapter->scan_info.scanAddIE) );
-            memcpy( pAdapter->scan_info.scanAddIE.addIEdata, pwextBuf->genIE.addIEdata, 
+            memset( &pHddCtx->scan_info.scanAddIE, 0, sizeof(pHddCtx->scan_info.scanAddIE) );
+            memcpy( pHddCtx->scan_info.scanAddIE.addIEdata, pwextBuf->genIE.addIEdata, 
                 pwextBuf->genIE.length );
-            pAdapter->scan_info.scanAddIE.length = pwextBuf->genIE.length;
+            pHddCtx->scan_info.scanAddIE.length = pwextBuf->genIE.length;
 
-            pwextBuf->roamProfile.pAddIEScan = pAdapter->scan_info.scanAddIE.addIEdata;
-            pwextBuf->roamProfile.nAddIEScanLength = pAdapter->scan_info.scanAddIE.length;
+            pwextBuf->roamProfile.pAddIEScan = pHddCtx->scan_info.scanAddIE.addIEdata;
+            pwextBuf->roamProfile.nAddIEScanLength = pHddCtx->scan_info.scanAddIE.length;
 
             /* clear previous genIE after use it */
             memset( &pwextBuf->genIE, 0, sizeof(pwextBuf->genIE) );
         }
 
         /* push addIEScan in scanRequset if exist */
-        if (pAdapter->scan_info.scanAddIE.addIEdata && 
-            pAdapter->scan_info.scanAddIE.length)
+        if (pHddCtx->scan_info.scanAddIE.addIEdata && 
+            pHddCtx->scan_info.scanAddIE.length)
         {
-            scanRequest.uIEFieldLen = pAdapter->scan_info.scanAddIE.length;
-            scanRequest.pIEField = pAdapter->scan_info.scanAddIE.addIEdata;
+            scanRequest.uIEFieldLen = pHddCtx->scan_info.scanAddIE.length;
+            scanRequest.pIEField = pHddCtx->scan_info.scanAddIE.addIEdata;
         }
 
         status = sme_ScanRequest( (WLAN_HDD_GET_CTX(pAdapter))->hHal, 
@@ -1116,12 +1120,12 @@
         if( !HAL_STATUS_SUCCESS(status) )
         {
             VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL, "%s: SME scan fail status %d !!!",__func__, status);
-            pAdapter->scan_info.mScanPending = FALSE;
+            pHddCtx->scan_info.mScanPending = FALSE;
             status = -EINVAL;
             goto exit_point;
         }
 
-        pAdapter->scan_info.scanId = scanId;
+        pHddCtx->scan_info.scanId = scanId;
 
     } //end of data->pointer
     else {
diff --git a/CORE/HDD/src/wlan_hdd_wext.c b/CORE/HDD/src/wlan_hdd_wext.c
index 4dd3530..ab4252e 100644
--- a/CORE/HDD/src/wlan_hdd_wext.c
+++ b/CORE/HDD/src/wlan_hdd_wext.c
@@ -2489,17 +2489,17 @@
     }
     else if (strcasecmp(cmd, "scan-active") == 0)
     {
-        pAdapter->scan_info.scan_mode = eSIR_ACTIVE_SCAN;
+        pHddCtx->scan_info.scan_mode = eSIR_ACTIVE_SCAN;
         ret = snprintf(cmd, cmd_len, "OK");
     }
     else if (strcasecmp(cmd, "scan-passive") == 0)
     {
-        pAdapter->scan_info.scan_mode = eSIR_PASSIVE_SCAN;
+        pHddCtx->scan_info.scan_mode = eSIR_PASSIVE_SCAN;
         ret = snprintf(cmd, cmd_len, "OK");
     }
     else if( strcasecmp(cmd, "scan-mode") == 0 )
     {
-        ret = snprintf(cmd, cmd_len, "ScanMode = %u", pAdapter->scan_info.scan_mode);
+        ret = snprintf(cmd, cmd_len, "ScanMode = %u", pHddCtx->scan_info.scan_mode);
     }
     else if( strcasecmp(cmd, "linkspeed") == 0 )
     {
@@ -6301,6 +6301,7 @@
 {
     hdd_wext_state_t *pwextBuf;
     hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
+    hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
 
     pwextBuf = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
 
@@ -6332,7 +6333,7 @@
     pwextBuf->wpaVersion = IW_AUTH_WPA_VERSION_DISABLED;
 
     /*Set the default scan mode*/
-    pAdapter->scan_info.scan_mode = eSIR_ACTIVE_SCAN;
+    pHddCtx->scan_info.scan_mode = eSIR_ACTIVE_SCAN;
 
     hdd_clearRoamProfileIe(pAdapter);