aboutsummaryrefslogtreecommitdiffstats
path: root/drivers
diff options
context:
space:
mode:
authorBob Copeland <me@bobcopeland.com>2009-03-30 22:30:30 -0400
committerJohn W. Linville <linville@tuxdriver.com>2009-04-22 16:54:37 -0400
commite3bb249be89dd387e78ca382d08fad31745edac9 (patch)
tree9050d6502ace74b8c5c3577825d1b91011fce8be /drivers
parent3a702e49c03ba959e3f5bb2b74ec9921a81c8c98 (diff)
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: Bob Copeland <me@bobcopeland.com> Signed-off-by: Luis R. Rodriguez <lrodriguez@atheros.com> Signed-off-by: John W. Linville <linville@tuxdriver.com>
Diffstat (limited to 'drivers')
-rw-r--r--drivers/net/wireless/ath/regd.c55
-rw-r--r--drivers/net/wireless/ath/regd.h12
-rw-r--r--drivers/net/wireless/ath9k/main.c47
3 files changed, 58 insertions, 56 deletions
diff --git a/drivers/net/wireless/ath/regd.c b/drivers/net/wireless/ath/regd.c
index 4d3935b6fbd..3ccf21cceb5 100644
--- a/drivers/net/wireless/ath/regd.c
+++ b/drivers/net/wireless/ath/regd.c
@@ -126,14 +126,13 @@ bool ath_is_world_regd(struct ath_regulatory *reg)
126} 126}
127EXPORT_SYMBOL(ath_is_world_regd); 127EXPORT_SYMBOL(ath_is_world_regd);
128 128
129const struct ieee80211_regdomain *ath_default_world_regdomain(void) 129static const struct ieee80211_regdomain *ath_default_world_regdomain(void)
130{ 130{
131 /* this is the most restrictive */ 131 /* this is the most restrictive */
132 return &ath_world_regdom_64; 132 return &ath_world_regdom_64;
133} 133}
134EXPORT_SYMBOL(ath_default_world_regdomain);
135 134
136const struct 135static const struct
137ieee80211_regdomain *ath_world_regdomain(struct ath_regulatory *reg) 136ieee80211_regdomain *ath_world_regdomain(struct ath_regulatory *reg)
138{ 137{
139 switch (reg->regpair->regDmnEnum) { 138 switch (reg->regpair->regDmnEnum) {
@@ -158,7 +157,6 @@ ieee80211_regdomain *ath_world_regdomain(struct ath_regulatory *reg)
158 return ath_default_world_regdomain(); 157 return ath_default_world_regdomain();
159 } 158 }
160} 159}
161EXPORT_SYMBOL(ath_world_regdomain);
162 160
163/* Frequency is one where radar detection is required */ 161/* Frequency is one where radar detection is required */
164static bool ath_is_radar_freq(u16 center_freq) 162static bool ath_is_radar_freq(u16 center_freq)
@@ -285,7 +283,7 @@ static void ath_reg_apply_active_scan_flags(
285} 283}
286 284
287/* Always apply Radar/DFS rules on freq range 5260 MHz - 5700 MHz */ 285/* Always apply Radar/DFS rules on freq range 5260 MHz - 5700 MHz */
288void ath_reg_apply_radar_flags(struct wiphy *wiphy) 286static void ath_reg_apply_radar_flags(struct wiphy *wiphy)
289{ 287{
290 struct ieee80211_supported_band *sband; 288 struct ieee80211_supported_band *sband;
291 struct ieee80211_channel *ch; 289 struct ieee80211_channel *ch;
@@ -316,11 +314,10 @@ void ath_reg_apply_radar_flags(struct wiphy *wiphy)
316 IEEE80211_CHAN_PASSIVE_SCAN; 314 IEEE80211_CHAN_PASSIVE_SCAN;
317 } 315 }
318} 316}
319EXPORT_SYMBOL(ath_reg_apply_radar_flags);
320 317
321void ath_reg_apply_world_flags(struct wiphy *wiphy, 318static void ath_reg_apply_world_flags(struct wiphy *wiphy,
322 enum nl80211_reg_initiator initiator, 319 enum nl80211_reg_initiator initiator,
323 struct ath_regulatory *reg) 320 struct ath_regulatory *reg)
324{ 321{
325 switch (reg->regpair->regDmnEnum) { 322 switch (reg->regpair->regDmnEnum) {
326 case 0x60: 323 case 0x60:
@@ -336,7 +333,6 @@ void ath_reg_apply_world_flags(struct wiphy *wiphy,
336 } 333 }
337 return; 334 return;
338} 335}
339EXPORT_SYMBOL(ath_reg_apply_world_flags);
340 336
341int ath_reg_notifier_apply(struct wiphy *wiphy, 337int ath_reg_notifier_apply(struct wiphy *wiphy,
342 struct regulatory_request *request, struct ath_regulatory *reg) 338 struct regulatory_request *request, struct ath_regulatory *reg)
@@ -360,7 +356,7 @@ int ath_reg_notifier_apply(struct wiphy *wiphy,
360} 356}
361EXPORT_SYMBOL(ath_reg_notifier_apply); 357EXPORT_SYMBOL(ath_reg_notifier_apply);
362 358
363bool ath_regd_is_eeprom_valid(struct ath_regulatory *reg) 359static bool ath_regd_is_eeprom_valid(struct ath_regulatory *reg)
364{ 360{
365 u16 rd = ath_regd_get_eepromRD(reg); 361 u16 rd = ath_regd_get_eepromRD(reg);
366 int i; 362 int i;
@@ -381,7 +377,6 @@ bool ath_regd_is_eeprom_valid(struct ath_regulatory *reg)
381 "ath: invalid regulatory domain/country code 0x%x\n", rd); 377 "ath: invalid regulatory domain/country code 0x%x\n", rd);
382 return false; 378 return false;
383} 379}
384EXPORT_SYMBOL(ath_regd_is_eeprom_valid);
385 380
386/* EEPROM country code to regpair mapping */ 381/* EEPROM country code to regpair mapping */
387static struct country_code_to_enum_rd* 382static struct country_code_to_enum_rd*
@@ -438,7 +433,40 @@ ath_get_regpair(int regdmn)
438 return NULL; 433 return NULL;
439} 434}
440 435
441int ath_regd_init(struct ath_regulatory *reg) 436static int ath_regd_init_wiphy(struct ath_regulatory *reg, struct wiphy *wiphy,
437 int (*reg_notifier)(struct wiphy *wiphy,
438 struct regulatory_request *request))
439{
440 const struct ieee80211_regdomain *regd;
441
442 wiphy->reg_notifier = reg_notifier;
443 wiphy->strict_regulatory = true;
444
445 if (ath_is_world_regd(reg)) {
446 /*
447 * Anything applied here (prior to wiphy registration) gets
448 * saved on the wiphy orig_* parameters
449 */
450 regd = ath_world_regdomain(reg);
451 wiphy->custom_regulatory = true;
452 wiphy->strict_regulatory = false;
453 } else {
454 /*
455 * This gets applied in the case of the absense of CRDA,
456 * it's our own custom world regulatory domain, similar to
457 * cfg80211's but we enable passive scanning.
458 */
459 regd = ath_default_world_regdomain();
460 }
461 wiphy_apply_custom_regulatory(wiphy, regd);
462 ath_reg_apply_radar_flags(wiphy);
463 ath_reg_apply_world_flags(wiphy, NL80211_REGDOM_SET_BY_DRIVER, reg);
464 return 0;
465}
466
467int ath_regd_init(struct ath_regulatory *reg, struct wiphy *wiphy,
468 int (*reg_notifier)(struct wiphy *wiphy,
469 struct regulatory_request *request))
442{ 470{
443 struct country_code_to_enum_rd *country = NULL; 471 struct country_code_to_enum_rd *country = NULL;
444 u16 regdmn; 472 u16 regdmn;
@@ -492,6 +520,7 @@ int ath_regd_init(struct ath_regulatory *reg)
492 printk(KERN_DEBUG "ath: Regpair detected: 0x%0x\n", 520 printk(KERN_DEBUG "ath: Regpair detected: 0x%0x\n",
493 reg->regpair->regDmnEnum); 521 reg->regpair->regDmnEnum);
494 522
523 ath_regd_init_wiphy(reg, wiphy, reg_notifier);
495 return 0; 524 return 0;
496} 525}
497EXPORT_SYMBOL(ath_regd_init); 526EXPORT_SYMBOL(ath_regd_init);
diff --git a/drivers/net/wireless/ath/regd.h b/drivers/net/wireless/ath/regd.h
index 981f5cf2bdb..eba7c7123b5 100644
--- a/drivers/net/wireless/ath/regd.h
+++ b/drivers/net/wireless/ath/regd.h
@@ -254,15 +254,9 @@ enum CountryCode {
254}; 254};
255 255
256bool ath_is_world_regd(struct ath_regulatory *reg); 256bool ath_is_world_regd(struct ath_regulatory *reg);
257const 257int ath_regd_init(struct ath_regulatory *reg, struct wiphy *wiphy,
258struct ieee80211_regdomain *ath_world_regdomain(struct ath_regulatory *reg); 258 int (*reg_notifier)(struct wiphy *wiphy,
259const struct ieee80211_regdomain *ath_default_world_regdomain(void); 259 struct regulatory_request *request));
260void ath_reg_apply_world_flags(struct wiphy *wiphy,
261 enum nl80211_reg_initiator,
262 struct ath_regulatory *reg);
263void ath_reg_apply_radar_flags(struct wiphy *wiphy);
264int ath_regd_init(struct ath_regulatory *reg);
265bool ath_regd_is_eeprom_valid(struct ath_regulatory *reg);
266u32 ath_regd_get_band_ctl(struct ath_regulatory *reg, 260u32 ath_regd_get_band_ctl(struct ath_regulatory *reg,
267 enum ieee80211_band band); 261 enum ieee80211_band band);
268int ath_reg_notifier_apply(struct wiphy *wiphy, 262int ath_reg_notifier_apply(struct wiphy *wiphy,
diff --git a/drivers/net/wireless/ath9k/main.c b/drivers/net/wireless/ath9k/main.c
index d779f00c9b9..8b6a7ea4e59 100644
--- a/drivers/net/wireless/ath9k/main.c
+++ b/drivers/net/wireless/ath9k/main.c
@@ -1352,6 +1352,17 @@ void ath_detach(struct ath_softc *sc)
1352 ath9k_ps_restore(sc); 1352 ath9k_ps_restore(sc);
1353} 1353}
1354 1354
1355static int ath9k_reg_notifier(struct wiphy *wiphy,
1356 struct regulatory_request *request)
1357{
1358 struct ieee80211_hw *hw = wiphy_to_ieee80211_hw(wiphy);
1359 struct ath_wiphy *aphy = hw->priv;
1360 struct ath_softc *sc = aphy->sc;
1361 struct ath_regulatory *reg = &sc->sc_ah->regulatory;
1362
1363 return ath_reg_notifier_apply(wiphy, request, reg);
1364}
1365
1355static int ath_init(u16 devid, struct ath_softc *sc) 1366static int ath_init(u16 devid, struct ath_softc *sc)
1356{ 1367{
1357 struct ath_hw *ah = NULL; 1368 struct ath_hw *ah = NULL;
@@ -1406,7 +1417,8 @@ static int ath_init(u16 devid, struct ath_softc *sc)
1406 for (i = 0; i < sc->keymax; i++) 1417 for (i = 0; i < sc->keymax; i++)
1407 ath9k_hw_keyreset(ah, (u16) i); 1418 ath9k_hw_keyreset(ah, (u16) i);
1408 1419
1409 if (ath_regd_init(&sc->sc_ah->regulatory)) 1420 if (ath_regd_init(&sc->sc_ah->regulatory, sc->hw->wiphy,
1421 ath9k_reg_notifier))
1410 goto bad; 1422 goto bad;
1411 1423
1412 /* default to MONITOR mode */ 1424 /* default to MONITOR mode */
@@ -1570,17 +1582,6 @@ bad:
1570 return error; 1582 return error;
1571} 1583}
1572 1584
1573static int ath9k_reg_notifier(struct wiphy *wiphy,
1574 struct regulatory_request *request)
1575{
1576 struct ieee80211_hw *hw = wiphy_to_ieee80211_hw(wiphy);
1577 struct ath_wiphy *aphy = hw->priv;
1578 struct ath_softc *sc = aphy->sc;
1579 struct ath_regulatory *reg = &sc->sc_ah->regulatory;
1580
1581 return ath_reg_notifier_apply(wiphy, request, reg);
1582}
1583
1584void ath_set_hw_capab(struct ath_softc *sc, struct ieee80211_hw *hw) 1585void ath_set_hw_capab(struct ath_softc *sc, struct ieee80211_hw *hw)
1585{ 1586{
1586 hw->flags = IEEE80211_HW_RX_INCLUDES_FCS | 1587 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 BIT(NL80211_IFTYPE_ADHOC) | 1601 BIT(NL80211_IFTYPE_ADHOC) |
1601 BIT(NL80211_IFTYPE_MESH_POINT); 1602 BIT(NL80211_IFTYPE_MESH_POINT);
1602 1603
1603 hw->wiphy->reg_notifier = ath9k_reg_notifier;
1604 hw->wiphy->strict_regulatory = true;
1605
1606 hw->queues = 4; 1604 hw->queues = 4;
1607 hw->max_rates = 4; 1605 hw->max_rates = 4;
1608 hw->channel_change_time = 5000; 1606 hw->channel_change_time = 5000;
@@ -1623,7 +1621,6 @@ void ath_set_hw_capab(struct ath_softc *sc, struct ieee80211_hw *hw)
1623int ath_attach(u16 devid, struct ath_softc *sc) 1621int ath_attach(u16 devid, struct ath_softc *sc)
1624{ 1622{
1625 struct ieee80211_hw *hw = sc->hw; 1623 struct ieee80211_hw *hw = sc->hw;
1626 const struct ieee80211_regdomain *regd;
1627 int error = 0, i; 1624 int error = 0, i;
1628 struct ath_regulatory *reg; 1625 struct ath_regulatory *reg;
1629 1626
@@ -1667,24 +1664,6 @@ int ath_attach(u16 devid, struct ath_softc *sc)
1667 goto error_attach; 1664 goto error_attach;
1668#endif 1665#endif
1669 1666
1670 if (ath_is_world_regd(reg)) {
1671 /* Anything applied here (prior to wiphy registration) gets
1672 * saved on the wiphy orig_* parameters */
1673 regd = ath_world_regdomain(reg);
1674 hw->wiphy->custom_regulatory = true;
1675 hw->wiphy->strict_regulatory = false;
1676 } else {
1677 /* This gets applied in the case of the absense of CRDA,
1678 * it's our own custom world regulatory domain, similar to
1679 * cfg80211's but we enable passive scanning */
1680 regd = ath_default_world_regdomain();
1681 }
1682 wiphy_apply_custom_regulatory(hw->wiphy, regd);
1683 ath_reg_apply_radar_flags(hw->wiphy);
1684 ath_reg_apply_world_flags(hw->wiphy,
1685 NL80211_REGDOM_SET_BY_DRIVER,
1686 reg);
1687
1688 INIT_WORK(&sc->chan_work, ath9k_wiphy_chan_work); 1667 INIT_WORK(&sc->chan_work, ath9k_wiphy_chan_work);
1689 INIT_DELAYED_WORK(&sc->wiphy_work, ath9k_wiphy_work); 1668 INIT_DELAYED_WORK(&sc->wiphy_work, ath9k_wiphy_work);
1690 sc->wiphy_scheduler_int = msecs_to_jiffies(500); 1669 sc->wiphy_scheduler_int = msecs_to_jiffies(500);