BRCM P2P update

- IFNAME for monitor interface is changed to m. from mon. This will
  give extra space for incrementing X in IFNAME (p2p-wlan0-X). Also, we
  have synced the reset of IFNAME w.r.t. monitor interface name.
- Fixed continuous P2P_DEV_FOUND events coming from GO. Removed the
  BRCM specific change for this.
- Fixed STATUS command for p2p interface.

Change-Id: I04210dd0b2bdba06b0192c0a61edfa0e5b47ab72
Signed-off-by: Dmitry Shmidt <dimitrysh@google.com>
diff --git a/wpa_supplicant/ctrl_iface.c b/wpa_supplicant/ctrl_iface.c
index 64ec284..1ee2d15 100644
--- a/wpa_supplicant/ctrl_iface.c
+++ b/wpa_supplicant/ctrl_iface.c
@@ -351,7 +351,7 @@
 	char *pin;
 	int ret;
 
-#if defined ANDROID_BRCM_P2P_PATCH && defined CONFIG_AP
+#if defined(ANDROID_BRCM_P2P_PATCH) && defined(CONFIG_AP)
 	struct wpa_supplicant *iface;
 #endif
 
@@ -367,7 +367,7 @@
 		return -1;
 	}
 
-#if defined ANDROID_BRCM_P2P_PATCH && defined CONFIG_AP
+#if defined(ANDROID_BRCM_P2P_PATCH) && defined(CONFIG_AP)
 	for (iface = wpa_s->global->ifaces; iface; iface = iface->next)	{
 		if (iface->ap_iface){
 			wpa_printf(MSG_DEBUG, "CTRL_IFACE WPS_PIN: iface 0x%08x wpa_s->ap_iface %p", iface, iface->ap_iface);
@@ -790,6 +790,19 @@
 	char *pos, *end, tmp[30];
 	int res, verbose, ret;
 
+#if defined(ANDROID_BRCM_P2P_PATCH) && defined(CONFIG_P2P)
+	/* We have to send status command to p2p interface if p2p_interface is started 
+	 * otherwise we can send it to primary interface
+	*/
+	struct wpa_supplicant* ifs;
+	for (ifs = wpa_s->global->ifaces; ifs; ifs = ifs->next) {
+		if ( (ifs->p2p_group_interface == P2P_GROUP_INTERFACE_GO ) ||(ifs->p2p_group_interface == P2P_GROUP_INTERFACE_CLIENT )) {
+			wpa_s = ifs;
+			break;
+		}
+	}
+#endif /* defined ANDROID_BRCM_P2P_PATCH && defined CONFIG_P2P */
+
 	verbose = os_strcmp(params, "-VERBOSE") == 0;
 	pos = buf;
 	end = buf + buflen;