Search Linux Wireless

[PATCH 05/12] cfg80211: add regulatory_set_custom_rd()

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



This adds regulatory_set_custom_rd() to allow drivers to apply custom
regulatory domains to their wireless device. This is required on drivers
that do not have a direct 1-1 mapping between a regugulatory domain and a
country. This applies to custom "world regulatory domains" which vendors
may use.

Signed-off-by: Luis R. Rodriguez <lrodriguez@xxxxxxxxxxx>
---
 include/net/wireless.h |   20 +++++++++++++++++++-
 net/wireless/reg.c     |   17 +++++++++++++++++
 2 files changed, 36 insertions(+), 1 deletions(-)

diff --git a/include/net/wireless.h b/include/net/wireless.h
index ea89958..16f020a 100644
--- a/include/net/wireless.h
+++ b/include/net/wireless.h
@@ -183,7 +183,8 @@ struct ieee80211_supported_band {
  * @class_dev: the class device representing /sys/class/ieee80211/<wiphy-name>
  * @ignore_country_ies: tells us the wireless core should ignore country IEs
  *	received by itself or by other wireless drivers. This will only
- *	apply if the driver has provided a regulatory_hint()
+ *	apply if the driver has provided its own regulatory domain via
+ *	regulatory_hint() or regulatory_set_custom_rd()
  * @fw_handles_regulatory: tells us the firmware for this device
  * 	has its own regulatory solution and cannot identify the
  * 	ISO / IEC 3166 alpha2 it belongs to. When this is enabled
@@ -405,4 +406,21 @@ extern void regulatory_hint(struct wiphy *wiphy, const char *alpha2);
 extern void regulatory_hint_11d(struct wiphy *wiphy,
 				u8 *country_ie,
 				u8 country_ie_len);
+
+/**
+ * regulatory_set_custom_rd - apply a custom driver regulatory domain
+ * @wiphy: the wireless device we want to process the regulatory domain on
+ * @custom_regd: the custom regulatory domain to use for this wiphy
+ *
+ * Drivers can sometimes have custom regulatory domains which do not apply
+ * to a specific country. Drivers can use this to apply such custom regulatory
+ * domains. The custom regulatory domain will be copied into a new wiphy->regd
+ * for internal usage within cfg80211. The driver is in charge of freeing
+ * the passed regulatory domain if created using kmalloc(). This can be called
+ * after the wiphy has been registered with cfg80211.
+ */
+extern int regulatory_set_custom_rd(
+	struct wiphy *wiphy,
+	const struct ieee80211_regdomain *custom_regd);
+
 #endif /* __NET_WIRELESS_H */
diff --git a/net/wireless/reg.c b/net/wireless/reg.c
index 127bec2..b05df36 100644
--- a/net/wireless/reg.c
+++ b/net/wireless/reg.c
@@ -1003,6 +1003,23 @@ static int reg_copy_regd(const struct ieee80211_regdomain **dst_regd,
 	return 0;
 }
 
+int regulatory_set_custom_rd(struct wiphy *wiphy,
+			       const struct ieee80211_regdomain *custom_regd)
+{
+	int r = 0;
+	mutex_lock(&cfg80211_drv_mutex);
+	r = reg_copy_regd(&wiphy->regd, custom_regd);
+	if (r)
+		goto unlock;
+	regd_update_regulatory(wiphy);
+	if (wiphy->reg_notifier)
+		wiphy->reg_notifier(wiphy, REGDOM_SET_BY_DRIVER);
+unlock:
+	mutex_unlock(&cfg80211_drv_mutex);
+	return r;
+}
+EXPORT_SYMBOL(regulatory_set_custom_rd);
+
 /* Return value which can be used by ignore_request() to indicate
  * it has been determined we should intersect two regulatory domains */
 #define REG_INTERSECT	1
-- 
1.6.1.rc3.51.g5832d

--
To unsubscribe from this list: send the line "unsubscribe linux-wireless" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html

[Index of Archives]     [Linux Host AP]     [ATH6KL]     [Linux Bluetooth]     [Linux Netdev]     [Kernel Newbies]     [Linux Kernel]     [IDE]     [Security]     [Git]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux ATA RAID]     [Samba]     [Device Mapper]
  Powered by Linux