aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRajkumar Manoharan <rmanoharan@atheros.com>2011-01-31 13:17:44 -0500
committerJohn W. Linville <linville@tuxdriver.com>2011-02-03 16:44:43 -0500
commit5048e8c378d095a548fe8a6ecd2f07d277ac5be2 (patch)
treed396e3226b9ac0425fbef775566130f72f0c7da2
parentc344c9cb01d1dc65f2d5c85f22790e7f01d7dcd8 (diff)
ath9k: move update tx power to common
move ath_update_txpow to common to remove code duplication in both ath9k & ath9k_htc. Signed-off-by: Rajkumar Manoharan <rmanoharan@atheros.com> Signed-off-by: John W. Linville <linville@tuxdriver.com>
-rw-r--r--drivers/net/wireless/ath/ath9k/common.c11
-rw-r--r--drivers/net/wireless/ath/ath9k/common.h2
-rw-r--r--drivers/net/wireless/ath/ath9k/main.c26
3 files changed, 23 insertions, 16 deletions
diff --git a/drivers/net/wireless/ath/ath9k/common.c b/drivers/net/wireless/ath/ath9k/common.c
index df1998d48253..615e68276e72 100644
--- a/drivers/net/wireless/ath/ath9k/common.c
+++ b/drivers/net/wireless/ath/ath9k/common.c
@@ -189,6 +189,17 @@ void ath9k_cmn_btcoex_bt_stomp(struct ath_common *common,
189} 189}
190EXPORT_SYMBOL(ath9k_cmn_btcoex_bt_stomp); 190EXPORT_SYMBOL(ath9k_cmn_btcoex_bt_stomp);
191 191
192void ath9k_cmn_update_txpow(struct ath_hw *ah, u16 cur_txpow,
193 u16 new_txpow, u16 *txpower)
194{
195 if (cur_txpow != new_txpow) {
196 ath9k_hw_set_txpowerlimit(ah, new_txpow, false);
197 /* read back in case value is clamped */
198 *txpower = ath9k_hw_regulatory(ah)->power_limit;
199 }
200}
201EXPORT_SYMBOL(ath9k_cmn_update_txpow);
202
192static int __init ath9k_cmn_init(void) 203static int __init ath9k_cmn_init(void)
193{ 204{
194 return 0; 205 return 0;
diff --git a/drivers/net/wireless/ath/ath9k/common.h b/drivers/net/wireless/ath/ath9k/common.h
index 4c7020b3a5a0..b2f7b5f89097 100644
--- a/drivers/net/wireless/ath/ath9k/common.h
+++ b/drivers/net/wireless/ath/ath9k/common.h
@@ -68,3 +68,5 @@ struct ath9k_channel *ath9k_cmn_get_curchannel(struct ieee80211_hw *hw,
68int ath9k_cmn_count_streams(unsigned int chainmask, int max); 68int ath9k_cmn_count_streams(unsigned int chainmask, int max);
69void ath9k_cmn_btcoex_bt_stomp(struct ath_common *common, 69void ath9k_cmn_btcoex_bt_stomp(struct ath_common *common,
70 enum ath_stomp_type stomp_type); 70 enum ath_stomp_type stomp_type);
71void ath9k_cmn_update_txpow(struct ath_hw *ah, u16 cur_txpow,
72 u16 new_txpow, u16 *txpower);
diff --git a/drivers/net/wireless/ath/ath9k/main.c b/drivers/net/wireless/ath/ath9k/main.c
index 048eaef11f4a..09eb0265b312 100644
--- a/drivers/net/wireless/ath/ath9k/main.c
+++ b/drivers/net/wireless/ath/ath9k/main.c
@@ -18,17 +18,6 @@
18#include "ath9k.h" 18#include "ath9k.h"
19#include "btcoex.h" 19#include "btcoex.h"
20 20
21static void ath_update_txpow(struct ath_softc *sc)
22{
23 struct ath_hw *ah = sc->sc_ah;
24
25 if (sc->curtxpow != sc->config.txpowlimit) {
26 ath9k_hw_set_txpowerlimit(ah, sc->config.txpowlimit, false);
27 /* read back in case value is clamped */
28 sc->curtxpow = ath9k_hw_regulatory(ah)->power_limit;
29 }
30}
31
32static u8 parse_mpdudensity(u8 mpdudensity) 21static u8 parse_mpdudensity(u8 mpdudensity)
33{ 22{
34 /* 23 /*
@@ -271,7 +260,8 @@ int ath_set_channel(struct ath_softc *sc, struct ieee80211_hw *hw,
271 goto ps_restore; 260 goto ps_restore;
272 } 261 }
273 262
274 ath_update_txpow(sc); 263 ath9k_cmn_update_txpow(ah, sc->curtxpow,
264 sc->config.txpowlimit, &sc->curtxpow);
275 ath9k_hw_set_interrupts(ah, ah->imask); 265 ath9k_hw_set_interrupts(ah, ah->imask);
276 266
277 if (!(sc->sc_flags & (SC_OP_OFFCHANNEL))) { 267 if (!(sc->sc_flags & (SC_OP_OFFCHANNEL))) {
@@ -863,7 +853,8 @@ void ath_radio_enable(struct ath_softc *sc, struct ieee80211_hw *hw)
863 channel->center_freq, r); 853 channel->center_freq, r);
864 } 854 }
865 855
866 ath_update_txpow(sc); 856 ath9k_cmn_update_txpow(ah, sc->curtxpow,
857 sc->config.txpowlimit, &sc->curtxpow);
867 if (ath_startrecv(sc) != 0) { 858 if (ath_startrecv(sc) != 0) {
868 ath_err(common, "Unable to restart recv logic\n"); 859 ath_err(common, "Unable to restart recv logic\n");
869 goto out; 860 goto out;
@@ -966,7 +957,8 @@ int ath_reset(struct ath_softc *sc, bool retry_tx)
966 * that changes the channel so update any state that 957 * that changes the channel so update any state that
967 * might change as a result. 958 * might change as a result.
968 */ 959 */
969 ath_update_txpow(sc); 960 ath9k_cmn_update_txpow(ah, sc->curtxpow,
961 sc->config.txpowlimit, &sc->curtxpow);
970 962
971 if ((sc->sc_flags & SC_OP_BEACONS) || !(sc->sc_flags & (SC_OP_OFFCHANNEL))) 963 if ((sc->sc_flags & SC_OP_BEACONS) || !(sc->sc_flags & (SC_OP_OFFCHANNEL)))
972 ath_beacon_config(sc, NULL); /* restart beacons */ 964 ath_beacon_config(sc, NULL); /* restart beacons */
@@ -1042,7 +1034,8 @@ static int ath9k_start(struct ieee80211_hw *hw)
1042 * This is needed only to setup initial state 1034 * This is needed only to setup initial state
1043 * but it's best done after a reset. 1035 * but it's best done after a reset.
1044 */ 1036 */
1045 ath_update_txpow(sc); 1037 ath9k_cmn_update_txpow(ah, sc->curtxpow,
1038 sc->config.txpowlimit, &sc->curtxpow);
1046 1039
1047 /* 1040 /*
1048 * Setup the hardware after reset: 1041 * Setup the hardware after reset:
@@ -1707,7 +1700,8 @@ static int ath9k_config(struct ieee80211_hw *hw, u32 changed)
1707 if (changed & IEEE80211_CONF_CHANGE_POWER) { 1700 if (changed & IEEE80211_CONF_CHANGE_POWER) {
1708 sc->config.txpowlimit = 2 * conf->power_level; 1701 sc->config.txpowlimit = 2 * conf->power_level;
1709 ath9k_ps_wakeup(sc); 1702 ath9k_ps_wakeup(sc);
1710 ath_update_txpow(sc); 1703 ath9k_cmn_update_txpow(ah, sc->curtxpow,
1704 sc->config.txpowlimit, &sc->curtxpow);
1711 ath9k_ps_restore(sc); 1705 ath9k_ps_restore(sc);
1712 } 1706 }
1713 1707