aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/net/wireless/iwlwifi/iwl-eeprom.c
diff options
context:
space:
mode:
authorDon Fry <donald.h.fry@intel.com>2011-04-20 18:25:14 -0400
committerWey-Yi Guy <wey-yi.w.guy@intel.com>2011-04-30 11:56:59 -0400
commit16b80b714f8ef86d47680e4afa0eeb8cc61daef4 (patch)
treefe12b355a891131b19946d308339ee394cfe4baf /drivers/net/wireless/iwlwifi/iwl-eeprom.c
parent9d143e9a0d68025efe902d86eb6207cbec36dcdb (diff)
iwlagn: semaphore and calib cleanup
All agn devices use the same eeprom semaphore and calib version routines. Delete the indirection and move the semaphore routines to where they are used and make static. Signed-off-by: Don Fry <donald.h.fry@intel.com> Signed-off-by: Wey-Yi Guy <wey-yi.w.guy@intel.com>
Diffstat (limited to 'drivers/net/wireless/iwlwifi/iwl-eeprom.c')
-rw-r--r--drivers/net/wireless/iwlwifi/iwl-eeprom.c43
1 files changed, 41 insertions, 2 deletions
diff --git a/drivers/net/wireless/iwlwifi/iwl-eeprom.c b/drivers/net/wireless/iwlwifi/iwl-eeprom.c
index 1e1a2d8df1d..c8397962632 100644
--- a/drivers/net/wireless/iwlwifi/iwl-eeprom.c
+++ b/drivers/net/wireless/iwlwifi/iwl-eeprom.c
@@ -142,6 +142,45 @@ static const u8 iwl_eeprom_band_7[] = { /* 5.2 ht40 channel */
142 * 142 *
143******************************************************************************/ 143******************************************************************************/
144 144
145/*
146 * The device's EEPROM semaphore prevents conflicts between driver and uCode
147 * when accessing the EEPROM; each access is a series of pulses to/from the
148 * EEPROM chip, not a single event, so even reads could conflict if they
149 * weren't arbitrated by the semaphore.
150 */
151static int iwl_eeprom_acquire_semaphore(struct iwl_priv *priv)
152{
153 u16 count;
154 int ret;
155
156 for (count = 0; count < EEPROM_SEM_RETRY_LIMIT; count++) {
157 /* Request semaphore */
158 iwl_set_bit(priv, CSR_HW_IF_CONFIG_REG,
159 CSR_HW_IF_CONFIG_REG_BIT_EEPROM_OWN_SEM);
160
161 /* See if we got it */
162 ret = iwl_poll_bit(priv, CSR_HW_IF_CONFIG_REG,
163 CSR_HW_IF_CONFIG_REG_BIT_EEPROM_OWN_SEM,
164 CSR_HW_IF_CONFIG_REG_BIT_EEPROM_OWN_SEM,
165 EEPROM_SEM_TIMEOUT);
166 if (ret >= 0) {
167 IWL_DEBUG_EEPROM(priv,
168 "Acquired semaphore after %d tries.\n",
169 count+1);
170 return ret;
171 }
172 }
173
174 return ret;
175}
176
177static void iwl_eeprom_release_semaphore(struct iwl_priv *priv)
178{
179 iwl_clear_bit(priv, CSR_HW_IF_CONFIG_REG,
180 CSR_HW_IF_CONFIG_REG_BIT_EEPROM_OWN_SEM);
181
182}
183
145static int iwl_eeprom_verify_signature(struct iwl_priv *priv) 184static int iwl_eeprom_verify_signature(struct iwl_priv *priv)
146{ 185{
147 u32 gp = iwl_read32(priv, CSR_EEPROM_GP) & CSR_EEPROM_GP_VALID_MSK; 186 u32 gp = iwl_read32(priv, CSR_EEPROM_GP) & CSR_EEPROM_GP_VALID_MSK;
@@ -421,7 +460,7 @@ int iwl_eeprom_init(struct iwl_priv *priv, u32 hw_rev)
421 } 460 }
422 461
423 /* Make sure driver (instead of uCode) is allowed to read EEPROM */ 462 /* Make sure driver (instead of uCode) is allowed to read EEPROM */
424 ret = priv->cfg->ops->lib->eeprom_ops.acquire_semaphore(priv); 463 ret = iwl_eeprom_acquire_semaphore(priv);
425 if (ret < 0) { 464 if (ret < 0) {
426 IWL_ERR(priv, "Failed to acquire EEPROM semaphore.\n"); 465 IWL_ERR(priv, "Failed to acquire EEPROM semaphore.\n");
427 ret = -ENOENT; 466 ret = -ENOENT;
@@ -488,7 +527,7 @@ int iwl_eeprom_init(struct iwl_priv *priv, u32 hw_rev)
488 527
489 ret = 0; 528 ret = 0;
490done: 529done:
491 priv->cfg->ops->lib->eeprom_ops.release_semaphore(priv); 530 iwl_eeprom_release_semaphore(priv);
492 531
493err: 532err:
494 if (ret) 533 if (ret)