mwifiex: cleanup in mwifiex_fill_cap_info()
authorAmitkumar Karwar <akarwar@marvell.com>
Sat, 8 Feb 2014 00:27:31 +0000 (16:27 -0800)
committerJohn W. Linville <linville@tuxdriver.com>
Wed, 12 Feb 2014 20:36:18 +0000 (15:36 -0500)
Pass 'struct ieee80211_ht_cap' pointer to
mwifiex_fill_cap_info() instead of
'struct mwifiex_ie_types_htcap' pointer, because the routine
internally uses the later one.
This patch also adds WARN_ON_ONCE check for NULL band.

Signed-off-by: Amitkumar Karwar <akarwar@marvell.com>
Signed-off-by: Bing Zhao <bzhao@marvell.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
drivers/net/wireless/mwifiex/11n.c
drivers/net/wireless/mwifiex/11n.h
drivers/net/wireless/mwifiex/join.c
drivers/net/wireless/mwifiex/scan.c

index 822e622fa323e45568d0fa8d1e8c9017e986cd43..616b1d6221b96ee416d6199eb70ada05cb4aac28 100644 (file)
  *
  * RD responder bit to set to clear in the extended capability header.
  */
-void
-mwifiex_fill_cap_info(struct mwifiex_private *priv, u8 radio_type,
-                     struct mwifiex_ie_types_htcap *ht_cap)
+int mwifiex_fill_cap_info(struct mwifiex_private *priv, u8 radio_type,
+                         struct ieee80211_ht_cap *ht_cap)
 {
-       uint16_t ht_ext_cap = le16_to_cpu(ht_cap->ht_cap.extended_ht_cap_info);
+       uint16_t ht_ext_cap = le16_to_cpu(ht_cap->extended_ht_cap_info);
        struct ieee80211_supported_band *sband =
                                        priv->wdev->wiphy->bands[radio_type];
 
-       ht_cap->ht_cap.ampdu_params_info =
+       if (WARN_ON_ONCE(!sband)) {
+               dev_err(priv->adapter->dev, "Invalid radio type!\n");
+               return -EINVAL;
+       }
+
+       ht_cap->ampdu_params_info =
                (sband->ht_cap.ampdu_factor &
                 IEEE80211_HT_AMPDU_PARM_FACTOR) |
                ((sband->ht_cap.ampdu_density <<
                 IEEE80211_HT_AMPDU_PARM_DENSITY_SHIFT) &
                 IEEE80211_HT_AMPDU_PARM_DENSITY);
 
-       memcpy((u8 *) &ht_cap->ht_cap.mcs, &sband->ht_cap.mcs,
+       memcpy((u8 *)&ht_cap->mcs, &sband->ht_cap.mcs,
               sizeof(sband->ht_cap.mcs));
 
        if (priv->bss_mode == NL80211_IFTYPE_STATION ||
@@ -57,17 +61,18 @@ mwifiex_fill_cap_info(struct mwifiex_private *priv, u8 radio_type,
             (priv->adapter->sec_chan_offset !=
                                        IEEE80211_HT_PARAM_CHA_SEC_NONE)))
                /* Set MCS32 for infra mode or ad-hoc mode with 40MHz support */
-               SETHT_MCS32(ht_cap->ht_cap.mcs.rx_mask);
+               SETHT_MCS32(ht_cap->mcs.rx_mask);
 
        /* Clear RD responder bit */
        ht_ext_cap &= ~IEEE80211_HT_EXT_CAP_RD_RESPONDER;
 
-       ht_cap->ht_cap.cap_info = cpu_to_le16(sband->ht_cap.cap);
-       ht_cap->ht_cap.extended_ht_cap_info = cpu_to_le16(ht_ext_cap);
+       ht_cap->cap_info = cpu_to_le16(sband->ht_cap.cap);
+       ht_cap->extended_ht_cap_info = cpu_to_le16(ht_ext_cap);
 
        if (ISSUPP_BEAMFORMING(priv->adapter->hw_dot_11n_dev_cap))
-               ht_cap->ht_cap.tx_BF_cap_info =
-                               cpu_to_le32(MWIFIEX_DEF_11N_TX_BF_CAP);
+               ht_cap->tx_BF_cap_info = cpu_to_le32(MWIFIEX_DEF_11N_TX_BF_CAP);
+
+       return 0;
 }
 
 /*
@@ -316,7 +321,7 @@ mwifiex_cmd_append_11n_tlv(struct mwifiex_private *priv,
                       sizeof(struct ieee_types_header),
                       le16_to_cpu(ht_cap->header.len));
 
-               mwifiex_fill_cap_info(priv, radio_type, ht_cap);
+               mwifiex_fill_cap_info(priv, radio_type, &ht_cap->ht_cap);
 
                *buffer += sizeof(struct mwifiex_ie_types_htcap);
                ret_len += sizeof(struct mwifiex_ie_types_htcap);
index 353032d55ff3c540316715d5c51e12fa181f88a3..fde39fedf0c03bf5b588391c0fa1196e58473bc4 100644 (file)
@@ -34,8 +34,8 @@ int mwifiex_cmd_11n_cfg(struct mwifiex_private *priv,
 int mwifiex_cmd_append_11n_tlv(struct mwifiex_private *priv,
                               struct mwifiex_bssdescriptor *bss_desc,
                               u8 **buffer);
-void mwifiex_fill_cap_info(struct mwifiex_private *, u8 radio_type,
-                          struct mwifiex_ie_types_htcap *);
+int mwifiex_fill_cap_info(struct mwifiex_private *, u8 radio_type,
+                         struct ieee80211_ht_cap *);
 int mwifiex_set_get_11n_htcap_cfg(struct mwifiex_private *priv,
                                  u16 action, int *htcap_cfg);
 void mwifiex_11n_delete_tx_ba_stream_tbl_entry(struct mwifiex_private *priv,
index d3934c6dbd8a4efa8d827ee07bf040a191583e3d..34472ea53841631ab2bed073c8cb4fe6c7e7009b 100644 (file)
@@ -982,7 +982,7 @@ mwifiex_cmd_802_11_ad_hoc_start(struct mwifiex_private *priv,
                       cpu_to_le16(sizeof(struct ieee80211_ht_cap));
                radio_type = mwifiex_band_to_radio_type(
                                        priv->adapter->config_bands);
-               mwifiex_fill_cap_info(priv, radio_type, ht_cap);
+               mwifiex_fill_cap_info(priv, radio_type, &ht_cap->ht_cap);
 
                if (adapter->sec_chan_offset ==
                                        IEEE80211_HT_PARAM_CHA_SEC_NONE) {
index c548a7d4877d02a04bf0caaa0888d4630ccc2f95..92adbb1ebabc1e3bd61e2af9c740c7470d4acb85 100644 (file)
@@ -957,7 +957,7 @@ mwifiex_config_scan(struct mwifiex_private *priv,
                                cpu_to_le16(sizeof(struct ieee80211_ht_cap));
                radio_type =
                        mwifiex_band_to_radio_type(priv->adapter->config_bands);
-               mwifiex_fill_cap_info(priv, radio_type, ht_cap);
+               mwifiex_fill_cap_info(priv, radio_type, &ht_cap->ht_cap);
                tlv_pos += sizeof(struct mwifiex_ie_types_htcap);
        }