wlan: Cancel existing remain_on_channel request upon change interface to
GO mode

GO-NEG is success and p2p client is scanning on GO operating channel so
that it can start 8-way handshake
GO logs show that beacons were sent on listen channel instead of
operating channel.
As supplicant dosent send cancel remain on channel ,fix this in driver
by calling  wlan_hdd_cancel_existing_remain_on_channel
API when change iface happens from P2P_DEVICE to P2P_GO.
Also corresponding fix needs to be done in wpa_supplicant.

Change-Id: I7d1f35ac096d89aa5277a139c6d7beda6b4afef1
CR-Fixed:  434013
diff --git a/CORE/HDD/inc/wlan_hdd_p2p.h b/CORE/HDD/inc/wlan_hdd_p2p.h
index 0273d3f..0469785 100644
--- a/CORE/HDD/inc/wlan_hdd_p2p.h
+++ b/CORE/HDD/inc/wlan_hdd_p2p.h
@@ -130,6 +130,7 @@
 void hdd_remainChanReadyHandler( hdd_adapter_t *pAdapter );
 void hdd_sendActionCnf( hdd_adapter_t *pAdapter, tANI_BOOLEAN actionSendSuccess );
 int wlan_hdd_check_remain_on_channel(hdd_adapter_t *pAdapter);
+void wlan_hdd_cancel_existing_remain_on_channel(hdd_adapter_t *pAdapter);
 
 #if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,3,0))
 int wlan_hdd_action( struct wiphy *wiphy, struct net_device *dev,
diff --git a/CORE/HDD/src/wlan_hdd_cfg80211.c b/CORE/HDD/src/wlan_hdd_cfg80211.c
index 4b1c10e..f018810 100644
--- a/CORE/HDD/src/wlan_hdd_cfg80211.c
+++ b/CORE/HDD/src/wlan_hdd_cfg80211.c
@@ -2252,7 +2252,8 @@
                 hdd_cfg_xlate_to_csr_phy_mode(pConfig->dot11Mode);
                 wdev->iftype = type;
 #ifdef WLAN_FEATURE_P2P
-                if (!strcmp("p2p0",ndev->name))
+                //Check for sub-string p2p to confirm its a p2p interface
+                if (NULL != strstr(ndev->name,"p2p"))
                 {     
                     pAdapter->device_mode = (type == NL80211_IFTYPE_STATION) ?
                                 WLAN_HDD_P2P_DEVICE : WLAN_HDD_P2P_CLIENT;
@@ -2282,6 +2283,11 @@
                       "%s: setting interface Type to %s", __func__,
                       (type == NL80211_IFTYPE_AP) ? "SoftAP" : "P2pGo");
 
+                //Cancel any remain on channel for GO mode
+                if (NL80211_IFTYPE_P2P_GO == type)
+                {
+                    wlan_hdd_cancel_existing_remain_on_channel(pAdapter);
+                }
                 if (NL80211_IFTYPE_AP == type)
                 {
                      /* As Loading WLAN Driver one interface being created for p2p device
@@ -2398,7 +2404,8 @@
                 hdd_deinit_adapter( pHddCtx, pAdapter );
                 wdev->iftype = type;
 #ifdef WLAN_FEATURE_P2P
-                if (!strcmp("p2p0",ndev->name))
+                //Check for sub-string p2p to confirm its a p2p interface
+                if (NULL != strstr(ndev->name,"p2p"))
                 {
                     pAdapter->device_mode = (type == NL80211_IFTYPE_STATION) ?
                                   WLAN_HDD_P2P_DEVICE : WLAN_HDD_P2P_CLIENT;
diff --git a/CORE/HDD/src/wlan_hdd_p2p.c b/CORE/HDD/src/wlan_hdd_p2p.c
index 6e74b2a..243e30c 100644
--- a/CORE/HDD/src/wlan_hdd_p2p.c
+++ b/CORE/HDD/src/wlan_hdd_p2p.c
@@ -165,7 +165,7 @@
     return eHAL_STATUS_SUCCESS;
 }
 
-static void wlan_hdd_cancel_existing_remain_on_channel(hdd_adapter_t *pAdapter)
+void wlan_hdd_cancel_existing_remain_on_channel(hdd_adapter_t *pAdapter)
 {
     hdd_cfg80211_state_t *cfgState = WLAN_HDD_GET_CFG_STATE_PTR( pAdapter );
     int status = 0;