iwlwifi: refactor iwl_setup_rxon_timing
authorJohannes Berg <johannes.berg@intel.com>
Thu, 29 Jul 2010 14:07:51 +0000 (07:07 -0700)
committerJohn W. Linville <linville@tuxdriver.com>
Tue, 24 Aug 2010 20:32:01 +0000 (16:32 -0400)
All callers of iwl_setup_rxon_timing() also send
the command right away, so rename the function
to iwl_send_rxon_timing() and move the sending
into it. Also, some callers clear the data, this
can be done always and thus moved in as well.
Finally, there's no reason for the function to
acquire the spinlock, but it should be called
with the mutex held, so assert that.

Signed-off-by: Johannes Berg <johannes.berg@intel.com>
Signed-off-by: Wey-Yi Guy <wey-yi.w.guy@intel.com>
drivers/net/wireless/iwlwifi/iwl-agn.c
drivers/net/wireless/iwlwifi/iwl-core.c
drivers/net/wireless/iwlwifi/iwl-core.h
drivers/net/wireless/iwlwifi/iwl3945-base.c

index 61ecd18..f832535 100644 (file)
@@ -3109,9 +3109,7 @@ void iwl_post_associate(struct iwl_priv *priv, struct ieee80211_vif *vif)
        priv->staging_rxon.filter_flags &= ~RXON_FILTER_ASSOC_MSK;
        iwlcore_commit_rxon(priv);
 
-       iwl_setup_rxon_timing(priv, vif);
-       ret = iwl_send_cmd_pdu(priv, REPLY_RXON_TIMING,
-                             sizeof(priv->rxon_timing), &priv->rxon_timing);
+       ret = iwl_send_rxon_timing(priv, vif);
        if (ret)
                IWL_WARN(priv, "REPLY_RXON_TIMING failed - "
                            "Attempting to continue.\n");
@@ -3347,9 +3345,7 @@ void iwl_config_ap(struct iwl_priv *priv, struct ieee80211_vif *vif)
                iwlcore_commit_rxon(priv);
 
                /* RXON Timing */
-               iwl_setup_rxon_timing(priv, vif);
-               ret = iwl_send_cmd_pdu(priv, REPLY_RXON_TIMING,
-                               sizeof(priv->rxon_timing), &priv->rxon_timing);
+               ret = iwl_send_rxon_timing(priv, vif);
                if (ret)
                        IWL_WARN(priv, "REPLY_RXON_TIMING failed - "
                                        "Attempting to continue.\n");
index 602636c..7754be4 100644 (file)
@@ -491,17 +491,19 @@ static u16 iwl_adjust_beacon_interval(u16 beacon_val, u16 max_beacon_val)
        return new_val;
 }
 
-void iwl_setup_rxon_timing(struct iwl_priv *priv, struct ieee80211_vif *vif)
+int iwl_send_rxon_timing(struct iwl_priv *priv, struct ieee80211_vif *vif)
 {
        u64 tsf;
        s32 interval_tm, rem;
-       unsigned long flags;
        struct ieee80211_conf *conf = NULL;
        u16 beacon_int;
 
        conf = ieee80211_get_hw_conf(priv->hw);
 
-       spin_lock_irqsave(&priv->lock, flags);
+       lockdep_assert_held(&priv->mutex);
+
+       memset(&priv->rxon_timing, 0, sizeof(struct iwl_rxon_time_cmd));
+
        priv->rxon_timing.timestamp = cpu_to_le64(priv->timestamp);
        priv->rxon_timing.listen_interval = cpu_to_le16(conf->listen_interval);
 
@@ -524,14 +526,16 @@ void iwl_setup_rxon_timing(struct iwl_priv *priv, struct ieee80211_vif *vif)
        rem = do_div(tsf, interval_tm);
        priv->rxon_timing.beacon_init_val = cpu_to_le32(interval_tm - rem);
 
-       spin_unlock_irqrestore(&priv->lock, flags);
        IWL_DEBUG_ASSOC(priv,
                        "beacon interval %d beacon timer %d beacon tim %d\n",
                        le16_to_cpu(priv->rxon_timing.beacon_interval),
                        le32_to_cpu(priv->rxon_timing.beacon_init_val),
                        le16_to_cpu(priv->rxon_timing.atim_window));
+
+       return iwl_send_cmd_pdu(priv, REPLY_RXON_TIMING,
+                               sizeof(priv->rxon_timing), &priv->rxon_timing);
 }
-EXPORT_SYMBOL(iwl_setup_rxon_timing);
+EXPORT_SYMBOL(iwl_send_rxon_timing);
 
 void iwl_set_rxon_hwcrypto(struct iwl_priv *priv, int hw_decrypt)
 {
index f5586b5..edadca5 100644 (file)
@@ -714,7 +714,7 @@ extern int iwl_send_lq_cmd(struct iwl_priv *priv,
 void iwl_apm_stop(struct iwl_priv *priv);
 int iwl_apm_init(struct iwl_priv *priv);
 
-void iwl_setup_rxon_timing(struct iwl_priv *priv, struct ieee80211_vif *vif);
+int iwl_send_rxon_timing(struct iwl_priv *priv, struct ieee80211_vif *vif);
 static inline int iwl_send_rxon_assoc(struct iwl_priv *priv)
 {
        return priv->cfg->ops->hcmd->rxon_assoc(priv);
index faa2e00..84494b1 100644 (file)
@@ -3094,10 +3094,7 @@ void iwl3945_post_associate(struct iwl_priv *priv, struct ieee80211_vif *vif)
        priv->staging_rxon.filter_flags &= ~RXON_FILTER_ASSOC_MSK;
        iwlcore_commit_rxon(priv);
 
-       memset(&priv->rxon_timing, 0, sizeof(struct iwl_rxon_time_cmd));
-       iwl_setup_rxon_timing(priv, vif);
-       rc = iwl_send_cmd_pdu(priv, REPLY_RXON_TIMING,
-                             sizeof(priv->rxon_timing), &priv->rxon_timing);
+       rc = iwl_send_rxon_timing(priv, vif);
        if (rc)
                IWL_WARN(priv, "REPLY_RXON_TIMING failed - "
                            "Attempting to continue.\n");
@@ -3271,11 +3268,7 @@ void iwl3945_config_ap(struct iwl_priv *priv, struct ieee80211_vif *vif)
                iwlcore_commit_rxon(priv);
 
                /* RXON Timing */
-               memset(&priv->rxon_timing, 0, sizeof(struct iwl_rxon_time_cmd));
-               iwl_setup_rxon_timing(priv, vif);
-               rc = iwl_send_cmd_pdu(priv, REPLY_RXON_TIMING,
-                                     sizeof(priv->rxon_timing),
-                                     &priv->rxon_timing);
+               rc = iwl_send_rxon_timing(priv, vif);
                if (rc)
                        IWL_WARN(priv, "REPLY_RXON_TIMING failed - "
                                        "Attempting to continue.\n");