Splits original functionality to: * ieee80211_get_superchan * ieee80211_channel_types_are_compatible Prepares for _oper_channel_type_removal. Change-Id: Ic1bd50ad4fde619eb4fdbffdd33c440289071c9a Signed-off-by: Michal Kazior <michal.kazior@xxxxxxxxx> --- net/mac80211/chan.c | 40 ++++++++++++++++++++++++++++------------ 1 files changed, 28 insertions(+), 12 deletions(-) diff --git a/net/mac80211/chan.c b/net/mac80211/chan.c index c76cf72..3234ad1 100644 --- a/net/mac80211/chan.c +++ b/net/mac80211/chan.c @@ -64,16 +64,14 @@ ieee80211_get_channel_mode(struct ieee80211_local *local, return mode; } -bool ieee80211_set_channel_type(struct ieee80211_local *local, - struct ieee80211_sub_if_data *sdata, - enum nl80211_channel_type chantype) +static enum nl80211_channel_type +ieee80211_get_superchan(struct ieee80211_local *local, + struct ieee80211_sub_if_data *sdata) { struct ieee80211_sub_if_data *tmp; enum nl80211_channel_type superchan = NL80211_CHAN_NO_HT; - bool result; mutex_lock(&local->iflist_mtx); - list_for_each_entry(tmp, &local->interfaces, list) { if (tmp == sdata) continue; @@ -99,6 +97,16 @@ bool ieee80211_set_channel_type(struct ieee80211_local *local, break; } } + mutex_unlock(&local->iflist_mtx); + + return superchan; +} + +static bool ieee80211_channel_types_are_compatible( + enum nl80211_channel_type superchan, + enum nl80211_channel_type chantype) +{ + bool result = true; switch (superchan) { case NL80211_CHAN_NO_HT: @@ -121,17 +129,25 @@ bool ieee80211_set_channel_type(struct ieee80211_local *local, if (superchan == chantype) break; result = false; - goto out; + break; } - local->_oper_channel_type = superchan; + return result; +} + +bool ieee80211_set_channel_type(struct ieee80211_local *local, + struct ieee80211_sub_if_data *sdata, + enum nl80211_channel_type chantype) +{ + enum nl80211_channel_type superchan; + superchan = ieee80211_get_superchan(local, sdata); + if (!ieee80211_channel_types_are_compatible(superchan, chantype)) + return false; + + local->_oper_channel_type = superchan; if (sdata) sdata->vif.bss_conf.channel_type = chantype; - result = true; - out: - mutex_unlock(&local->iflist_mtx); - - return result; + return true; } -- 1.7.0.4 -- To unsubscribe from this list: send the line "unsubscribe linux-wireless" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html