Commit eeabee7e authored by Ben Greear's avatar Ben Greear Committed by John W. Linville

mac80211: Be more careful when changing channels.

If we cannot set the channel type, set the channel back to the
original.

Don't update the driver hardware if nothing actually changed.
Signed-off-by: default avatarBen Greear <greearb@candelatech.com>
Signed-off-by: default avatarJohn W. Linville <linville@tuxdriver.com>
parent 75abde4d
...@@ -1215,6 +1215,9 @@ static int ieee80211_set_channel(struct wiphy *wiphy, ...@@ -1215,6 +1215,9 @@ static int ieee80211_set_channel(struct wiphy *wiphy,
{ {
struct ieee80211_local *local = wiphy_priv(wiphy); struct ieee80211_local *local = wiphy_priv(wiphy);
struct ieee80211_sub_if_data *sdata = NULL; struct ieee80211_sub_if_data *sdata = NULL;
struct ieee80211_channel *old_oper;
enum nl80211_channel_type old_oper_type;
enum nl80211_channel_type old_vif_oper_type= NL80211_CHAN_NO_HT;
if (netdev) if (netdev)
sdata = IEEE80211_DEV_TO_SUB_IF(netdev); sdata = IEEE80211_DEV_TO_SUB_IF(netdev);
...@@ -1232,13 +1235,23 @@ static int ieee80211_set_channel(struct wiphy *wiphy, ...@@ -1232,13 +1235,23 @@ static int ieee80211_set_channel(struct wiphy *wiphy,
break; break;
} }
local->oper_channel = chan; if (sdata)
old_vif_oper_type = sdata->vif.bss_conf.channel_type;
old_oper_type = local->_oper_channel_type;
if (!ieee80211_set_channel_type(local, sdata, channel_type)) if (!ieee80211_set_channel_type(local, sdata, channel_type))
return -EBUSY; return -EBUSY;
ieee80211_hw_config(local, IEEE80211_CONF_CHANGE_CHANNEL); old_oper = local->oper_channel;
if (sdata && sdata->vif.type != NL80211_IFTYPE_MONITOR) local->oper_channel = chan;
/* Update driver if changes were actually made. */
if ((old_oper != local->oper_channel) ||
(old_oper_type != local->_oper_channel_type))
ieee80211_hw_config(local, IEEE80211_CONF_CHANGE_CHANNEL);
if ((sdata && sdata->vif.type != NL80211_IFTYPE_MONITOR) &&
old_vif_oper_type != sdata->vif.bss_conf.channel_type)
ieee80211_bss_info_change_notify(sdata, BSS_CHANGED_HT); ieee80211_bss_info_change_notify(sdata, BSS_CHANGED_HT);
return 0; return 0;
......
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