diff options
author | Johannes Berg <johannes.berg@intel.com> | 2012-12-06 09:44:07 -0500 |
---|---|---|
committer | Johannes Berg <johannes.berg@intel.com> | 2013-01-03 07:01:29 -0500 |
commit | 379b82f4c9dc6e67bf61aa61b096c06a2f320f60 (patch) | |
tree | 4124d3f006f874f7dbfb75bf46437e9cd00d273e /net/wireless/reg.c | |
parent | fe7ef5e9ba0c60bab01390493a4c6790f7b093af (diff) |
regulatory: pass new regdomain to reset function
Instead of assigning after calling the function do
it inside the function. This will later avoid a
period of time where the pointer is NULL.
Acked-by: Luis R. Rodriguez <mcgrof@do-not-panic.com>
Signed-off-by: Johannes Berg <johannes.berg@intel.com>
Diffstat (limited to 'net/wireless/reg.c')
-rw-r--r-- | net/wireless/reg.c | 26 |
1 files changed, 11 insertions, 15 deletions
diff --git a/net/wireless/reg.c b/net/wireless/reg.c index 2e38b47939a3..35541d6d4145 100644 --- a/net/wireless/reg.c +++ b/net/wireless/reg.c | |||
@@ -183,7 +183,8 @@ static char user_alpha2[2]; | |||
183 | module_param(ieee80211_regdom, charp, 0444); | 183 | module_param(ieee80211_regdom, charp, 0444); |
184 | MODULE_PARM_DESC(ieee80211_regdom, "IEEE 802.11 regulatory domain code"); | 184 | MODULE_PARM_DESC(ieee80211_regdom, "IEEE 802.11 regulatory domain code"); |
185 | 185 | ||
186 | static void reset_regdomains(bool full_reset) | 186 | static void reset_regdomains(bool full_reset, |
187 | const struct ieee80211_regdomain *new_regdom) | ||
187 | { | 188 | { |
188 | assert_cfg80211_lock(); | 189 | assert_cfg80211_lock(); |
189 | assert_reg_lock(); | 190 | assert_reg_lock(); |
@@ -200,7 +201,7 @@ static void reset_regdomains(bool full_reset) | |||
200 | kfree(cfg80211_world_regdom); | 201 | kfree(cfg80211_world_regdom); |
201 | 202 | ||
202 | cfg80211_world_regdom = &world_regdom; | 203 | cfg80211_world_regdom = &world_regdom; |
203 | cfg80211_regdomain = NULL; | 204 | cfg80211_regdomain = new_regdom; |
204 | 205 | ||
205 | if (!full_reset) | 206 | if (!full_reset) |
206 | return; | 207 | return; |
@@ -221,10 +222,9 @@ static void update_world_regdomain(const struct ieee80211_regdomain *rd) | |||
221 | assert_cfg80211_lock(); | 222 | assert_cfg80211_lock(); |
222 | assert_reg_lock(); | 223 | assert_reg_lock(); |
223 | 224 | ||
224 | reset_regdomains(false); | 225 | reset_regdomains(false, rd); |
225 | 226 | ||
226 | cfg80211_world_regdom = rd; | 227 | cfg80211_world_regdom = rd; |
227 | cfg80211_regdomain = rd; | ||
228 | } | 228 | } |
229 | 229 | ||
230 | bool is_world_regdom(const char *alpha2) | 230 | bool is_world_regdom(const char *alpha2) |
@@ -1817,7 +1817,7 @@ static void restore_regulatory_settings(bool reset_user) | |||
1817 | mutex_lock(&cfg80211_mutex); | 1817 | mutex_lock(&cfg80211_mutex); |
1818 | mutex_lock(®_mutex); | 1818 | mutex_lock(®_mutex); |
1819 | 1819 | ||
1820 | reset_regdomains(true); | 1820 | reset_regdomains(true, cfg80211_world_regdom); |
1821 | restore_alpha2(alpha2, reset_user); | 1821 | restore_alpha2(alpha2, reset_user); |
1822 | 1822 | ||
1823 | /* | 1823 | /* |
@@ -1848,9 +1848,8 @@ static void restore_regulatory_settings(bool reset_user) | |||
1848 | } | 1848 | } |
1849 | 1849 | ||
1850 | /* First restore to the basic regulatory settings */ | 1850 | /* First restore to the basic regulatory settings */ |
1851 | cfg80211_regdomain = cfg80211_world_regdom; | 1851 | world_alpha2[0] = cfg80211_world_regdom->alpha2[0]; |
1852 | world_alpha2[0] = cfg80211_regdomain->alpha2[0]; | 1852 | world_alpha2[1] = cfg80211_world_regdom->alpha2[1]; |
1853 | world_alpha2[1] = cfg80211_regdomain->alpha2[1]; | ||
1854 | 1853 | ||
1855 | list_for_each_entry(rdev, &cfg80211_rdev_list, list) { | 1854 | list_for_each_entry(rdev, &cfg80211_rdev_list, list) { |
1856 | if (rdev->wiphy.flags & WIPHY_FLAG_CUSTOM_REGULATORY) | 1855 | if (rdev->wiphy.flags & WIPHY_FLAG_CUSTOM_REGULATORY) |
@@ -2101,8 +2100,7 @@ static int __set_regdom(const struct ieee80211_regdomain *rd) | |||
2101 | 2100 | ||
2102 | if (!last_request->intersect) { | 2101 | if (!last_request->intersect) { |
2103 | if (last_request->initiator != NL80211_REGDOM_SET_BY_DRIVER) { | 2102 | if (last_request->initiator != NL80211_REGDOM_SET_BY_DRIVER) { |
2104 | reset_regdomains(false); | 2103 | reset_regdomains(false, rd); |
2105 | cfg80211_regdomain = rd; | ||
2106 | return 0; | 2104 | return 0; |
2107 | } | 2105 | } |
2108 | 2106 | ||
@@ -2123,8 +2121,7 @@ static int __set_regdom(const struct ieee80211_regdomain *rd) | |||
2123 | return PTR_ERR(regd); | 2121 | return PTR_ERR(regd); |
2124 | 2122 | ||
2125 | request_wiphy->regd = regd; | 2123 | request_wiphy->regd = regd; |
2126 | reset_regdomains(false); | 2124 | reset_regdomains(false, rd); |
2127 | cfg80211_regdomain = rd; | ||
2128 | return 0; | 2125 | return 0; |
2129 | } | 2126 | } |
2130 | 2127 | ||
@@ -2147,8 +2144,7 @@ static int __set_regdom(const struct ieee80211_regdomain *rd) | |||
2147 | 2144 | ||
2148 | rd = NULL; | 2145 | rd = NULL; |
2149 | 2146 | ||
2150 | reset_regdomains(false); | 2147 | reset_regdomains(false, intersected_rd); |
2151 | cfg80211_regdomain = intersected_rd; | ||
2152 | 2148 | ||
2153 | return 0; | 2149 | return 0; |
2154 | } | 2150 | } |
@@ -2319,7 +2315,7 @@ void regulatory_exit(void) | |||
2319 | /* Lock to suppress warnings */ | 2315 | /* Lock to suppress warnings */ |
2320 | mutex_lock(&cfg80211_mutex); | 2316 | mutex_lock(&cfg80211_mutex); |
2321 | mutex_lock(®_mutex); | 2317 | mutex_lock(®_mutex); |
2322 | reset_regdomains(true); | 2318 | reset_regdomains(true, NULL); |
2323 | mutex_unlock(&cfg80211_mutex); | 2319 | mutex_unlock(&cfg80211_mutex); |
2324 | mutex_unlock(®_mutex); | 2320 | mutex_unlock(®_mutex); |
2325 | 2321 | ||