Search Linux Wireless

[PATCH] rt2x00: Provide regulatory hint with rt2500pci/usb

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

 



rt2500pci and rt2500usb contain a special field in the EEPROM
which indicates which regulatory domain the card belongs to.
This code can easily be translated into a country code which
we can send as alpha2 hint for CRDA.

Please note that most cards will have 0xffff as EEPROM value,
and thus do not provide a regulatory hint through the EEPROM.

Signed-off-by: Ivo van Doorn <IvDoorn@xxxxxxxxx>
---
diff --git a/drivers/net/wireless/rt2x00/rt2500pci.c b/drivers/net/wireless/rt2x00/rt2500pci.c
index 76f016d..98d3c6c 100644
--- a/drivers/net/wireless/rt2x00/rt2500pci.c
+++ b/drivers/net/wireless/rt2x00/rt2500pci.c
@@ -1512,6 +1512,17 @@ static int rt2500pci_validate_eeprom(struct rt2x00_dev *rt2x00dev)
 	return 0;
 }
 
+static const char* reg_domain_map[] = {
+	"US",	/* REGION_FCC: 1-11 */
+	"CA",	/* REGION_IC: 1-11 */
+	"DE",	/* REGION_ETSI: 1-13 */
+	"ES",	/* REGION_SPAIN: 10-11 */
+	"FR",	/* REGION_FRANCE: 10-13 */
+	"JP",	/* REGION_MKK: 14 */
+	"JP",	/* REGION_MKK1: 1-14 */
+	"IL",	/* REGION_ISRAEL: 3-9 */
+};
+
 static int rt2500pci_init_eeprom(struct rt2x00_dev *rt2x00dev)
 {
 	u32 reg;
@@ -1577,6 +1588,16 @@ static int rt2500pci_init_eeprom(struct rt2x00_dev *rt2x00dev)
 		__set_bit(CONFIG_DISABLE_LINK_TUNING, &rt2x00dev->flags);
 
 	/*
+	 * Read Geography information, if it contains valid data we should
+	 * send the regulatory hint as alpha2 value to cfg80211.
+	 */
+	rt2x00_eeprom_read(rt2x00dev, EEPROM_GEOGRAPHY, &eeprom);
+	if (eeprom != 0xffff) {
+		value = rt2x00_get_field16(eeprom, EEPROM_GEOGRAPHY_GEO);
+		regulatory_hint(rt2x00dev->hw->wiphy, reg_domain_map[value]);
+	}
+
+	/*
 	 * Read the RSSI <-> dBm offset information.
 	 */
 	rt2x00_eeprom_read(rt2x00dev, EEPROM_CALIBRATE_OFFSET, &eeprom);
diff --git a/drivers/net/wireless/rt2x00/rt2500usb.c b/drivers/net/wireless/rt2x00/rt2500usb.c
index 2bc4e46..7f364dd 100644
--- a/drivers/net/wireless/rt2x00/rt2500usb.c
+++ b/drivers/net/wireless/rt2x00/rt2500usb.c
@@ -1546,6 +1546,17 @@ static int rt2500usb_validate_eeprom(struct rt2x00_dev *rt2x00dev)
 	return 0;
 }
 
+static const char* reg_domain_map[] = {
+	"US",	/* REGION_FCC: 1-11 */
+	"CA",	/* REGION_IC: 1-11 */
+	"DE",	/* REGION_ETSI: 1-13 */
+	"ES",	/* REGION_SPAIN: 10-11 */
+	"FR",	/* REGION_FRANCE: 10-13 */
+	"JP",	/* REGION_MKK: 14 */
+	"JP",	/* REGION_MKK1: 1-14 */
+	"IL",	/* REGION_ISRAEL: 3-9 */
+};
+
 static int rt2500usb_init_eeprom(struct rt2x00_dev *rt2x00dev)
 {
 	u16 reg;
@@ -1626,6 +1637,16 @@ static int rt2500usb_init_eeprom(struct rt2x00_dev *rt2x00dev)
 		__set_bit(CONFIG_DISABLE_LINK_TUNING, &rt2x00dev->flags);
 
 	/*
+	 * Read Geography information, if it contains valid data we should
+	 * send the regulatory hint as alpha2 value to cfg80211.
+	 */
+	rt2x00_eeprom_read(rt2x00dev, EEPROM_GEOGRAPHY, &eeprom);
+	if (eeprom != 0xffff) {
+		value = rt2x00_get_field16(eeprom, EEPROM_GEOGRAPHY_GEO);
+		regulatory_hint(rt2x00dev->hw->wiphy, reg_domain_map[value]);
+	}
+
+	/*
 	 * Read the RSSI <-> dBm offset information.
 	 */
 	rt2x00_eeprom_read(rt2x00dev, EEPROM_CALIBRATE_OFFSET, &eeprom);
--
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