1 --- a/drivers/net/wireless/ath/ath9k/ath9k.h
2 +++ b/drivers/net/wireless/ath/ath9k/ath9k.h
3 @@ -591,6 +591,7 @@ struct ath_softc {
4 struct ieee80211_hw *hw;
10 struct survey_info *cur_survey;
11 @@ -655,6 +656,7 @@ struct ath_softc {
15 +int ath9k_config(struct ieee80211_hw *hw, u32 changed);
16 void ath9k_tasklet(unsigned long data);
17 int ath_cabq_update(struct ath_softc *);
19 --- a/drivers/net/wireless/ath/ath9k/debug.c
20 +++ b/drivers/net/wireless/ath/ath9k/debug.c
21 @@ -1663,6 +1663,50 @@ static const struct file_operations fops
26 +static ssize_t read_file_chan_bw(struct file *file, char __user *user_buf,
27 + size_t count, loff_t *ppos)
29 + struct ath_softc *sc = file->private_data;
33 + len = sprintf(buf, "0x%08x\n", sc->chan_bw);
34 + return simple_read_from_buffer(user_buf, count, ppos, buf, len);
37 +static ssize_t write_file_chan_bw(struct file *file, const char __user *user_buf,
38 + size_t count, loff_t *ppos)
40 + struct ath_softc *sc = file->private_data;
41 + unsigned long chan_bw;
45 + len = min(count, sizeof(buf) - 1);
46 + if (copy_from_user(buf, user_buf, len))
50 + if (strict_strtoul(buf, 0, &chan_bw))
53 + sc->chan_bw = chan_bw;
54 + if (!(sc->sc_flags & SC_OP_INVALID))
55 + ath9k_config(sc->hw, IEEE80211_CONF_CHANGE_CHANNEL);
60 +static const struct file_operations fops_chanbw = {
61 + .read = read_file_chan_bw,
62 + .write = write_file_chan_bw,
63 + .open = ath9k_debugfs_open,
64 + .owner = THIS_MODULE,
65 + .llseek = default_llseek,
69 int ath9k_init_debug(struct ath_hw *ah)
71 struct ath_common *common = ath9k_hw_common(ah);
72 @@ -1724,6 +1768,9 @@ int ath9k_init_debug(struct ath_hw *ah)
73 debugfs_create_file("eeprom", S_IRUSR, sc->debug.debugfs_phy, sc,
76 + debugfs_create_file("chanbw", S_IRUSR | S_IWUSR, sc->debug.debugfs_phy,
80 memset(&sc->debug.bb_mac_samp, 0, sizeof(sc->debug.bb_mac_samp));
81 sc->debug.sampidx = 0;
82 --- a/drivers/net/wireless/ath/ath9k/main.c
83 +++ b/drivers/net/wireless/ath/ath9k/main.c
84 @@ -1564,7 +1564,7 @@ static void ath9k_disable_ps(struct ath_
88 -static int ath9k_config(struct ieee80211_hw *hw, u32 changed)
89 +int ath9k_config(struct ieee80211_hw *hw, u32 changed)
91 struct ath_softc *sc = hw->priv;
92 struct ath_hw *ah = sc->sc_ah;
93 @@ -1616,9 +1616,10 @@ static int ath9k_config(struct ieee80211
95 if (changed & IEEE80211_CONF_CHANGE_CHANNEL) {
96 struct ieee80211_channel *curchan = hw->conf.channel;
97 - struct ath9k_channel old_chan;
98 + struct ath9k_channel old_chan, *hchan;
99 int pos = curchan->hw_value;
105 @@ -1671,7 +1672,23 @@ static int ath9k_config(struct ieee80211
106 memset(&sc->survey[pos], 0, sizeof(struct survey_info));
109 - if (ath_set_channel(sc, hw, &sc->sc_ah->channels[pos]) < 0) {
110 + hchan = &sc->sc_ah->channels[pos];
111 + oldflags = hchan->channelFlags;
112 + switch (sc->chan_bw) {
114 + hchan->channelFlags &= ~CHANNEL_HALF;
115 + hchan->channelFlags |= CHANNEL_QUARTER;
118 + hchan->channelFlags &= ~CHANNEL_QUARTER;
119 + hchan->channelFlags |= CHANNEL_HALF;
122 + hchan->channelFlags &= ~(CHANNEL_HALF | CHANNEL_QUARTER);
126 + if (ath_set_channel(sc, hw, hchan) < 0) {
127 ath_err(common, "Unable to set channel\n");
128 mutex_unlock(&sc->mutex);
130 --- a/drivers/net/wireless/ath/ath9k/hw.c
131 +++ b/drivers/net/wireless/ath/ath9k/hw.c
132 @@ -1609,6 +1609,10 @@ int ath9k_hw_reset(struct ath_hw *ah, st
133 caldata->rtt_hist.num_readings)
136 + if (!ah->curchan || ((ah->curchan->channelFlags ^ chan->channelFlags) &
137 + (CHANNEL_HALF | CHANNEL_QUARTER)))
138 + bChannelChange = false;
140 if (bChannelChange &&
141 (ah->chip_fullsleep != true) &&
142 (ah->curchan != NULL) &&