From: Reinette Chatre <reinette.chatre@intel.com>
Date: Tue, 29 Jun 2010 14:24:51 -0700
Subject: [PATCH] iwlwifi: fix TX power configuration on 3945 and 4965 devices
Patch-mainline: Probably 2.6.35
References: bnc#619440 bnc#610421

When receiving a TX power change request from mac80211 the functions
servicing these requests for 3945 and 4965 uses information in the active
RXON. In iwl_mac_config the staging RXON is prepared based on various
directions from mac80211 and only at the end is the staging RXON committed
to the device and the active RXON updated.

By servicing the TX power change request while servicing the other requests
that modify the staging RXON we loose the new information provided by mac80211.

Fix this by servicing the TX power change request after the RXON has been committed
to the device and active RXON thus contains accurate information.


21 Jan 2011 jeffm:
This patch may have been superced by 2295c66b68ae160dde2e6e2dc4f3061105153bfc
but needs review.

Signed-off-by: Reinette Chatre <reinette.chatre@intel.com>
Acked-by: Jeff Mahoney <jeffm@suse.com>
---
 drivers/net/wireless/iwlwifi/iwl-core.c |   15 ++++++++-------
 1 file changed, 8 insertions(+), 7 deletions(-)

--- a/drivers/net/wireless/iwlwifi/iwl-core.c
+++ b/drivers/net/wireless/iwlwifi/iwl-core.c
@@ -2160,13 +2160,6 @@ int iwl_mac_config(struct ieee80211_hw *
 			IWL_DEBUG_MAC80211(priv, "Error setting sleep level\n");
 	}
 
-	if (changed & IEEE80211_CONF_CHANGE_POWER) {
-		IWL_DEBUG_MAC80211(priv, "TX Power old=%d new=%d\n",
-			priv->tx_power_user_lmt, conf->power_level);
-
-		iwl_set_tx_power(priv, conf->power_level, false);
-	}
-
 	if (!iwl_is_ready(priv)) {
 		IWL_DEBUG_MAC80211(priv, "leave - not ready\n");
 		goto out;
@@ -2181,6 +2174,14 @@ int iwl_mac_config(struct ieee80211_hw *
				"Not re-sending same RXON configuration.\n");
	}
 
+	if (changed & IEEE80211_CONF_CHANGE_POWER) {
+		IWL_DEBUG_MAC80211(priv, "TX Power old=%d new=%d\n",
+			priv->tx_power_user_lmt, conf->power_level);
+
+		iwl_set_tx_power(priv, conf->power_level, false);
+	}
+
+
 out:
 	IWL_DEBUG_MAC80211(priv, "leave\n");
	mutex_unlock(&priv->mutex);
