Skip to content

Commit 306b79e

Browse files
committed
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>
1 parent 7fc82af commit 306b79e

1 file changed

Lines changed: 14 additions & 8 deletions

File tree

‎net/wireless/nl80211.c‎

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -6285,16 +6285,22 @@ static int nl80211_del_station(struct sk_buff *skb, struct genl_info *info)
62856285
if (info->attrs[NL80211_ATTR_MAC])
62866286
params.mac = nla_data(info->attrs[NL80211_ATTR_MAC]);
62876287

6288-
if (dev->ieee80211_ptr->iftype != NL80211_IFTYPE_AP &&
6289-
dev->ieee80211_ptr->iftype != NL80211_IFTYPE_AP_VLAN &&
6290-
dev->ieee80211_ptr->iftype != NL80211_IFTYPE_MESH_POINT &&
6291-
dev->ieee80211_ptr->iftype != NL80211_IFTYPE_P2P_GO &&
6292-
dev->ieee80211_ptr->iftype != NL80211_IFTYPE_ADHOC)
6288+
switch (dev->ieee80211_ptr->iftype) {
6289+
case NL80211_IFTYPE_AP:
6290+
case NL80211_IFTYPE_AP_VLAN:
6291+
case NL80211_IFTYPE_MESH_POINT:
6292+
case NL80211_IFTYPE_P2P_GO:
6293+
/* always accept these */
6294+
break;
6295+
case NL80211_IFTYPE_ADHOC:
6296+
/* conditionally accept */
6297+
if (wiphy_ext_feature_isset(&rdev->wiphy,
6298+
NL80211_EXT_FEATURE_DEL_IBSS_STA))
6299+
break;
62936300
return -EINVAL;
6294-
if (dev->ieee80211_ptr->iftype == NL80211_IFTYPE_ADHOC &&
6295-
!wiphy_ext_feature_isset(&rdev->wiphy,
6296-
NL80211_EXT_FEATURE_DEL_IBSS_STA))
6301+
default:
62976302
return -EINVAL;
6303+
}
62986304

62996305
if (!rdev->ops->del_station)
63006306
return -EOPNOTSUPP;

0 commit comments

Comments
 (0)