Commit e3bb249b authored by Bob Copeland's avatar Bob Copeland Committed by John W. Linville

ath: move more setup code into ath_regd_init

Setup the wiphy regulatory parameters when first initializing the
Atheros regulatory module.  We can remove five exported symbols this
way and simplify the driver code for both ath5k and ath9k.
Signed-off-by: default avatarBob Copeland <me@bobcopeland.com>
Signed-off-by: default avatarLuis R. Rodriguez <lrodriguez@atheros.com>
Signed-off-by: default avatarJohn W. Linville <linville@tuxdriver.com>
parent 3a702e49
...@@ -126,14 +126,13 @@ bool ath_is_world_regd(struct ath_regulatory *reg) ...@@ -126,14 +126,13 @@ bool ath_is_world_regd(struct ath_regulatory *reg)
} }
EXPORT_SYMBOL(ath_is_world_regd); EXPORT_SYMBOL(ath_is_world_regd);
const struct ieee80211_regdomain *ath_default_world_regdomain(void) static const struct ieee80211_regdomain *ath_default_world_regdomain(void)
{ {
/* this is the most restrictive */ /* this is the most restrictive */
return &ath_world_regdom_64; return &ath_world_regdom_64;
} }
EXPORT_SYMBOL(ath_default_world_regdomain);
const struct static const struct
ieee80211_regdomain *ath_world_regdomain(struct ath_regulatory *reg) ieee80211_regdomain *ath_world_regdomain(struct ath_regulatory *reg)
{ {
switch (reg->regpair->regDmnEnum) { switch (reg->regpair->regDmnEnum) {
...@@ -158,7 +157,6 @@ ieee80211_regdomain *ath_world_regdomain(struct ath_regulatory *reg) ...@@ -158,7 +157,6 @@ ieee80211_regdomain *ath_world_regdomain(struct ath_regulatory *reg)
return ath_default_world_regdomain(); return ath_default_world_regdomain();
} }
} }
EXPORT_SYMBOL(ath_world_regdomain);
/* Frequency is one where radar detection is required */ /* Frequency is one where radar detection is required */
static bool ath_is_radar_freq(u16 center_freq) static bool ath_is_radar_freq(u16 center_freq)
...@@ -285,7 +283,7 @@ static void ath_reg_apply_active_scan_flags( ...@@ -285,7 +283,7 @@ static void ath_reg_apply_active_scan_flags(
} }
/* Always apply Radar/DFS rules on freq range 5260 MHz - 5700 MHz */ /* Always apply Radar/DFS rules on freq range 5260 MHz - 5700 MHz */
void ath_reg_apply_radar_flags(struct wiphy *wiphy) static void ath_reg_apply_radar_flags(struct wiphy *wiphy)
{ {
struct ieee80211_supported_band *sband; struct ieee80211_supported_band *sband;
struct ieee80211_channel *ch; struct ieee80211_channel *ch;
...@@ -316,11 +314,10 @@ void ath_reg_apply_radar_flags(struct wiphy *wiphy) ...@@ -316,11 +314,10 @@ void ath_reg_apply_radar_flags(struct wiphy *wiphy)
IEEE80211_CHAN_PASSIVE_SCAN; IEEE80211_CHAN_PASSIVE_SCAN;
} }
} }
EXPORT_SYMBOL(ath_reg_apply_radar_flags);
void ath_reg_apply_world_flags(struct wiphy *wiphy, static void ath_reg_apply_world_flags(struct wiphy *wiphy,
enum nl80211_reg_initiator initiator, enum nl80211_reg_initiator initiator,
struct ath_regulatory *reg) struct ath_regulatory *reg)
{ {
switch (reg->regpair->regDmnEnum) { switch (reg->regpair->regDmnEnum) {
case 0x60: case 0x60:
...@@ -336,7 +333,6 @@ void ath_reg_apply_world_flags(struct wiphy *wiphy, ...@@ -336,7 +333,6 @@ void ath_reg_apply_world_flags(struct wiphy *wiphy,
} }
return; return;
} }
EXPORT_SYMBOL(ath_reg_apply_world_flags);
int ath_reg_notifier_apply(struct wiphy *wiphy, int ath_reg_notifier_apply(struct wiphy *wiphy,
struct regulatory_request *request, struct ath_regulatory *reg) struct regulatory_request *request, struct ath_regulatory *reg)
...@@ -360,7 +356,7 @@ int ath_reg_notifier_apply(struct wiphy *wiphy, ...@@ -360,7 +356,7 @@ int ath_reg_notifier_apply(struct wiphy *wiphy,
} }
EXPORT_SYMBOL(ath_reg_notifier_apply); EXPORT_SYMBOL(ath_reg_notifier_apply);
bool ath_regd_is_eeprom_valid(struct ath_regulatory *reg) static bool ath_regd_is_eeprom_valid(struct ath_regulatory *reg)
{ {
u16 rd = ath_regd_get_eepromRD(reg); u16 rd = ath_regd_get_eepromRD(reg);
int i; int i;
...@@ -381,7 +377,6 @@ bool ath_regd_is_eeprom_valid(struct ath_regulatory *reg) ...@@ -381,7 +377,6 @@ bool ath_regd_is_eeprom_valid(struct ath_regulatory *reg)
"ath: invalid regulatory domain/country code 0x%x\n", rd); "ath: invalid regulatory domain/country code 0x%x\n", rd);
return false; return false;
} }
EXPORT_SYMBOL(ath_regd_is_eeprom_valid);
/* EEPROM country code to regpair mapping */ /* EEPROM country code to regpair mapping */
static struct country_code_to_enum_rd* static struct country_code_to_enum_rd*
...@@ -438,7 +433,40 @@ ath_get_regpair(int regdmn) ...@@ -438,7 +433,40 @@ ath_get_regpair(int regdmn)
return NULL; return NULL;
} }
int ath_regd_init(struct ath_regulatory *reg) static int ath_regd_init_wiphy(struct ath_regulatory *reg, struct wiphy *wiphy,
int (*reg_notifier)(struct wiphy *wiphy,
struct regulatory_request *request))
{
const struct ieee80211_regdomain *regd;
wiphy->reg_notifier = reg_notifier;
wiphy->strict_regulatory = true;
if (ath_is_world_regd(reg)) {
/*
* Anything applied here (prior to wiphy registration) gets
* saved on the wiphy orig_* parameters
*/
regd = ath_world_regdomain(reg);
wiphy->custom_regulatory = true;
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 = ath_default_world_regdomain();
}
wiphy_apply_custom_regulatory(wiphy, regd);
ath_reg_apply_radar_flags(wiphy);
ath_reg_apply_world_flags(wiphy, NL80211_REGDOM_SET_BY_DRIVER, reg);
return 0;
}
int ath_regd_init(struct ath_regulatory *reg, struct wiphy *wiphy,
int (*reg_notifier)(struct wiphy *wiphy,
struct regulatory_request *request))
{ {
struct country_code_to_enum_rd *country = NULL; struct country_code_to_enum_rd *country = NULL;
u16 regdmn; u16 regdmn;
...@@ -492,6 +520,7 @@ int ath_regd_init(struct ath_regulatory *reg) ...@@ -492,6 +520,7 @@ int ath_regd_init(struct ath_regulatory *reg)
printk(KERN_DEBUG "ath: Regpair detected: 0x%0x\n", printk(KERN_DEBUG "ath: Regpair detected: 0x%0x\n",
reg->regpair->regDmnEnum); reg->regpair->regDmnEnum);
ath_regd_init_wiphy(reg, wiphy, reg_notifier);
return 0; return 0;
} }
EXPORT_SYMBOL(ath_regd_init); EXPORT_SYMBOL(ath_regd_init);
......
...@@ -254,15 +254,9 @@ enum CountryCode { ...@@ -254,15 +254,9 @@ enum CountryCode {
}; };
bool ath_is_world_regd(struct ath_regulatory *reg); bool ath_is_world_regd(struct ath_regulatory *reg);
const int ath_regd_init(struct ath_regulatory *reg, struct wiphy *wiphy,
struct ieee80211_regdomain *ath_world_regdomain(struct ath_regulatory *reg); int (*reg_notifier)(struct wiphy *wiphy,
const struct ieee80211_regdomain *ath_default_world_regdomain(void); struct regulatory_request *request));
void ath_reg_apply_world_flags(struct wiphy *wiphy,
enum nl80211_reg_initiator,
struct ath_regulatory *reg);
void ath_reg_apply_radar_flags(struct wiphy *wiphy);
int ath_regd_init(struct ath_regulatory *reg);
bool ath_regd_is_eeprom_valid(struct ath_regulatory *reg);
u32 ath_regd_get_band_ctl(struct ath_regulatory *reg, u32 ath_regd_get_band_ctl(struct ath_regulatory *reg,
enum ieee80211_band band); enum ieee80211_band band);
int ath_reg_notifier_apply(struct wiphy *wiphy, int ath_reg_notifier_apply(struct wiphy *wiphy,
......
...@@ -1352,6 +1352,17 @@ void ath_detach(struct ath_softc *sc) ...@@ -1352,6 +1352,17 @@ void ath_detach(struct ath_softc *sc)
ath9k_ps_restore(sc); ath9k_ps_restore(sc);
} }
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);
}
static int ath_init(u16 devid, struct ath_softc *sc) static int ath_init(u16 devid, struct ath_softc *sc)
{ {
struct ath_hw *ah = NULL; struct ath_hw *ah = NULL;
...@@ -1406,7 +1417,8 @@ static int ath_init(u16 devid, struct ath_softc *sc) ...@@ -1406,7 +1417,8 @@ static int ath_init(u16 devid, struct ath_softc *sc)
for (i = 0; i < sc->keymax; i++) for (i = 0; i < sc->keymax; i++)
ath9k_hw_keyreset(ah, (u16) i); ath9k_hw_keyreset(ah, (u16) i);
if (ath_regd_init(&sc->sc_ah->regulatory)) if (ath_regd_init(&sc->sc_ah->regulatory, sc->hw->wiphy,
ath9k_reg_notifier))
goto bad; goto bad;
/* default to MONITOR mode */ /* default to MONITOR mode */
...@@ -1570,17 +1582,6 @@ static int ath_init(u16 devid, struct ath_softc *sc) ...@@ -1570,17 +1582,6 @@ static int ath_init(u16 devid, struct ath_softc *sc)
return error; 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) void ath_set_hw_capab(struct ath_softc *sc, struct ieee80211_hw *hw)
{ {
hw->flags = IEEE80211_HW_RX_INCLUDES_FCS | hw->flags = IEEE80211_HW_RX_INCLUDES_FCS |
...@@ -1600,9 +1601,6 @@ void ath_set_hw_capab(struct ath_softc *sc, struct ieee80211_hw *hw) ...@@ -1600,9 +1601,6 @@ void ath_set_hw_capab(struct ath_softc *sc, struct ieee80211_hw *hw)
BIT(NL80211_IFTYPE_ADHOC) | BIT(NL80211_IFTYPE_ADHOC) |
BIT(NL80211_IFTYPE_MESH_POINT); BIT(NL80211_IFTYPE_MESH_POINT);
hw->wiphy->reg_notifier = ath9k_reg_notifier;
hw->wiphy->strict_regulatory = true;
hw->queues = 4; hw->queues = 4;
hw->max_rates = 4; hw->max_rates = 4;
hw->channel_change_time = 5000; hw->channel_change_time = 5000;
...@@ -1623,7 +1621,6 @@ void ath_set_hw_capab(struct ath_softc *sc, struct ieee80211_hw *hw) ...@@ -1623,7 +1621,6 @@ void ath_set_hw_capab(struct ath_softc *sc, struct ieee80211_hw *hw)
int ath_attach(u16 devid, struct ath_softc *sc) int ath_attach(u16 devid, struct ath_softc *sc)
{ {
struct ieee80211_hw *hw = sc->hw; struct ieee80211_hw *hw = sc->hw;
const struct ieee80211_regdomain *regd;
int error = 0, i; int error = 0, i;
struct ath_regulatory *reg; struct ath_regulatory *reg;
...@@ -1667,24 +1664,6 @@ int ath_attach(u16 devid, struct ath_softc *sc) ...@@ -1667,24 +1664,6 @@ int ath_attach(u16 devid, struct ath_softc *sc)
goto error_attach; goto error_attach;
#endif #endif
if (ath_is_world_regd(reg)) {
/* Anything applied here (prior to wiphy registration) gets
* saved on the wiphy orig_* parameters */
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 = ath_default_world_regdomain();
}
wiphy_apply_custom_regulatory(hw->wiphy, regd);
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_WORK(&sc->chan_work, ath9k_wiphy_chan_work);
INIT_DELAYED_WORK(&sc->wiphy_work, ath9k_wiphy_work); INIT_DELAYED_WORK(&sc->wiphy_work, ath9k_wiphy_work);
sc->wiphy_scheduler_int = msecs_to_jiffies(500); sc->wiphy_scheduler_int = msecs_to_jiffies(500);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment