--- a/drivers/net/wireless/ath/ath9k/ath9k.h +++ b/drivers/net/wireless/ath/ath9k/ath9k.h @@ -687,6 +687,7 @@ struct ath_softc { struct ieee80211_hw *hw; struct device *dev; + u32 chan_bw; struct survey_info *cur_survey; struct survey_info survey[ATH9K_NUM_CHANNELS]; @@ -891,6 +892,7 @@ struct fft_sample_ht20 { u8 data[SPECTRAL_HT20_NUM_BINS]; } __packed; +int ath9k_config(struct ieee80211_hw *hw, u32 changed); void ath9k_tasklet(unsigned long data); int ath_cabq_update(struct ath_softc *); --- a/drivers/net/wireless/ath/ath9k/debug.c +++ b/drivers/net/wireless/ath/ath9k/debug.c @@ -2059,6 +2059,50 @@ static const struct file_operations fops .owner = THIS_MODULE }; + +static ssize_t read_file_chan_bw(struct file *file, char __user *user_buf, + size_t count, loff_t *ppos) +{ + struct ath_softc *sc = file->private_data; + char buf[32]; + unsigned int len; + + len = sprintf(buf, "0x%08x\n", sc->chan_bw); + return simple_read_from_buffer(user_buf, count, ppos, buf, len); +} + +static ssize_t write_file_chan_bw(struct file *file, const char __user *user_buf, + size_t count, loff_t *ppos) +{ + struct ath_softc *sc = file->private_data; + unsigned long chan_bw; + char buf[32]; + ssize_t len; + + len = min(count, sizeof(buf) - 1); + if (copy_from_user(buf, user_buf, len)) + return -EFAULT; + + buf[len] = '\0'; + if (strict_strtoul(buf, 0, &chan_bw)) + return -EINVAL; + + sc->chan_bw = chan_bw; + if (!test_bit(SC_OP_INVALID, &sc->sc_flags)) + ath9k_config(sc->hw, IEEE80211_CONF_CHANGE_CHANNEL); + + return count; +} + +static const struct file_operations fops_chanbw = { + .read = read_file_chan_bw, + .write = write_file_chan_bw, + .open = simple_open, + .owner = THIS_MODULE, + .llseek = default_llseek, +}; + + int ath9k_init_debug(struct ath_hw *ah) { struct ath_common *common = ath9k_hw_common(ah); @@ -2078,6 +2122,8 @@ int ath9k_init_debug(struct ath_hw *ah) debugfs_create_file("eeprom", S_IRUSR, sc->debug.debugfs_phy, sc, &fops_eeprom); + debugfs_create_file("chanbw", S_IRUSR | S_IWUSR, sc->debug.debugfs_phy, + sc, &fops_chanbw); debugfs_create_file("dma", S_IRUSR, sc->debug.debugfs_phy, sc, &fops_dma); debugfs_create_file("interrupt", S_IRUSR, sc->debug.debugfs_phy, sc, --- a/drivers/net/wireless/ath/ath9k/main.c +++ b/drivers/net/wireless/ath/ath9k/main.c @@ -1140,7 +1140,7 @@ int ath9k_spectral_scan_config(struct ie return 0; } -static int ath9k_config(struct ieee80211_hw *hw, u32 changed) +int ath9k_config(struct ieee80211_hw *hw, u32 changed) { struct ath_softc *sc = hw->priv; struct ath_hw *ah = sc->sc_ah; @@ -1196,9 +1196,11 @@ static int ath9k_config(struct ieee80211 struct ieee80211_channel *curchan = hw->conf.chandef.chan; enum nl80211_channel_type channel_type = cfg80211_get_chandef_type(&conf->chandef); + struct ath9k_channel *hchan; int pos = curchan->hw_value; int old_pos = -1; unsigned long flags; + u32 oldflags; if (ah->curchan) old_pos = ah->curchan - &ah->channels[0]; @@ -1241,7 +1243,23 @@ static int ath9k_config(struct ieee80211 memset(&sc->survey[pos], 0, sizeof(struct survey_info)); } - if (ath_set_channel(sc, hw, &sc->sc_ah->channels[pos]) < 0) { + hchan = &sc->sc_ah->channels[pos]; + oldflags = hchan->channelFlags; + switch (sc->chan_bw) { + case 5: + hchan->channelFlags &= ~CHANNEL_HALF; + hchan->channelFlags |= CHANNEL_QUARTER; + break; + case 10: + hchan->channelFlags &= ~CHANNEL_QUARTER; + hchan->channelFlags |= CHANNEL_HALF; + break; + default: + hchan->channelFlags &= ~(CHANNEL_HALF | CHANNEL_QUARTER); + break; + } + + if (ath_set_channel(sc, hw, hchan) < 0) { ath_err(common, "Unable to set channel\n"); mutex_unlock(&sc->mutex); ath9k_ps_restore(sc);