diff options
author | Johannes Berg <johannes.berg@intel.com> | 2010-01-21 08:28:40 -0500 |
---|---|---|
committer | Reinette Chatre <reinette.chatre@intel.com> | 2010-01-29 14:13:36 -0500 |
commit | 9f1f3ceacb7e52d9bc0364b4f26ae418de79656f (patch) | |
tree | ca2ea32b79d783e32408545b21a5b9e4aa5eef9a /drivers/net/wireless | |
parent | 4d6959219bb71aa34383fc1a1a520820aee6292b (diff) |
iwlagn: simplify ucode loading
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>
Diffstat (limited to 'drivers/net/wireless')
-rw-r--r-- | drivers/net/wireless/iwlwifi/iwl-5000.c | 63 |
1 files changed, 22 insertions, 41 deletions
diff --git a/drivers/net/wireless/iwlwifi/iwl-5000.c b/drivers/net/wireless/iwlwifi/iwl-5000.c index 6bb433a0e535..6d5988901341 100644 --- a/drivers/net/wireless/iwlwifi/iwl-5000.c +++ b/drivers/net/wireless/iwlwifi/iwl-5000.c | |||
@@ -412,12 +412,14 @@ static void iwl5000_rx_calib_complete(struct iwl_priv *priv, | |||
412 | /* | 412 | /* |
413 | * ucode | 413 | * ucode |
414 | */ | 414 | */ |
415 | static int iwl5000_load_section(struct iwl_priv *priv, | 415 | static int iwl5000_load_section(struct iwl_priv *priv, const char *name, |
416 | struct fw_desc *image, | 416 | struct fw_desc *image, u32 dst_addr) |
417 | u32 dst_addr) | ||
418 | { | 417 | { |
419 | dma_addr_t phy_addr = image->p_addr; | 418 | dma_addr_t phy_addr = image->p_addr; |
420 | u32 byte_cnt = image->len; | 419 | u32 byte_cnt = image->len; |
420 | int ret; | ||
421 | |||
422 | priv->ucode_write_complete = 0; | ||
421 | 423 | ||
422 | iwl_write_direct32(priv, | 424 | iwl_write_direct32(priv, |
423 | FH_TCSR_CHNL_TX_CONFIG_REG(FH_SRVC_CHNL), | 425 | FH_TCSR_CHNL_TX_CONFIG_REG(FH_SRVC_CHNL), |
@@ -447,57 +449,36 @@ static int iwl5000_load_section(struct iwl_priv *priv, | |||
447 | FH_TCSR_TX_CONFIG_REG_VAL_DMA_CREDIT_DISABLE | | 449 | FH_TCSR_TX_CONFIG_REG_VAL_DMA_CREDIT_DISABLE | |
448 | FH_TCSR_TX_CONFIG_REG_VAL_CIRQ_HOST_ENDTFD); | 450 | FH_TCSR_TX_CONFIG_REG_VAL_CIRQ_HOST_ENDTFD); |
449 | 451 | ||
450 | return 0; | 452 | IWL_DEBUG_INFO(priv, "%s uCode section being loaded...\n", name); |
451 | } | ||
452 | |||
453 | static int iwl5000_load_given_ucode(struct iwl_priv *priv, | ||
454 | struct fw_desc *inst_image, | ||
455 | struct fw_desc *data_image) | ||
456 | { | ||
457 | int ret = 0; | ||
458 | |||
459 | ret = iwl5000_load_section(priv, inst_image, | ||
460 | IWL50_RTC_INST_LOWER_BOUND); | ||
461 | if (ret) | ||
462 | return ret; | ||
463 | |||
464 | IWL_DEBUG_INFO(priv, "INST uCode section being loaded...\n"); | ||
465 | ret = wait_event_interruptible_timeout(priv->wait_command_queue, | 453 | ret = wait_event_interruptible_timeout(priv->wait_command_queue, |
466 | priv->ucode_write_complete, 5 * HZ); | 454 | priv->ucode_write_complete, 5 * HZ); |
467 | if (ret == -ERESTARTSYS) { | 455 | if (ret == -ERESTARTSYS) { |
468 | IWL_ERR(priv, "Could not load the INST uCode section due " | 456 | IWL_ERR(priv, "Could not load the %s uCode section due " |
469 | "to interrupt\n"); | 457 | "to interrupt\n", name); |
470 | return ret; | 458 | return ret; |
471 | } | 459 | } |
472 | if (!ret) { | 460 | if (!ret) { |
473 | IWL_ERR(priv, "Could not load the INST uCode section\n"); | 461 | IWL_ERR(priv, "Could not load the %s uCode section\n", |
462 | name); | ||
474 | return -ETIMEDOUT; | 463 | return -ETIMEDOUT; |
475 | } | 464 | } |
476 | 465 | ||
477 | priv->ucode_write_complete = 0; | 466 | return 0; |
478 | 467 | } | |
479 | ret = iwl5000_load_section( | ||
480 | priv, data_image, IWL50_RTC_DATA_LOWER_BOUND); | ||
481 | if (ret) | ||
482 | return ret; | ||
483 | 468 | ||
484 | IWL_DEBUG_INFO(priv, "DATA uCode section being loaded...\n"); | 469 | static int iwl5000_load_given_ucode(struct iwl_priv *priv, |
470 | struct fw_desc *inst_image, | ||
471 | struct fw_desc *data_image) | ||
472 | { | ||
473 | int ret = 0; | ||
485 | 474 | ||
486 | ret = wait_event_interruptible_timeout(priv->wait_command_queue, | 475 | ret = iwl5000_load_section(priv, "INST", inst_image, |
487 | priv->ucode_write_complete, 5 * HZ); | 476 | IWL50_RTC_INST_LOWER_BOUND); |
488 | if (ret == -ERESTARTSYS) { | 477 | if (ret) |
489 | IWL_ERR(priv, "Could not load the INST uCode section due " | ||
490 | "to interrupt\n"); | ||
491 | return ret; | 478 | return ret; |
492 | } else if (!ret) { | ||
493 | IWL_ERR(priv, "Could not load the DATA uCode section\n"); | ||
494 | return -ETIMEDOUT; | ||
495 | } else | ||
496 | ret = 0; | ||
497 | |||
498 | priv->ucode_write_complete = 0; | ||
499 | 479 | ||
500 | return ret; | 480 | return iwl5000_load_section(priv, "DATA", data_image, |
481 | IWL50_RTC_DATA_LOWER_BOUND); | ||
501 | } | 482 | } |
502 | 483 | ||
503 | int iwl5000_load_ucode(struct iwl_priv *priv) | 484 | int iwl5000_load_ucode(struct iwl_priv *priv) |