Commit 0671894f authored by Simon Wunderlich's avatar Simon Wunderlich Committed by John W. Linville

ath9k: use chandef instead of channel_type

To enable support for 5/10 MHz, some internal functions must be
converted from using the (old) channel_type to chandef. This is a good
chance to change all remaining occurences.
Signed-off-by: default avatarSimon Wunderlich <siwu@hrz.tu-chemnitz.de>
Signed-off-by: default avatarMathias Kretschmer <mathias.kretschmer@fokus.fraunhofer.de>
Signed-off-by: default avatarJohn W. Linville <linville@tuxdriver.com>
parent 92367fe7
...@@ -49,37 +49,40 @@ int ath9k_cmn_get_hw_crypto_keytype(struct sk_buff *skb) ...@@ -49,37 +49,40 @@ int ath9k_cmn_get_hw_crypto_keytype(struct sk_buff *skb)
} }
EXPORT_SYMBOL(ath9k_cmn_get_hw_crypto_keytype); EXPORT_SYMBOL(ath9k_cmn_get_hw_crypto_keytype);
static u32 ath9k_get_extchanmode(struct ieee80211_channel *chan, static u32 ath9k_get_extchanmode(struct cfg80211_chan_def *chandef)
enum nl80211_channel_type channel_type)
{ {
u32 chanmode = 0; u32 chanmode = 0;
switch (chan->band) { switch (chandef->chan->band) {
case IEEE80211_BAND_2GHZ: case IEEE80211_BAND_2GHZ:
switch (channel_type) { switch (chandef->width) {
case NL80211_CHAN_NO_HT: case NL80211_CHAN_WIDTH_20_NOHT:
case NL80211_CHAN_HT20: case NL80211_CHAN_WIDTH_20:
chanmode = CHANNEL_G_HT20; chanmode = CHANNEL_G_HT20;
break; break;
case NL80211_CHAN_HT40PLUS: case NL80211_CHAN_WIDTH_40:
chanmode = CHANNEL_G_HT40PLUS; if (chandef->center_freq1 > chandef->chan->center_freq)
chanmode = CHANNEL_G_HT40PLUS;
else
chanmode = CHANNEL_G_HT40MINUS;
break; break;
case NL80211_CHAN_HT40MINUS: default:
chanmode = CHANNEL_G_HT40MINUS;
break; break;
} }
break; break;
case IEEE80211_BAND_5GHZ: case IEEE80211_BAND_5GHZ:
switch (channel_type) { switch (chandef->width) {
case NL80211_CHAN_NO_HT: case NL80211_CHAN_WIDTH_20_NOHT:
case NL80211_CHAN_HT20: case NL80211_CHAN_WIDTH_20:
chanmode = CHANNEL_A_HT20; chanmode = CHANNEL_A_HT20;
break; break;
case NL80211_CHAN_HT40PLUS: case NL80211_CHAN_WIDTH_40:
chanmode = CHANNEL_A_HT40PLUS; if (chandef->center_freq1 > chandef->chan->center_freq)
chanmode = CHANNEL_A_HT40PLUS;
else
chanmode = CHANNEL_A_HT40MINUS;
break; break;
case NL80211_CHAN_HT40MINUS: default:
chanmode = CHANNEL_A_HT40MINUS;
break; break;
} }
break; break;
...@@ -94,13 +97,12 @@ static u32 ath9k_get_extchanmode(struct ieee80211_channel *chan, ...@@ -94,13 +97,12 @@ static u32 ath9k_get_extchanmode(struct ieee80211_channel *chan,
* Update internal channel flags. * Update internal channel flags.
*/ */
void ath9k_cmn_update_ichannel(struct ath9k_channel *ichan, void ath9k_cmn_update_ichannel(struct ath9k_channel *ichan,
struct ieee80211_channel *chan, struct cfg80211_chan_def *chandef)
enum nl80211_channel_type channel_type)
{ {
ichan->channel = chan->center_freq; ichan->channel = chandef->chan->center_freq;
ichan->chan = chan; ichan->chan = chandef->chan;
if (chan->band == IEEE80211_BAND_2GHZ) { if (chandef->chan->band == IEEE80211_BAND_2GHZ) {
ichan->chanmode = CHANNEL_G; ichan->chanmode = CHANNEL_G;
ichan->channelFlags = CHANNEL_2GHZ | CHANNEL_OFDM; ichan->channelFlags = CHANNEL_2GHZ | CHANNEL_OFDM;
} else { } else {
...@@ -108,8 +110,22 @@ void ath9k_cmn_update_ichannel(struct ath9k_channel *ichan, ...@@ -108,8 +110,22 @@ void ath9k_cmn_update_ichannel(struct ath9k_channel *ichan,
ichan->channelFlags = CHANNEL_5GHZ | CHANNEL_OFDM; ichan->channelFlags = CHANNEL_5GHZ | CHANNEL_OFDM;
} }
if (channel_type != NL80211_CHAN_NO_HT) switch (chandef->width) {
ichan->chanmode = ath9k_get_extchanmode(chan, channel_type); case NL80211_CHAN_WIDTH_5:
ichan->channelFlags |= CHANNEL_QUARTER;
break;
case NL80211_CHAN_WIDTH_10:
ichan->channelFlags |= CHANNEL_HALF;
break;
case NL80211_CHAN_WIDTH_20_NOHT:
break;
case NL80211_CHAN_WIDTH_20:
case NL80211_CHAN_WIDTH_40:
ichan->chanmode = ath9k_get_extchanmode(chandef);
break;
default:
WARN_ON(1);
}
} }
EXPORT_SYMBOL(ath9k_cmn_update_ichannel); EXPORT_SYMBOL(ath9k_cmn_update_ichannel);
...@@ -125,8 +141,7 @@ struct ath9k_channel *ath9k_cmn_get_curchannel(struct ieee80211_hw *hw, ...@@ -125,8 +141,7 @@ struct ath9k_channel *ath9k_cmn_get_curchannel(struct ieee80211_hw *hw,
chan_idx = curchan->hw_value; chan_idx = curchan->hw_value;
channel = &ah->channels[chan_idx]; channel = &ah->channels[chan_idx];
ath9k_cmn_update_ichannel(channel, curchan, ath9k_cmn_update_ichannel(channel, &hw->conf.chandef);
cfg80211_get_chandef_type(&hw->conf.chandef));
return channel; return channel;
} }
......
...@@ -44,8 +44,7 @@ ...@@ -44,8 +44,7 @@
int ath9k_cmn_get_hw_crypto_keytype(struct sk_buff *skb); int ath9k_cmn_get_hw_crypto_keytype(struct sk_buff *skb);
void ath9k_cmn_update_ichannel(struct ath9k_channel *ichan, void ath9k_cmn_update_ichannel(struct ath9k_channel *ichan,
struct ieee80211_channel *chan, struct cfg80211_chan_def *chandef);
enum nl80211_channel_type channel_type);
struct ath9k_channel *ath9k_cmn_get_curchannel(struct ieee80211_hw *hw, struct ath9k_channel *ath9k_cmn_get_curchannel(struct ieee80211_hw *hw,
struct ath_hw *ah); struct ath_hw *ah);
int ath9k_cmn_count_streams(unsigned int chainmask, int max); int ath9k_cmn_count_streams(unsigned int chainmask, int max);
......
...@@ -1203,16 +1203,13 @@ static int ath9k_htc_config(struct ieee80211_hw *hw, u32 changed) ...@@ -1203,16 +1203,13 @@ static int ath9k_htc_config(struct ieee80211_hw *hw, u32 changed)
if ((changed & IEEE80211_CONF_CHANGE_CHANNEL) || chip_reset) { if ((changed & IEEE80211_CONF_CHANGE_CHANNEL) || chip_reset) {
struct ieee80211_channel *curchan = hw->conf.chandef.chan; struct ieee80211_channel *curchan = hw->conf.chandef.chan;
enum nl80211_channel_type channel_type =
cfg80211_get_chandef_type(&hw->conf.chandef);
int pos = curchan->hw_value; int pos = curchan->hw_value;
ath_dbg(common, CONFIG, "Set channel: %d MHz\n", ath_dbg(common, CONFIG, "Set channel: %d MHz\n",
curchan->center_freq); curchan->center_freq);
ath9k_cmn_update_ichannel(&priv->ah->channels[pos], ath9k_cmn_update_ichannel(&priv->ah->channels[pos],
hw->conf.chandef.chan, &hw->conf.chandef);
channel_type);
if (ath9k_htc_set_channel(priv, hw, &priv->ah->channels[pos]) < 0) { if (ath9k_htc_set_channel(priv, hw, &priv->ah->channels[pos]) < 0) {
ath_err(common, "Unable to set channel\n"); ath_err(common, "Unable to set channel\n");
......
...@@ -726,13 +726,15 @@ static void ath9k_init_band_txpower(struct ath_softc *sc, int band) ...@@ -726,13 +726,15 @@ static void ath9k_init_band_txpower(struct ath_softc *sc, int band)
struct ieee80211_supported_band *sband; struct ieee80211_supported_band *sband;
struct ieee80211_channel *chan; struct ieee80211_channel *chan;
struct ath_hw *ah = sc->sc_ah; struct ath_hw *ah = sc->sc_ah;
struct cfg80211_chan_def chandef;
int i; int i;
sband = &sc->sbands[band]; sband = &sc->sbands[band];
for (i = 0; i < sband->n_channels; i++) { for (i = 0; i < sband->n_channels; i++) {
chan = &sband->channels[i]; chan = &sband->channels[i];
ah->curchan = &ah->channels[chan->hw_value]; ah->curchan = &ah->channels[chan->hw_value];
ath9k_cmn_update_ichannel(ah->curchan, chan, NL80211_CHAN_HT20); cfg80211_chandef_create(&chandef, chan, NL80211_CHAN_HT20);
ath9k_cmn_update_ichannel(ah->curchan, &chandef);
ath9k_hw_set_txpowerlimit(ah, MAX_RATE_POWER, true); ath9k_hw_set_txpowerlimit(ah, MAX_RATE_POWER, true);
} }
} }
......
...@@ -1201,8 +1201,6 @@ static int ath9k_config(struct ieee80211_hw *hw, u32 changed) ...@@ -1201,8 +1201,6 @@ static int ath9k_config(struct ieee80211_hw *hw, u32 changed)
if ((changed & IEEE80211_CONF_CHANGE_CHANNEL) || reset_channel) { if ((changed & IEEE80211_CONF_CHANGE_CHANNEL) || reset_channel) {
struct ieee80211_channel *curchan = hw->conf.chandef.chan; struct ieee80211_channel *curchan = hw->conf.chandef.chan;
enum nl80211_channel_type channel_type =
cfg80211_get_chandef_type(&conf->chandef);
int pos = curchan->hw_value; int pos = curchan->hw_value;
int old_pos = -1; int old_pos = -1;
unsigned long flags; unsigned long flags;
...@@ -1210,8 +1208,8 @@ static int ath9k_config(struct ieee80211_hw *hw, u32 changed) ...@@ -1210,8 +1208,8 @@ static int ath9k_config(struct ieee80211_hw *hw, u32 changed)
if (ah->curchan) if (ah->curchan)
old_pos = ah->curchan - &ah->channels[0]; old_pos = ah->curchan - &ah->channels[0];
ath_dbg(common, CONFIG, "Set channel: %d MHz type: %d\n", ath_dbg(common, CONFIG, "Set channel: %d MHz width: %d\n",
curchan->center_freq, channel_type); curchan->center_freq, hw->conf.chandef.width);
/* update survey stats for the old channel before switching */ /* update survey stats for the old channel before switching */
spin_lock_irqsave(&common->cc_lock, flags); spin_lock_irqsave(&common->cc_lock, flags);
...@@ -1219,7 +1217,7 @@ static int ath9k_config(struct ieee80211_hw *hw, u32 changed) ...@@ -1219,7 +1217,7 @@ static int ath9k_config(struct ieee80211_hw *hw, u32 changed)
spin_unlock_irqrestore(&common->cc_lock, flags); spin_unlock_irqrestore(&common->cc_lock, flags);
ath9k_cmn_update_ichannel(&sc->sc_ah->channels[pos], ath9k_cmn_update_ichannel(&sc->sc_ah->channels[pos],
curchan, channel_type); &conf->chandef);
/* /*
* If the operating channel changes, change the survey in-use flags * If the operating channel changes, change the survey in-use flags
......
...@@ -1326,8 +1326,8 @@ static void ath_rate_update(void *priv, struct ieee80211_supported_band *sband, ...@@ -1326,8 +1326,8 @@ static void ath_rate_update(void *priv, struct ieee80211_supported_band *sband,
ath_rc_init(sc, priv_sta); ath_rc_init(sc, priv_sta);
ath_dbg(ath9k_hw_common(sc->sc_ah), CONFIG, ath_dbg(ath9k_hw_common(sc->sc_ah), CONFIG,
"Operating HT Bandwidth changed to: %d\n", "Operating Bandwidth changed to: %d\n",
cfg80211_get_chandef_type(&sc->hw->conf.chandef)); sc->hw->conf.chandef.width);
} }
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment