#include <linux/kernel.h>
 #include <linux/slab.h>
+#include <net/cfg80211.h>
+#include <net/mac80211.h>
 #include <net/wireless.h>
-#include "ath9k.h"
+#include "regd.h"
 #include "regd_common.h"
 
 /*
 
 /* Can be used for:
  * 0x60, 0x61, 0x62 */
-static const struct ieee80211_regdomain ath9k_world_regdom_60_61_62 = {
+static const struct ieee80211_regdomain ath_world_regdom_60_61_62 = {
        .n_reg_rules = 5,
        .alpha2 =  "99",
        .reg_rules = {
 };
 
 /* Can be used by 0x63 and 0x65 */
-static const struct ieee80211_regdomain ath9k_world_regdom_63_65 = {
+static const struct ieee80211_regdomain ath_world_regdom_63_65 = {
        .n_reg_rules = 4,
        .alpha2 =  "99",
        .reg_rules = {
 };
 
 /* Can be used by 0x64 only */
-static const struct ieee80211_regdomain ath9k_world_regdom_64 = {
+static const struct ieee80211_regdomain ath_world_regdom_64 = {
        .n_reg_rules = 3,
        .alpha2 =  "99",
        .reg_rules = {
 };
 
 /* Can be used by 0x66 and 0x69 */
-static const struct ieee80211_regdomain ath9k_world_regdom_66_69 = {
+static const struct ieee80211_regdomain ath_world_regdom_66_69 = {
        .n_reg_rules = 3,
        .alpha2 =  "99",
        .reg_rules = {
 };
 
 /* Can be used by 0x67, 0x6A and 0x68 */
-static const struct ieee80211_regdomain ath9k_world_regdom_67_68_6A = {
+static const struct ieee80211_regdomain ath_world_regdom_67_68_6A = {
        .n_reg_rules = 4,
        .alpha2 =  "99",
        .reg_rules = {
                (regd == WORLD);
 }
 
-static u16 ath9k_regd_get_eepromRD(struct ath9k_regulatory *reg)
+static u16 ath_regd_get_eepromRD(struct ath_regulatory *reg)
 {
        return reg->current_rd & ~WORLDWIDE_ROAMING_FLAG;
 }
 
-bool ath9k_is_world_regd(struct ath9k_regulatory *reg)
+bool ath_is_world_regd(struct ath_regulatory *reg)
 {
-       return is_wwr_sku(ath9k_regd_get_eepromRD(reg));
+       return is_wwr_sku(ath_regd_get_eepromRD(reg));
 }
+EXPORT_SYMBOL(ath_is_world_regd);
 
-const struct ieee80211_regdomain *ath9k_default_world_regdomain(void)
+const struct ieee80211_regdomain *ath_default_world_regdomain(void)
 {
        /* this is the most restrictive */
-       return &ath9k_world_regdom_64;
+       return &ath_world_regdom_64;
 }
+EXPORT_SYMBOL(ath_default_world_regdomain);
 
 const struct
-ieee80211_regdomain *ath9k_world_regdomain(struct ath9k_regulatory *reg)
+ieee80211_regdomain *ath_world_regdomain(struct ath_regulatory *reg)
 {
        switch (reg->regpair->regDmnEnum) {
        case 0x60:
        case 0x61:
        case 0x62:
-               return &ath9k_world_regdom_60_61_62;
+               return &ath_world_regdom_60_61_62;
        case 0x63:
        case 0x65:
-               return &ath9k_world_regdom_63_65;
+               return &ath_world_regdom_63_65;
        case 0x64:
-               return &ath9k_world_regdom_64;
+               return &ath_world_regdom_64;
        case 0x66:
        case 0x69:
-               return &ath9k_world_regdom_66_69;
+               return &ath_world_regdom_66_69;
        case 0x67:
        case 0x68:
        case 0x6A:
-               return &ath9k_world_regdom_67_68_6A;
+               return &ath_world_regdom_67_68_6A;
        default:
                WARN_ON(1);
-               return ath9k_default_world_regdomain();
+               return ath_default_world_regdomain();
        }
 }
+EXPORT_SYMBOL(ath_world_regdomain);
 
 /* Frequency is one where radar detection is required */
-static bool ath9k_is_radar_freq(u16 center_freq)
+static bool ath_is_radar_freq(u16 center_freq)
 {
        return (center_freq >= 5260 && center_freq <= 5700);
 }
  *   received a beacon on a channel we can enable active scan and
  *   adhoc (or beaconing).
  */
-static void ath9k_reg_apply_beaconing_flags(
+static void ath_reg_apply_beaconing_flags(
        struct wiphy *wiphy,
        enum nl80211_reg_initiator initiator)
 {
 
                        ch = &sband->channels[i];
 
-                       if (ath9k_is_radar_freq(ch->center_freq) ||
+                       if (ath_is_radar_freq(ch->center_freq) ||
                            (ch->flags & IEEE80211_CHAN_RADAR))
                                continue;
 
 }
 
 /* Allows active scan scan on Ch 12 and 13 */
-static void ath9k_reg_apply_active_scan_flags(
+static void ath_reg_apply_active_scan_flags(
        struct wiphy *wiphy,
        enum nl80211_reg_initiator initiator)
 {
 }
 
 /* Always apply Radar/DFS rules on freq range 5260 MHz - 5700 MHz */
-void ath9k_reg_apply_radar_flags(struct wiphy *wiphy)
+void ath_reg_apply_radar_flags(struct wiphy *wiphy)
 {
        struct ieee80211_supported_band *sband;
        struct ieee80211_channel *ch;
 
        for (i = 0; i < sband->n_channels; i++) {
                ch = &sband->channels[i];
-               if (!ath9k_is_radar_freq(ch->center_freq))
+               if (!ath_is_radar_freq(ch->center_freq))
                        continue;
                /* We always enable radar detection/DFS on this
                 * frequency range. Additionally we also apply on
                                     IEEE80211_CHAN_PASSIVE_SCAN;
        }
 }
+EXPORT_SYMBOL(ath_reg_apply_radar_flags);
 
-void ath9k_reg_apply_world_flags(struct wiphy *wiphy,
-                                enum nl80211_reg_initiator initiator,
-                                struct ath9k_regulatory *reg)
+void ath_reg_apply_world_flags(struct wiphy *wiphy,
+                              enum nl80211_reg_initiator initiator,
+                              struct ath_regulatory *reg)
 {
        switch (reg->regpair->regDmnEnum) {
        case 0x60:
        case 0x63:
        case 0x66:
        case 0x67:
-               ath9k_reg_apply_beaconing_flags(wiphy, initiator);
+               ath_reg_apply_beaconing_flags(wiphy, initiator);
                break;
        case 0x68:
-               ath9k_reg_apply_beaconing_flags(wiphy, initiator);
-               ath9k_reg_apply_active_scan_flags(wiphy, initiator);
+               ath_reg_apply_beaconing_flags(wiphy, initiator);
+               ath_reg_apply_active_scan_flags(wiphy, initiator);
                break;
        }
        return;
 }
+EXPORT_SYMBOL(ath_reg_apply_world_flags);
 
-static int ath9k_reg_notifier_apply(struct wiphy *wiphy,
-       struct regulatory_request *request, struct ath9k_regulatory *reg)
+int ath_reg_notifier_apply(struct wiphy *wiphy,
+       struct regulatory_request *request, struct ath_regulatory *reg)
 {
        /* We always apply this */
-       ath9k_reg_apply_radar_flags(wiphy);
+       ath_reg_apply_radar_flags(wiphy);
 
        switch (request->initiator) {
        case NL80211_REGDOM_SET_BY_DRIVER:
        case NL80211_REGDOM_SET_BY_USER:
                break;
        case NL80211_REGDOM_SET_BY_COUNTRY_IE:
-               if (ath9k_is_world_regd(reg))
-                       ath9k_reg_apply_world_flags(wiphy, request->initiator,
-                                                   reg);
+               if (ath_is_world_regd(reg))
+                       ath_reg_apply_world_flags(wiphy, request->initiator,
+                                                 reg);
                break;
        }
 
        return 0;
 }
+EXPORT_SYMBOL(ath_reg_notifier_apply);
 
-int ath9k_reg_notifier(struct wiphy *wiphy, struct regulatory_request *request)
+bool ath_regd_is_eeprom_valid(struct ath_regulatory *reg)
 {
-       struct ieee80211_hw *hw = wiphy_to_ieee80211_hw(wiphy);
-       struct ath_wiphy *aphy = hw->priv;
-       struct ath_softc *sc = aphy->sc;
-       struct ath9k_regulatory *reg = &sc->sc_ah->regulatory;
-
-       return ath9k_reg_notifier_apply(wiphy, request, reg);
-}
-
-bool ath9k_regd_is_eeprom_valid(struct ath9k_regulatory *reg)
-{
-        u16 rd = ath9k_regd_get_eepromRD(reg);
+        u16 rd = ath_regd_get_eepromRD(reg);
        int i;
 
        if (rd & COUNTRY_ERD_FLAG) {
                                return true;
        }
        printk(KERN_DEBUG
-                "ath9k: invalid regulatory domain/country code 0x%x\n", rd);
+                "ath: invalid regulatory domain/country code 0x%x\n", rd);
        return false;
 }
+EXPORT_SYMBOL(ath_regd_is_eeprom_valid);
 
 /* EEPROM country code to regpair mapping */
 static struct country_code_to_enum_rd*
-ath9k_regd_find_country(u16 countryCode)
+ath_regd_find_country(u16 countryCode)
 {
        int i;
 
 
 /* EEPROM rd code to regpair mapping */
 static struct country_code_to_enum_rd*
-ath9k_regd_find_country_by_rd(int regdmn)
+ath_regd_find_country_by_rd(int regdmn)
 {
        int i;
 
 }
 
 /* Returns the map of the EEPROM set RD to a country code */
-static u16 ath9k_regd_get_default_country(u16 rd)
+static u16 ath_regd_get_default_country(u16 rd)
 {
        if (rd & COUNTRY_ERD_FLAG) {
                struct country_code_to_enum_rd *country = NULL;
                u16 cc = rd & ~COUNTRY_ERD_FLAG;
 
-               country = ath9k_regd_find_country(cc);
+               country = ath_regd_find_country(cc);
                if (country != NULL)
                        return cc;
        }
 }
 
 static struct reg_dmn_pair_mapping*
-ath9k_get_regpair(int regdmn)
+ath_get_regpair(int regdmn)
 {
        int i;
 
        return NULL;
 }
 
-int ath9k_regd_init(struct ath9k_regulatory *reg)
+int ath_regd_init(struct ath_regulatory *reg)
 {
        struct country_code_to_enum_rd *country = NULL;
        u16 regdmn;
 
-       if (!ath9k_regd_is_eeprom_valid(reg)) {
-               printk(KERN_DEBUG "ath9k: Invalid EEPROM contents\n");
+       if (!ath_regd_is_eeprom_valid(reg)) {
+               printk(KERN_DEBUG "ath: Invalid EEPROM contents\n");
                return -EINVAL;
        }
 
-       regdmn = ath9k_regd_get_eepromRD(reg);
-       reg->country_code = ath9k_regd_get_default_country(regdmn);
+       regdmn = ath_regd_get_eepromRD(reg);
+       reg->country_code = ath_regd_get_default_country(regdmn);
 
        if (reg->country_code == CTRY_DEFAULT &&
            regdmn == CTRY_DEFAULT)
        if (reg->country_code == CTRY_DEFAULT) {
                country = NULL;
        } else {
-               country = ath9k_regd_find_country(reg->country_code);
+               country = ath_regd_find_country(reg->country_code);
                if (country == NULL) {
                        printk(KERN_DEBUG
-                               "ath9k: Country is NULL!!!!, cc= %d\n",
+                               "ath: Country is NULL!!!!, cc= %d\n",
                                reg->country_code);
                        return -EINVAL;
                } else
                        regdmn = country->regDmnEnum;
        }
 
-       reg->regpair = ath9k_get_regpair(regdmn);
+       reg->regpair = ath_get_regpair(regdmn);
 
        if (!reg->regpair) {
-               printk(KERN_DEBUG "ath9k: "
+               printk(KERN_DEBUG "ath: "
                        "No regulatory domain pair found, cannot continue\n");
                return -EINVAL;
        }
 
        if (!country)
-               country = ath9k_regd_find_country_by_rd(regdmn);
+               country = ath_regd_find_country_by_rd(regdmn);
 
        if (country) {
                reg->alpha2[0] = country->isoName[0];
                reg->alpha2[1] = '0';
        }
 
-       printk(KERN_DEBUG "ath9k: Country alpha2 being used: %c%c\n",
+       printk(KERN_DEBUG "ath: Country alpha2 being used: %c%c\n",
                reg->alpha2[0], reg->alpha2[1]);
-       printk(KERN_DEBUG "ath9k: Regpair detected: 0x%0x\n",
+       printk(KERN_DEBUG "ath: Regpair detected: 0x%0x\n",
                reg->regpair->regDmnEnum);
 
        return 0;
 }
+EXPORT_SYMBOL(ath_regd_init);
 
-static
-u32 ath9k_regd_get_band_ctl(struct ath9k_regulatory *reg,
-       enum ieee80211_band band)
+u32 ath_regd_get_band_ctl(struct ath_regulatory *reg,
+                         enum ieee80211_band band)
 {
        if (!reg->regpair ||
            (reg->country_code == CTRY_DEFAULT &&
-            is_wwr_sku(ath9k_regd_get_eepromRD(reg)))) {
+            is_wwr_sku(ath_regd_get_eepromRD(reg)))) {
                return SD_NO_CTL;
        }
 
 
        return NO_CTL;
 }
-
-u32 ath9k_regd_get_ctl(struct ath9k_regulatory *reg, struct ath9k_channel *chan)
-{
-       u32 ctl = ath9k_regd_get_band_ctl(reg, chan->chan->band);
-
-       if (IS_CHAN_B(chan))
-               ctl |= CTL_11B;
-       else if (IS_CHAN_G(chan))
-               ctl |= CTL_11G;
-       else
-               ctl |= CTL_11A;
-
-       return ctl;
-}
+EXPORT_SYMBOL(ath_regd_get_band_ctl);
 
        for (i = 0; i < sc->keymax; i++)
                ath9k_hw_keyreset(ah, (u16) i);
 
-       if (ath9k_regd_init(&sc->sc_ah->regulatory))
+       if (ath_regd_init(&sc->sc_ah->regulatory))
                goto bad;
 
        /* default to MONITOR mode */
        return error;
 }
 
+static int ath9k_reg_notifier(struct wiphy *wiphy,
+                             struct regulatory_request *request)
+{
+       struct ieee80211_hw *hw = wiphy_to_ieee80211_hw(wiphy);
+       struct ath_wiphy *aphy = hw->priv;
+       struct ath_softc *sc = aphy->sc;
+       struct ath_regulatory *reg = &sc->sc_ah->regulatory;
+
+       return ath_reg_notifier_apply(wiphy, request, reg);
+}
+
 void ath_set_hw_capab(struct ath_softc *sc, struct ieee80211_hw *hw)
 {
        hw->flags = IEEE80211_HW_RX_INCLUDES_FCS |
        struct ieee80211_hw *hw = sc->hw;
        const struct ieee80211_regdomain *regd;
        int error = 0, i;
-       struct ath9k_regulatory *reg;
+       struct ath_regulatory *reg;
 
        DPRINTF(sc, ATH_DBG_CONFIG, "Attach ATH hw\n");
 
                goto error_attach;
 #endif
 
-       if (ath9k_is_world_regd(reg)) {
+       if (ath_is_world_regd(reg)) {
                /* Anything applied here (prior to wiphy registration) gets
                 * saved on the wiphy orig_* parameters */
-               regd = ath9k_world_regdomain(reg);
+               regd = ath_world_regdomain(reg);
                hw->wiphy->custom_regulatory = true;
                hw->wiphy->strict_regulatory = false;
        } else {
                /* This gets applied in the case of the absense of CRDA,
                 * it's our own custom world regulatory domain, similar to
                 * cfg80211's but we enable passive scanning */
-               regd = ath9k_default_world_regdomain();
+               regd = ath_default_world_regdomain();
        }
        wiphy_apply_custom_regulatory(hw->wiphy, regd);
-       ath9k_reg_apply_radar_flags(hw->wiphy);
-       ath9k_reg_apply_world_flags(hw->wiphy,
-                                   NL80211_REGDOM_SET_BY_DRIVER,
-                                   reg);
+       ath_reg_apply_radar_flags(hw->wiphy);
+       ath_reg_apply_world_flags(hw->wiphy,
+                                 NL80211_REGDOM_SET_BY_DRIVER,
+                                 reg);
 
        INIT_WORK(&sc->chan_work, ath9k_wiphy_chan_work);
        INIT_DELAYED_WORK(&sc->wiphy_work, ath9k_wiphy_work);
 
        error = ieee80211_register_hw(hw);
 
-       if (!ath9k_is_world_regd(reg)) {
+       if (!ath_is_world_regd(reg)) {
                error = regulatory_hint(hw->wiphy, reg->alpha2);
                if (error)
                        goto error_attach;