Re: [PATCH v2] cfg80211: Create structure for combination check/iter function parameters

2016-10-13 Thread Johannes Berg
On Wed, 2016-10-12 at 18:25 +0530, Purushottam Kushwaha wrote:
> Move growing parameter list to a structure for check/iter combination
> functions in cfg80211 and mac80211.
> 
Thanks, applied.

johannes


[PATCH v2] cfg80211: Create structure for combination check/iter function parameters

2016-10-12 Thread Purushottam Kushwaha
Move growing parameter list to a structure for check/iter combination
functions in cfg80211 and mac80211.

Signed-off-by: Purushottam Kushwaha 
---
 .../broadcom/brcm80211/brcmfmac/cfg80211.c | 26 ++-
 include/net/cfg80211.h | 46 ++--
 net/mac80211/util.c| 50 +++---
 net/wireless/util.c| 28 ++--
 4 files changed, 78 insertions(+), 72 deletions(-)

diff --git a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/cfg80211.c 
b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/cfg80211.c
index b777e1b..44e1c70 100644
--- a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/cfg80211.c
+++ b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/cfg80211.c
@@ -414,23 +414,26 @@ static int brcmf_vif_change_validate(struct 
brcmf_cfg80211_info *cfg,
 struct brcmf_cfg80211_vif *vif,
 enum nl80211_iftype new_type)
 {
-   int iftype_num[NUM_NL80211_IFTYPES];
struct brcmf_cfg80211_vif *pos;
bool check_combos = false;
int ret = 0;
+   struct iface_combination_params params = {
+   .num_different_channels = 1,
+   .radar_detect = 0,
+   .iftype_num = {0},
+   };
 
-   memset(&iftype_num[0], 0, sizeof(iftype_num));
list_for_each_entry(pos, &cfg->vif_list, list)
if (pos == vif) {
-   iftype_num[new_type]++;
+   params.iftype_num[new_type]++;
} else {
/* concurrent interfaces so need check combinations */
check_combos = true;
-   iftype_num[pos->wdev.iftype]++;
+   params.iftype_num[pos->wdev.iftype]++;
}
 
if (check_combos)
-   ret = cfg80211_check_combinations(cfg->wiphy, 1, 0, iftype_num);
+   ret = cfg80211_check_combinations(cfg->wiphy, ¶ms);
 
return ret;
 }
@@ -438,15 +441,18 @@ static int brcmf_vif_change_validate(struct 
brcmf_cfg80211_info *cfg,
 static int brcmf_vif_add_validate(struct brcmf_cfg80211_info *cfg,
  enum nl80211_iftype new_type)
 {
-   int iftype_num[NUM_NL80211_IFTYPES];
struct brcmf_cfg80211_vif *pos;
+   struct iface_combination_params params = {
+   .num_different_channels = 1,
+   .radar_detect = 0,
+   .iftype_num = {0},
+   };
 
-   memset(&iftype_num[0], 0, sizeof(iftype_num));
list_for_each_entry(pos, &cfg->vif_list, list)
-   iftype_num[pos->wdev.iftype]++;
+   params.iftype_num[pos->wdev.iftype]++;
 
-   iftype_num[new_type]++;
-   return cfg80211_check_combinations(cfg->wiphy, 1, 0, iftype_num);
+   params.iftype_num[new_type]++;
+   return cfg80211_check_combinations(cfg->wiphy, ¶ms);
 }
 
 static void convert_key_from_CPU(struct brcmf_wsec_key *key,
diff --git a/include/net/cfg80211.h b/include/net/cfg80211.h
index fe78f02..21bbe44 100644
--- a/include/net/cfg80211.h
+++ b/include/net/cfg80211.h
@@ -772,6 +772,26 @@ struct cfg80211_csa_settings {
 };
 
 /**
+ * struct iface_combination_params - input parameters for interface 
combinations
+ *
+ * Used to pass interface combination parameters
+ *
+ * @num_different_channels: the number of different channels we want
+ * to use for verification
+ * @radar_detect: a bitmap where each bit corresponds to a channel
+ * width where radar detection is needed, as in the definition of
+ * &struct ieee80211_iface_combination.@radar_detect_widths
+ * @iftype_num: array with the numbers of interfaces of each interface
+ * type.  The index is the interface type as specified in &enum
+ * nl80211_iftype.
+ */
+struct iface_combination_params {
+   int num_different_channels;
+   u8 radar_detect;
+   int iftype_num[NUM_NL80211_IFTYPES];
+};
+
+/**
  * enum station_parameters_apply_mask - station parameter values to apply
  * @STATION_PARAM_APPLY_UAPSD: apply new uAPSD parameters (uapsd_queues, 
max_sp)
  * @STATION_PARAM_APPLY_CAPABILITY: apply new capability
@@ -5575,36 +5595,20 @@ void cfg80211_report_wowlan_wakeup(struct wireless_dev 
*wdev,
  * cfg80211_check_combinations - check interface combinations
  *
  * @wiphy: the wiphy
- * @num_different_channels: the number of different channels we want
- * to use for verification
- * @radar_detect: a bitmap where each bit corresponds to a channel
- * width where radar detection is needed, as in the definition of
- * &struct ieee80211_iface_combination.@radar_detect_widths
- * @iftype_num: array with the numbers of interfaces of each interface
- * type.  The index is the interface type as specified in &enum
- * nl80211_iftype.
+ * @params: the interface combinations parameter
  *
  * This function can be called by the