提交 73d7b5ac 编写于 作者: Z Zhu, Yi 提交者: John W. Linville

iwlwifi: iwl_poll_{direct_}bit cleanup

The patch merges implementation of iwl_poll_bit() and
iwl_poll_direct_bit() by letting the latter be a special case of
the former.
Signed-off-by: NZhu Yi <yi.zhu@intel.com>
Signed-off-by: NReinette Chatre <reinette.chatre@intel.com>
Signed-off-by: NJohn W. Linville <linville@tuxdriver.com>
上级 42802d71
...@@ -321,6 +321,7 @@ struct iwl3945_eeprom { ...@@ -321,6 +321,7 @@ struct iwl3945_eeprom {
/* RSSR */ /* RSSR */
#define FH_RSSR_CTRL (FH_RSSR_TABLE+0x000) #define FH_RSSR_CTRL (FH_RSSR_TABLE+0x000)
#define FH_RSSR_STATUS (FH_RSSR_TABLE+0x004) #define FH_RSSR_STATUS (FH_RSSR_TABLE+0x004)
#define FH_RSSR_CHNL0_RX_STATUS_CHNL_IDLE (0x01000000)
/* TCSR */ /* TCSR */
#define FH_TCSR(_channel) (FH_TCSR_TABLE+(_channel)*0x20) #define FH_TCSR(_channel) (FH_TCSR_TABLE+(_channel)*0x20)
#define FH_TCSR_CONFIG(_channel) (FH_TCSR(_channel)+0x00) #define FH_TCSR_CONFIG(_channel) (FH_TCSR(_channel)+0x00)
......
...@@ -271,16 +271,7 @@ static inline void iwl3945_write_reg_buf(struct iwl3945_priv *priv, ...@@ -271,16 +271,7 @@ static inline void iwl3945_write_reg_buf(struct iwl3945_priv *priv,
static inline int _iwl3945_poll_direct_bit(struct iwl3945_priv *priv, static inline int _iwl3945_poll_direct_bit(struct iwl3945_priv *priv,
u32 addr, u32 mask, int timeout) u32 addr, u32 mask, int timeout)
{ {
int i = 0; return _iwl3945_poll_bit(priv, addr, mask, mask, timeout);
do {
if ((_iwl3945_read_direct32(priv, addr) & mask) == mask)
return i;
udelay(10);
i += 10;
} while (i < timeout);
return -ETIMEDOUT;
} }
#ifdef CONFIG_IWL3945_DEBUG #ifdef CONFIG_IWL3945_DEBUG
......
...@@ -1103,9 +1103,8 @@ int iwl3945_hw_nic_init(struct iwl3945_priv *priv) ...@@ -1103,9 +1103,8 @@ int iwl3945_hw_nic_init(struct iwl3945_priv *priv)
CSR_GIO_CHICKEN_BITS_REG_BIT_L1A_NO_L0S_RX); CSR_GIO_CHICKEN_BITS_REG_BIT_L1A_NO_L0S_RX);
iwl3945_set_bit(priv, CSR_GP_CNTRL, CSR_GP_CNTRL_REG_FLAG_INIT_DONE); iwl3945_set_bit(priv, CSR_GP_CNTRL, CSR_GP_CNTRL_REG_FLAG_INIT_DONE);
rc = iwl3945_poll_bit(priv, CSR_GP_CNTRL, rc = iwl3945_poll_direct_bit(priv, CSR_GP_CNTRL,
CSR_GP_CNTRL_REG_FLAG_MAC_CLOCK_READY, CSR_GP_CNTRL_REG_FLAG_MAC_CLOCK_READY, 25000);
CSR_GP_CNTRL_REG_FLAG_MAC_CLOCK_READY, 25000);
if (rc < 0) { if (rc < 0) {
spin_unlock_irqrestore(&priv->lock, flags); spin_unlock_irqrestore(&priv->lock, flags);
IWL_DEBUG_INFO("Failed to init the card\n"); IWL_DEBUG_INFO("Failed to init the card\n");
...@@ -1286,8 +1285,7 @@ int iwl3945_hw_nic_stop_master(struct iwl3945_priv *priv) ...@@ -1286,8 +1285,7 @@ int iwl3945_hw_nic_stop_master(struct iwl3945_priv *priv)
IWL_DEBUG_INFO("Card in power save, master is already " IWL_DEBUG_INFO("Card in power save, master is already "
"stopped\n"); "stopped\n");
else { else {
rc = iwl3945_poll_bit(priv, CSR_RESET, rc = iwl3945_poll_direct_bit(priv, CSR_RESET,
CSR_RESET_REG_FLAG_MASTER_DISABLED,
CSR_RESET_REG_FLAG_MASTER_DISABLED, 100); CSR_RESET_REG_FLAG_MASTER_DISABLED, 100);
if (rc < 0) { if (rc < 0) {
spin_unlock_irqrestore(&priv->lock, flags); spin_unlock_irqrestore(&priv->lock, flags);
...@@ -1312,9 +1310,8 @@ int iwl3945_hw_nic_reset(struct iwl3945_priv *priv) ...@@ -1312,9 +1310,8 @@ int iwl3945_hw_nic_reset(struct iwl3945_priv *priv)
iwl3945_set_bit(priv, CSR_RESET, CSR_RESET_REG_FLAG_SW_RESET); iwl3945_set_bit(priv, CSR_RESET, CSR_RESET_REG_FLAG_SW_RESET);
rc = iwl3945_poll_bit(priv, CSR_GP_CNTRL, iwl3945_poll_direct_bit(priv, CSR_GP_CNTRL,
CSR_GP_CNTRL_REG_FLAG_MAC_CLOCK_READY, CSR_GP_CNTRL_REG_FLAG_MAC_CLOCK_READY, 25000);
CSR_GP_CNTRL_REG_FLAG_MAC_CLOCK_READY, 25000);
rc = iwl3945_grab_nic_access(priv); rc = iwl3945_grab_nic_access(priv);
if (!rc) { if (!rc) {
...@@ -2311,7 +2308,8 @@ int iwl3945_hw_rxq_stop(struct iwl3945_priv *priv) ...@@ -2311,7 +2308,8 @@ int iwl3945_hw_rxq_stop(struct iwl3945_priv *priv)
} }
iwl3945_write_direct32(priv, FH_RCSR_CONFIG(0), 0); iwl3945_write_direct32(priv, FH_RCSR_CONFIG(0), 0);
rc = iwl3945_poll_direct_bit(priv, FH_RSSR_STATUS, (1 << 24), 1000); rc = iwl3945_poll_direct_bit(priv, FH_RSSR_STATUS,
FH_RSSR_CHNL0_RX_STATUS_CHNL_IDLE, 1000);
if (rc < 0) if (rc < 0)
IWL_ERROR("Can't stop Rx DMA.\n"); IWL_ERROR("Can't stop Rx DMA.\n");
......
...@@ -352,9 +352,8 @@ static int iwl4965_apm_init(struct iwl_priv *priv) ...@@ -352,9 +352,8 @@ static int iwl4965_apm_init(struct iwl_priv *priv)
iwl_set_bit(priv, CSR_GP_CNTRL, CSR_GP_CNTRL_REG_FLAG_INIT_DONE); iwl_set_bit(priv, CSR_GP_CNTRL, CSR_GP_CNTRL_REG_FLAG_INIT_DONE);
/* wait for clock stabilization */ /* wait for clock stabilization */
ret = iwl_poll_bit(priv, CSR_GP_CNTRL, ret = iwl_poll_direct_bit(priv, CSR_GP_CNTRL,
CSR_GP_CNTRL_REG_FLAG_MAC_CLOCK_READY, CSR_GP_CNTRL_REG_FLAG_MAC_CLOCK_READY, 25000);
CSR_GP_CNTRL_REG_FLAG_MAC_CLOCK_READY, 25000);
if (ret < 0) { if (ret < 0) {
IWL_DEBUG_INFO("Failed to init the card\n"); IWL_DEBUG_INFO("Failed to init the card\n");
goto out; goto out;
...@@ -436,9 +435,8 @@ static int iwl4965_apm_stop_master(struct iwl_priv *priv) ...@@ -436,9 +435,8 @@ static int iwl4965_apm_stop_master(struct iwl_priv *priv)
/* set stop master bit */ /* set stop master bit */
iwl_set_bit(priv, CSR_RESET, CSR_RESET_REG_FLAG_STOP_MASTER); iwl_set_bit(priv, CSR_RESET, CSR_RESET_REG_FLAG_STOP_MASTER);
ret = iwl_poll_bit(priv, CSR_RESET, ret = iwl_poll_direct_bit(priv, CSR_RESET,
CSR_RESET_REG_FLAG_MASTER_DISABLED, CSR_RESET_REG_FLAG_MASTER_DISABLED, 100);
CSR_RESET_REG_FLAG_MASTER_DISABLED, 100);
if (ret < 0) if (ret < 0)
goto out; goto out;
...@@ -482,10 +480,8 @@ static int iwl4965_apm_reset(struct iwl_priv *priv) ...@@ -482,10 +480,8 @@ static int iwl4965_apm_reset(struct iwl_priv *priv)
iwl_set_bit(priv, CSR_GP_CNTRL, CSR_GP_CNTRL_REG_FLAG_INIT_DONE); iwl_set_bit(priv, CSR_GP_CNTRL, CSR_GP_CNTRL_REG_FLAG_INIT_DONE);
ret = iwl_poll_bit(priv, CSR_GP_CNTRL, ret = iwl_poll_direct_bit(priv, CSR_GP_CNTRL,
CSR_GP_CNTRL_REG_FLAG_MAC_CLOCK_READY, CSR_GP_CNTRL_REG_FLAG_MAC_CLOCK_READY, 25000);
CSR_GP_CNTRL_REG_FLAG_MAC_CLOCK_READY, 25000);
if (ret < 0) if (ret < 0)
goto out; goto out;
......
...@@ -81,8 +81,7 @@ static int iwl5000_apm_stop_master(struct iwl_priv *priv) ...@@ -81,8 +81,7 @@ static int iwl5000_apm_stop_master(struct iwl_priv *priv)
/* set stop master bit */ /* set stop master bit */
iwl_set_bit(priv, CSR_RESET, CSR_RESET_REG_FLAG_STOP_MASTER); iwl_set_bit(priv, CSR_RESET, CSR_RESET_REG_FLAG_STOP_MASTER);
ret = iwl_poll_bit(priv, CSR_RESET, ret = iwl_poll_direct_bit(priv, CSR_RESET,
CSR_RESET_REG_FLAG_MASTER_DISABLED,
CSR_RESET_REG_FLAG_MASTER_DISABLED, 100); CSR_RESET_REG_FLAG_MASTER_DISABLED, 100);
if (ret < 0) if (ret < 0)
goto out; goto out;
...@@ -120,9 +119,8 @@ static int iwl5000_apm_init(struct iwl_priv *priv) ...@@ -120,9 +119,8 @@ static int iwl5000_apm_init(struct iwl_priv *priv)
iwl_set_bit(priv, CSR_GP_CNTRL, CSR_GP_CNTRL_REG_FLAG_INIT_DONE); iwl_set_bit(priv, CSR_GP_CNTRL, CSR_GP_CNTRL_REG_FLAG_INIT_DONE);
/* wait for clock stabilization */ /* wait for clock stabilization */
ret = iwl_poll_bit(priv, CSR_GP_CNTRL, ret = iwl_poll_direct_bit(priv, CSR_GP_CNTRL,
CSR_GP_CNTRL_REG_FLAG_MAC_CLOCK_READY, CSR_GP_CNTRL_REG_FLAG_MAC_CLOCK_READY, 25000);
CSR_GP_CNTRL_REG_FLAG_MAC_CLOCK_READY, 25000);
if (ret < 0) { if (ret < 0) {
IWL_DEBUG_INFO("Failed to init the card\n"); IWL_DEBUG_INFO("Failed to init the card\n");
return ret; return ret;
...@@ -189,9 +187,8 @@ static int iwl5000_apm_reset(struct iwl_priv *priv) ...@@ -189,9 +187,8 @@ static int iwl5000_apm_reset(struct iwl_priv *priv)
iwl_set_bit(priv, CSR_GP_CNTRL, CSR_GP_CNTRL_REG_FLAG_INIT_DONE); iwl_set_bit(priv, CSR_GP_CNTRL, CSR_GP_CNTRL_REG_FLAG_INIT_DONE);
/* wait for clock stabilization */ /* wait for clock stabilization */
ret = iwl_poll_bit(priv, CSR_GP_CNTRL, ret = iwl_poll_direct_bit(priv, CSR_GP_CNTRL,
CSR_GP_CNTRL_REG_FLAG_MAC_CLOCK_READY, CSR_GP_CNTRL_REG_FLAG_MAC_CLOCK_READY, 25000);
CSR_GP_CNTRL_REG_FLAG_MAC_CLOCK_READY, 25000);
if (ret < 0) { if (ret < 0) {
IWL_DEBUG_INFO("Failed to init the card\n"); IWL_DEBUG_INFO("Failed to init the card\n");
goto out; goto out;
......
...@@ -169,10 +169,9 @@ int iwlcore_eeprom_acquire_semaphore(struct iwl_priv *priv) ...@@ -169,10 +169,9 @@ int iwlcore_eeprom_acquire_semaphore(struct iwl_priv *priv)
CSR_HW_IF_CONFIG_REG_BIT_EEPROM_OWN_SEM); CSR_HW_IF_CONFIG_REG_BIT_EEPROM_OWN_SEM);
/* See if we got it */ /* See if we got it */
ret = iwl_poll_bit(priv, CSR_HW_IF_CONFIG_REG, ret = iwl_poll_direct_bit(priv, CSR_HW_IF_CONFIG_REG,
CSR_HW_IF_CONFIG_REG_BIT_EEPROM_OWN_SEM, CSR_HW_IF_CONFIG_REG_BIT_EEPROM_OWN_SEM,
CSR_HW_IF_CONFIG_REG_BIT_EEPROM_OWN_SEM, EEPROM_SEM_TIMEOUT);
EEPROM_SEM_TIMEOUT);
if (ret >= 0) { if (ret >= 0) {
IWL_DEBUG_IO("Acquired semaphore after %d tries.\n", IWL_DEBUG_IO("Acquired semaphore after %d tries.\n",
count+1); count+1);
......
...@@ -269,19 +269,10 @@ static inline void iwl_write_reg_buf(struct iwl_priv *priv, ...@@ -269,19 +269,10 @@ static inline void iwl_write_reg_buf(struct iwl_priv *priv,
} }
} }
static inline int _iwl_poll_direct_bit(struct iwl_priv *priv, static inline int _iwl_poll_direct_bit(struct iwl_priv *priv, u32 addr,
u32 addr, u32 mask, int timeout) u32 mask, int timeout)
{ {
int i = 0; return _iwl_poll_bit(priv, addr, mask, mask, timeout);
do {
if ((_iwl_read_direct32(priv, addr) & mask) == mask)
return i;
udelay(10);
i += 10;
} while (i < timeout);
return -ETIMEDOUT;
} }
#ifdef CONFIG_IWLWIFI_DEBUG #ifdef CONFIG_IWLWIFI_DEBUG
......
...@@ -467,10 +467,8 @@ int iwl_rxq_stop(struct iwl_priv *priv) ...@@ -467,10 +467,8 @@ int iwl_rxq_stop(struct iwl_priv *priv)
/* stop Rx DMA */ /* stop Rx DMA */
iwl_write_direct32(priv, FH_MEM_RCSR_CHNL0_CONFIG_REG, 0); iwl_write_direct32(priv, FH_MEM_RCSR_CHNL0_CONFIG_REG, 0);
ret = iwl_poll_direct_bit(priv, FH_MEM_RSSR_RX_STATUS_REG, iwl_poll_direct_bit(priv, FH_MEM_RSSR_RX_STATUS_REG,
(1 << 24), 1000); FH_RSSR_CHNL0_RX_STATUS_CHNL_IDLE, 1000);
if (ret < 0)
IWL_ERROR("Can't stop Rx DMA.\n");
iwl_release_nic_access(priv); iwl_release_nic_access(priv);
spin_unlock_irqrestore(&priv->lock, flags); spin_unlock_irqrestore(&priv->lock, flags);
......
...@@ -7925,9 +7925,8 @@ static int iwl3945_pci_probe(struct pci_dev *pdev, const struct pci_device_id *e ...@@ -7925,9 +7925,8 @@ static int iwl3945_pci_probe(struct pci_dev *pdev, const struct pci_device_id *e
CSR_GIO_CHICKEN_BITS_REG_BIT_DIS_L0S_EXIT_TIMER); CSR_GIO_CHICKEN_BITS_REG_BIT_DIS_L0S_EXIT_TIMER);
iwl3945_set_bit(priv, CSR_GP_CNTRL, CSR_GP_CNTRL_REG_FLAG_INIT_DONE); iwl3945_set_bit(priv, CSR_GP_CNTRL, CSR_GP_CNTRL_REG_FLAG_INIT_DONE);
err = iwl3945_poll_bit(priv, CSR_GP_CNTRL, err = iwl3945_poll_direct_bit(priv, CSR_GP_CNTRL,
CSR_GP_CNTRL_REG_FLAG_MAC_CLOCK_READY, CSR_GP_CNTRL_REG_FLAG_MAC_CLOCK_READY, 25000);
CSR_GP_CNTRL_REG_FLAG_MAC_CLOCK_READY, 25000);
if (err < 0) { if (err < 0) {
IWL_DEBUG_INFO("Failed to init the card\n"); IWL_DEBUG_INFO("Failed to init the card\n");
goto out_remove_sysfs; goto out_remove_sysfs;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册