prima: Fix Auto trigger of TDLS connection after p2p disconnection

Currently, There is no check to verify either tdls
last mode is configured to eTDLS_SUPPORT_ENABLED or
eTDLS_SUPPORT_EXPLICIT_TRIGGER_ONLY leading
to auto trigger of TDLS connection, To mitigate
include check to verify the same.

Change-Id: Ic054221201d22685542b37a58fc32ba7e8674389
CRs-Fixed: 884301
diff --git a/CORE/HDD/src/wlan_hdd_assoc.c b/CORE/HDD/src/wlan_hdd_assoc.c
index b3a5419..2b49a75 100644
--- a/CORE/HDD/src/wlan_hdd_assoc.c
+++ b/CORE/HDD/src/wlan_hdd_assoc.c
@@ -1088,13 +1088,16 @@
                }
             }
             if ((TRUE == pHddCtx->cfg_ini->fEnableTDLSSupport) &&
-                          (TRUE == sme_IsFeatureSupportedByFW(TDLS))) {
+                          (TRUE == sme_IsFeatureSupportedByFW(TDLS)) &&
+                          (eTDLS_SUPPORT_ENABLED == pHddCtx->tdls_mode_last ||
+                           eTDLS_SUPPORT_EXPLICIT_TRIGGER_ONLY ==
+                                           pHddCtx->tdls_mode_last)) {
                 if (pAdapter->device_mode != WLAN_HDD_INFRA_STATION)
                     /* Enable TDLS support Once P2P session ends since
                      * upond detection of concurrency TDLS would be disabled
                      */
-                    wlan_hdd_tdls_set_mode(pHddCtx, eTDLS_SUPPORT_ENABLED,
-                                                                     FALSE);
+                    wlan_hdd_tdls_set_mode(pHddCtx, pHddCtx->tdls_mode_last,
+                                           FALSE);
             }
             //If the Device Mode is Station
             // and the P2P Client is Connected
diff --git a/CORE/HDD/src/wlan_hdd_hostapd.c b/CORE/HDD/src/wlan_hdd_hostapd.c
index 70a76d4..6a6f1f5 100644
--- a/CORE/HDD/src/wlan_hdd_hostapd.c
+++ b/CORE/HDD/src/wlan_hdd_hostapd.c
@@ -925,7 +925,10 @@
             pHddApCtx->operatingChannel = 0; //Invalidate the channel info.
 
             if ((TRUE == pHddCtx->cfg_ini->fEnableTDLSSupport) &&
-                    (TRUE == sme_IsFeatureSupportedByFW(TDLS)))
+                    (TRUE == sme_IsFeatureSupportedByFW(TDLS)) &&
+                    (eTDLS_SUPPORT_ENABLED == pHddCtx->tdls_mode_last ||
+                     eTDLS_SUPPORT_EXPLICIT_TRIGGER_ONLY ==
+                                                pHddCtx->tdls_mode_last))
             {
                 if (pHostapdAdapter->device_mode == WLAN_HDD_P2P_GO)
                 {
@@ -933,7 +936,8 @@
                      * upond detection of concurrency TDLS would be disabled
                      */
                     hddLog(LOG1, FL("Enable TDLS support"));
-                    wlan_hdd_tdls_set_mode(pHddCtx, eTDLS_SUPPORT_ENABLED, FALSE);
+                    wlan_hdd_tdls_set_mode(pHddCtx, pHddCtx->tdls_mode_last,
+                                           FALSE);
                 }
             }
 
diff --git a/CORE/HDD/src/wlan_hdd_tdls.c b/CORE/HDD/src/wlan_hdd_tdls.c
index 3b87e96..72e8c00 100644
--- a/CORE/HDD/src/wlan_hdd_tdls.c
+++ b/CORE/HDD/src/wlan_hdd_tdls.c
@@ -90,13 +90,13 @@
 
     if (adapter == NULL) {
         hddLog(LOGE, FL("Station Adapter Not Found"));
-        return;
+        goto done;
     }
 
     connected_tdls_peers = wlan_hdd_tdlsConnectedPeers(adapter);
     if (!connected_tdls_peers) {
-         hddLog(LOG1, FL("No TDLS connected peers to delete TDLS peers"));
-         return;
+        hddLog(LOG1, FL("No TDLS connected peers to delete TDLS peers"));
+        goto done;
     }
 
     /* TDLS is not supported in case of concurrency
@@ -158,6 +158,7 @@
                 eSIR_MAC_TDLS_TEARDOWN_UNSPEC_REASON);
     }
 
+done:
     wlan_hdd_tdls_set_mode(hddctx, eTDLS_SUPPORT_DISABLED, FALSE);
     hddLog(LOG1, FL("TDLS Support Disabled"));
 }