aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/net/wireless/broadcom
diff options
context:
space:
mode:
authorRafał Miłecki <zajec5@gmail.com>2016-06-07 15:10:18 -0400
committerKalle Valo <kvalo@codeaurora.org>2016-06-29 11:41:34 -0400
commitf568adac7d1a50a7412a902ebc831730a9b80bf9 (patch)
treea46cd7b0244969632dad6944cdeb6301b9d11907 /drivers/net/wireless/broadcom
parent742fb20fd4c75bd08733b0ea232c7e0fa67a6f87 (diff)
brcmfmac: slightly simplify building interface combinations
This change reorders some operations in brcmf_setup_ifmodes in hope to make it simpler: 1) It allocates arrays right before filling them. This way it's easier to follow requested array length as it's immediately followed by code filling it. It's easier to check e.g. why we need 4 entries for P2P. Other than that it deduplicates some checks (e.g. for P2P). 2) It reorders code to first prepare limits and then define a new combo. Previously this was mixed (e.g. we were setting num of channels before preparing limits). 3) It modifies mbss code to use i variable just like other combos do. Signed-off-by: Rafał Miłecki <zajec5@gmail.com> Acked-by: Arend van Spriel <arend.vanspriel@broadcom.com> Signed-off-by: Kalle Valo <kvalo@codeaurora.org>
Diffstat (limited to 'drivers/net/wireless/broadcom')
-rw-r--r--drivers/net/wireless/broadcom/brcm80211/brcmfmac/cfg80211.c37
1 files changed, 16 insertions, 21 deletions
diff --git a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/cfg80211.c b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/cfg80211.c
index 264bd638a3d9..a5db9531de5d 100644
--- a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/cfg80211.c
+++ b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/cfg80211.c
@@ -6284,29 +6284,15 @@ static int brcmf_setup_ifmodes(struct wiphy *wiphy, struct brcmf_if *ifp)
6284 if (!combo) 6284 if (!combo)
6285 goto err; 6285 goto err;
6286 6286
6287 c0_limits = kcalloc(p2p ? 3 : 2, sizeof(*c0_limits), GFP_KERNEL);
6288 if (!c0_limits)
6289 goto err;
6290
6291 if (p2p) {
6292 p2p_limits = kcalloc(4, sizeof(*p2p_limits), GFP_KERNEL);
6293 if (!p2p_limits)
6294 goto err;
6295 }
6296
6297 if (mbss) {
6298 mbss_limits = kcalloc(1, sizeof(*mbss_limits), GFP_KERNEL);
6299 if (!mbss_limits)
6300 goto err;
6301 }
6302
6303 wiphy->interface_modes = BIT(NL80211_IFTYPE_STATION) | 6287 wiphy->interface_modes = BIT(NL80211_IFTYPE_STATION) |
6304 BIT(NL80211_IFTYPE_ADHOC) | 6288 BIT(NL80211_IFTYPE_ADHOC) |
6305 BIT(NL80211_IFTYPE_AP); 6289 BIT(NL80211_IFTYPE_AP);
6306 6290
6307 c = 0; 6291 c = 0;
6308 i = 0; 6292 i = 0;
6309 combo[c].num_different_channels = 1; 6293 c0_limits = kcalloc(p2p ? 3 : 2, sizeof(*c0_limits), GFP_KERNEL);
6294 if (!c0_limits)
6295 goto err;
6310 c0_limits[i].max = 1; 6296 c0_limits[i].max = 1;
6311 c0_limits[i++].types = BIT(NL80211_IFTYPE_STATION); 6297 c0_limits[i++].types = BIT(NL80211_IFTYPE_STATION);
6312 if (p2p) { 6298 if (p2p) {
@@ -6324,6 +6310,7 @@ static int brcmf_setup_ifmodes(struct wiphy *wiphy, struct brcmf_if *ifp)
6324 c0_limits[i].max = 1; 6310 c0_limits[i].max = 1;
6325 c0_limits[i++].types = BIT(NL80211_IFTYPE_AP); 6311 c0_limits[i++].types = BIT(NL80211_IFTYPE_AP);
6326 } 6312 }
6313 combo[c].num_different_channels = 1;
6327 combo[c].max_interfaces = i; 6314 combo[c].max_interfaces = i;
6328 combo[c].n_limits = i; 6315 combo[c].n_limits = i;
6329 combo[c].limits = c0_limits; 6316 combo[c].limits = c0_limits;
@@ -6331,7 +6318,9 @@ static int brcmf_setup_ifmodes(struct wiphy *wiphy, struct brcmf_if *ifp)
6331 if (p2p) { 6318 if (p2p) {
6332 c++; 6319 c++;
6333 i = 0; 6320 i = 0;
6334 combo[c].num_different_channels = 1; 6321 p2p_limits = kcalloc(4, sizeof(*p2p_limits), GFP_KERNEL);
6322 if (!p2p_limits)
6323 goto err;
6335 p2p_limits[i].max = 1; 6324 p2p_limits[i].max = 1;
6336 p2p_limits[i++].types = BIT(NL80211_IFTYPE_STATION); 6325 p2p_limits[i++].types = BIT(NL80211_IFTYPE_STATION);
6337 p2p_limits[i].max = 1; 6326 p2p_limits[i].max = 1;
@@ -6340,6 +6329,7 @@ static int brcmf_setup_ifmodes(struct wiphy *wiphy, struct brcmf_if *ifp)
6340 p2p_limits[i++].types = BIT(NL80211_IFTYPE_P2P_CLIENT); 6329 p2p_limits[i++].types = BIT(NL80211_IFTYPE_P2P_CLIENT);
6341 p2p_limits[i].max = 1; 6330 p2p_limits[i].max = 1;
6342 p2p_limits[i++].types = BIT(NL80211_IFTYPE_P2P_DEVICE); 6331 p2p_limits[i++].types = BIT(NL80211_IFTYPE_P2P_DEVICE);
6332 combo[c].num_different_channels = 1;
6343 combo[c].max_interfaces = i; 6333 combo[c].max_interfaces = i;
6344 combo[c].n_limits = i; 6334 combo[c].n_limits = i;
6345 combo[c].limits = p2p_limits; 6335 combo[c].limits = p2p_limits;
@@ -6347,14 +6337,19 @@ static int brcmf_setup_ifmodes(struct wiphy *wiphy, struct brcmf_if *ifp)
6347 6337
6348 if (mbss) { 6338 if (mbss) {
6349 c++; 6339 c++;
6340 i = 0;
6341 mbss_limits = kcalloc(1, sizeof(*mbss_limits), GFP_KERNEL);
6342 if (!mbss_limits)
6343 goto err;
6344 mbss_limits[i].max = 4;
6345 mbss_limits[i++].types = BIT(NL80211_IFTYPE_AP);
6350 combo[c].beacon_int_infra_match = true; 6346 combo[c].beacon_int_infra_match = true;
6351 combo[c].num_different_channels = 1; 6347 combo[c].num_different_channels = 1;
6352 mbss_limits[0].max = 4;
6353 mbss_limits[0].types = BIT(NL80211_IFTYPE_AP);
6354 combo[c].max_interfaces = 4; 6348 combo[c].max_interfaces = 4;
6355 combo[c].n_limits = 1; 6349 combo[c].n_limits = i;
6356 combo[c].limits = mbss_limits; 6350 combo[c].limits = mbss_limits;
6357 } 6351 }
6352
6358 wiphy->n_iface_combinations = n_combos; 6353 wiphy->n_iface_combinations = n_combos;
6359 wiphy->iface_combinations = combo; 6354 wiphy->iface_combinations = combo;
6360 return 0; 6355 return 0;