diff options
author | Luciano Coelho <luciano.coelho@intel.com> | 2014-02-20 09:36:21 -0500 |
---|---|---|
committer | Johannes Berg <johannes.berg@intel.com> | 2014-02-21 03:33:10 -0500 |
commit | 7b2106aea2638948806df248215b14efd84c5ffc (patch) | |
tree | 8babafa0ad2b8ea1e1cde737e474e82f7c35f91b | |
parent | e5d2f954714bccd4a87e042720ae8e85f9a0aada (diff) |
cfg80211: remove radar requirements check from cfg80211_can_use_iftype_chan()
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>
-rw-r--r-- | net/wireless/ibss.c | 7 | ||||
-rw-r--r-- | net/wireless/mesh.c | 6 | ||||
-rw-r--r-- | net/wireless/util.c | 31 |
3 files changed, 10 insertions, 34 deletions
diff --git a/net/wireless/ibss.c b/net/wireless/ibss.c index 1470b90e438f..349db9ddc0d1 100644 --- a/net/wireless/ibss.c +++ b/net/wireless/ibss.c | |||
@@ -128,12 +128,11 @@ int __cfg80211_join_ibss(struct cfg80211_registered_device *rdev, | |||
128 | #endif | 128 | #endif |
129 | check_chan = params->chandef.chan; | 129 | check_chan = params->chandef.chan; |
130 | if (params->userspace_handles_dfs) { | 130 | if (params->userspace_handles_dfs) { |
131 | /* use channel NULL to check for radar even if the current | 131 | /* Check for radar even if the current channel is not |
132 | * channel is not a radar channel - it might decide to change | 132 | * a radar channel - it might decide to change to DFS |
133 | * to DFS channel later. | 133 | * channel later. |
134 | */ | 134 | */ |
135 | radar_detect_width = BIT(params->chandef.width); | 135 | radar_detect_width = BIT(params->chandef.width); |
136 | check_chan = NULL; | ||
137 | } | 136 | } |
138 | 137 | ||
139 | err = cfg80211_can_use_iftype_chan(rdev, wdev, wdev->iftype, | 138 | err = cfg80211_can_use_iftype_chan(rdev, wdev, wdev->iftype, |
diff --git a/net/wireless/mesh.c b/net/wireless/mesh.c index d42a3fcb2f67..5af5cc6b2c4c 100644 --- a/net/wireless/mesh.c +++ b/net/wireless/mesh.c | |||
@@ -236,6 +236,12 @@ int cfg80211_set_mesh_channel(struct cfg80211_registered_device *rdev, | |||
236 | if (!netif_running(wdev->netdev)) | 236 | if (!netif_running(wdev->netdev)) |
237 | return -ENETDOWN; | 237 | return -ENETDOWN; |
238 | 238 | ||
239 | /* cfg80211_can_use_chan() calls | ||
240 | * cfg80211_can_use_iftype_chan() with no radar | ||
241 | * detection, so if we're trying to use a radar | ||
242 | * channel here, something is wrong. | ||
243 | */ | ||
244 | WARN_ON_ONCE(chandef->chan->flags & IEEE80211_CHAN_RADAR); | ||
239 | err = cfg80211_can_use_chan(rdev, wdev, chandef->chan, | 245 | err = cfg80211_can_use_chan(rdev, wdev, chandef->chan, |
240 | CHAN_MODE_SHARED); | 246 | CHAN_MODE_SHARED); |
241 | if (err) | 247 | if (err) |
diff --git a/net/wireless/util.c b/net/wireless/util.c index 780b4546c9c7..57b3ce7a6b92 100644 --- a/net/wireless/util.c +++ b/net/wireless/util.c | |||
@@ -1269,7 +1269,6 @@ int cfg80211_can_use_iftype_chan(struct cfg80211_registered_device *rdev, | |||
1269 | enum cfg80211_chan_mode chmode; | 1269 | enum cfg80211_chan_mode chmode; |
1270 | int num_different_channels = 0; | 1270 | int num_different_channels = 0; |
1271 | int total = 1; | 1271 | int total = 1; |
1272 | bool radar_required = false; | ||
1273 | int i, j; | 1272 | int i, j; |
1274 | 1273 | ||
1275 | ASSERT_RTNL(); | 1274 | ASSERT_RTNL(); |
@@ -1277,35 +1276,7 @@ int cfg80211_can_use_iftype_chan(struct cfg80211_registered_device *rdev, | |||
1277 | if (WARN_ON(hweight32(radar_detect) > 1)) | 1276 | if (WARN_ON(hweight32(radar_detect) > 1)) |
1278 | return -EINVAL; | 1277 | return -EINVAL; |
1279 | 1278 | ||
1280 | switch (iftype) { | 1279 | if (WARN_ON(iftype >= NUM_NL80211_IFTYPES)) |
1281 | case NL80211_IFTYPE_ADHOC: | ||
1282 | case NL80211_IFTYPE_AP: | ||
1283 | case NL80211_IFTYPE_AP_VLAN: | ||
1284 | case NL80211_IFTYPE_MESH_POINT: | ||
1285 | case NL80211_IFTYPE_P2P_GO: | ||
1286 | case NL80211_IFTYPE_WDS: | ||
1287 | /* if the interface could potentially choose a DFS channel, | ||
1288 | * then mark DFS as required. | ||
1289 | */ | ||
1290 | if (!chan) { | ||
1291 | if (chanmode != CHAN_MODE_UNDEFINED && radar_detect) | ||
1292 | radar_required = true; | ||
1293 | break; | ||
1294 | } | ||
1295 | radar_required = !!(chan->flags & IEEE80211_CHAN_RADAR); | ||
1296 | break; | ||
1297 | case NL80211_IFTYPE_P2P_CLIENT: | ||
1298 | case NL80211_IFTYPE_STATION: | ||
1299 | case NL80211_IFTYPE_P2P_DEVICE: | ||
1300 | case NL80211_IFTYPE_MONITOR: | ||
1301 | break; | ||
1302 | case NUM_NL80211_IFTYPES: | ||
1303 | case NL80211_IFTYPE_UNSPECIFIED: | ||
1304 | default: | ||
1305 | return -EINVAL; | ||
1306 | } | ||
1307 | |||
1308 | if (radar_required && !radar_detect) | ||
1309 | return -EINVAL; | 1280 | return -EINVAL; |
1310 | 1281 | ||
1311 | /* Always allow software iftypes */ | 1282 | /* Always allow software iftypes */ |