aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/net
diff options
context:
space:
mode:
authorZhu, Yi <yi.zhu@intel.com>2008-12-05 10:58:40 -0500
committerJohn W. Linville <linville@tuxdriver.com>2008-12-12 13:48:21 -0500
commit73d7b5acc461bdc99e0135779d15e1874c6e00a6 (patch)
tree30c62a728e57cc83f938a2a69a0188d624c42793 /drivers/net
parent42802d71dd14dd0e435a8da59d817d0c6f8a2866 (diff)
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: Zhu Yi <yi.zhu@intel.com> Signed-off-by: Reinette Chatre <reinette.chatre@intel.com> Signed-off-by: John W. Linville <linville@tuxdriver.com>
Diffstat (limited to 'drivers/net')
-rw-r--r--drivers/net/wireless/iwlwifi/iwl-3945-hw.h1
-rw-r--r--drivers/net/wireless/iwlwifi/iwl-3945-io.h11
-rw-r--r--drivers/net/wireless/iwlwifi/iwl-3945.c16
-rw-r--r--drivers/net/wireless/iwlwifi/iwl-4965.c16
-rw-r--r--drivers/net/wireless/iwlwifi/iwl-5000.c13
-rw-r--r--drivers/net/wireless/iwlwifi/iwl-eeprom.c7
-rw-r--r--drivers/net/wireless/iwlwifi/iwl-io.h15
-rw-r--r--drivers/net/wireless/iwlwifi/iwl-rx.c6
-rw-r--r--drivers/net/wireless/iwlwifi/iwl3945-base.c5
9 files changed, 30 insertions, 60 deletions
diff --git a/drivers/net/wireless/iwlwifi/iwl-3945-hw.h b/drivers/net/wireless/iwlwifi/iwl-3945-hw.h
index 644bd9e08052..f0f7dc7ae7c6 100644
--- a/drivers/net/wireless/iwlwifi/iwl-3945-hw.h
+++ b/drivers/net/wireless/iwlwifi/iwl-3945-hw.h
@@ -321,6 +321,7 @@ struct iwl3945_eeprom {
321/* RSSR */ 321/* RSSR */
322#define FH_RSSR_CTRL (FH_RSSR_TABLE+0x000) 322#define FH_RSSR_CTRL (FH_RSSR_TABLE+0x000)
323#define FH_RSSR_STATUS (FH_RSSR_TABLE+0x004) 323#define FH_RSSR_STATUS (FH_RSSR_TABLE+0x004)
324#define FH_RSSR_CHNL0_RX_STATUS_CHNL_IDLE (0x01000000)
324/* TCSR */ 325/* TCSR */
325#define FH_TCSR(_channel) (FH_TCSR_TABLE+(_channel)*0x20) 326#define FH_TCSR(_channel) (FH_TCSR_TABLE+(_channel)*0x20)
326#define FH_TCSR_CONFIG(_channel) (FH_TCSR(_channel)+0x00) 327#define FH_TCSR_CONFIG(_channel) (FH_TCSR(_channel)+0x00)
diff --git a/drivers/net/wireless/iwlwifi/iwl-3945-io.h b/drivers/net/wireless/iwlwifi/iwl-3945-io.h
index 2f749432e4bc..994f8bab0dab 100644
--- a/drivers/net/wireless/iwlwifi/iwl-3945-io.h
+++ b/drivers/net/wireless/iwlwifi/iwl-3945-io.h
@@ -271,16 +271,7 @@ static inline void iwl3945_write_reg_buf(struct iwl3945_priv *priv,
271static inline int _iwl3945_poll_direct_bit(struct iwl3945_priv *priv, 271static inline int _iwl3945_poll_direct_bit(struct iwl3945_priv *priv,
272 u32 addr, u32 mask, int timeout) 272 u32 addr, u32 mask, int timeout)
273{ 273{
274 int i = 0; 274 return _iwl3945_poll_bit(priv, addr, mask, mask, timeout);
275
276 do {
277 if ((_iwl3945_read_direct32(priv, addr) & mask) == mask)
278 return i;
279 udelay(10);
280 i += 10;
281 } while (i < timeout);
282
283 return -ETIMEDOUT;
284} 275}
285 276
286#ifdef CONFIG_IWL3945_DEBUG 277#ifdef CONFIG_IWL3945_DEBUG
diff --git a/drivers/net/wireless/iwlwifi/iwl-3945.c b/drivers/net/wireless/iwlwifi/iwl-3945.c
index 4e9e592b1cab..1c35fa857be6 100644
--- a/drivers/net/wireless/iwlwifi/iwl-3945.c
+++ b/drivers/net/wireless/iwlwifi/iwl-3945.c
@@ -1103,9 +1103,8 @@ int iwl3945_hw_nic_init(struct iwl3945_priv *priv)
1103 CSR_GIO_CHICKEN_BITS_REG_BIT_L1A_NO_L0S_RX); 1103 CSR_GIO_CHICKEN_BITS_REG_BIT_L1A_NO_L0S_RX);
1104 1104
1105 iwl3945_set_bit(priv, CSR_GP_CNTRL, CSR_GP_CNTRL_REG_FLAG_INIT_DONE); 1105 iwl3945_set_bit(priv, CSR_GP_CNTRL, CSR_GP_CNTRL_REG_FLAG_INIT_DONE);
1106 rc = iwl3945_poll_bit(priv, CSR_GP_CNTRL, 1106 rc = iwl3945_poll_direct_bit(priv, CSR_GP_CNTRL,
1107 CSR_GP_CNTRL_REG_FLAG_MAC_CLOCK_READY, 1107 CSR_GP_CNTRL_REG_FLAG_MAC_CLOCK_READY, 25000);
1108 CSR_GP_CNTRL_REG_FLAG_MAC_CLOCK_READY, 25000);
1109 if (rc < 0) { 1108 if (rc < 0) {
1110 spin_unlock_irqrestore(&priv->lock, flags); 1109 spin_unlock_irqrestore(&priv->lock, flags);
1111 IWL_DEBUG_INFO("Failed to init the card\n"); 1110 IWL_DEBUG_INFO("Failed to init the card\n");
@@ -1286,8 +1285,7 @@ int iwl3945_hw_nic_stop_master(struct iwl3945_priv *priv)
1286 IWL_DEBUG_INFO("Card in power save, master is already " 1285 IWL_DEBUG_INFO("Card in power save, master is already "
1287 "stopped\n"); 1286 "stopped\n");
1288 else { 1287 else {
1289 rc = iwl3945_poll_bit(priv, CSR_RESET, 1288 rc = iwl3945_poll_direct_bit(priv, CSR_RESET,
1290 CSR_RESET_REG_FLAG_MASTER_DISABLED,
1291 CSR_RESET_REG_FLAG_MASTER_DISABLED, 100); 1289 CSR_RESET_REG_FLAG_MASTER_DISABLED, 100);
1292 if (rc < 0) { 1290 if (rc < 0) {
1293 spin_unlock_irqrestore(&priv->lock, flags); 1291 spin_unlock_irqrestore(&priv->lock, flags);
@@ -1312,9 +1310,8 @@ int iwl3945_hw_nic_reset(struct iwl3945_priv *priv)
1312 1310
1313 iwl3945_set_bit(priv, CSR_RESET, CSR_RESET_REG_FLAG_SW_RESET); 1311 iwl3945_set_bit(priv, CSR_RESET, CSR_RESET_REG_FLAG_SW_RESET);
1314 1312
1315 rc = iwl3945_poll_bit(priv, CSR_GP_CNTRL, 1313 iwl3945_poll_direct_bit(priv, CSR_GP_CNTRL,
1316 CSR_GP_CNTRL_REG_FLAG_MAC_CLOCK_READY, 1314 CSR_GP_CNTRL_REG_FLAG_MAC_CLOCK_READY, 25000);
1317 CSR_GP_CNTRL_REG_FLAG_MAC_CLOCK_READY, 25000);
1318 1315
1319 rc = iwl3945_grab_nic_access(priv); 1316 rc = iwl3945_grab_nic_access(priv);
1320 if (!rc) { 1317 if (!rc) {
@@ -2311,7 +2308,8 @@ int iwl3945_hw_rxq_stop(struct iwl3945_priv *priv)
2311 } 2308 }
2312 2309
2313 iwl3945_write_direct32(priv, FH_RCSR_CONFIG(0), 0); 2310 iwl3945_write_direct32(priv, FH_RCSR_CONFIG(0), 0);
2314 rc = iwl3945_poll_direct_bit(priv, FH_RSSR_STATUS, (1 << 24), 1000); 2311 rc = iwl3945_poll_direct_bit(priv, FH_RSSR_STATUS,
2312 FH_RSSR_CHNL0_RX_STATUS_CHNL_IDLE, 1000);
2315 if (rc < 0) 2313 if (rc < 0)
2316 IWL_ERROR("Can't stop Rx DMA.\n"); 2314 IWL_ERROR("Can't stop Rx DMA.\n");
2317 2315
diff --git a/drivers/net/wireless/iwlwifi/iwl-4965.c b/drivers/net/wireless/iwlwifi/iwl-4965.c
index c961e2c716d3..324825e810ff 100644
--- a/drivers/net/wireless/iwlwifi/iwl-4965.c
+++ b/drivers/net/wireless/iwlwifi/iwl-4965.c
@@ -352,9 +352,8 @@ static int iwl4965_apm_init(struct iwl_priv *priv)
352 iwl_set_bit(priv, CSR_GP_CNTRL, CSR_GP_CNTRL_REG_FLAG_INIT_DONE); 352 iwl_set_bit(priv, CSR_GP_CNTRL, CSR_GP_CNTRL_REG_FLAG_INIT_DONE);
353 353
354 /* wait for clock stabilization */ 354 /* wait for clock stabilization */
355 ret = iwl_poll_bit(priv, CSR_GP_CNTRL, 355 ret = iwl_poll_direct_bit(priv, CSR_GP_CNTRL,
356 CSR_GP_CNTRL_REG_FLAG_MAC_CLOCK_READY, 356 CSR_GP_CNTRL_REG_FLAG_MAC_CLOCK_READY, 25000);
357 CSR_GP_CNTRL_REG_FLAG_MAC_CLOCK_READY, 25000);
358 if (ret < 0) { 357 if (ret < 0) {
359 IWL_DEBUG_INFO("Failed to init the card\n"); 358 IWL_DEBUG_INFO("Failed to init the card\n");
360 goto out; 359 goto out;
@@ -436,9 +435,8 @@ static int iwl4965_apm_stop_master(struct iwl_priv *priv)
436 /* set stop master bit */ 435 /* set stop master bit */
437 iwl_set_bit(priv, CSR_RESET, CSR_RESET_REG_FLAG_STOP_MASTER); 436 iwl_set_bit(priv, CSR_RESET, CSR_RESET_REG_FLAG_STOP_MASTER);
438 437
439 ret = iwl_poll_bit(priv, CSR_RESET, 438 ret = iwl_poll_direct_bit(priv, CSR_RESET,
440 CSR_RESET_REG_FLAG_MASTER_DISABLED, 439 CSR_RESET_REG_FLAG_MASTER_DISABLED, 100);
441 CSR_RESET_REG_FLAG_MASTER_DISABLED, 100);
442 if (ret < 0) 440 if (ret < 0)
443 goto out; 441 goto out;
444 442
@@ -482,10 +480,8 @@ static int iwl4965_apm_reset(struct iwl_priv *priv)
482 480
483 iwl_set_bit(priv, CSR_GP_CNTRL, CSR_GP_CNTRL_REG_FLAG_INIT_DONE); 481 iwl_set_bit(priv, CSR_GP_CNTRL, CSR_GP_CNTRL_REG_FLAG_INIT_DONE);
484 482
485 ret = iwl_poll_bit(priv, CSR_GP_CNTRL, 483 ret = iwl_poll_direct_bit(priv, CSR_GP_CNTRL,
486 CSR_GP_CNTRL_REG_FLAG_MAC_CLOCK_READY, 484 CSR_GP_CNTRL_REG_FLAG_MAC_CLOCK_READY, 25000);
487 CSR_GP_CNTRL_REG_FLAG_MAC_CLOCK_READY, 25000);
488
489 if (ret < 0) 485 if (ret < 0)
490 goto out; 486 goto out;
491 487
diff --git a/drivers/net/wireless/iwlwifi/iwl-5000.c b/drivers/net/wireless/iwlwifi/iwl-5000.c
index 438e4bd0a9a8..1b82742ea333 100644
--- a/drivers/net/wireless/iwlwifi/iwl-5000.c
+++ b/drivers/net/wireless/iwlwifi/iwl-5000.c
@@ -81,8 +81,7 @@ static int iwl5000_apm_stop_master(struct iwl_priv *priv)
81 /* set stop master bit */ 81 /* set stop master bit */
82 iwl_set_bit(priv, CSR_RESET, CSR_RESET_REG_FLAG_STOP_MASTER); 82 iwl_set_bit(priv, CSR_RESET, CSR_RESET_REG_FLAG_STOP_MASTER);
83 83
84 ret = iwl_poll_bit(priv, CSR_RESET, 84 ret = iwl_poll_direct_bit(priv, CSR_RESET,
85 CSR_RESET_REG_FLAG_MASTER_DISABLED,
86 CSR_RESET_REG_FLAG_MASTER_DISABLED, 100); 85 CSR_RESET_REG_FLAG_MASTER_DISABLED, 100);
87 if (ret < 0) 86 if (ret < 0)
88 goto out; 87 goto out;
@@ -120,9 +119,8 @@ static int iwl5000_apm_init(struct iwl_priv *priv)
120 iwl_set_bit(priv, CSR_GP_CNTRL, CSR_GP_CNTRL_REG_FLAG_INIT_DONE); 119 iwl_set_bit(priv, CSR_GP_CNTRL, CSR_GP_CNTRL_REG_FLAG_INIT_DONE);
121 120
122 /* wait for clock stabilization */ 121 /* wait for clock stabilization */
123 ret = iwl_poll_bit(priv, CSR_GP_CNTRL, 122 ret = iwl_poll_direct_bit(priv, CSR_GP_CNTRL,
124 CSR_GP_CNTRL_REG_FLAG_MAC_CLOCK_READY, 123 CSR_GP_CNTRL_REG_FLAG_MAC_CLOCK_READY, 25000);
125 CSR_GP_CNTRL_REG_FLAG_MAC_CLOCK_READY, 25000);
126 if (ret < 0) { 124 if (ret < 0) {
127 IWL_DEBUG_INFO("Failed to init the card\n"); 125 IWL_DEBUG_INFO("Failed to init the card\n");
128 return ret; 126 return ret;
@@ -189,9 +187,8 @@ static int iwl5000_apm_reset(struct iwl_priv *priv)
189 iwl_set_bit(priv, CSR_GP_CNTRL, CSR_GP_CNTRL_REG_FLAG_INIT_DONE); 187 iwl_set_bit(priv, CSR_GP_CNTRL, CSR_GP_CNTRL_REG_FLAG_INIT_DONE);
190 188
191 /* wait for clock stabilization */ 189 /* wait for clock stabilization */
192 ret = iwl_poll_bit(priv, CSR_GP_CNTRL, 190 ret = iwl_poll_direct_bit(priv, CSR_GP_CNTRL,
193 CSR_GP_CNTRL_REG_FLAG_MAC_CLOCK_READY, 191 CSR_GP_CNTRL_REG_FLAG_MAC_CLOCK_READY, 25000);
194 CSR_GP_CNTRL_REG_FLAG_MAC_CLOCK_READY, 25000);
195 if (ret < 0) { 192 if (ret < 0) {
196 IWL_DEBUG_INFO("Failed to init the card\n"); 193 IWL_DEBUG_INFO("Failed to init the card\n");
197 goto out; 194 goto out;
diff --git a/drivers/net/wireless/iwlwifi/iwl-eeprom.c b/drivers/net/wireless/iwlwifi/iwl-eeprom.c
index 792a3c15f172..ae04327ec9ee 100644
--- a/drivers/net/wireless/iwlwifi/iwl-eeprom.c
+++ b/drivers/net/wireless/iwlwifi/iwl-eeprom.c
@@ -169,10 +169,9 @@ int iwlcore_eeprom_acquire_semaphore(struct iwl_priv *priv)
169 CSR_HW_IF_CONFIG_REG_BIT_EEPROM_OWN_SEM); 169 CSR_HW_IF_CONFIG_REG_BIT_EEPROM_OWN_SEM);
170 170
171 /* See if we got it */ 171 /* See if we got it */
172 ret = iwl_poll_bit(priv, CSR_HW_IF_CONFIG_REG, 172 ret = iwl_poll_direct_bit(priv, CSR_HW_IF_CONFIG_REG,
173 CSR_HW_IF_CONFIG_REG_BIT_EEPROM_OWN_SEM, 173 CSR_HW_IF_CONFIG_REG_BIT_EEPROM_OWN_SEM,
174 CSR_HW_IF_CONFIG_REG_BIT_EEPROM_OWN_SEM, 174 EEPROM_SEM_TIMEOUT);
175 EEPROM_SEM_TIMEOUT);
176 if (ret >= 0) { 175 if (ret >= 0) {
177 IWL_DEBUG_IO("Acquired semaphore after %d tries.\n", 176 IWL_DEBUG_IO("Acquired semaphore after %d tries.\n",
178 count+1); 177 count+1);
diff --git a/drivers/net/wireless/iwlwifi/iwl-io.h b/drivers/net/wireless/iwlwifi/iwl-io.h
index a5c489af937a..c56dc215fef7 100644
--- a/drivers/net/wireless/iwlwifi/iwl-io.h
+++ b/drivers/net/wireless/iwlwifi/iwl-io.h
@@ -269,19 +269,10 @@ static inline void iwl_write_reg_buf(struct iwl_priv *priv,
269 } 269 }
270} 270}
271 271
272static inline int _iwl_poll_direct_bit(struct iwl_priv *priv, 272static inline int _iwl_poll_direct_bit(struct iwl_priv *priv, u32 addr,
273 u32 addr, u32 mask, int timeout) 273 u32 mask, int timeout)
274{ 274{
275 int i = 0; 275 return _iwl_poll_bit(priv, addr, mask, mask, timeout);
276
277 do {
278 if ((_iwl_read_direct32(priv, addr) & mask) == mask)
279 return i;
280 udelay(10);
281 i += 10;
282 } while (i < timeout);
283
284 return -ETIMEDOUT;
285} 276}
286 277
287#ifdef CONFIG_IWLWIFI_DEBUG 278#ifdef CONFIG_IWLWIFI_DEBUG
diff --git a/drivers/net/wireless/iwlwifi/iwl-rx.c b/drivers/net/wireless/iwlwifi/iwl-rx.c
index 6dd16c7b5d93..1938e6d5026a 100644
--- a/drivers/net/wireless/iwlwifi/iwl-rx.c
+++ b/drivers/net/wireless/iwlwifi/iwl-rx.c
@@ -467,10 +467,8 @@ int iwl_rxq_stop(struct iwl_priv *priv)
467 467
468 /* stop Rx DMA */ 468 /* stop Rx DMA */
469 iwl_write_direct32(priv, FH_MEM_RCSR_CHNL0_CONFIG_REG, 0); 469 iwl_write_direct32(priv, FH_MEM_RCSR_CHNL0_CONFIG_REG, 0);
470 ret = iwl_poll_direct_bit(priv, FH_MEM_RSSR_RX_STATUS_REG, 470 iwl_poll_direct_bit(priv, FH_MEM_RSSR_RX_STATUS_REG,
471 (1 << 24), 1000); 471 FH_RSSR_CHNL0_RX_STATUS_CHNL_IDLE, 1000);
472 if (ret < 0)
473 IWL_ERROR("Can't stop Rx DMA.\n");
474 472
475 iwl_release_nic_access(priv); 473 iwl_release_nic_access(priv);
476 spin_unlock_irqrestore(&priv->lock, flags); 474 spin_unlock_irqrestore(&priv->lock, flags);
diff --git a/drivers/net/wireless/iwlwifi/iwl3945-base.c b/drivers/net/wireless/iwlwifi/iwl3945-base.c
index 1a411c2d83e6..f7fa68bf8314 100644
--- a/drivers/net/wireless/iwlwifi/iwl3945-base.c
+++ b/drivers/net/wireless/iwlwifi/iwl3945-base.c
@@ -7925,9 +7925,8 @@ static int iwl3945_pci_probe(struct pci_dev *pdev, const struct pci_device_id *e
7925 CSR_GIO_CHICKEN_BITS_REG_BIT_DIS_L0S_EXIT_TIMER); 7925 CSR_GIO_CHICKEN_BITS_REG_BIT_DIS_L0S_EXIT_TIMER);
7926 7926
7927 iwl3945_set_bit(priv, CSR_GP_CNTRL, CSR_GP_CNTRL_REG_FLAG_INIT_DONE); 7927 iwl3945_set_bit(priv, CSR_GP_CNTRL, CSR_GP_CNTRL_REG_FLAG_INIT_DONE);
7928 err = iwl3945_poll_bit(priv, CSR_GP_CNTRL, 7928 err = iwl3945_poll_direct_bit(priv, CSR_GP_CNTRL,
7929 CSR_GP_CNTRL_REG_FLAG_MAC_CLOCK_READY, 7929 CSR_GP_CNTRL_REG_FLAG_MAC_CLOCK_READY, 25000);
7930 CSR_GP_CNTRL_REG_FLAG_MAC_CLOCK_READY, 25000);
7931 if (err < 0) { 7930 if (err < 0) {
7932 IWL_DEBUG_INFO("Failed to init the card\n"); 7931 IWL_DEBUG_INFO("Failed to init the card\n");
7933 goto out_remove_sysfs; 7932 goto out_remove_sysfs;