aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJohannes Berg <johannes.berg@intel.com>2012-05-16 17:50:17 -0400
committerJohn W. Linville <linville@tuxdriver.com>2012-06-05 15:32:16 -0400
commitd58e7e37aac0465b08527adadc8016421bd4060e (patch)
treee0a06894e131012e97a892704970ab0b8b1141f2
parent3d9e6e12077d2611749ba3145bc4934aae461425 (diff)
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: Johannes Berg <johannes.berg@intel.com> Signed-off-by: John W. Linville <linville@tuxdriver.com>
-rw-r--r--include/net/cfg80211.h5
-rw-r--r--net/mac80211/ibss.c3
-rw-r--r--net/wireless/chan.c22
3 files changed, 11 insertions, 19 deletions
diff --git a/include/net/cfg80211.h b/include/net/cfg80211.h
index 0289d4ce7070..a8496f4ff5f1 100644
--- a/include/net/cfg80211.h
+++ b/include/net/cfg80211.h
@@ -3359,11 +3359,14 @@ void cfg80211_report_obss_beacon(struct wiphy *wiphy,
3359 const u8 *frame, size_t len, 3359 const u8 *frame, size_t len,
3360 int freq, int sig_dbm, gfp_t gfp); 3360 int freq, int sig_dbm, gfp_t gfp);
3361 3361
3362/* 3362/**
3363 * cfg80211_can_beacon_sec_chan - test if ht40 on extension channel can be used 3363 * cfg80211_can_beacon_sec_chan - test if ht40 on extension channel can be used
3364 * @wiphy: the wiphy 3364 * @wiphy: the wiphy
3365 * @chan: main channel 3365 * @chan: main channel
3366 * @channel_type: HT mode 3366 * @channel_type: HT mode
3367 *
3368 * This function returns true if there is no secondary channel or the secondary
3369 * channel can be used for beaconing (i.e. is not a radar channel etc.)
3367 */ 3370 */
3368bool cfg80211_can_beacon_sec_chan(struct wiphy *wiphy, 3371bool cfg80211_can_beacon_sec_chan(struct wiphy *wiphy,
3369 struct ieee80211_channel *chan, 3372 struct ieee80211_channel *chan,
diff --git a/net/mac80211/ibss.c b/net/mac80211/ibss.c
index 0bc47a825692..725cb4be229d 100644
--- a/net/mac80211/ibss.c
+++ b/net/mac80211/ibss.c
@@ -82,8 +82,7 @@ static void __ieee80211_sta_join_ibss(struct ieee80211_sub_if_data *sdata,
82 82
83 local->oper_channel = chan; 83 local->oper_channel = chan;
84 channel_type = ifibss->channel_type; 84 channel_type = ifibss->channel_type;
85 if (channel_type > NL80211_CHAN_HT20 && 85 if (!cfg80211_can_beacon_sec_chan(local->hw.wiphy, chan, channel_type))
86 !cfg80211_can_beacon_sec_chan(local->hw.wiphy, chan, channel_type))
87 channel_type = NL80211_CHAN_HT20; 86 channel_type = NL80211_CHAN_HT20;
88 if (!ieee80211_set_channel_type(local, sdata, channel_type)) { 87 if (!ieee80211_set_channel_type(local, sdata, channel_type)) {
89 /* can only fail due to HT40+/- mismatch */ 88 /* can only fail due to HT40+/- mismatch */
diff --git a/net/wireless/chan.c b/net/wireless/chan.c
index 884801ac4dd0..20b87d895722 100644
--- a/net/wireless/chan.c
+++ b/net/wireless/chan.c
@@ -60,7 +60,7 @@ bool cfg80211_can_beacon_sec_chan(struct wiphy *wiphy,
60 diff = -20; 60 diff = -20;
61 break; 61 break;
62 default: 62 default:
63 return false; 63 return true;
64 } 64 }
65 65
66 sec_chan = ieee80211_get_channel(wiphy, chan->center_freq + diff); 66 sec_chan = ieee80211_get_channel(wiphy, chan->center_freq + diff);
@@ -107,21 +107,11 @@ int cfg80211_set_freq(struct cfg80211_registered_device *rdev,
107 wdev->iftype == NL80211_IFTYPE_AP || 107 wdev->iftype == NL80211_IFTYPE_AP ||
108 wdev->iftype == NL80211_IFTYPE_AP_VLAN || 108 wdev->iftype == NL80211_IFTYPE_AP_VLAN ||
109 wdev->iftype == NL80211_IFTYPE_MESH_POINT || 109 wdev->iftype == NL80211_IFTYPE_MESH_POINT ||
110 wdev->iftype == NL80211_IFTYPE_P2P_GO)) { 110 wdev->iftype == NL80211_IFTYPE_P2P_GO) &&
111 switch (channel_type) { 111 !cfg80211_can_beacon_sec_chan(&rdev->wiphy, chan, channel_type)) {
112 case NL80211_CHAN_HT40PLUS: 112 printk(KERN_DEBUG
113 case NL80211_CHAN_HT40MINUS: 113 "cfg80211: Secondary channel not allowed to beacon\n");
114 if (!cfg80211_can_beacon_sec_chan(&rdev->wiphy, chan, 114 return -EINVAL;
115 channel_type)) {
116 printk(KERN_DEBUG
117 "cfg80211: Secondary channel not "
118 "allowed to initiate communication\n");
119 return -EINVAL;
120 }
121 break;
122 default:
123 break;
124 }
125 } 115 }
126 116
127 result = rdev->ops->set_channel(&rdev->wiphy, 117 result = rdev->ops->set_channel(&rdev->wiphy,