summaryrefslogtreecommitdiffstats
path: root/drivers/net/wireless/ath5k/regdom.c
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@linux-foundation.org>2008-01-29 22:54:01 +1100
committerLinus Torvalds <torvalds@linux-foundation.org>2008-01-29 22:54:01 +1100
commit0ba6c33bcddc64a54b5f1c25a696c4767dc76292 (patch)
tree62e616f97a4762d8e75bf732e4827af2d15d52c5 /drivers/net/wireless/ath5k/regdom.c
parent21af0297c7e56024a5ccc4d8ad2a590f9ec371ba (diff)
parent85040bcb4643cba578839e953f25e2d1965d83d0 (diff)
Merge git://git.kernel.org/pub/scm/linux/kernel/git/davem/net-2.6.25
* git://git.kernel.org/pub/scm/linux/kernel/git/davem/net-2.6.25: (1470 commits) [IPV6] ADDRLABEL: Fix double free on label deletion. [PPP]: Sparse warning fixes. [IPV4] fib_trie: remove unneeded NULL check [IPV4] fib_trie: More whitespace cleanup. [NET_SCHED]: Use nla_policy for attribute validation in ematches [NET_SCHED]: Use nla_policy for attribute validation in actions [NET_SCHED]: Use nla_policy for attribute validation in classifiers [NET_SCHED]: Use nla_policy for attribute validation in packet schedulers [NET_SCHED]: sch_api: introduce constant for rate table size [NET_SCHED]: Use typeful attribute parsing helpers [NET_SCHED]: Use typeful attribute construction helpers [NET_SCHED]: Use NLA_PUT_STRING for string dumping [NET_SCHED]: Use nla_nest_start/nla_nest_end [NET_SCHED]: Propagate nla_parse return value [NET_SCHED]: act_api: use PTR_ERR in tcf_action_init/tcf_action_get [NET_SCHED]: act_api: use nlmsg_parse [NET_SCHED]: act_api: fix netlink API conversion bug [NET_SCHED]: sch_netem: use nla_parse_nested_compat [NET_SCHED]: sch_atm: fix format string warning [NETNS]: Add namespace for ICMP replying code. ...
Diffstat (limited to 'drivers/net/wireless/ath5k/regdom.c')
-rw-r--r--drivers/net/wireless/ath5k/regdom.c121
1 files changed, 121 insertions, 0 deletions
diff --git a/drivers/net/wireless/ath5k/regdom.c b/drivers/net/wireless/ath5k/regdom.c
new file mode 100644
index 00000000000..e851957dacf
--- /dev/null
+++ b/drivers/net/wireless/ath5k/regdom.c
@@ -0,0 +1,121 @@
+/*
+ * Copyright (c) 2004, 2005 Reyk Floeter <reyk@vantronix.net>
+ *
+ * Permission to use, copy, modify, and distribute this software for any
+ * purpose with or without fee is hereby granted, provided that the above
+ * copyright notice and this permission notice appear in all copies.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
+ * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
+ * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
+ * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
+ * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
+ * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
+ * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+ */
+
+/*
+ * Basic regulation domain extensions for the IEEE 802.11 stack
+ */
+
+#include <linux/kernel.h>
+#include <linux/string.h>
+
+#include "regdom.h"
+
+static const struct ath5k_regdommap {
+ enum ath5k_regdom dmn;
+ enum ath5k_regdom dmn5;
+ enum ath5k_regdom dmn2;
+} r_map[] = {
+ { DMN_DEFAULT, DMN_DEBUG, DMN_DEBUG },
+ { DMN_NULL_WORLD, DMN_NULL, DMN_WORLD },
+ { DMN_NULL_ETSIB, DMN_NULL, DMN_ETSIB },
+ { DMN_NULL_ETSIC, DMN_NULL, DMN_ETSIC },
+ { DMN_FCC1_FCCA, DMN_FCC1, DMN_FCCA },
+ { DMN_FCC1_WORLD, DMN_FCC1, DMN_WORLD },
+ { DMN_FCC2_FCCA, DMN_FCC2, DMN_FCCA },
+ { DMN_FCC2_WORLD, DMN_FCC2, DMN_WORLD },
+ { DMN_FCC2_ETSIC, DMN_FCC2, DMN_ETSIC },
+ { DMN_FRANCE_NULL, DMN_ETSI3, DMN_ETSI3 },
+ { DMN_FCC3_FCCA, DMN_FCC3, DMN_WORLD },
+ { DMN_ETSI1_WORLD, DMN_ETSI1, DMN_WORLD },
+ { DMN_ETSI3_ETSIA, DMN_ETSI3, DMN_WORLD },
+ { DMN_ETSI2_WORLD, DMN_ETSI2, DMN_WORLD },
+ { DMN_ETSI3_WORLD, DMN_ETSI3, DMN_WORLD },
+ { DMN_ETSI4_WORLD, DMN_ETSI4, DMN_WORLD },
+ { DMN_ETSI4_ETSIC, DMN_ETSI4, DMN_ETSIC },
+ { DMN_ETSI5_WORLD, DMN_ETSI5, DMN_WORLD },
+ { DMN_ETSI6_WORLD, DMN_ETSI6, DMN_WORLD },
+ { DMN_ETSI_NULL, DMN_ETSI1, DMN_ETSI1 },
+ { DMN_MKK1_MKKA, DMN_MKK1, DMN_MKKA },
+ { DMN_MKK1_MKKB, DMN_MKK1, DMN_MKKA },
+ { DMN_APL4_WORLD, DMN_APL4, DMN_WORLD },
+ { DMN_MKK2_MKKA, DMN_MKK2, DMN_MKKA },
+ { DMN_APL_NULL, DMN_APL1, DMN_NULL },
+ { DMN_APL2_WORLD, DMN_APL2, DMN_WORLD },
+ { DMN_APL2_APLC, DMN_APL2, DMN_WORLD },
+ { DMN_APL3_WORLD, DMN_APL3, DMN_WORLD },
+ { DMN_MKK1_FCCA, DMN_MKK1, DMN_FCCA },
+ { DMN_APL2_APLD, DMN_APL2, DMN_APLD },
+ { DMN_MKK1_MKKA1, DMN_MKK1, DMN_MKKA },
+ { DMN_MKK1_MKKA2, DMN_MKK1, DMN_MKKA },
+ { DMN_APL1_WORLD, DMN_APL1, DMN_WORLD },
+ { DMN_APL1_FCCA, DMN_APL1, DMN_FCCA },
+ { DMN_APL1_APLA, DMN_APL1, DMN_WORLD },
+ { DMN_APL1_ETSIC, DMN_APL1, DMN_ETSIC },
+ { DMN_APL2_ETSIC, DMN_APL2, DMN_ETSIC },
+ { DMN_APL5_WORLD, DMN_APL5, DMN_WORLD },
+ { DMN_WOR0_WORLD, DMN_WORLD, DMN_WORLD },
+ { DMN_WOR1_WORLD, DMN_WORLD, DMN_WORLD },
+ { DMN_WOR2_WORLD, DMN_WORLD, DMN_WORLD },
+ { DMN_WOR3_WORLD, DMN_WORLD, DMN_WORLD },
+ { DMN_WOR4_WORLD, DMN_WORLD, DMN_WORLD },
+ { DMN_WOR5_ETSIC, DMN_WORLD, DMN_WORLD },
+ { DMN_WOR01_WORLD, DMN_WORLD, DMN_WORLD },
+ { DMN_WOR02_WORLD, DMN_WORLD, DMN_WORLD },
+ { DMN_EU1_WORLD, DMN_ETSI1, DMN_WORLD },
+ { DMN_WOR9_WORLD, DMN_WORLD, DMN_WORLD },
+ { DMN_WORA_WORLD, DMN_WORLD, DMN_WORLD },
+};
+
+enum ath5k_regdom ath5k_regdom2flag(enum ath5k_regdom dmn, u16 mhz)
+{
+ unsigned int i;
+
+ for (i = 0; i < ARRAY_SIZE(r_map); i++) {
+ if (r_map[i].dmn == dmn) {
+ if (mhz >= 2000 && mhz <= 3000)
+ return r_map[i].dmn2;
+ if (mhz >= IEEE80211_CHANNELS_5GHZ_MIN &&
+ mhz <= IEEE80211_CHANNELS_5GHZ_MAX)
+ return r_map[i].dmn5;
+ }
+ }
+
+ return DMN_DEBUG;
+}
+
+u16 ath5k_regdom_from_ieee(enum ath5k_regdom ieee)
+{
+ u32 regdomain = (u32)ieee;
+
+ /*
+ * Use the default regulation domain if the value is empty
+ * or not supported by the net80211 regulation code.
+ */
+ if (ath5k_regdom2flag(regdomain, IEEE80211_CHANNELS_5GHZ_MIN) ==
+ DMN_DEBUG)
+ return (u16)AR5K_TUNE_REGDOMAIN;
+
+ /* It is supported, just return the value */
+ return regdomain;
+}
+
+enum ath5k_regdom ath5k_regdom_to_ieee(u16 regdomain)
+{
+ enum ath5k_regdom ieee = (enum ath5k_regdom)regdomain;
+
+ return ieee;
+}
+