]> err.no Git - linux-2.6/commitdiff
iwlwifi: refactor stop master function
authorTomas Winkler <tomas.winkler@intel.com>
Thu, 29 May 2008 08:34:59 +0000 (16:34 +0800)
committerJohn W. Linville <linville@tuxdriver.com>
Tue, 3 Jun 2008 19:00:20 +0000 (15:00 -0400)
This patch refactors stop master function for 4965 and 5000.
Currently it duplicates the function.

Signed-off-by: Tomas Winkler <tomas.winkler@intel.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
drivers/net/wireless/iwlwifi/iwl-4965.c
drivers/net/wireless/iwlwifi/iwl-5000.c
drivers/net/wireless/iwlwifi/iwl-dev.h

index 080fc54db151386fc6ac791f7ab55cd704ead2db..c5864903f5ef30096a6c1474608f4945d6a3cc28 100644 (file)
@@ -579,39 +579,6 @@ static void iwl4965_nic_config(struct iwl_priv *priv)
        spin_unlock_irqrestore(&priv->lock, flags);
 }
 
-int iwl4965_hw_nic_stop_master(struct iwl_priv *priv)
-{
-       int rc = 0;
-       u32 reg_val;
-       unsigned long flags;
-
-       spin_lock_irqsave(&priv->lock, flags);
-
-       /* set stop master bit */
-       iwl_set_bit(priv, CSR_RESET, CSR_RESET_REG_FLAG_STOP_MASTER);
-
-       reg_val = iwl_read32(priv, CSR_GP_CNTRL);
-
-       if (CSR_GP_CNTRL_REG_FLAG_MAC_POWER_SAVE ==
-           (reg_val & CSR_GP_CNTRL_REG_MSK_POWER_SAVE_TYPE))
-               IWL_DEBUG_INFO("Card in power save, master is already "
-                              "stopped\n");
-       else {
-               rc = iwl_poll_bit(priv, CSR_RESET,
-                                 CSR_RESET_REG_FLAG_MASTER_DISABLED,
-                                 CSR_RESET_REG_FLAG_MASTER_DISABLED, 100);
-               if (rc < 0) {
-                       spin_unlock_irqrestore(&priv->lock, flags);
-                       return rc;
-               }
-       }
-
-       spin_unlock_irqrestore(&priv->lock, flags);
-       IWL_DEBUG_INFO("stop master\n");
-
-       return rc;
-}
-
 /**
  * iwl4965_hw_txq_ctx_stop - Stop all Tx DMA channels, free Tx queue memory
  */
@@ -642,11 +609,34 @@ void iwl4965_hw_txq_ctx_stop(struct iwl_priv *priv)
        iwl_hw_txq_ctx_free(priv);
 }
 
+static int iwl4965_apm_stop_master(struct iwl_priv *priv)
+{
+       int ret = 0;
+       unsigned long flags;
+
+       spin_lock_irqsave(&priv->lock, flags);
+
+       /* set stop master bit */
+       iwl_set_bit(priv, CSR_RESET, CSR_RESET_REG_FLAG_STOP_MASTER);
+
+       ret = iwl_poll_bit(priv, CSR_RESET,
+                                 CSR_RESET_REG_FLAG_MASTER_DISABLED,
+                                 CSR_RESET_REG_FLAG_MASTER_DISABLED, 100);
+       if (ret < 0)
+               goto out;
+
+out:
+       spin_unlock_irqrestore(&priv->lock, flags);
+       IWL_DEBUG_INFO("stop master\n");
+
+       return ret;
+}
+
 static void iwl4965_apm_stop(struct iwl_priv *priv)
 {
        unsigned long flags;
 
-       iwl4965_hw_nic_stop_master(priv);
+       iwl4965_apm_stop_master(priv);
 
        spin_lock_irqsave(&priv->lock, flags);
 
@@ -663,7 +653,7 @@ static int iwl4965_apm_reset(struct iwl_priv *priv)
        int ret = 0;
        unsigned long flags;
 
-       iwl4965_hw_nic_stop_master(priv);
+       iwl4965_apm_stop_master(priv);
 
        spin_lock_irqsave(&priv->lock, flags);
 
index 27cfe3c9a58dc55d9bdc3cf3c522d4510b44b7b3..d6074522c4463833ee1658c78cac65c535c54f38 100644 (file)
@@ -56,6 +56,31 @@ static const u16 iwl5000_default_queue_to_tx_fifo[] = {
        IWL_TX_FIFO_HCCA_2
 };
 
+/* FIXME: same implementation as 4965 */
+static int iwl5000_apm_stop_master(struct iwl_priv *priv)
+{
+       int ret = 0;
+       unsigned long flags;
+
+       spin_lock_irqsave(&priv->lock, flags);
+
+       /* set stop master bit */
+       iwl_set_bit(priv, CSR_RESET, CSR_RESET_REG_FLAG_STOP_MASTER);
+
+       ret = iwl_poll_bit(priv, CSR_RESET,
+                                 CSR_RESET_REG_FLAG_MASTER_DISABLED,
+                                 CSR_RESET_REG_FLAG_MASTER_DISABLED, 100);
+       if (ret < 0)
+               goto out;
+
+out:
+       spin_unlock_irqrestore(&priv->lock, flags);
+       IWL_DEBUG_INFO("stop master\n");
+
+       return ret;
+}
+
+
 static int iwl5000_apm_init(struct iwl_priv *priv)
 {
        int ret = 0;
@@ -105,7 +130,7 @@ static void iwl5000_apm_stop(struct iwl_priv *priv)
 {
        unsigned long flags;
 
-       iwl4965_hw_nic_stop_master(priv);
+       iwl5000_apm_stop_master(priv);
 
        spin_lock_irqsave(&priv->lock, flags);
 
@@ -124,7 +149,7 @@ static int iwl5000_apm_reset(struct iwl_priv *priv)
        int ret = 0;
        unsigned long flags;
 
-       iwl4965_hw_nic_stop_master(priv);
+       iwl5000_apm_stop_master(priv);
 
        spin_lock_irqsave(&priv->lock, flags);
 
index d193da3a635ac143f5587cb7ccd2efdb7bb78ca0..44bd827a8bc3bfabbd996aa3affab6f18a478367 100644 (file)
@@ -686,7 +686,6 @@ extern void iwl4965_hw_setup_deferred_work(struct iwl_priv *priv);
 extern void iwl4965_hw_cancel_deferred_work(struct iwl_priv *priv);
 extern int iwl4965_hw_rxq_stop(struct iwl_priv *priv);
 extern int iwl4965_hw_set_hw_params(struct iwl_priv *priv);
-extern int iwl4965_hw_nic_stop_master(struct iwl_priv *priv);
 extern void iwl4965_hw_txq_ctx_stop(struct iwl_priv *priv);
 extern int iwl4965_hw_get_temperature(struct iwl_priv *priv);
 extern unsigned int iwl4965_hw_get_beacon_cmd(struct iwl_priv *priv,