Linux wireless drivers development
 help / color / mirror / Atom feed
From: Bruno Randolf <br1@einfach.org>
To: linville@tuxdriver.com
Cc: ath5k-devel@lists.ath5k.org, linux-wireless@vger.kernel.org,
	mickflemm@gmail.com
Subject: [PATCH 3/5] ath5k: Track current TX power separately from max TX power
Date: Tue, 21 Dec 2010 17:30:32 +0900	[thread overview]
Message-ID: <20101221083032.8765.42449.stgit@localhost6.localdomain6> (raw)
In-Reply-To: <20101221083020.8765.16350.stgit@localhost6.localdomain6>

Add a new variable to keep track of the currently configured tx power. Before
max_pwr was re-used for keeping the maximum allowed power as well as the
current configuration. Doing a min() on it allows you to lower the txpower, but
how would you be able to make it higher again?

This patch fixes that by adding a new variable ah_cur_pwr which is used instead
of txp_max_pwr to keep the current configuration. txp_max_pwr is used to check
if we are within the limits.

Another problem fixed by this patch is that it avoids setting a zero txpower
when things are initialized first and the current power is not yet set.

Signed-off-by: Bruno Randolf <br1@einfach.org>
---
 drivers/net/wireless/ath/ath5k/ath5k.h |    1 +
 drivers/net/wireless/ath/ath5k/phy.c   |    7 +++----
 2 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/drivers/net/wireless/ath/ath5k/ath5k.h b/drivers/net/wireless/ath/ath5k/ath5k.h
index e6491bf..342da28 100644
--- a/drivers/net/wireless/ath/ath5k/ath5k.h
+++ b/drivers/net/wireless/ath/ath5k/ath5k.h
@@ -1107,6 +1107,7 @@ struct ath5k_hw {
 		/* Values in 0.25dB units */
 		s16		txp_min_pwr;
 		s16		txp_max_pwr;
+		s16		txp_cur_pwr;
 		/* Values in 0.5dB units */
 		s16		txp_offset;
 		s16		txp_ofdm;
diff --git a/drivers/net/wireless/ath/ath5k/phy.c b/drivers/net/wireless/ath/ath5k/phy.c
index 6f0cf3a..18c58cd 100644
--- a/drivers/net/wireless/ath/ath5k/phy.c
+++ b/drivers/net/wireless/ath/ath5k/phy.c
@@ -3096,7 +3096,7 @@ ath5k_setup_rate_powertable(struct ath5k_hw *ah, u16 max_pwr,
 
 	/* Min/max in 0.25dB units */
 	ah->ah_txpower.txp_min_pwr = 2 * rates[7];
-	ah->ah_txpower.txp_max_pwr = 2 * rates[0];
+	ah->ah_txpower.txp_cur_pwr = 2 * rates[0];
 	ah->ah_txpower.txp_ofdm = rates[7];
 }
 
@@ -3150,8 +3150,6 @@ ath5k_hw_txpower(struct ath5k_hw *ah, struct ieee80211_channel *channel,
 		/* Reset TX power values */
 		memset(&ah->ah_txpower, 0, sizeof(ah->ah_txpower));
 		ah->ah_txpower.txp_tpc = AR5K_TUNE_TPC_TXPOWER;
-		ah->ah_txpower.txp_min_pwr = 0;
-		ah->ah_txpower.txp_max_pwr = AR5K_TUNE_MAX_TXPOWER;
 
 		/* Calculate the powertable */
 		ret = ath5k_setup_channel_powertable(ah, channel,
@@ -3290,7 +3288,8 @@ int ath5k_hw_phy_init(struct ath5k_hw *ah, struct ieee80211_channel *channel,
 	 * properly set curve indices.
 	 */
 	ret = ath5k_hw_txpower(ah, channel, ee_mode,
-				ah->ah_txpower.txp_max_pwr / 2);
+		ah->ah_txpower.txp_cur_pwr ?
+			ah->ah_txpower.txp_cur_pwr / 2 : AR5K_TUNE_MAX_TXPOWER);
 	if (ret)
 		return ret;
 


  parent reply	other threads:[~2010-12-21  8:30 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-12-21  8:30 [PATCH 1/5] ath5k: Simplify powertable recalculation Bruno Randolf
2010-12-21  8:30 ` [PATCH 2/5] ath5k: Separate powertable setup and writing Bruno Randolf
2010-12-21 14:48   ` Nick Kossifidis
2010-12-21  8:30 ` Bruno Randolf [this message]
2010-12-21 14:48   ` [PATCH 3/5] ath5k: Track current TX power separately from max TX power Nick Kossifidis
2010-12-21  8:30 ` [PATCH 4/5] ath5k: Remove ATH5K_INI_RFGAIN defines, use band instead Bruno Randolf
2010-12-21 14:49   ` Nick Kossifidis
2010-12-21  8:30 ` [PATCH 5/5] ath5k: Use helper function to get eeprom mode from channel Bruno Randolf
2010-12-21 14:49   ` Nick Kossifidis
2010-12-21 14:47 ` [PATCH 1/5] ath5k: Simplify powertable recalculation Nick Kossifidis

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20101221083032.8765.42449.stgit@localhost6.localdomain6 \
    --to=br1@einfach.org \
    --cc=ath5k-devel@lists.ath5k.org \
    --cc=linux-wireless@vger.kernel.org \
    --cc=linville@tuxdriver.com \
    --cc=mickflemm@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox