From 2d17b67c28e8b1279b53c09881259cd819336fab Mon Sep 17 00:00:00 2001
From: Felix Fietkau <nbd@openwrt.org>
Date: Sat, 7 Jan 2012 20:54:33 +0000
Subject: [PATCH] ath9k: merge a channel change fix from linux-wireless

SVN-Revision: 29684
---
 .../mac80211/patches/300-pending_work.patch   | 38 +++++++++++++++++--
 .../patches/513-ath9k_channelbw_debugfs.patch | 10 ++---
 .../patches/531-ath9k_cur_txpower.patch       |  4 +-
 .../patches/580-ath9k_extra_leds.patch        |  6 +--
 4 files changed, 45 insertions(+), 13 deletions(-)

diff --git a/package/mac80211/patches/300-pending_work.patch b/package/mac80211/patches/300-pending_work.patch
index 1b7f41b19a..eb09e03e1c 100644
--- a/package/mac80211/patches/300-pending_work.patch
+++ b/package/mac80211/patches/300-pending_work.patch
@@ -348,7 +348,29 @@
  	}
  
  	/*
-@@ -1752,18 +1708,12 @@ static int ath9k_config(struct ieee80211
+@@ -1678,7 +1634,6 @@ static int ath9k_config(struct ieee80211
+ 
+ 	if (changed & IEEE80211_CONF_CHANGE_CHANNEL) {
+ 		struct ieee80211_channel *curchan = hw->conf.channel;
+-		struct ath9k_channel old_chan;
+ 		int pos = curchan->hw_value;
+ 		int old_pos = -1;
+ 		unsigned long flags;
+@@ -1704,11 +1659,8 @@ static int ath9k_config(struct ieee80211
+ 		 * Preserve the current channel values, before updating
+ 		 * the same channel
+ 		 */
+-		if (old_pos == pos) {
+-			memcpy(&old_chan, &sc->sc_ah->channels[pos],
+-				sizeof(struct ath9k_channel));
+-			ah->curchan = &old_chan;
+-		}
++		if (ah->curchan && (old_pos == pos))
++			ath9k_hw_getnf(ah, ah->curchan);
+ 
+ 		ath9k_cmn_update_ichannel(&sc->sc_ah->channels[pos],
+ 					  curchan, conf->channel_type);
+@@ -1752,18 +1704,12 @@ static int ath9k_config(struct ieee80211
  		ath_dbg(common, ATH_DBG_CONFIG,
  			"Set power: %d\n", conf->power_level);
  		sc->config.txpowlimit = 2 * conf->power_level;
@@ -368,7 +390,7 @@
  
  	return 0;
  }
-@@ -2331,9 +2281,6 @@ static void ath9k_flush(struct ieee80211
+@@ -2331,9 +2277,6 @@ static void ath9k_flush(struct ieee80211
  		return;
  	}
  
@@ -378,7 +400,7 @@
  	for (j = 0; j < timeout; j++) {
  		bool npend = false;
  
-@@ -2351,21 +2298,22 @@ static void ath9k_flush(struct ieee80211
+@@ -2351,21 +2294,22 @@ static void ath9k_flush(struct ieee80211
  		}
  
  		if (!npend)
@@ -1347,3 +1369,13 @@
  	__sta_info_free(local, sta);
  
  	return 0;
+--- a/drivers/net/wireless/ath/ath9k/calib.c
++++ b/drivers/net/wireless/ath/ath9k/calib.c
+@@ -402,6 +402,7 @@ bool ath9k_hw_getnf(struct ath_hw *ah, s
+ 	ah->noise = ath9k_hw_getchan_noise(ah, chan);
+ 	return true;
+ }
++EXPORT_SYMBOL(ath9k_hw_getnf);
+ 
+ void ath9k_init_nfcal_hist_buffer(struct ath_hw *ah,
+ 				  struct ath9k_channel *chan)
diff --git a/package/mac80211/patches/513-ath9k_channelbw_debugfs.patch b/package/mac80211/patches/513-ath9k_channelbw_debugfs.patch
index c5ca0e2b57..ae65b60e1b 100644
--- a/package/mac80211/patches/513-ath9k_channelbw_debugfs.patch
+++ b/package/mac80211/patches/513-ath9k_channelbw_debugfs.patch
@@ -90,19 +90,19 @@
  {
  	struct ath_softc *sc = hw->priv;
  	struct ath_hw *ah = sc->sc_ah;
-@@ -1616,9 +1616,10 @@ static int ath9k_config(struct ieee80211
+@@ -1616,9 +1616,11 @@ static int ath9k_config(struct ieee80211
  
  	if (changed & IEEE80211_CONF_CHANGE_CHANNEL) {
  		struct ieee80211_channel *curchan = hw->conf.channel;
--		struct ath9k_channel old_chan;
-+		struct ath9k_channel old_chan, *hchan;
++		struct ath9k_channel *hchan;
  		int pos = curchan->hw_value;
  		int old_pos = -1;
-+		u32 oldflags;
  		unsigned long flags;
++		u32 oldflags;
  
  		if (ah->curchan)
-@@ -1671,7 +1672,23 @@ static int ath9k_config(struct ieee80211
+ 			old_pos = ah->curchan - &ah->channels[0];
+@@ -1667,7 +1669,23 @@ static int ath9k_config(struct ieee80211
  			memset(&sc->survey[pos], 0, sizeof(struct survey_info));
  		}
  
diff --git a/package/mac80211/patches/531-ath9k_cur_txpower.patch b/package/mac80211/patches/531-ath9k_cur_txpower.patch
index bedfef8fd8..adc5292f80 100644
--- a/package/mac80211/patches/531-ath9k_cur_txpower.patch
+++ b/package/mac80211/patches/531-ath9k_cur_txpower.patch
@@ -1,6 +1,6 @@
 --- a/drivers/net/wireless/ath/ath9k/main.c
 +++ b/drivers/net/wireless/ath/ath9k/main.c
-@@ -1694,6 +1694,8 @@ int ath9k_config(struct ieee80211_hw *hw
+@@ -1691,6 +1691,8 @@ int ath9k_config(struct ieee80211_hw *hw
  			return -EINVAL;
  		}
  
@@ -9,7 +9,7 @@
  		/*
  		 * The most recent snapshot of channel->noisefloor for the old
  		 * channel is only available after the hardware reset. Copy it to
-@@ -1709,6 +1711,7 @@ int ath9k_config(struct ieee80211_hw *hw
+@@ -1706,6 +1708,7 @@ int ath9k_config(struct ieee80211_hw *hw
  		sc->config.txpowlimit = 2 * conf->power_level;
  		ath9k_cmn_update_txpow(ah, sc->curtxpow,
  				       sc->config.txpowlimit, &sc->curtxpow);
diff --git a/package/mac80211/patches/580-ath9k_extra_leds.patch b/package/mac80211/patches/580-ath9k_extra_leds.patch
index a079607241..9569b707d3 100644
--- a/package/mac80211/patches/580-ath9k_extra_leds.patch
+++ b/package/mac80211/patches/580-ath9k_extra_leds.patch
@@ -1,6 +1,6 @@
 --- a/drivers/net/wireless/ath/ath9k/ath9k.h
 +++ b/drivers/net/wireless/ath/ath9k/ath9k.h
-@@ -474,6 +474,9 @@ void ath9k_btcoex_timer_pause(struct ath
+@@ -475,6 +475,9 @@ void ath9k_btcoex_timer_pause(struct ath
  #ifdef CONFIG_MAC80211_LEDS
  void ath_init_leds(struct ath_softc *sc);
  void ath_deinit_leds(struct ath_softc *sc);
@@ -10,7 +10,7 @@
  #else
  static inline void ath_init_leds(struct ath_softc *sc)
  {
-@@ -594,6 +597,13 @@ struct ath9k_vif_iter_data {
+@@ -595,6 +598,13 @@ struct ath9k_vif_iter_data {
  	int nothers;   /* number of vifs not specified above. */
  };
  
@@ -24,7 +24,7 @@
  struct ath_softc {
  	struct ieee80211_hw *hw;
  	struct device *dev;
-@@ -637,9 +647,8 @@ struct ath_softc {
+@@ -638,9 +648,8 @@ struct ath_softc {
  	struct ieee80211_supported_band sbands[IEEE80211_NUM_BANDS];
  
  #ifdef CONFIG_MAC80211_LEDS
-- 
GitLab