Commit d58e7e37 authored by Johannes Berg's avatar Johannes Berg Committed by John W. Linville

cfg80211: simplify cfg80211_can_beacon_sec_chan API

Change cfg80211_can_beacon_sec_chan() to return true
if there is no secondary channel to simplify all the
current users of it. They all check the channel type
before calling the function because it returns false
if there's no secondary channel.

Also actually document the return value.
Signed-off-by: default avatarJohannes Berg <johannes.berg@intel.com>
Signed-off-by: default avatarJohn W. Linville <linville@tuxdriver.com>
parent 3d9e6e12
...@@ -3359,11 +3359,14 @@ void cfg80211_report_obss_beacon(struct wiphy *wiphy, ...@@ -3359,11 +3359,14 @@ void cfg80211_report_obss_beacon(struct wiphy *wiphy,
const u8 *frame, size_t len, const u8 *frame, size_t len,
int freq, int sig_dbm, gfp_t gfp); int freq, int sig_dbm, gfp_t gfp);
/* /**
* cfg80211_can_beacon_sec_chan - test if ht40 on extension channel can be used * cfg80211_can_beacon_sec_chan - test if ht40 on extension channel can be used
* @wiphy: the wiphy * @wiphy: the wiphy
* @chan: main channel * @chan: main channel
* @channel_type: HT mode * @channel_type: HT mode
*
* This function returns true if there is no secondary channel or the secondary
* channel can be used for beaconing (i.e. is not a radar channel etc.)
*/ */
bool cfg80211_can_beacon_sec_chan(struct wiphy *wiphy, bool cfg80211_can_beacon_sec_chan(struct wiphy *wiphy,
struct ieee80211_channel *chan, struct ieee80211_channel *chan,
......
...@@ -82,8 +82,7 @@ static void __ieee80211_sta_join_ibss(struct ieee80211_sub_if_data *sdata, ...@@ -82,8 +82,7 @@ static void __ieee80211_sta_join_ibss(struct ieee80211_sub_if_data *sdata,
local->oper_channel = chan; local->oper_channel = chan;
channel_type = ifibss->channel_type; channel_type = ifibss->channel_type;
if (channel_type > NL80211_CHAN_HT20 && if (!cfg80211_can_beacon_sec_chan(local->hw.wiphy, chan, channel_type))
!cfg80211_can_beacon_sec_chan(local->hw.wiphy, chan, channel_type))
channel_type = NL80211_CHAN_HT20; channel_type = NL80211_CHAN_HT20;
if (!ieee80211_set_channel_type(local, sdata, channel_type)) { if (!ieee80211_set_channel_type(local, sdata, channel_type)) {
/* can only fail due to HT40+/- mismatch */ /* can only fail due to HT40+/- mismatch */
......
...@@ -60,7 +60,7 @@ bool cfg80211_can_beacon_sec_chan(struct wiphy *wiphy, ...@@ -60,7 +60,7 @@ bool cfg80211_can_beacon_sec_chan(struct wiphy *wiphy,
diff = -20; diff = -20;
break; break;
default: default:
return false; return true;
} }
sec_chan = ieee80211_get_channel(wiphy, chan->center_freq + diff); sec_chan = ieee80211_get_channel(wiphy, chan->center_freq + diff);
...@@ -107,22 +107,12 @@ int cfg80211_set_freq(struct cfg80211_registered_device *rdev, ...@@ -107,22 +107,12 @@ int cfg80211_set_freq(struct cfg80211_registered_device *rdev,
wdev->iftype == NL80211_IFTYPE_AP || wdev->iftype == NL80211_IFTYPE_AP ||
wdev->iftype == NL80211_IFTYPE_AP_VLAN || wdev->iftype == NL80211_IFTYPE_AP_VLAN ||
wdev->iftype == NL80211_IFTYPE_MESH_POINT || wdev->iftype == NL80211_IFTYPE_MESH_POINT ||
wdev->iftype == NL80211_IFTYPE_P2P_GO)) { wdev->iftype == NL80211_IFTYPE_P2P_GO) &&
switch (channel_type) { !cfg80211_can_beacon_sec_chan(&rdev->wiphy, chan, channel_type)) {
case NL80211_CHAN_HT40PLUS:
case NL80211_CHAN_HT40MINUS:
if (!cfg80211_can_beacon_sec_chan(&rdev->wiphy, chan,
channel_type)) {
printk(KERN_DEBUG printk(KERN_DEBUG
"cfg80211: Secondary channel not " "cfg80211: Secondary channel not allowed to beacon\n");
"allowed to initiate communication\n");
return -EINVAL; return -EINVAL;
} }
break;
default:
break;
}
}
result = rdev->ops->set_channel(&rdev->wiphy, result = rdev->ops->set_channel(&rdev->wiphy,
wdev ? wdev->netdev : NULL, wdev ? wdev->netdev : NULL,
......
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