1 From: =?UTF-8?q?Rafa=C5=82=20Mi=C5=82ecki?= <zajec5@gmail.com>
2 Date: Tue, 7 Jun 2016 21:10:18 +0200
3 Subject: [PATCH] brcmfmac: slightly simplify building interface combinations
5 Content-Type: text/plain; charset=UTF-8
6 Content-Transfer-Encoding: 8bit
8 This change reorders some operations in brcmf_setup_ifmodes in hope to
10 1) It allocates arrays right before filling them. This way it's easier
11 to follow requested array length as it's immediately followed by
12 code filling it. It's easier to check e.g. why we need 4 entries for
13 P2P. Other than that it deduplicates some checks (e.g. for P2P).
14 2) It reorders code to first prepare limits and then define a new combo.
15 Previously this was mixed (e.g. we were setting num of channels
16 before preparing limits).
17 3) It modifies mbss code to use i variable just like other combos do.
19 Signed-off-by: Rafał Miłecki <zajec5@gmail.com>
20 Acked-by: Arend van Spriel <arend.vanspriel@broadcom.com>
21 Signed-off-by: Kalle Valo <kvalo@codeaurora.org>
24 --- a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/cfg80211.c
25 +++ b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/cfg80211.c
26 @@ -6284,29 +6284,15 @@ static int brcmf_setup_ifmodes(struct wi
30 - c0_limits = kcalloc(p2p ? 3 : 2, sizeof(*c0_limits), GFP_KERNEL);
35 - p2p_limits = kcalloc(4, sizeof(*p2p_limits), GFP_KERNEL);
41 - mbss_limits = kcalloc(1, sizeof(*mbss_limits), GFP_KERNEL);
46 wiphy->interface_modes = BIT(NL80211_IFTYPE_STATION) |
47 BIT(NL80211_IFTYPE_ADHOC) |
48 BIT(NL80211_IFTYPE_AP);
52 - combo[c].num_different_channels = 1;
53 + c0_limits = kcalloc(p2p ? 3 : 2, sizeof(*c0_limits), GFP_KERNEL);
57 c0_limits[i++].types = BIT(NL80211_IFTYPE_STATION);
59 @@ -6324,6 +6310,7 @@ static int brcmf_setup_ifmodes(struct wi
61 c0_limits[i++].types = BIT(NL80211_IFTYPE_AP);
63 + combo[c].num_different_channels = 1;
64 combo[c].max_interfaces = i;
65 combo[c].n_limits = i;
66 combo[c].limits = c0_limits;
67 @@ -6331,7 +6318,9 @@ static int brcmf_setup_ifmodes(struct wi
71 - combo[c].num_different_channels = 1;
72 + p2p_limits = kcalloc(4, sizeof(*p2p_limits), GFP_KERNEL);
75 p2p_limits[i].max = 1;
76 p2p_limits[i++].types = BIT(NL80211_IFTYPE_STATION);
77 p2p_limits[i].max = 1;
78 @@ -6340,6 +6329,7 @@ static int brcmf_setup_ifmodes(struct wi
79 p2p_limits[i++].types = BIT(NL80211_IFTYPE_P2P_CLIENT);
80 p2p_limits[i].max = 1;
81 p2p_limits[i++].types = BIT(NL80211_IFTYPE_P2P_DEVICE);
82 + combo[c].num_different_channels = 1;
83 combo[c].max_interfaces = i;
84 combo[c].n_limits = i;
85 combo[c].limits = p2p_limits;
86 @@ -6347,14 +6337,19 @@ static int brcmf_setup_ifmodes(struct wi
91 + mbss_limits = kcalloc(1, sizeof(*mbss_limits), GFP_KERNEL);
94 + mbss_limits[i].max = 4;
95 + mbss_limits[i++].types = BIT(NL80211_IFTYPE_AP);
96 combo[c].beacon_int_infra_match = true;
97 combo[c].num_different_channels = 1;
98 - mbss_limits[0].max = 4;
99 - mbss_limits[0].types = BIT(NL80211_IFTYPE_AP);
100 combo[c].max_interfaces = 4;
101 - combo[c].n_limits = 1;
102 + combo[c].n_limits = i;
103 combo[c].limits = mbss_limits;
106 wiphy->n_iface_combinations = n_combos;
107 wiphy->iface_combinations = combo;