p54: regulatory domain hints
authorChristian Lamparter <chunkeey@web.de>
Fri, 26 Dec 2008 20:50:33 +0000 (21:50 +0100)
committerJohn W. Linville <linville@tuxdriver.com>
Thu, 29 Jan 2009 20:59:40 +0000 (15:59 -0500)
This patch adds a sub-routine that parses the default country eeprom entry
and forwards the obtained Alpha2 identifier to the regulatory sub-system.

Note: I dropped the p54 specific regdomain<->alpha2 conversion code for now.
But it will be added as soon as there's the common library function is ready.

Signed-off-by: Christian Lamparter <chunkeey@web.de>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
drivers/net/wireless/p54/p54common.c
drivers/net/wireless/p54/p54common.h

index 28d9833..8d2df5b 100644 (file)
@@ -376,6 +376,36 @@ static void p54_parse_rssical(struct ieee80211_hw *dev, void *data, int len,
        }
 }
 
+static void p54_parse_default_country(struct ieee80211_hw *dev,
+                                     void *data, int len)
+{
+       struct pda_country *country;
+
+       if (len != sizeof(*country)) {
+               printk(KERN_ERR "%s: found possible invalid default country "
+                               "eeprom entry. (entry size: %d)\n",
+                      wiphy_name(dev->wiphy), len);
+
+               print_hex_dump_bytes("country:", DUMP_PREFIX_NONE,
+                                    data, len);
+
+               printk(KERN_ERR "%s: please report this issue.\n",
+                       wiphy_name(dev->wiphy));
+               return;
+       }
+
+       country = (struct pda_country *) data;
+       if (country->flags == PDR_COUNTRY_CERT_CODE_PSEUDO)
+               regulatory_hint(dev->wiphy, country->alpha2);
+       else {
+               /* TODO:
+                * write a shared/common function that converts
+                * "Regulatory domain codes" (802.11-2007 14.8.2.2)
+                * into ISO/IEC 3166-1 alpha2 for regulatory_hint.
+                */
+       }
+}
+
 static int p54_parse_eeprom(struct ieee80211_hw *dev, void *eeprom, int len)
 {
        struct p54_common *priv = dev->priv;
@@ -463,6 +493,9 @@ static int p54_parse_eeprom(struct ieee80211_hw *dev, void *eeprom, int len)
                        memcpy(priv->iq_autocal, entry->data, data_len);
                        priv->iq_autocal_len = data_len / sizeof(struct pda_iq_autocal_entry);
                        break;
+               case PDR_DEFAULT_COUNTRY:
+                       p54_parse_default_country(dev, entry->data, data_len);
+                       break;
                case PDR_INTERFACE_LIST:
                        tmp = entry->data;
                        while ((u8 *)tmp < entry->data + data_len) {
@@ -497,7 +530,6 @@ static int p54_parse_eeprom(struct ieee80211_hw *dev, void *eeprom, int len)
                case PDR_UTF8_OEM_NAME:
                case PDR_UTF8_PRODUCT_NAME:
                case PDR_COUNTRY_LIST:
-               case PDR_DEFAULT_COUNTRY:
                case PDR_ANTENNA_GAIN:
                case PDR_PRISM_INDIGO_PA_CALIBRATION_DATA:
                case PDR_REGULATORY_POWER_LIMITS:
index 514f660..163e3ad 100644 (file)
@@ -180,6 +180,12 @@ struct pda_rssi_cal_entry {
        __le16 add;
 } __attribute__ ((packed));
 
+struct pda_country {
+       u8 regdomain;
+       u8 alpha2[2];
+       u8 flags;
+} __attribute__ ((packed));
+
 /*
  * this defines the PDR codes used to build PDAs as defined in document
  * number 553155. The current implementation mirrors version 1.1 of the