From 3e6172f91e412d50436402124a5687950510debe Mon Sep 17 00:00:00 2001 From: Abhishek Singh Date: Wed, 4 May 2016 16:56:48 +0530 Subject: [PATCH] qcacld-3.0: Reset the global reg params during wiphy unregisteration qcacld-2.0 to qcacld-3.0 propagation After boot when driver is loaded for the first time, driver call the regulatory_hint with default country. From kernel 3.18 onward regulatory_hint removes the REGULATORY_CUSTOM_REG flag from wiphy flags. But once reg notifier is called for the country the wiphy flags are restored from the original flags stored in driver. Now if driver is unloaded and loaded again, kernel calls the reg notifier for the last country set by driver before unload. In static drivers the global static flag init_by_driver will remain true even after unload and load and thus init_by_reg_core is not set to true when kernel calls the reg notifier. Thus driver ends up sending reg hint to kernel with same country, this reg hint removes the REGULATORY_CUSTOM_REG flag from wiphy flags and is dropped in the kernel as country has not changed. As reg notifier is not called for the reg hint and wiphy flags are not restored. To avoid changing of wiphy flags, reset the global static reg params during wiphy unregisteration. Change-Id: I01b29a2314ab4192e6bc9076978d54762a85c9e8 CRs-Fixed: 1003390 --- core/hdd/inc/wlan_hdd_regulatory.h | 2 ++ core/hdd/src/wlan_hdd_cfg80211.c | 6 +++++- core/hdd/src/wlan_hdd_regulatory.c | 14 ++++++++++++++ 3 files changed, 21 insertions(+), 1 deletion(-) diff --git a/core/hdd/inc/wlan_hdd_regulatory.h b/core/hdd/inc/wlan_hdd_regulatory.h index d541b14ba95c..846e43fd3683 100644 --- a/core/hdd/inc/wlan_hdd_regulatory.h +++ b/core/hdd/inc/wlan_hdd_regulatory.h @@ -34,6 +34,8 @@ * HDD Regulatory prototype implementation */ +void hdd_reset_global_reg_params(void); + int hdd_regulatory_init(hdd_context_t *hdd_ctx, struct wiphy *wiphy); void hdd_program_country_code(hdd_context_t *hdd_ctx); diff --git a/core/hdd/src/wlan_hdd_cfg80211.c b/core/hdd/src/wlan_hdd_cfg80211.c index 10bbc0fcb289..685124a0f7cf 100644 --- a/core/hdd/src/wlan_hdd_cfg80211.c +++ b/core/hdd/src/wlan_hdd_cfg80211.c @@ -86,6 +86,8 @@ #include "wlan_hdd_tsf.h" #include "wlan_hdd_subnet_detect.h" +#include + #define g_mode_rates_size (12) #define a_mode_rates_size (8) @@ -6138,7 +6140,8 @@ int wlan_hdd_cfg80211_init(struct device *dev, * @ wiphy: the wiphy to validate against * * this function deinit cfg80211 and cleanup the - * memory allocated in wlan_hdd_cfg80211_init + * memory allocated in wlan_hdd_cfg80211_init also + * reset the global reg params. * * Return: void */ @@ -6153,6 +6156,7 @@ void wlan_hdd_cfg80211_deinit(struct wiphy *wiphy) wiphy->bands[i]->channels = NULL; } } + hdd_reset_global_reg_params(); } /* diff --git a/core/hdd/src/wlan_hdd_regulatory.c b/core/hdd/src/wlan_hdd_regulatory.c index 7c204db4a1f8..6f7457ebe09b 100644 --- a/core/hdd/src/wlan_hdd_regulatory.c +++ b/core/hdd/src/wlan_hdd_regulatory.c @@ -202,6 +202,20 @@ static void hdd_update_regulatory_info(hdd_context_t *hdd_ctx) } +/** + * hdd_reset_global_reg_params - Reset global static reg params + * + * This function is helpful in static driver to reset + * the global params. + * + * Return: void + */ +void hdd_reset_global_reg_params(void) +{ + init_by_driver = false; + init_by_reg_core = false; +} + /** * hdd_regulatory_wiphy_init() - regulatory wiphy init * @hdd_ctx: hdd context