summaryrefslogtreecommitdiffstats
path: root/net/wireless
diff options
context:
space:
mode:
authorJohannes Berg <johannes.berg@intel.com>2020-03-20 11:38:35 +0100
committerJohannes Berg <johannes.berg@intel.com>2020-03-20 14:42:20 +0100
commit306b79ea6ece18d66bea80876983ae693d66ed52 (patch)
tree6ab7a386d038fa7e13030d9cf570fe25aa237e77 /net/wireless
parent7fc82af856d6bc26910902f8f42659b162864955 (diff)
downloadlinux-306b79ea6ece18d66bea80876983ae693d66ed52.tar.bz2
nl80211: clarify code in nl80211_del_station()
The long if chain of interface types is hard to read, especially now with the additional condition after it. Use a switch statement to clarify this code. Signed-off-by: Johannes Berg <johannes.berg@intel.com> Link: https://lore.kernel.org/r/20200320113834.2c51b9e8e341.I3fa5dc3f7d3cb1dbbd77191d764586f7da993f3f@changeid Signed-off-by: Johannes Berg <johannes.berg@intel.com>
Diffstat (limited to 'net/wireless')
-rw-r--r--net/wireless/nl80211.c22
1 files changed, 14 insertions, 8 deletions
diff --git a/net/wireless/nl80211.c b/net/wireless/nl80211.c
index bc7d81231547..ad87e9db9a91 100644
--- a/net/wireless/nl80211.c
+++ b/net/wireless/nl80211.c
@@ -6285,16 +6285,22 @@ static int nl80211_del_station(struct sk_buff *skb, struct genl_info *info)
if (info->attrs[NL80211_ATTR_MAC])
params.mac = nla_data(info->attrs[NL80211_ATTR_MAC]);
- if (dev->ieee80211_ptr->iftype != NL80211_IFTYPE_AP &&
- dev->ieee80211_ptr->iftype != NL80211_IFTYPE_AP_VLAN &&
- dev->ieee80211_ptr->iftype != NL80211_IFTYPE_MESH_POINT &&
- dev->ieee80211_ptr->iftype != NL80211_IFTYPE_P2P_GO &&
- dev->ieee80211_ptr->iftype != NL80211_IFTYPE_ADHOC)
+ switch (dev->ieee80211_ptr->iftype) {
+ case NL80211_IFTYPE_AP:
+ case NL80211_IFTYPE_AP_VLAN:
+ case NL80211_IFTYPE_MESH_POINT:
+ case NL80211_IFTYPE_P2P_GO:
+ /* always accept these */
+ break;
+ case NL80211_IFTYPE_ADHOC:
+ /* conditionally accept */
+ if (wiphy_ext_feature_isset(&rdev->wiphy,
+ NL80211_EXT_FEATURE_DEL_IBSS_STA))
+ break;
return -EINVAL;
- if (dev->ieee80211_ptr->iftype == NL80211_IFTYPE_ADHOC &&
- !wiphy_ext_feature_isset(&rdev->wiphy,
- NL80211_EXT_FEATURE_DEL_IBSS_STA))
+ default:
return -EINVAL;
+ }
if (!rdev->ops->del_station)
return -EOPNOTSUPP;