wlan: Return appropriate value for SETBAND request

If SETBAND is issued by VENDOR command, then it expects SUCCESS/FAILURE
status, but if SETBAND is issued by IOCTL, then it expects
CHANNEL_CHANGE_EVENT.
Hence return appropriate value when SETBAND is issued, depending up on
from where request is coming.

Change-Id: Ic7d289544a1ff859dce794bc7811b1c39c0b988c
CRs-Fixed: 884528
diff --git a/CORE/HDD/src/wlan_hdd_cfg80211.c b/CORE/HDD/src/wlan_hdd_cfg80211.c
index e8d54a8..b047788 100644
--- a/CORE/HDD/src/wlan_hdd_cfg80211.c
+++ b/CORE/HDD/src/wlan_hdd_cfg80211.c
@@ -5334,8 +5334,13 @@
         return -EINVAL;
     }
 
-    return hdd_setBand(dev,
+    hdd_ctx->isSetBandByNL = TRUE;
+    ret = hdd_setBand(dev,
                        nla_get_u32(tb[QCA_WLAN_VENDOR_ATTR_SETBAND_VALUE]));
+    hdd_ctx->isSetBandByNL = FALSE;
+
+    EXIT();
+    return ret;
 }
 
 /**
diff --git a/CORE/HDD/src/wlan_hdd_wext.c b/CORE/HDD/src/wlan_hdd_wext.c
index 34b8c3a..1ae105e 100644
--- a/CORE/HDD/src/wlan_hdd_wext.c
+++ b/CORE/HDD/src/wlan_hdd_wext.c
@@ -366,6 +366,18 @@
 #define WLAN_ADAPTER 0
 #define P2P_ADAPTER  1
 
+/*
+ * When supplicant sends SETBAND ioctl it queries for channels from
+ * cfg80211 layer by sending itself EVENT_CHANNEL_LIST_CHANGED command.
+ * This is not required if the return type from ioctl is
+ * DO_NOT_SEND_CHANNEL_CHANGE_EVENT as wiphy will send channel change
+ * event as part of regulatory_hint.
+ */
+enum {
+    SEND_CHANNEL_CHANGE_EVENT = 0,
+    DO_NOT_SEND_CHANNEL_CHANGE_EVENT,
+};
+
 /*MCC Configuration parameters */
 enum {
     MCC_SCHEDULE_TIME_SLICE_CFG_PARAM = 1,
@@ -9329,7 +9341,7 @@
     eCsrBand currBand = eCSR_BAND_MAX;
     eCsrBand connectedBand;
     tpAniSirGlobal pMac;
-    int retval = 0;
+    int retval = SEND_CHANNEL_CHANGE_EVENT;
 
     ENTER();
     pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
@@ -9510,6 +9522,7 @@
                            " in kernel db");
              }
 
+             retval = DO_NOT_SEND_CHANNEL_CHANGE_EVENT;
         }
         else
         {
@@ -9570,7 +9583,10 @@
         }
     }
     EXIT();
-    return 0;
+    if (TRUE == pHddCtx->isSetBandByNL)
+        return 0;
+    else
+        return retval;
 }
 
 int hdd_setBand_helper(struct net_device *dev, const char *command)