Skip to content

Commit

Permalink
iwlagn: simplify ucode loading
Browse files Browse the repository at this point in the history
Move the waiting into iwl5000_load_section instead
of duplicating it in the caller.

Signed-off-by: Johannes Berg <johannes.berg@intel.com>
Signed-off-by: Reinette Chatre <reinette.chatre@intel.com>
  • Loading branch information
Johannes Berg authored and Reinette Chatre committed Jan 29, 2010
1 parent 4d69592 commit 9f1f3ce
Showing 1 changed file with 22 additions and 41 deletions.
63 changes: 22 additions & 41 deletions drivers/net/wireless/iwlwifi/iwl-5000.c
Original file line number Diff line number Diff line change
Expand Up @@ -412,12 +412,14 @@ static void iwl5000_rx_calib_complete(struct iwl_priv *priv,
/*
* ucode
*/
static int iwl5000_load_section(struct iwl_priv *priv,
struct fw_desc *image,
u32 dst_addr)
static int iwl5000_load_section(struct iwl_priv *priv, const char *name,
struct fw_desc *image, u32 dst_addr)
{
dma_addr_t phy_addr = image->p_addr;
u32 byte_cnt = image->len;
int ret;

priv->ucode_write_complete = 0;

iwl_write_direct32(priv,
FH_TCSR_CHNL_TX_CONFIG_REG(FH_SRVC_CHNL),
Expand Down Expand Up @@ -447,57 +449,36 @@ static int iwl5000_load_section(struct iwl_priv *priv,
FH_TCSR_TX_CONFIG_REG_VAL_DMA_CREDIT_DISABLE |
FH_TCSR_TX_CONFIG_REG_VAL_CIRQ_HOST_ENDTFD);

return 0;
}

static int iwl5000_load_given_ucode(struct iwl_priv *priv,
struct fw_desc *inst_image,
struct fw_desc *data_image)
{
int ret = 0;

ret = iwl5000_load_section(priv, inst_image,
IWL50_RTC_INST_LOWER_BOUND);
if (ret)
return ret;

IWL_DEBUG_INFO(priv, "INST uCode section being loaded...\n");
IWL_DEBUG_INFO(priv, "%s uCode section being loaded...\n", name);
ret = wait_event_interruptible_timeout(priv->wait_command_queue,
priv->ucode_write_complete, 5 * HZ);
if (ret == -ERESTARTSYS) {
IWL_ERR(priv, "Could not load the INST uCode section due "
"to interrupt\n");
IWL_ERR(priv, "Could not load the %s uCode section due "
"to interrupt\n", name);
return ret;
}
if (!ret) {
IWL_ERR(priv, "Could not load the INST uCode section\n");
IWL_ERR(priv, "Could not load the %s uCode section\n",
name);
return -ETIMEDOUT;
}

priv->ucode_write_complete = 0;

ret = iwl5000_load_section(
priv, data_image, IWL50_RTC_DATA_LOWER_BOUND);
if (ret)
return ret;
return 0;
}

IWL_DEBUG_INFO(priv, "DATA uCode section being loaded...\n");
static int iwl5000_load_given_ucode(struct iwl_priv *priv,
struct fw_desc *inst_image,
struct fw_desc *data_image)
{
int ret = 0;

ret = wait_event_interruptible_timeout(priv->wait_command_queue,
priv->ucode_write_complete, 5 * HZ);
if (ret == -ERESTARTSYS) {
IWL_ERR(priv, "Could not load the INST uCode section due "
"to interrupt\n");
ret = iwl5000_load_section(priv, "INST", inst_image,
IWL50_RTC_INST_LOWER_BOUND);
if (ret)
return ret;
} else if (!ret) {
IWL_ERR(priv, "Could not load the DATA uCode section\n");
return -ETIMEDOUT;
} else
ret = 0;

priv->ucode_write_complete = 0;

return ret;
return iwl5000_load_section(priv, "DATA", data_image,
IWL50_RTC_DATA_LOWER_BOUND);
}

int iwl5000_load_ucode(struct iwl_priv *priv)
Expand Down

0 comments on commit 9f1f3ce

Please sign in to comment.