Cumulative patch from commit 3eaaca1a0b372f31ddc43d152c3681dce48889bb

3eaaca1 P2P: Allow GO Negotiation Request to update peer entry after PD
443427e P2P: Add missing direct global ctrl_iface commands for P2P
37b4198 P2P: Use GO's operating channel to optimize scan during join
a691d99 P2P: Don't expire the peer, if GO Negotiation is in progress
a0e9d89 Use minimal scan delay upon EVENT_INTERFACE_ADDED
5ddd07c Reset normal_scans counter upon entering INTERFACE_DISABLED state

Change-Id: I07ea029ba6d473af39c74c10b7058de0056695da
Signed-off-by: Dmitry Shmidt <dimitrysh@google.com>
diff --git a/wpa_supplicant/p2p_supplicant.c b/wpa_supplicant/p2p_supplicant.c
index c36b65f..91ed508 100644
--- a/wpa_supplicant/p2p_supplicant.c
+++ b/wpa_supplicant/p2p_supplicant.c
@@ -4239,17 +4239,7 @@
 	struct wpabuf *wps_ie, *ies;
 	size_t ielen;
 	int freqs[2] = { 0, 0 };
-#ifdef ANDROID_P2P
-	int oper_freq;
 
-	/* If freq is not provided, check the operating freq of the GO and do a
-	 * a directed scan to save time
-	 */
-	if(!freq) {
-		freq = (oper_freq = p2p_get_oper_freq(wpa_s->global->p2p,
-			 wpa_s->pending_join_iface_addr) == -1) ? 0 : oper_freq; 
-	}
-#endif
 	os_memset(&params, 0, sizeof(params));
 
 	/* P2P Wildcard SSID */
@@ -4289,6 +4279,18 @@
 	params.p2p_probe = 1;
 	params.extra_ies = wpabuf_head(ies);
 	params.extra_ies_len = wpabuf_len(ies);
+
+	if (!freq) {
+		int oper_freq;
+		/*
+		 * If freq is not provided, check the operating freq of the GO
+		 * and use a single channel scan on if possible.
+		 */
+		oper_freq = p2p_get_oper_freq(wpa_s->global->p2p,
+					      wpa_s->pending_join_iface_addr);
+		if (oper_freq > 0)
+			freq = oper_freq;
+	}
 	if (freq > 0) {
 		freqs[0] = freq;
 		params.freqs = freqs;