cfg80211: remove radar requirements check from cfg80211_can_use_iftype_chan()
authorLuciano Coelho <luciano.coelho@intel.com>
Thu, 20 Feb 2014 14:36:21 +0000 (16:36 +0200)
committerJohannes Berg <johannes.berg@intel.com>
Fri, 21 Feb 2014 08:33:10 +0000 (09:33 +0100)
We don't have to double check whether the parameters passed to
cfg80211_can_use_iftype_chan() are correct.  We should just make sure
they *are* when we call this function.

Remove the radar_detect argument check in
cfg80211_can_use_iftype_chan() to simplify the code.

Signed-off-by: Luciano Coelho <luciano.coelho@intel.com>
[keep braces around a long comment + single statement]
Signed-off-by: Johannes Berg <johannes.berg@intel.com>
net/wireless/ibss.c
net/wireless/mesh.c
net/wireless/util.c

index 1470b90e438f4bf6306be3591fdf6d376676ec5f..349db9ddc0d13737eb84f874bc3b556b61b38026 100644 (file)
@@ -128,12 +128,11 @@ int __cfg80211_join_ibss(struct cfg80211_registered_device *rdev,
 #endif
        check_chan = params->chandef.chan;
        if (params->userspace_handles_dfs) {
-               /* use channel NULL to check for radar even if the current
-                * channel is not a radar channel - it might decide to change
-                * to DFS channel later.
+               /* Check for radar even if the current channel is not
+                * a radar channel - it might decide to change to DFS
+                * channel later.
                 */
                radar_detect_width = BIT(params->chandef.width);
-               check_chan = NULL;
        }
 
        err = cfg80211_can_use_iftype_chan(rdev, wdev, wdev->iftype,
index d42a3fcb2f67ae0fb7a563f07ee74f96fa17fee7..5af5cc6b2c4c2406475a3063a69eef80cc14691f 100644 (file)
@@ -236,6 +236,12 @@ int cfg80211_set_mesh_channel(struct cfg80211_registered_device *rdev,
                if (!netif_running(wdev->netdev))
                        return -ENETDOWN;
 
+               /* cfg80211_can_use_chan() calls
+                * cfg80211_can_use_iftype_chan() with no radar
+                * detection, so if we're trying to use a radar
+                * channel here, something is wrong.
+                */
+               WARN_ON_ONCE(chandef->chan->flags & IEEE80211_CHAN_RADAR);
                err = cfg80211_can_use_chan(rdev, wdev, chandef->chan,
                                            CHAN_MODE_SHARED);
                if (err)
index 780b4546c9c74c133d2de69ddcc352ca0979b8fe..57b3ce7a6b9255df15b5064ac5fd177414a662cc 100644 (file)
@@ -1269,7 +1269,6 @@ int cfg80211_can_use_iftype_chan(struct cfg80211_registered_device *rdev,
        enum cfg80211_chan_mode chmode;
        int num_different_channels = 0;
        int total = 1;
-       bool radar_required = false;
        int i, j;
 
        ASSERT_RTNL();
@@ -1277,35 +1276,7 @@ int cfg80211_can_use_iftype_chan(struct cfg80211_registered_device *rdev,
        if (WARN_ON(hweight32(radar_detect) > 1))
                return -EINVAL;
 
-       switch (iftype) {
-       case NL80211_IFTYPE_ADHOC:
-       case NL80211_IFTYPE_AP:
-       case NL80211_IFTYPE_AP_VLAN:
-       case NL80211_IFTYPE_MESH_POINT:
-       case NL80211_IFTYPE_P2P_GO:
-       case NL80211_IFTYPE_WDS:
-               /* if the interface could potentially choose a DFS channel,
-                * then mark DFS as required.
-                */
-               if (!chan) {
-                       if (chanmode != CHAN_MODE_UNDEFINED && radar_detect)
-                               radar_required = true;
-                       break;
-               }
-               radar_required = !!(chan->flags & IEEE80211_CHAN_RADAR);
-               break;
-       case NL80211_IFTYPE_P2P_CLIENT:
-       case NL80211_IFTYPE_STATION:
-       case NL80211_IFTYPE_P2P_DEVICE:
-       case NL80211_IFTYPE_MONITOR:
-               break;
-       case NUM_NL80211_IFTYPES:
-       case NL80211_IFTYPE_UNSPECIFIED:
-       default:
-               return -EINVAL;
-       }
-
-       if (radar_required && !radar_detect)
+       if (WARN_ON(iftype >= NUM_NL80211_IFTYPES))
                return -EINVAL;
 
        /* Always allow software iftypes */