wlan: Synchronize country code HDD ioctl
HDD device ioctl for the country code should only return once it
updates the wiphy data structure.
Change-Id: I594b81786d5443444cdfafdb12de79e2080d869a
CRs-Fixed: 530587
diff --git a/CORE/HDD/inc/wlan_hdd_main.h b/CORE/HDD/inc/wlan_hdd_main.h
index f762225..dbca411 100644
--- a/CORE/HDD/inc/wlan_hdd_main.h
+++ b/CORE/HDD/inc/wlan_hdd_main.h
@@ -115,6 +115,7 @@
#define WLAN_WAIT_TIME_DISCONNECT 500
#define WLAN_WAIT_TIME_STATS 800
#define WLAN_WAIT_TIME_POWER 800
+#define WLAN_WAIT_TIME_COUNTRY 1000
/* Amount of time to wait for sme close session callback.
This value should be larger than the timeout used by WDI to wait for
a response from WCNSS */
diff --git a/CORE/HDD/inc/wlan_hdd_wext.h b/CORE/HDD/inc/wlan_hdd_wext.h
index 6d2e266..fc661a0 100644
--- a/CORE/HDD/inc/wlan_hdd_wext.h
+++ b/CORE/HDD/inc/wlan_hdd_wext.h
@@ -427,6 +427,7 @@
#ifdef WLAN_FEATURE_PACKET_FILTERING
void wlan_hdd_set_mc_addr_list(hdd_adapter_t *pAdapter, v_U8_t set);
#endif
+void* wlan_hdd_change_country_code_callback(void *pAdapter);
#endif // __WEXT_IW_H__
diff --git a/CORE/HDD/src/wlan_hdd_main.c b/CORE/HDD/src/wlan_hdd_main.c
index 5a4e878..fadebb8 100644
--- a/CORE/HDD/src/wlan_hdd_main.c
+++ b/CORE/HDD/src/wlan_hdd_main.c
@@ -638,16 +638,31 @@
country_code = command + 8;
+ INIT_COMPLETION(pAdapter->change_country_code);
hdd_checkandupdate_dfssetting(pAdapter, country_code);
hdd_checkandupdate_phymode(pAdapter, country_code);
- ret = (int)sme_ChangeCountryCode(pHddCtx->hHal, NULL, country_code,
- pAdapter, pHddCtx->pvosContext, eSIR_TRUE);
- if( 0 != ret )
+ ret = (int)sme_ChangeCountryCode(pHddCtx->hHal,
+ (void *)(tSmeChangeCountryCallback)
+ wlan_hdd_change_country_code_callback,
+ country_code, pAdapter, pHddCtx->pvosContext, eSIR_TRUE);
+ if (eHAL_STATUS_SUCCESS == ret)
+ {
+ ret = wait_for_completion_interruptible_timeout(
+ &pAdapter->change_country_code,
+ msecs_to_jiffies(WLAN_WAIT_TIME_COUNTRY));
+ if (0 >= ret)
+ {
+ hddLog(VOS_TRACE_LEVEL_ERROR, "%s: SME while setting country code timed out",
+ __func__);
+ }
+ }
+ else
{
VOS_TRACE( VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_FATAL,
- "%s: SME Change Country code fail ret=%d\n",__func__, ret);
-
+ "%s: SME Change Country code fail ret=%d", __func__, ret);
+ ret = -EINVAL;
}
+
}
/*
command should be a string having format
@@ -3146,6 +3161,7 @@
init_completion(&pHddCtx->tx_sus_event_var);
init_completion(&pHddCtx->rx_sus_event_var);
init_completion(&pAdapter->ula_complete);
+ init_completion(&pAdapter->change_country_code);
pAdapter->isLinkUpSvcNeeded = FALSE;
pAdapter->higherDtimTransition = eANI_BOOLEAN_TRUE;