diff options
author | Tomas Winkler <tomas.winkler@intel.com> | 2008-05-29 04:34:59 -0400 |
---|---|---|
committer | John W. Linville <linville@tuxdriver.com> | 2008-06-03 15:00:20 -0400 |
commit | 46315e012236af887cf442fd494a91b1d36858b9 (patch) | |
tree | dce2020ca64e6ef8b445ed09fe98ed0ff0522d4a | |
parent | f118a91d16127e461cc8c17c529306910f13a8b1 (diff) |
iwlwifi: refactor stop master function
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>
-rw-r--r-- | drivers/net/wireless/iwlwifi/iwl-4965.c | 60 | ||||
-rw-r--r-- | drivers/net/wireless/iwlwifi/iwl-5000.c | 29 | ||||
-rw-r--r-- | drivers/net/wireless/iwlwifi/iwl-dev.h | 1 |
3 files changed, 52 insertions, 38 deletions
diff --git a/drivers/net/wireless/iwlwifi/iwl-4965.c b/drivers/net/wireless/iwlwifi/iwl-4965.c index 080fc54db151..c5864903f5ef 100644 --- a/drivers/net/wireless/iwlwifi/iwl-4965.c +++ b/drivers/net/wireless/iwlwifi/iwl-4965.c | |||
@@ -579,39 +579,6 @@ static void iwl4965_nic_config(struct iwl_priv *priv) | |||
579 | spin_unlock_irqrestore(&priv->lock, flags); | 579 | spin_unlock_irqrestore(&priv->lock, flags); |
580 | } | 580 | } |
581 | 581 | ||
582 | int iwl4965_hw_nic_stop_master(struct iwl_priv *priv) | ||
583 | { | ||
584 | int rc = 0; | ||
585 | u32 reg_val; | ||
586 | unsigned long flags; | ||
587 | |||
588 | spin_lock_irqsave(&priv->lock, flags); | ||
589 | |||
590 | /* set stop master bit */ | ||
591 | iwl_set_bit(priv, CSR_RESET, CSR_RESET_REG_FLAG_STOP_MASTER); | ||
592 | |||
593 | reg_val = iwl_read32(priv, CSR_GP_CNTRL); | ||
594 | |||
595 | if (CSR_GP_CNTRL_REG_FLAG_MAC_POWER_SAVE == | ||
596 | (reg_val & CSR_GP_CNTRL_REG_MSK_POWER_SAVE_TYPE)) | ||
597 | IWL_DEBUG_INFO("Card in power save, master is already " | ||
598 | "stopped\n"); | ||
599 | else { | ||
600 | rc = iwl_poll_bit(priv, CSR_RESET, | ||
601 | CSR_RESET_REG_FLAG_MASTER_DISABLED, | ||
602 | CSR_RESET_REG_FLAG_MASTER_DISABLED, 100); | ||
603 | if (rc < 0) { | ||
604 | spin_unlock_irqrestore(&priv->lock, flags); | ||
605 | return rc; | ||
606 | } | ||
607 | } | ||
608 | |||
609 | spin_unlock_irqrestore(&priv->lock, flags); | ||
610 | IWL_DEBUG_INFO("stop master\n"); | ||
611 | |||
612 | return rc; | ||
613 | } | ||
614 | |||
615 | /** | 582 | /** |
616 | * iwl4965_hw_txq_ctx_stop - Stop all Tx DMA channels, free Tx queue memory | 583 | * iwl4965_hw_txq_ctx_stop - Stop all Tx DMA channels, free Tx queue memory |
617 | */ | 584 | */ |
@@ -642,11 +609,34 @@ void iwl4965_hw_txq_ctx_stop(struct iwl_priv *priv) | |||
642 | iwl_hw_txq_ctx_free(priv); | 609 | iwl_hw_txq_ctx_free(priv); |
643 | } | 610 | } |
644 | 611 | ||
612 | static int iwl4965_apm_stop_master(struct iwl_priv *priv) | ||
613 | { | ||
614 | int ret = 0; | ||
615 | unsigned long flags; | ||
616 | |||
617 | spin_lock_irqsave(&priv->lock, flags); | ||
618 | |||
619 | /* set stop master bit */ | ||
620 | iwl_set_bit(priv, CSR_RESET, CSR_RESET_REG_FLAG_STOP_MASTER); | ||
621 | |||
622 | ret = iwl_poll_bit(priv, CSR_RESET, | ||
623 | CSR_RESET_REG_FLAG_MASTER_DISABLED, | ||
624 | CSR_RESET_REG_FLAG_MASTER_DISABLED, 100); | ||
625 | if (ret < 0) | ||
626 | goto out; | ||
627 | |||
628 | out: | ||
629 | spin_unlock_irqrestore(&priv->lock, flags); | ||
630 | IWL_DEBUG_INFO("stop master\n"); | ||
631 | |||
632 | return ret; | ||
633 | } | ||
634 | |||
645 | static void iwl4965_apm_stop(struct iwl_priv *priv) | 635 | static void iwl4965_apm_stop(struct iwl_priv *priv) |
646 | { | 636 | { |
647 | unsigned long flags; | 637 | unsigned long flags; |
648 | 638 | ||
649 | iwl4965_hw_nic_stop_master(priv); | 639 | iwl4965_apm_stop_master(priv); |
650 | 640 | ||
651 | spin_lock_irqsave(&priv->lock, flags); | 641 | spin_lock_irqsave(&priv->lock, flags); |
652 | 642 | ||
@@ -663,7 +653,7 @@ static int iwl4965_apm_reset(struct iwl_priv *priv) | |||
663 | int ret = 0; | 653 | int ret = 0; |
664 | unsigned long flags; | 654 | unsigned long flags; |
665 | 655 | ||
666 | iwl4965_hw_nic_stop_master(priv); | 656 | iwl4965_apm_stop_master(priv); |
667 | 657 | ||
668 | spin_lock_irqsave(&priv->lock, flags); | 658 | spin_lock_irqsave(&priv->lock, flags); |
669 | 659 | ||
diff --git a/drivers/net/wireless/iwlwifi/iwl-5000.c b/drivers/net/wireless/iwlwifi/iwl-5000.c index 27cfe3c9a58d..d6074522c446 100644 --- a/drivers/net/wireless/iwlwifi/iwl-5000.c +++ b/drivers/net/wireless/iwlwifi/iwl-5000.c | |||
@@ -56,6 +56,31 @@ static const u16 iwl5000_default_queue_to_tx_fifo[] = { | |||
56 | IWL_TX_FIFO_HCCA_2 | 56 | IWL_TX_FIFO_HCCA_2 |
57 | }; | 57 | }; |
58 | 58 | ||
59 | /* FIXME: same implementation as 4965 */ | ||
60 | static int iwl5000_apm_stop_master(struct iwl_priv *priv) | ||
61 | { | ||
62 | int ret = 0; | ||
63 | unsigned long flags; | ||
64 | |||
65 | spin_lock_irqsave(&priv->lock, flags); | ||
66 | |||
67 | /* set stop master bit */ | ||
68 | iwl_set_bit(priv, CSR_RESET, CSR_RESET_REG_FLAG_STOP_MASTER); | ||
69 | |||
70 | ret = iwl_poll_bit(priv, CSR_RESET, | ||
71 | CSR_RESET_REG_FLAG_MASTER_DISABLED, | ||
72 | CSR_RESET_REG_FLAG_MASTER_DISABLED, 100); | ||
73 | if (ret < 0) | ||
74 | goto out; | ||
75 | |||
76 | out: | ||
77 | spin_unlock_irqrestore(&priv->lock, flags); | ||
78 | IWL_DEBUG_INFO("stop master\n"); | ||
79 | |||
80 | return ret; | ||
81 | } | ||
82 | |||
83 | |||
59 | static int iwl5000_apm_init(struct iwl_priv *priv) | 84 | static int iwl5000_apm_init(struct iwl_priv *priv) |
60 | { | 85 | { |
61 | int ret = 0; | 86 | int ret = 0; |
@@ -105,7 +130,7 @@ static void iwl5000_apm_stop(struct iwl_priv *priv) | |||
105 | { | 130 | { |
106 | unsigned long flags; | 131 | unsigned long flags; |
107 | 132 | ||
108 | iwl4965_hw_nic_stop_master(priv); | 133 | iwl5000_apm_stop_master(priv); |
109 | 134 | ||
110 | spin_lock_irqsave(&priv->lock, flags); | 135 | spin_lock_irqsave(&priv->lock, flags); |
111 | 136 | ||
@@ -124,7 +149,7 @@ static int iwl5000_apm_reset(struct iwl_priv *priv) | |||
124 | int ret = 0; | 149 | int ret = 0; |
125 | unsigned long flags; | 150 | unsigned long flags; |
126 | 151 | ||
127 | iwl4965_hw_nic_stop_master(priv); | 152 | iwl5000_apm_stop_master(priv); |
128 | 153 | ||
129 | spin_lock_irqsave(&priv->lock, flags); | 154 | spin_lock_irqsave(&priv->lock, flags); |
130 | 155 | ||
diff --git a/drivers/net/wireless/iwlwifi/iwl-dev.h b/drivers/net/wireless/iwlwifi/iwl-dev.h index d193da3a635a..44bd827a8bc3 100644 --- a/drivers/net/wireless/iwlwifi/iwl-dev.h +++ b/drivers/net/wireless/iwlwifi/iwl-dev.h | |||
@@ -686,7 +686,6 @@ extern void iwl4965_hw_setup_deferred_work(struct iwl_priv *priv); | |||
686 | extern void iwl4965_hw_cancel_deferred_work(struct iwl_priv *priv); | 686 | extern void iwl4965_hw_cancel_deferred_work(struct iwl_priv *priv); |
687 | extern int iwl4965_hw_rxq_stop(struct iwl_priv *priv); | 687 | extern int iwl4965_hw_rxq_stop(struct iwl_priv *priv); |
688 | extern int iwl4965_hw_set_hw_params(struct iwl_priv *priv); | 688 | extern int iwl4965_hw_set_hw_params(struct iwl_priv *priv); |
689 | extern int iwl4965_hw_nic_stop_master(struct iwl_priv *priv); | ||
690 | extern void iwl4965_hw_txq_ctx_stop(struct iwl_priv *priv); | 689 | extern void iwl4965_hw_txq_ctx_stop(struct iwl_priv *priv); |
691 | extern int iwl4965_hw_get_temperature(struct iwl_priv *priv); | 690 | extern int iwl4965_hw_get_temperature(struct iwl_priv *priv); |
692 | extern unsigned int iwl4965_hw_get_beacon_cmd(struct iwl_priv *priv, | 691 | extern unsigned int iwl4965_hw_get_beacon_cmd(struct iwl_priv *priv, |