From patchwork Tue Jun 7 19:10:18 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?b?UmFmYcWCIE1pxYJlY2tp?= X-Patchwork-Id: 9162267 X-Patchwork-Delegate: kvalo@adurom.com Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id DAC5F60777 for ; Tue, 7 Jun 2016 19:11:02 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id C9C46252D5 for ; Tue, 7 Jun 2016 19:11:02 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id BCD8B2823D; Tue, 7 Jun 2016 19:11:02 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.8 required=2.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED,FREEMAIL_FROM,RCVD_IN_DNSWL_HI,T_DKIM_INVALID autolearn=unavailable version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 5BE7D252D5 for ; Tue, 7 Jun 2016 19:11:02 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754548AbcFGTKj (ORCPT ); Tue, 7 Jun 2016 15:10:39 -0400 Received: from mail-lf0-f68.google.com ([209.85.215.68]:36826 "EHLO mail-lf0-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754498AbcFGTKi (ORCPT ); Tue, 7 Jun 2016 15:10:38 -0400 Received: by mail-lf0-f68.google.com with SMTP id h68so17010712lfh.3; Tue, 07 Jun 2016 12:10:36 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=QJGhp03S0sEydpiGTDM/7tnRjb5KTIBtaNsyFf7wY4U=; b=lg8GOl3ud9WlYFFZ7nyIGmnFiLl1D9ez9dDHZ+n2GBwep28nf96SK9cdK8JCKjM0Tm Mo79ZUWIVKpGUz+M18K6vOYu2WV221FKUh7lcOA/bD6kb2fHMlPkn1XbQ4gSrQO308uN GUvL6o9cThhx57NzZqGVjKa3tDVonIipzUu/IwAt8S30MGM58wINGUAiFmOkTncSCdAq 8JM+4YjEON/6mH33f2BJsko+6WlvFsy7SSCmjQvZ4vw3TnbtVZAdi7zOmdK6x+AqDaF0 S2F58USiYzbWDoNsK57sRg75wfS5dwVI9aNeMMACQqYF8Z4zPIuBHFulco2XJqxKsmM9 qpRg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=QJGhp03S0sEydpiGTDM/7tnRjb5KTIBtaNsyFf7wY4U=; b=CP3vTNaF/cm4SmN/0eiS8z3beD+esJ8erCxlawBpc+WrYNE+8lbc8D7+Y6h41hpJAd PXtNKIHX5znpT7ZOP+kv5uJ9UL1VbO1tLnxA6gM/0dsrdFhXo/XCFxRJrDF2TjGgrIfa 4bj62pRq0+mEMRf75QaE/a2YrqTI037YCoQf5sHmb7kOSlM3nwvBxCphFzWmc3qHhij6 e4SHapb299I9vn6dCuWbrUS+yw8xwRZCGGWDznb/qcbH3cQFb5h799sXvuwTZCZGhy0G IjLn0AqUgFxY+H4MUSHT2s0RWyPh1h3nKb/Di/no/eaQ3BFVBtrQEM4P0rdNedLSYJBu aPPg== X-Gm-Message-State: ALyK8tLROEZr8mOS2blVyi7IjtVp5Sn5+Kq/OE5eRUTPA28xVCmJBdKARMjN5YFMHkWLLg== X-Received: by 10.25.73.137 with SMTP id w131mr2839987lfa.22.1465326635242; Tue, 07 Jun 2016 12:10:35 -0700 (PDT) Received: from linux-samsung.lan (ip-194-187-74-233.konfederacka.maverick.com.pl. [194.187.74.233]) by smtp.gmail.com with ESMTPSA id wj3sm2451431lbb.33.2016.06.07.12.10.33 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 07 Jun 2016 12:10:34 -0700 (PDT) From: =?UTF-8?q?Rafa=C5=82=20Mi=C5=82ecki?= To: Kalle Valo Cc: =?UTF-8?q?Rafa=C5=82=20Mi=C5=82ecki?= , Brett Rudley , Arend van Spriel , "Franky (Zhenhui) Lin" , Hante Meuleman , Pieter-Paul Giesberts , linux-wireless@vger.kernel.org (open list:BROADCOM BRCM80211 IEEE802.11n WIRELESS DRIVER), brcm80211-dev-list@broadcom.com (open list:BROADCOM BRCM80211 IEEE802.11n WIRELESS DRIVER), netdev@vger.kernel.org (open list:NETWORKING DRIVERS), linux-kernel@vger.kernel.org (open list) Subject: [PATCH] brcmfmac: slightly simplify building interface combinations Date: Tue, 7 Jun 2016 21:10:18 +0200 Message-Id: <1465326626-365-1-git-send-email-zajec5@gmail.com> X-Mailer: git-send-email 1.8.4.5 MIME-Version: 1.0 Sender: linux-wireless-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-wireless@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP 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 Acked-by: Arend van Spriel --- .../broadcom/brcm80211/brcmfmac/cfg80211.c | 37 ++++++++++------------ 1 file 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 4894eb7..33e682e 100644 --- a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/cfg80211.c +++ b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/cfg80211.c @@ -6300,29 +6300,15 @@ static int brcmf_setup_ifmodes(struct wiphy *wiphy, struct brcmf_if *ifp) if (!combo) goto err; - c0_limits = kcalloc(p2p ? 3 : 2, sizeof(*c0_limits), GFP_KERNEL); - if (!c0_limits) - goto err; - - if (p2p) { - p2p_limits = kcalloc(4, sizeof(*p2p_limits), GFP_KERNEL); - if (!p2p_limits) - goto err; - } - - if (mbss) { - mbss_limits = kcalloc(1, sizeof(*mbss_limits), GFP_KERNEL); - if (!mbss_limits) - goto err; - } - wiphy->interface_modes = BIT(NL80211_IFTYPE_STATION) | BIT(NL80211_IFTYPE_ADHOC) | BIT(NL80211_IFTYPE_AP); c = 0; i = 0; - combo[c].num_different_channels = 1; + c0_limits = kcalloc(p2p ? 3 : 2, sizeof(*c0_limits), GFP_KERNEL); + if (!c0_limits) + goto err; c0_limits[i].max = 1; c0_limits[i++].types = BIT(NL80211_IFTYPE_STATION); if (p2p) { @@ -6340,6 +6326,7 @@ static int brcmf_setup_ifmodes(struct wiphy *wiphy, struct brcmf_if *ifp) c0_limits[i].max = 1; c0_limits[i++].types = BIT(NL80211_IFTYPE_AP); } + combo[c].num_different_channels = 1; combo[c].max_interfaces = i; combo[c].n_limits = i; combo[c].limits = c0_limits; @@ -6347,7 +6334,9 @@ static int brcmf_setup_ifmodes(struct wiphy *wiphy, struct brcmf_if *ifp) if (p2p) { c++; i = 0; - combo[c].num_different_channels = 1; + p2p_limits = kcalloc(4, sizeof(*p2p_limits), GFP_KERNEL); + if (!p2p_limits) + goto err; p2p_limits[i].max = 1; p2p_limits[i++].types = BIT(NL80211_IFTYPE_STATION); p2p_limits[i].max = 1; @@ -6356,6 +6345,7 @@ static int brcmf_setup_ifmodes(struct wiphy *wiphy, struct brcmf_if *ifp) p2p_limits[i++].types = BIT(NL80211_IFTYPE_P2P_CLIENT); p2p_limits[i].max = 1; p2p_limits[i++].types = BIT(NL80211_IFTYPE_P2P_DEVICE); + combo[c].num_different_channels = 1; combo[c].max_interfaces = i; combo[c].n_limits = i; combo[c].limits = p2p_limits; @@ -6363,14 +6353,19 @@ static int brcmf_setup_ifmodes(struct wiphy *wiphy, struct brcmf_if *ifp) if (mbss) { c++; + i = 0; + mbss_limits = kcalloc(1, sizeof(*mbss_limits), GFP_KERNEL); + if (!mbss_limits) + goto err; + mbss_limits[i].max = 4; + mbss_limits[i++].types = BIT(NL80211_IFTYPE_AP); combo[c].beacon_int_infra_match = true; combo[c].num_different_channels = 1; - mbss_limits[0].max = 4; - mbss_limits[0].types = BIT(NL80211_IFTYPE_AP); combo[c].max_interfaces = 4; - combo[c].n_limits = 1; + combo[c].n_limits = i; combo[c].limits = mbss_limits; } + wiphy->n_iface_combinations = n_combos; wiphy->iface_combinations = combo; return 0;