Skip to contentSkip to conversation

ath9k: Move regulatory information to a separate structure

PATCH In review Sujith 2 participants 2 messages Feb 9, 2009 – Feb 10, 2009 Networking drivers (wireless)

lore
Share & tools
lore

Sujith

author
#0 lore raw

PATCH 5/10 ath9k: Move regulatory information to a separate structure

---
 drivers/net/wireless/ath9k/eeprom.c |   16 ++++++------
 drivers/net/wireless/ath9k/hw.c     |   37 ++++++++++++++-------------
 drivers/net/wireless/ath9k/hw.h     |   12 +-------
 drivers/net/wireless/ath9k/main.c   |    2 +-
 drivers/net/wireless/ath9k/regd.c   |   48 +++++++++++++++++-----------------
 drivers/net/wireless/ath9k/regd.h   |   12 ++++++++
 6 files changed, 66 insertions(+), 61 deletions(-)
drivers/net/wireless/ath9k/eeprom.c +8 -8
index 420a060..d58d8a3 100644
@@ -1232,9 +1232,9 @@ static bool ath9k_hw_set_def_power_per_rate_table(struct ath_hal *ah,
 
 	maxRegAllowedPower = twiceMaxRegulatoryPower + twiceLargestAntenna;
 
-	if (ah->ah_tpScale != ATH9K_TP_SCALE_MAX) {
+	if (ah->regulatory.tp_scale != ATH9K_TP_SCALE_MAX) {
 		maxRegAllowedPower -=
-			(tpScaleReductionTable[(ah->ah_tpScale)] * 2);
+			(tpScaleReductionTable[(ah->regulatory.tp_scale)] * 2);
 	}
 
 	scaledPower = min(powerLimit, maxRegAllowedPower);
@@ -1510,9 +1510,9 @@ static bool ath9k_hw_set_4k_power_per_rate_table(struct ath_hal *ah,
 
 	maxRegAllowedPower = twiceMaxRegulatoryPower + twiceLargestAntenna;
 
-	if (ah->ah_tpScale != ATH9K_TP_SCALE_MAX) {
+	if (ah->regulatory.tp_scale != ATH9K_TP_SCALE_MAX) {
 		maxRegAllowedPower -=
-			(tpScaleReductionTable[(ah->ah_tpScale)] * 2);
+			(tpScaleReductionTable[(ah->regulatory.tp_scale)] * 2);
 	}
 
 	scaledPower = min(powerLimit, maxRegAllowedPower);
@@ -1823,10 +1823,10 @@ static int ath9k_hw_def_set_txpower(struct ath_hal *ah,
 		i = rateHt20_0;
 
 	if (AR_SREV_9280_10_OR_LATER(ah))
-		ah->ah_maxPowerLevel =
+		ah->regulatory.max_power_level =
 			ratesArray[i] + AR5416_PWR_TABLE_OFFSET * 2;
 	else
-		ah->ah_maxPowerLevel = ratesArray[i];
+		ah->regulatory.max_power_level = ratesArray[i];
 
 	return 0;
 }
@@ -1951,10 +1951,10 @@ static int ath9k_hw_4k_set_txpower(struct ath_hal *ah,
 		i = rateHt20_0;
 
 	if (AR_SREV_9280_10_OR_LATER(ah))
-		ah->ah_maxPowerLevel =
+		ah->regulatory.max_power_level =
 			ratesArray[i] + AR5416_PWR_TABLE_OFFSET * 2;
 	else
-		ah->ah_maxPowerLevel = ratesArray[i];
+		ah->regulatory.max_power_level = ratesArray[i];
 
 	return 0;
 }
drivers/net/wireless/ath9k/hw.c +19 -18
index 164a543..9eafada 100644
@@ -409,7 +409,7 @@ static struct ath_hal_5416 *ath9k_hw_newstate(u16 devid,
 	ah->ah_sc = sc;
 	ah->ah_sh = mem;
 	ah->hw_version.magic = AR5416_MAGIC;
-	ah->ah_countryCode = CTRY_DEFAULT;
+	ah->regulatory.country_code = CTRY_DEFAULT;
 	ah->hw_version.devid = devid;
 	ah->hw_version.subvendorid = 0;
 
@@ -419,8 +419,8 @@ static struct ath_hal_5416 *ath9k_hw_newstate(u16 devid,
 	if (!AR_SREV_9100(ah))
 		ah->ah_flags = AH_USE_EEPROM;
 
-	ah->ah_powerLimit = MAX_RATE_POWER;
-	ah->ah_tpScale = ATH9K_TP_SCALE_MAX;
+	ah->regulatory.power_limit = MAX_RATE_POWER;
+	ah->regulatory.tp_scale = ATH9K_TP_SCALE_MAX;
 	ahp->ah_atimWindow = 0;
 	ahp->ah_diversityControl = ah->ah_config.diversity_control;
 	ahp->ah_antennaSwitchSwap =
@@ -1337,7 +1337,7 @@ static int ath9k_hw_process_ini(struct ath_hal *ah,
 				      channel->max_antenna_gain * 2,
 				      channel->max_power * 2,
 				      min((u32) MAX_RATE_POWER,
-					  (u32) ah->ah_powerLimit));
+					  (u32) ah->regulatory.power_limit));
 	if (status != 0) {
 		DPRINTF(ah->ah_sc, ATH_DBG_POWER_MGMT,
 			"error init'ing transmit power\n");
@@ -1668,7 +1668,7 @@ static bool ath9k_hw_channel_change(struct ath_hal *ah,
 				 channel->max_antenna_gain * 2,
 				 channel->max_power * 2,
 				 min((u32) MAX_RATE_POWER,
-				     (u32) ah->ah_powerLimit)) != 0) {
+				     (u32) ah->regulatory.power_limit)) != 0) {
 		DPRINTF(ah->ah_sc, ATH_DBG_EEPROM,
 			"error init'ing transmit power\n");
 		return false;
@@ -3136,21 +3136,22 @@ bool ath9k_hw_fill_cap_info(struct ath_hal *ah)
 
 	eeval = ath9k_hw_get_eeprom(ah, EEP_REG_0);
 
-	ah->ah_currentRD = eeval;
+	ah->regulatory.current_rd = eeval;
 
 	eeval = ath9k_hw_get_eeprom(ah, EEP_REG_1);
-	ah->ah_currentRDExt = eeval;
+	ah->regulatory.current_rd_ext = eeval;
 
 	capField = ath9k_hw_get_eeprom(ah, EEP_OP_CAP);
 
 	if (ah->ah_opmode != NL80211_IFTYPE_AP &&
 	    ah->hw_version.subvendorid == AR_SUBVENDOR_ID_NEW_A) {
-		if (ah->ah_currentRD == 0x64 || ah->ah_currentRD == 0x65)
-			ah->ah_currentRD += 5;
-		else if (ah->ah_currentRD == 0x41)
-			ah->ah_currentRD = 0x43;
+		if (ah->regulatory.current_rd == 0x64 ||
+		    ah->regulatory.current_rd == 0x65)
+			ah->regulatory.current_rd += 5;
+		else if (ah->regulatory.current_rd == 0x41)
+			ah->regulatory.current_rd = 0x43;
 		DPRINTF(ah->ah_sc, ATH_DBG_REGULATORY,
-			"regdomain mapped to 0x%x\n", ah->ah_currentRD);
+			"regdomain mapped to 0x%x\n", ah->regulatory.current_rd);
 	}
 
 	eeval = ath9k_hw_get_eeprom(ah, EEP_OP_MODE);
@@ -3292,7 +3293,7 @@ bool ath9k_hw_fill_cap_info(struct ath_hal *ah)
 	else
 		pCap->hw_caps |= ATH9K_HW_CAP_4KB_SPLITTRANS;
 
-	if (ah->ah_currentRDExt & (1 << REG_EXT_JAPAN_MIDBAND)) {
+	if (ah->regulatory.current_rd_ext & (1 << REG_EXT_JAPAN_MIDBAND)) {
 		pCap->reg_cap =
 			AR_EEPROM_EEREGCAP_EN_KK_NEW_11A |
 			AR_EEPROM_EEREGCAP_EN_KK_U1_EVEN |
@@ -3392,13 +3393,13 @@ bool ath9k_hw_getcapability(struct ath_hal *ah, enum ath9k_capability_type type,
 		case 0:
 			return 0;
 		case 1:
-			*result = ah->ah_powerLimit;
+			*result = ah->regulatory.power_limit;
 			return 0;
 		case 2:
-			*result = ah->ah_maxPowerLevel;
+			*result = ah->regulatory.max_power_level;
 			return 0;
 		case 3:
-			*result = ah->ah_tpScale;
+			*result = ah->regulatory.tp_scale;
 			return 0;
 		}
 		return false;
@@ -3655,14 +3656,14 @@ bool ath9k_hw_set_txpowerlimit(struct ath_hal *ah, u32 limit)
 	struct ath9k_channel *chan = ah->ah_curchan;
 	struct ieee80211_channel *channel = chan->chan;
 
-	ah->ah_powerLimit = min(limit, (u32) MAX_RATE_POWER);
+	ah->regulatory.power_limit = min(limit, (u32) MAX_RATE_POWER);
 
 	if (ath9k_hw_set_txpower(ah, chan,
 				 ath9k_regd_get_ctl(ah, chan),
 				 channel->max_antenna_gain * 2,
 				 channel->max_power * 2,
 				 min((u32) MAX_RATE_POWER,
-				     (u32) ah->ah_powerLimit)) != 0)
+				     (u32) ah->regulatory.power_limit)) != 0)
 		return false;
 
 	return true;
drivers/net/wireless/ath9k/hw.h +2 -10
index afa64bd..3fdf962 100644
@@ -425,17 +425,9 @@ struct ath_hal {
 	enum nl80211_iftype ah_opmode;
 	struct ath9k_ops_config ah_config;
 	struct ath9k_hw_capabilities ah_caps;
-
-	u16 ah_countryCode;
+	struct ath9k_regulatory regulatory;
 	u32 ah_flags;
-	int16_t ah_powerLimit;
-	u16 ah_maxPowerLevel;
-	u32 ah_tpScale;
-	u16 ah_currentRD;
-	u16 ah_currentRDExt;
-	u16 ah_currentRDInUse;
-	char alpha2[2];
-	struct reg_dmn_pair_mapping *regpair;
+
 	enum ath9k_power_mode ah_power_mode;
 	enum ath9k_power_mode ah_restore_mode;
 
drivers/net/wireless/ath9k/main.c +1 -1
index dacf97a..a1c76ec 100644
@@ -1659,7 +1659,7 @@ int ath_attach(u16 devid, struct ath_softc *sc)
 	error = ieee80211_register_hw(hw);
 
 	if (!ath9k_is_world_regd(sc->sc_ah))
-		regulatory_hint(hw->wiphy, sc->sc_ah->alpha2);
+		regulatory_hint(hw->wiphy, sc->sc_ah->regulatory.alpha2);
 
 	/* Initialize LED control */
 	ath_init_leds(sc);
drivers/net/wireless/ath9k/regd.c +24 -24

112 lines not on this page · raw message

drivers/net/wireless/ath9k/regd.h +12 -0
index d1c4457..65abdf4 100644
@@ -45,6 +45,18 @@ struct country_code_to_enum_rd {
 	const char *isoName;
 };
 
+struct ath9k_regulatory {
+	char alpha2[2];
+	u16 country_code;
+	u16 max_power_level;
+	u32 tp_scale;
+	u16 current_rd;
+	u16 current_rd_ext;
+	u16 current_rd_inuse;
+	int16_t power_limit;
+	struct reg_dmn_pair_mapping *regpair;
+};
+
 enum CountryCode {
 	CTRY_ALBANIA = 8,
 	CTRY_ALGERIA = 12,
Signature · 1 line
1.6.1
#1 lore raw
Quoted 10 lines · Sujith
---
 drivers/net/wireless/ath9k/eeprom.c |   16 ++++++------
 drivers/net/wireless/ath9k/hw.c     |   37 ++++++++++++++-------------
 drivers/net/wireless/ath9k/hw.h     |   12 +-------
 drivers/net/wireless/ath9k/main.c   |    2 +-
 drivers/net/wireless/ath9k/regd.c   |   48 +++++++++++++++++-----------------
 drivers/net/wireless/ath9k/regd.h   |   12 ++++++++
 6 files changed, 66 insertions(+), 61 deletions(-)

Heh, I just did this in my own tree, only I called it ah_regdomain. regulatory is better though. (My goal is sharing code with ath5k.)

Signature · 1 line
Bob Copeland %% www.bobcopeland.com