cfg80211: simplify cfg80211_can_beacon_sec_chan API
authorJohannes Berg <johannes.berg@intel.com>
Wed, 16 May 2012 21:50:17 +0000 (23:50 +0200)
committerJohn W. Linville <linville@tuxdriver.com>
Tue, 5 Jun 2012 19:32:16 +0000 (15:32 -0400)
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>
include/net/cfg80211.h
net/mac80211/ibss.c
net/wireless/chan.c

index 0289d4ce70706be603059b2ea9fdd63d57aa019e..a8496f4ff5f16d461474c73b83ef45bd465bf89a 100644 (file)
@@ -3359,11 +3359,14 @@ void cfg80211_report_obss_beacon(struct wiphy *wiphy,
                                 const u8 *frame, size_t len,
                                 int freq, int sig_dbm, gfp_t gfp);
 
-/*
+/**
  * cfg80211_can_beacon_sec_chan - test if ht40 on extension channel can be used
  * @wiphy: the wiphy
  * @chan: main channel
  * @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,
                                  struct ieee80211_channel *chan,
index 0bc47a8256925ce2876eb98b617e5c26863a1837..725cb4be229dec4359830a4db5152ace6c56e2e7 100644 (file)
@@ -82,8 +82,7 @@ static void __ieee80211_sta_join_ibss(struct ieee80211_sub_if_data *sdata,
 
        local->oper_channel = chan;
        channel_type = ifibss->channel_type;
-       if (channel_type > NL80211_CHAN_HT20 &&
-           !cfg80211_can_beacon_sec_chan(local->hw.wiphy, chan, channel_type))
+       if (!cfg80211_can_beacon_sec_chan(local->hw.wiphy, chan, channel_type))
                channel_type = NL80211_CHAN_HT20;
        if (!ieee80211_set_channel_type(local, sdata, channel_type)) {
                /* can only fail due to HT40+/- mismatch */
index 884801ac4dd07a24db5b46c3df52fe44d81e2eec..20b87d895722b6190bad6ee87a916b9b49ac6cde 100644 (file)
@@ -60,7 +60,7 @@ bool cfg80211_can_beacon_sec_chan(struct wiphy *wiphy,
                diff = -20;
                break;
        default:
-               return false;
+               return true;
        }
 
        sec_chan = ieee80211_get_channel(wiphy, chan->center_freq + diff);
@@ -107,21 +107,11 @@ int cfg80211_set_freq(struct cfg80211_registered_device *rdev,
                     wdev->iftype == NL80211_IFTYPE_AP ||
                     wdev->iftype == NL80211_IFTYPE_AP_VLAN ||
                     wdev->iftype == NL80211_IFTYPE_MESH_POINT ||
-                    wdev->iftype == NL80211_IFTYPE_P2P_GO)) {
-               switch (channel_type) {
-               case NL80211_CHAN_HT40PLUS:
-               case NL80211_CHAN_HT40MINUS:
-                       if (!cfg80211_can_beacon_sec_chan(&rdev->wiphy, chan,
-                                                         channel_type)) {
-                               printk(KERN_DEBUG
-                                      "cfg80211: Secondary channel not "
-                                      "allowed to initiate communication\n");
-                               return -EINVAL;
-                       }
-                       break;
-               default:
-                       break;
-               }
+                    wdev->iftype == NL80211_IFTYPE_P2P_GO) &&
+           !cfg80211_can_beacon_sec_chan(&rdev->wiphy, chan, channel_type)) {
+               printk(KERN_DEBUG
+                      "cfg80211: Secondary channel not allowed to beacon\n");
+               return -EINVAL;
        }
 
        result = rdev->ops->set_channel(&rdev->wiphy,
This page took 0.034081 seconds and 5 git commands to generate.