aboutsummaryrefslogtreecommitdiffstats
path: root/drivers
diff options
context:
space:
mode:
authorDon Fry <donald.h.fry@intel.com>2011-11-10 09:55:09 -0500
committerJohn W. Linville <linville@tuxdriver.com>2011-11-11 12:32:53 -0500
commitbaa0005663d6b4aa48ab5c632d74b459fcfeb086 (patch)
tree19a3b1b7168807df9fa5e75616f97a6ec5710d8e /drivers
parent8929c24bf2ef4fb983ff86478116092080f8773f (diff)
iwlagn: push knowledge of ucode image lower down
Move the knowledge of the ucode image to lower level routines. Also do not pass the iwl_priv structure lower than it needs to be. Signed-off-by: Don Fry <donald.h.fry@intel.com> Signed-off-by: Wey-Yi Guy <wey-yi.w.guy@intel.com> Signed-off-by: John W. Linville <linville@tuxdriver.com>
Diffstat (limited to 'drivers')
-rw-r--r--drivers/net/wireless/iwlwifi/iwl-agn-ucode.c51
1 files changed, 30 insertions, 21 deletions
diff --git a/drivers/net/wireless/iwlwifi/iwl-agn-ucode.c b/drivers/net/wireless/iwlwifi/iwl-agn-ucode.c
index 1ad4af42f37e..9144ef5efe49 100644
--- a/drivers/net/wireless/iwlwifi/iwl-agn-ucode.c
+++ b/drivers/net/wireless/iwlwifi/iwl-agn-ucode.c
@@ -142,9 +142,16 @@ static inline struct fw_img *iwl_get_ucode_image(struct iwl_priv *priv,
142} 142}
143 143
144static int iwlagn_load_given_ucode(struct iwl_priv *priv, 144static int iwlagn_load_given_ucode(struct iwl_priv *priv,
145 struct fw_img *image) 145 enum iwlagn_ucode_type ucode_type)
146{ 146{
147 int ret = 0; 147 int ret = 0;
148 struct fw_img *image = iwl_get_ucode_image(priv, ucode_type);
149
150
151 if (!image) {
152 IWL_ERR(priv, "Invalid ucode requested (%d)\n", ucode_type);
153 return -EINVAL;
154 }
148 155
149 ret = iwlagn_load_section(trans(priv), "INST", &image->code, 156 ret = iwlagn_load_section(trans(priv), "INST", &image->code,
150 IWLAGN_RTC_INST_LOWER_BOUND); 157 IWLAGN_RTC_INST_LOWER_BOUND);
@@ -435,7 +442,7 @@ static int iwlagn_alive_notify(struct iwl_priv *priv)
435 * using sample data 100 bytes apart. If these sample points are good, 442 * using sample data 100 bytes apart. If these sample points are good,
436 * it's a pretty good bet that everything between them is good, too. 443 * it's a pretty good bet that everything between them is good, too.
437 */ 444 */
438static int iwl_verify_inst_sparse(struct iwl_priv *priv, 445static int iwl_verify_inst_sparse(struct iwl_bus *bus,
439 struct fw_desc *fw_desc) 446 struct fw_desc *fw_desc)
440{ 447{
441 __le32 *image = (__le32 *)fw_desc->v_addr; 448 __le32 *image = (__le32 *)fw_desc->v_addr;
@@ -443,15 +450,15 @@ static int iwl_verify_inst_sparse(struct iwl_priv *priv,
443 u32 val; 450 u32 val;
444 u32 i; 451 u32 i;
445 452
446 IWL_DEBUG_FW(priv, "ucode inst image size is %u\n", len); 453 IWL_DEBUG_FW(bus, "ucode inst image size is %u\n", len);
447 454
448 for (i = 0; i < len; i += 100, image += 100/sizeof(u32)) { 455 for (i = 0; i < len; i += 100, image += 100/sizeof(u32)) {
449 /* read data comes through single port, auto-incr addr */ 456 /* read data comes through single port, auto-incr addr */
450 /* NOTE: Use the debugless read so we don't flood kernel log 457 /* NOTE: Use the debugless read so we don't flood kernel log
451 * if IWL_DL_IO is set */ 458 * if IWL_DL_IO is set */
452 iwl_write_direct32(bus(priv), HBUS_TARG_MEM_RADDR, 459 iwl_write_direct32(bus, HBUS_TARG_MEM_RADDR,
453 i + IWLAGN_RTC_INST_LOWER_BOUND); 460 i + IWLAGN_RTC_INST_LOWER_BOUND);
454 val = iwl_read32(bus(priv), HBUS_TARG_MEM_RDAT); 461 val = iwl_read32(bus, HBUS_TARG_MEM_RDAT);
455 if (val != le32_to_cpu(*image)) 462 if (val != le32_to_cpu(*image))
456 return -EIO; 463 return -EIO;
457 } 464 }
@@ -459,7 +466,7 @@ static int iwl_verify_inst_sparse(struct iwl_priv *priv,
459 return 0; 466 return 0;
460} 467}
461 468
462static void iwl_print_mismatch_inst(struct iwl_priv *priv, 469static void iwl_print_mismatch_inst(struct iwl_bus *bus,
463 struct fw_desc *fw_desc) 470 struct fw_desc *fw_desc)
464{ 471{
465 __le32 *image = (__le32 *)fw_desc->v_addr; 472 __le32 *image = (__le32 *)fw_desc->v_addr;
@@ -468,18 +475,18 @@ static void iwl_print_mismatch_inst(struct iwl_priv *priv,
468 u32 offs; 475 u32 offs;
469 int errors = 0; 476 int errors = 0;
470 477
471 IWL_DEBUG_FW(priv, "ucode inst image size is %u\n", len); 478 IWL_DEBUG_FW(bus, "ucode inst image size is %u\n", len);
472 479
473 iwl_write_direct32(bus(priv), HBUS_TARG_MEM_RADDR, 480 iwl_write_direct32(bus, HBUS_TARG_MEM_RADDR,
474 IWLAGN_RTC_INST_LOWER_BOUND); 481 IWLAGN_RTC_INST_LOWER_BOUND);
475 482
476 for (offs = 0; 483 for (offs = 0;
477 offs < len && errors < 20; 484 offs < len && errors < 20;
478 offs += sizeof(u32), image++) { 485 offs += sizeof(u32), image++) {
479 /* read data comes through single port, auto-incr addr */ 486 /* read data comes through single port, auto-incr addr */
480 val = iwl_read32(bus(priv), HBUS_TARG_MEM_RDAT); 487 val = iwl_read32(bus, HBUS_TARG_MEM_RDAT);
481 if (val != le32_to_cpu(*image)) { 488 if (val != le32_to_cpu(*image)) {
482 IWL_ERR(priv, "uCode INST section at " 489 IWL_ERR(bus, "uCode INST section at "
483 "offset 0x%x, is 0x%x, s/b 0x%x\n", 490 "offset 0x%x, is 0x%x, s/b 0x%x\n",
484 offs, val, le32_to_cpu(*image)); 491 offs, val, le32_to_cpu(*image));
485 errors++; 492 errors++;
@@ -491,16 +498,24 @@ static void iwl_print_mismatch_inst(struct iwl_priv *priv,
491 * iwl_verify_ucode - determine which instruction image is in SRAM, 498 * iwl_verify_ucode - determine which instruction image is in SRAM,
492 * and verify its contents 499 * and verify its contents
493 */ 500 */
494static int iwl_verify_ucode(struct iwl_priv *priv, struct fw_img *img) 501static int iwl_verify_ucode(struct iwl_priv *priv,
502 enum iwlagn_ucode_type ucode_type)
495{ 503{
496 if (!iwl_verify_inst_sparse(priv, &img->code)) { 504 struct fw_img *img = iwl_get_ucode_image(priv, ucode_type);
505
506 if (!img) {
507 IWL_ERR(priv, "Invalid ucode requested (%d)\n", ucode_type);
508 return -EINVAL;
509 }
510
511 if (!iwl_verify_inst_sparse(bus(priv), &img->code)) {
497 IWL_DEBUG_FW(priv, "uCode is good in inst SRAM\n"); 512 IWL_DEBUG_FW(priv, "uCode is good in inst SRAM\n");
498 return 0; 513 return 0;
499 } 514 }
500 515
501 IWL_ERR(priv, "UCODE IMAGE IN INSTRUCTION SRAM NOT VALID!!\n"); 516 IWL_ERR(priv, "UCODE IMAGE IN INSTRUCTION SRAM NOT VALID!!\n");
502 517
503 iwl_print_mismatch_inst(priv, &img->code); 518 iwl_print_mismatch_inst(bus(priv), &img->code);
504 return -EIO; 519 return -EIO;
505} 520}
506 521
@@ -542,12 +557,6 @@ int iwlagn_load_ucode_wait_alive(struct iwl_priv *priv,
542 struct iwlagn_alive_data alive_data; 557 struct iwlagn_alive_data alive_data;
543 int ret; 558 int ret;
544 enum iwlagn_ucode_type old_type; 559 enum iwlagn_ucode_type old_type;
545 struct fw_img *image = iwl_get_ucode_image(priv, ucode_type);
546
547 if (!image) {
548 IWL_ERR(priv, "Invalid ucode requested (%d)\n", ucode_type);
549 return -EINVAL;
550 }
551 560
552 ret = iwl_trans_start_device(trans(priv)); 561 ret = iwl_trans_start_device(trans(priv));
553 if (ret) 562 if (ret)
@@ -559,7 +568,7 @@ int iwlagn_load_ucode_wait_alive(struct iwl_priv *priv,
559 old_type = priv->ucode_type; 568 old_type = priv->ucode_type;
560 priv->ucode_type = ucode_type; 569 priv->ucode_type = ucode_type;
561 570
562 ret = iwlagn_load_given_ucode(priv, image); 571 ret = iwlagn_load_given_ucode(priv, ucode_type);
563 if (ret) { 572 if (ret) {
564 priv->ucode_type = old_type; 573 priv->ucode_type = old_type;
565 iwlagn_remove_notification(priv, &alive_wait); 574 iwlagn_remove_notification(priv, &alive_wait);
@@ -590,7 +599,7 @@ int iwlagn_load_ucode_wait_alive(struct iwl_priv *priv,
590 * skip it for WoWLAN. 599 * skip it for WoWLAN.
591 */ 600 */
592 if (ucode_type != IWL_UCODE_WOWLAN) { 601 if (ucode_type != IWL_UCODE_WOWLAN) {
593 ret = iwl_verify_ucode(priv, image); 602 ret = iwl_verify_ucode(priv, ucode_type);
594 if (ret) { 603 if (ret) {
595 priv->ucode_type = old_type; 604 priv->ucode_type = old_type;
596 return ret; 605 return ret;