diff options
Diffstat (limited to 'net/wireless/reg.c')
-rw-r--r-- | net/wireless/reg.c | 49 |
1 files changed, 33 insertions, 16 deletions
diff --git a/net/wireless/reg.c b/net/wireless/reg.c index 37693b6ef23a..ab801a1097b2 100644 --- a/net/wireless/reg.c +++ b/net/wireless/reg.c | |||
@@ -63,6 +63,10 @@ static struct regulatory_request *last_request; | |||
63 | /* To trigger userspace events */ | 63 | /* To trigger userspace events */ |
64 | static struct platform_device *reg_pdev; | 64 | static struct platform_device *reg_pdev; |
65 | 65 | ||
66 | static struct device_type reg_device_type = { | ||
67 | .uevent = reg_device_uevent, | ||
68 | }; | ||
69 | |||
66 | /* | 70 | /* |
67 | * Central wireless core regulatory domains, we only need two, | 71 | * Central wireless core regulatory domains, we only need two, |
68 | * the current one and a world regulatory domain in case we have no | 72 | * the current one and a world regulatory domain in case we have no |
@@ -362,16 +366,11 @@ static inline void reg_regdb_query(const char *alpha2) {} | |||
362 | 366 | ||
363 | /* | 367 | /* |
364 | * This lets us keep regulatory code which is updated on a regulatory | 368 | * This lets us keep regulatory code which is updated on a regulatory |
365 | * basis in userspace. | 369 | * basis in userspace. Country information is filled in by |
370 | * reg_device_uevent | ||
366 | */ | 371 | */ |
367 | static int call_crda(const char *alpha2) | 372 | static int call_crda(const char *alpha2) |
368 | { | 373 | { |
369 | char country_env[9 + 2] = "COUNTRY="; | ||
370 | char *envp[] = { | ||
371 | country_env, | ||
372 | NULL | ||
373 | }; | ||
374 | |||
375 | if (!is_world_regdom((char *) alpha2)) | 374 | if (!is_world_regdom((char *) alpha2)) |
376 | pr_info("Calling CRDA for country: %c%c\n", | 375 | pr_info("Calling CRDA for country: %c%c\n", |
377 | alpha2[0], alpha2[1]); | 376 | alpha2[0], alpha2[1]); |
@@ -381,10 +380,7 @@ static int call_crda(const char *alpha2) | |||
381 | /* query internal regulatory database (if it exists) */ | 380 | /* query internal regulatory database (if it exists) */ |
382 | reg_regdb_query(alpha2); | 381 | reg_regdb_query(alpha2); |
383 | 382 | ||
384 | country_env[8] = alpha2[0]; | 383 | return kobject_uevent(®_pdev->dev.kobj, KOBJ_CHANGE); |
385 | country_env[9] = alpha2[1]; | ||
386 | |||
387 | return kobject_uevent_env(®_pdev->dev.kobj, KOBJ_CHANGE, envp); | ||
388 | } | 384 | } |
389 | 385 | ||
390 | /* Used by nl80211 before kmalloc'ing our regulatory domain */ | 386 | /* Used by nl80211 before kmalloc'ing our regulatory domain */ |
@@ -813,7 +809,7 @@ static void handle_channel(struct wiphy *wiphy, | |||
813 | if (r) { | 809 | if (r) { |
814 | /* | 810 | /* |
815 | * We will disable all channels that do not match our | 811 | * We will disable all channels that do not match our |
816 | * recieved regulatory rule unless the hint is coming | 812 | * received regulatory rule unless the hint is coming |
817 | * from a Country IE and the Country IE had no information | 813 | * from a Country IE and the Country IE had no information |
818 | * about a band. The IEEE 802.11 spec allows for an AP | 814 | * about a band. The IEEE 802.11 spec allows for an AP |
819 | * to send only a subset of the regulatory rules allowed, | 815 | * to send only a subset of the regulatory rules allowed, |
@@ -842,7 +838,7 @@ static void handle_channel(struct wiphy *wiphy, | |||
842 | request_wiphy && request_wiphy == wiphy && | 838 | request_wiphy && request_wiphy == wiphy && |
843 | request_wiphy->flags & WIPHY_FLAG_STRICT_REGULATORY) { | 839 | request_wiphy->flags & WIPHY_FLAG_STRICT_REGULATORY) { |
844 | /* | 840 | /* |
845 | * This gaurantees the driver's requested regulatory domain | 841 | * This guarantees the driver's requested regulatory domain |
846 | * will always be used as a base for further regulatory | 842 | * will always be used as a base for further regulatory |
847 | * settings | 843 | * settings |
848 | */ | 844 | */ |
@@ -1801,9 +1797,9 @@ void regulatory_hint_disconnect(void) | |||
1801 | 1797 | ||
1802 | static bool freq_is_chan_12_13_14(u16 freq) | 1798 | static bool freq_is_chan_12_13_14(u16 freq) |
1803 | { | 1799 | { |
1804 | if (freq == ieee80211_channel_to_frequency(12) || | 1800 | if (freq == ieee80211_channel_to_frequency(12, IEEE80211_BAND_2GHZ) || |
1805 | freq == ieee80211_channel_to_frequency(13) || | 1801 | freq == ieee80211_channel_to_frequency(13, IEEE80211_BAND_2GHZ) || |
1806 | freq == ieee80211_channel_to_frequency(14)) | 1802 | freq == ieee80211_channel_to_frequency(14, IEEE80211_BAND_2GHZ)) |
1807 | return true; | 1803 | return true; |
1808 | return false; | 1804 | return false; |
1809 | } | 1805 | } |
@@ -2087,6 +2083,25 @@ int set_regdom(const struct ieee80211_regdomain *rd) | |||
2087 | return r; | 2083 | return r; |
2088 | } | 2084 | } |
2089 | 2085 | ||
2086 | #ifdef CONFIG_HOTPLUG | ||
2087 | int reg_device_uevent(struct device *dev, struct kobj_uevent_env *env) | ||
2088 | { | ||
2089 | if (last_request && !last_request->processed) { | ||
2090 | if (add_uevent_var(env, "COUNTRY=%c%c", | ||
2091 | last_request->alpha2[0], | ||
2092 | last_request->alpha2[1])) | ||
2093 | return -ENOMEM; | ||
2094 | } | ||
2095 | |||
2096 | return 0; | ||
2097 | } | ||
2098 | #else | ||
2099 | int reg_device_uevent(struct device *dev, struct kobj_uevent_env *env) | ||
2100 | { | ||
2101 | return -ENODEV; | ||
2102 | } | ||
2103 | #endif /* CONFIG_HOTPLUG */ | ||
2104 | |||
2090 | /* Caller must hold cfg80211_mutex */ | 2105 | /* Caller must hold cfg80211_mutex */ |
2091 | void reg_device_remove(struct wiphy *wiphy) | 2106 | void reg_device_remove(struct wiphy *wiphy) |
2092 | { | 2107 | { |
@@ -2118,6 +2133,8 @@ int __init regulatory_init(void) | |||
2118 | if (IS_ERR(reg_pdev)) | 2133 | if (IS_ERR(reg_pdev)) |
2119 | return PTR_ERR(reg_pdev); | 2134 | return PTR_ERR(reg_pdev); |
2120 | 2135 | ||
2136 | reg_pdev->dev.type = ®_device_type; | ||
2137 | |||
2121 | spin_lock_init(®_requests_lock); | 2138 | spin_lock_init(®_requests_lock); |
2122 | spin_lock_init(®_pending_beacons_lock); | 2139 | spin_lock_init(®_pending_beacons_lock); |
2123 | 2140 | ||