1 From: Arend van Spriel <arend@broadcom.com>
2 Date: Thu, 20 Aug 2015 22:06:05 +0200
3 Subject: [PATCH] brcmfmac: make use of cfg80211_check_combinations()
5 Use cfg80211_check_combinations() so we can bail out early when an
6 interface add or change results in an invalid combination.
8 Reviewed-by: Hante Meuleman <meuleman@broadcom.com>
9 Reviewed-by: Franky (Zhenhui) Lin <frankyl@broadcom.com>
10 Reviewed-by: Pieter-Paul Giesberts <pieterpg@broadcom.com>
11 Signed-off-by: Arend van Spriel <arend@broadcom.com>
12 Signed-off-by: Kalle Valo <kvalo@codeaurora.org>
15 --- a/drivers/net/wireless/brcm80211/brcmfmac/cfg80211.c
16 +++ b/drivers/net/wireless/brcm80211/brcmfmac/cfg80211.c
17 @@ -469,6 +469,36 @@ brcmf_find_wpsie(const u8 *parse, u32 le
21 +static int brcmf_vif_change_validate(struct brcmf_cfg80211_info *cfg,
22 + struct brcmf_cfg80211_vif *vif,
23 + enum nl80211_iftype new_type)
25 + int iftype_num[NUM_NL80211_IFTYPES];
26 + struct brcmf_cfg80211_vif *pos;
28 + memset(&iftype_num[0], 0, sizeof(iftype_num));
29 + list_for_each_entry(pos, &cfg->vif_list, list)
31 + iftype_num[new_type]++;
33 + iftype_num[pos->wdev.iftype]++;
35 + return cfg80211_check_combinations(cfg->wiphy, 1, 0, iftype_num);
38 +static int brcmf_vif_add_validate(struct brcmf_cfg80211_info *cfg,
39 + enum nl80211_iftype new_type)
41 + int iftype_num[NUM_NL80211_IFTYPES];
42 + struct brcmf_cfg80211_vif *pos;
44 + memset(&iftype_num[0], 0, sizeof(iftype_num));
45 + list_for_each_entry(pos, &cfg->vif_list, list)
46 + iftype_num[pos->wdev.iftype]++;
48 + iftype_num[new_type]++;
49 + return cfg80211_check_combinations(cfg->wiphy, 1, 0, iftype_num);
52 static void convert_key_from_CPU(struct brcmf_wsec_key *key,
53 struct brcmf_wsec_key_le *key_le)
54 @@ -663,8 +693,14 @@ static struct wireless_dev *brcmf_cfg802
55 struct vif_params *params)
57 struct wireless_dev *wdev;
60 brcmf_dbg(TRACE, "enter: %s type %d\n", name, type);
61 + err = brcmf_vif_add_validate(wiphy_to_cfg(wiphy), type);
63 + brcmf_err("iface validation failed: err=%d\n", err);
64 + return ERR_PTR(err);
67 case NL80211_IFTYPE_ADHOC:
68 case NL80211_IFTYPE_STATION:
69 @@ -823,8 +859,12 @@ brcmf_cfg80211_change_iface(struct wiphy
73 - brcmf_dbg(TRACE, "Enter, ndev=%p, type=%d\n", ndev, type);
75 + brcmf_dbg(TRACE, "Enter, idx=%d, type=%d\n", ifp->bssidx, type);
76 + err = brcmf_vif_change_validate(wiphy_to_cfg(wiphy), vif, type);
78 + brcmf_err("iface validation failed: err=%d\n", err);
82 case NL80211_IFTYPE_MONITOR:
83 case NL80211_IFTYPE_WDS: