diff options
author | Bob Copeland <me@bobcopeland.com> | 2009-03-30 22:30:28 -0400 |
---|---|---|
committer | John W. Linville <linville@tuxdriver.com> | 2009-04-22 16:54:37 -0400 |
commit | c02cf3738c9dbc446c160b9d49a001eb2be316c8 (patch) | |
tree | 0a119c84972ead9f15752da578105391b31d31d5 /drivers/net/wireless/ath9k/regd.c | |
parent | fc2ada30cacc28c96eabc598d3ef294338d8dcf5 (diff) |
ath9k: pass regd structure directly to regulatory functions
All regulatory information is encapsulated by the ath9k_regulatory
struct, so we can now change all the callers to take that directly
instead of struct ath_hw. This in turn will enable us to move the
regulatory functions to common code also used by ath5k, since both
can use this regulatory struct.
Signed-off-by: Bob Copeland <me@bobcopeland.com>
Acked-by: Luis R. Rodriguez <lrodriguez@atheros.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
Diffstat (limited to 'drivers/net/wireless/ath9k/regd.c')
-rw-r--r-- | drivers/net/wireless/ath9k/regd.c | 118 |
1 files changed, 61 insertions, 57 deletions
diff --git a/drivers/net/wireless/ath9k/regd.c b/drivers/net/wireless/ath9k/regd.c index 43ed35ba95cf..7eaa59e4a7d1 100644 --- a/drivers/net/wireless/ath9k/regd.c +++ b/drivers/net/wireless/ath9k/regd.c | |||
@@ -113,14 +113,14 @@ static inline bool is_wwr_sku(u16 regd) | |||
113 | (regd == WORLD); | 113 | (regd == WORLD); |
114 | } | 114 | } |
115 | 115 | ||
116 | static u16 ath9k_regd_get_eepromRD(struct ath_hw *ah) | 116 | static u16 ath9k_regd_get_eepromRD(struct ath9k_regulatory *reg) |
117 | { | 117 | { |
118 | return ah->regulatory.current_rd & ~WORLDWIDE_ROAMING_FLAG; | 118 | return reg->current_rd & ~WORLDWIDE_ROAMING_FLAG; |
119 | } | 119 | } |
120 | 120 | ||
121 | bool ath9k_is_world_regd(struct ath_hw *ah) | 121 | bool ath9k_is_world_regd(struct ath9k_regulatory *reg) |
122 | { | 122 | { |
123 | return is_wwr_sku(ath9k_regd_get_eepromRD(ah)); | 123 | return is_wwr_sku(ath9k_regd_get_eepromRD(reg)); |
124 | } | 124 | } |
125 | 125 | ||
126 | const struct ieee80211_regdomain *ath9k_default_world_regdomain(void) | 126 | const struct ieee80211_regdomain *ath9k_default_world_regdomain(void) |
@@ -129,9 +129,10 @@ const struct ieee80211_regdomain *ath9k_default_world_regdomain(void) | |||
129 | return &ath9k_world_regdom_64; | 129 | return &ath9k_world_regdom_64; |
130 | } | 130 | } |
131 | 131 | ||
132 | const struct ieee80211_regdomain *ath9k_world_regdomain(struct ath_hw *ah) | 132 | const struct |
133 | ieee80211_regdomain *ath9k_world_regdomain(struct ath9k_regulatory *reg) | ||
133 | { | 134 | { |
134 | switch (ah->regulatory.regpair->regDmnEnum) { | 135 | switch (reg->regpair->regDmnEnum) { |
135 | case 0x60: | 136 | case 0x60: |
136 | case 0x61: | 137 | case 0x61: |
137 | case 0x62: | 138 | case 0x62: |
@@ -312,14 +313,10 @@ void ath9k_reg_apply_radar_flags(struct wiphy *wiphy) | |||
312 | } | 313 | } |
313 | 314 | ||
314 | void ath9k_reg_apply_world_flags(struct wiphy *wiphy, | 315 | void ath9k_reg_apply_world_flags(struct wiphy *wiphy, |
315 | enum nl80211_reg_initiator initiator) | 316 | enum nl80211_reg_initiator initiator, |
317 | struct ath9k_regulatory *reg) | ||
316 | { | 318 | { |
317 | struct ieee80211_hw *hw = wiphy_to_ieee80211_hw(wiphy); | 319 | switch (reg->regpair->regDmnEnum) { |
318 | struct ath_wiphy *aphy = hw->priv; | ||
319 | struct ath_softc *sc = aphy->sc; | ||
320 | struct ath_hw *ah = sc->sc_ah; | ||
321 | |||
322 | switch (ah->regulatory.regpair->regDmnEnum) { | ||
323 | case 0x60: | 320 | case 0x60: |
324 | case 0x63: | 321 | case 0x63: |
325 | case 0x66: | 322 | case 0x66: |
@@ -334,12 +331,9 @@ void ath9k_reg_apply_world_flags(struct wiphy *wiphy, | |||
334 | return; | 331 | return; |
335 | } | 332 | } |
336 | 333 | ||
337 | int ath9k_reg_notifier(struct wiphy *wiphy, struct regulatory_request *request) | 334 | static int ath9k_reg_notifier_apply(struct wiphy *wiphy, |
335 | struct regulatory_request *request, struct ath9k_regulatory *reg) | ||
338 | { | 336 | { |
339 | struct ieee80211_hw *hw = wiphy_to_ieee80211_hw(wiphy); | ||
340 | struct ath_wiphy *aphy = hw->priv; | ||
341 | struct ath_softc *sc = aphy->sc; | ||
342 | |||
343 | /* We always apply this */ | 337 | /* We always apply this */ |
344 | ath9k_reg_apply_radar_flags(wiphy); | 338 | ath9k_reg_apply_radar_flags(wiphy); |
345 | 339 | ||
@@ -349,17 +343,28 @@ int ath9k_reg_notifier(struct wiphy *wiphy, struct regulatory_request *request) | |||
349 | case NL80211_REGDOM_SET_BY_USER: | 343 | case NL80211_REGDOM_SET_BY_USER: |
350 | break; | 344 | break; |
351 | case NL80211_REGDOM_SET_BY_COUNTRY_IE: | 345 | case NL80211_REGDOM_SET_BY_COUNTRY_IE: |
352 | if (ath9k_is_world_regd(sc->sc_ah)) | 346 | if (ath9k_is_world_regd(reg)) |
353 | ath9k_reg_apply_world_flags(wiphy, request->initiator); | 347 | ath9k_reg_apply_world_flags(wiphy, request->initiator, |
348 | reg); | ||
354 | break; | 349 | break; |
355 | } | 350 | } |
356 | 351 | ||
357 | return 0; | 352 | return 0; |
358 | } | 353 | } |
359 | 354 | ||
360 | bool ath9k_regd_is_eeprom_valid(struct ath_hw *ah) | 355 | int ath9k_reg_notifier(struct wiphy *wiphy, struct regulatory_request *request) |
356 | { | ||
357 | struct ieee80211_hw *hw = wiphy_to_ieee80211_hw(wiphy); | ||
358 | struct ath_wiphy *aphy = hw->priv; | ||
359 | struct ath_softc *sc = aphy->sc; | ||
360 | struct ath9k_regulatory *reg = &sc->sc_ah->regulatory; | ||
361 | |||
362 | return ath9k_reg_notifier_apply(wiphy, request, reg); | ||
363 | } | ||
364 | |||
365 | bool ath9k_regd_is_eeprom_valid(struct ath9k_regulatory *reg) | ||
361 | { | 366 | { |
362 | u16 rd = ath9k_regd_get_eepromRD(ah); | 367 | u16 rd = ath9k_regd_get_eepromRD(reg); |
363 | int i; | 368 | int i; |
364 | 369 | ||
365 | if (rd & COUNTRY_ERD_FLAG) { | 370 | if (rd & COUNTRY_ERD_FLAG) { |
@@ -374,8 +379,8 @@ bool ath9k_regd_is_eeprom_valid(struct ath_hw *ah) | |||
374 | if (regDomainPairs[i].regDmnEnum == rd) | 379 | if (regDomainPairs[i].regDmnEnum == rd) |
375 | return true; | 380 | return true; |
376 | } | 381 | } |
377 | DPRINTF(ah->ah_sc, ATH_DBG_REGULATORY, | 382 | printk(KERN_DEBUG |
378 | "invalid regulatory domain/country code 0x%x\n", rd); | 383 | "ath9k: invalid regulatory domain/country code 0x%x\n", rd); |
379 | return false; | 384 | return false; |
380 | } | 385 | } |
381 | 386 | ||
@@ -434,41 +439,40 @@ ath9k_get_regpair(int regdmn) | |||
434 | return NULL; | 439 | return NULL; |
435 | } | 440 | } |
436 | 441 | ||
437 | int ath9k_regd_init(struct ath_hw *ah) | 442 | int ath9k_regd_init(struct ath9k_regulatory *reg) |
438 | { | 443 | { |
439 | struct country_code_to_enum_rd *country = NULL; | 444 | struct country_code_to_enum_rd *country = NULL; |
440 | u16 regdmn; | 445 | u16 regdmn; |
441 | 446 | ||
442 | if (!ath9k_regd_is_eeprom_valid(ah)) { | 447 | if (!ath9k_regd_is_eeprom_valid(reg)) { |
443 | DPRINTF(ah->ah_sc, ATH_DBG_REGULATORY, | 448 | printk(KERN_DEBUG "ath9k: Invalid EEPROM contents\n"); |
444 | "Invalid EEPROM contents\n"); | ||
445 | return -EINVAL; | 449 | return -EINVAL; |
446 | } | 450 | } |
447 | 451 | ||
448 | regdmn = ath9k_regd_get_eepromRD(ah); | 452 | regdmn = ath9k_regd_get_eepromRD(reg); |
449 | ah->regulatory.country_code = ath9k_regd_get_default_country(regdmn); | 453 | reg->country_code = ath9k_regd_get_default_country(regdmn); |
450 | 454 | ||
451 | if (ah->regulatory.country_code == CTRY_DEFAULT && | 455 | if (reg->country_code == CTRY_DEFAULT && |
452 | regdmn == CTRY_DEFAULT) | 456 | regdmn == CTRY_DEFAULT) |
453 | ah->regulatory.country_code = CTRY_UNITED_STATES; | 457 | reg->country_code = CTRY_UNITED_STATES; |
454 | 458 | ||
455 | if (ah->regulatory.country_code == CTRY_DEFAULT) { | 459 | if (reg->country_code == CTRY_DEFAULT) { |
456 | country = NULL; | 460 | country = NULL; |
457 | } else { | 461 | } else { |
458 | country = ath9k_regd_find_country(ah->regulatory.country_code); | 462 | country = ath9k_regd_find_country(reg->country_code); |
459 | if (country == NULL) { | 463 | if (country == NULL) { |
460 | DPRINTF(ah->ah_sc, ATH_DBG_REGULATORY, | 464 | printk(KERN_DEBUG |
461 | "Country is NULL!!!!, cc= %d\n", | 465 | "ath9k: Country is NULL!!!!, cc= %d\n", |
462 | ah->regulatory.country_code); | 466 | reg->country_code); |
463 | return -EINVAL; | 467 | return -EINVAL; |
464 | } else | 468 | } else |
465 | regdmn = country->regDmnEnum; | 469 | regdmn = country->regDmnEnum; |
466 | } | 470 | } |
467 | 471 | ||
468 | ah->regulatory.regpair = ath9k_get_regpair(regdmn); | 472 | reg->regpair = ath9k_get_regpair(regdmn); |
469 | 473 | ||
470 | if (!ah->regulatory.regpair) { | 474 | if (!reg->regpair) { |
471 | DPRINTF(ah->ah_sc, ATH_DBG_FATAL, | 475 | printk(KERN_DEBUG "ath9k: " |
472 | "No regulatory domain pair found, cannot continue\n"); | 476 | "No regulatory domain pair found, cannot continue\n"); |
473 | return -EINVAL; | 477 | return -EINVAL; |
474 | } | 478 | } |
@@ -477,36 +481,36 @@ int ath9k_regd_init(struct ath_hw *ah) | |||
477 | country = ath9k_regd_find_country_by_rd(regdmn); | 481 | country = ath9k_regd_find_country_by_rd(regdmn); |
478 | 482 | ||
479 | if (country) { | 483 | if (country) { |
480 | ah->regulatory.alpha2[0] = country->isoName[0]; | 484 | reg->alpha2[0] = country->isoName[0]; |
481 | ah->regulatory.alpha2[1] = country->isoName[1]; | 485 | reg->alpha2[1] = country->isoName[1]; |
482 | } else { | 486 | } else { |
483 | ah->regulatory.alpha2[0] = '0'; | 487 | reg->alpha2[0] = '0'; |
484 | ah->regulatory.alpha2[1] = '0'; | 488 | reg->alpha2[1] = '0'; |
485 | } | 489 | } |
486 | 490 | ||
487 | DPRINTF(ah->ah_sc, ATH_DBG_REGULATORY, | 491 | printk(KERN_DEBUG "ath9k: Country alpha2 being used: %c%c\n", |
488 | "Country alpha2 being used: %c%c\n" | 492 | reg->alpha2[0], reg->alpha2[1]); |
489 | "Regulatory.Regpair detected: 0x%0x\n", | 493 | printk(KERN_DEBUG "ath9k: Regpair detected: 0x%0x\n", |
490 | ah->regulatory.alpha2[0], ah->regulatory.alpha2[1], | 494 | reg->regpair->regDmnEnum); |
491 | ah->regulatory.regpair->regDmnEnum); | ||
492 | 495 | ||
493 | return 0; | 496 | return 0; |
494 | } | 497 | } |
495 | 498 | ||
496 | static | 499 | static |
497 | u32 ath9k_regd_get_band_ctl(struct ath_hw *ah, enum ieee80211_band band) | 500 | u32 ath9k_regd_get_band_ctl(struct ath9k_regulatory *reg, |
501 | enum ieee80211_band band) | ||
498 | { | 502 | { |
499 | if (!ah->regulatory.regpair || | 503 | if (!reg->regpair || |
500 | (ah->regulatory.country_code == CTRY_DEFAULT && | 504 | (reg->country_code == CTRY_DEFAULT && |
501 | is_wwr_sku(ath9k_regd_get_eepromRD(ah)))) { | 505 | is_wwr_sku(ath9k_regd_get_eepromRD(reg)))) { |
502 | return SD_NO_CTL; | 506 | return SD_NO_CTL; |
503 | } | 507 | } |
504 | 508 | ||
505 | switch (band) { | 509 | switch (band) { |
506 | case IEEE80211_BAND_2GHZ: | 510 | case IEEE80211_BAND_2GHZ: |
507 | return ah->regulatory.regpair->reg_2ghz_ctl; | 511 | return reg->regpair->reg_2ghz_ctl; |
508 | case IEEE80211_BAND_5GHZ: | 512 | case IEEE80211_BAND_5GHZ: |
509 | return ah->regulatory.regpair->reg_5ghz_ctl; | 513 | return reg->regpair->reg_5ghz_ctl; |
510 | default: | 514 | default: |
511 | return NO_CTL; | 515 | return NO_CTL; |
512 | } | 516 | } |
@@ -514,9 +518,9 @@ u32 ath9k_regd_get_band_ctl(struct ath_hw *ah, enum ieee80211_band band) | |||
514 | return NO_CTL; | 518 | return NO_CTL; |
515 | } | 519 | } |
516 | 520 | ||
517 | u32 ath9k_regd_get_ctl(struct ath_hw *ah, struct ath9k_channel *chan) | 521 | u32 ath9k_regd_get_ctl(struct ath9k_regulatory *reg, struct ath9k_channel *chan) |
518 | { | 522 | { |
519 | u32 ctl = ath9k_regd_get_band_ctl(ah, chan->chan->band); | 523 | u32 ctl = ath9k_regd_get_band_ctl(reg, chan->chan->band); |
520 | 524 | ||
521 | if (IS_CHAN_B(chan)) | 525 | if (IS_CHAN_B(chan)) |
522 | ctl |= CTL_11B; | 526 | ctl |= CTL_11B; |