diff options
author | Don Fry <donald.h.fry@intel.com> | 2012-02-07 17:21:32 -0500 |
---|---|---|
committer | Wey-Yi Guy <wey-yi.w.guy@intel.com> | 2012-02-17 13:56:24 -0500 |
commit | 06e03f8ce91b71c6ce4134c8bf9ed801aed0382c (patch) | |
tree | f1f34572b8d5b0a954a43007a79ecc5fd57f8d20 /drivers/net/wireless/iwlwifi/iwl-ucode.c | |
parent | 69655ebf1a64eb922e2ed94ed62898e3c47dd492 (diff) |
iwlwifi: changes args to iwl_nic for firmware operations
Remove the references to iwl_priv from the firmware request and
parsing routines. They are generic to the nic.
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-ucode.c')
-rw-r--r-- | drivers/net/wireless/iwlwifi/iwl-ucode.c | 149 |
1 files changed, 75 insertions, 74 deletions
diff --git a/drivers/net/wireless/iwlwifi/iwl-ucode.c b/drivers/net/wireless/iwlwifi/iwl-ucode.c index 0d04a4d7dc84..01768f709a76 100644 --- a/drivers/net/wireless/iwlwifi/iwl-ucode.c +++ b/drivers/net/wireless/iwlwifi/iwl-ucode.c | |||
@@ -690,10 +690,10 @@ static void iwl_ucode_callback(const struct firmware *ucode_raw, void *context); | |||
690 | #define UCODE_EXPERIMENTAL_INDEX 100 | 690 | #define UCODE_EXPERIMENTAL_INDEX 100 |
691 | #define UCODE_EXPERIMENTAL_TAG "exp" | 691 | #define UCODE_EXPERIMENTAL_TAG "exp" |
692 | 692 | ||
693 | int __must_check iwl_request_firmware(struct iwl_priv *priv, bool first) | 693 | int __must_check iwl_request_firmware(struct iwl_nic *nic, bool first) |
694 | { | 694 | { |
695 | struct iwl_nic *nic = nic(priv); | 695 | struct iwl_cfg *cfg = cfg(nic); |
696 | const char *name_pre = cfg(priv)->fw_name_pre; | 696 | const char *name_pre = cfg->fw_name_pre; |
697 | char tag[8]; | 697 | char tag[8]; |
698 | 698 | ||
699 | if (first) { | 699 | if (first) { |
@@ -702,28 +702,28 @@ int __must_check iwl_request_firmware(struct iwl_priv *priv, bool first) | |||
702 | strcpy(tag, UCODE_EXPERIMENTAL_TAG); | 702 | strcpy(tag, UCODE_EXPERIMENTAL_TAG); |
703 | } else if (nic->fw_index == UCODE_EXPERIMENTAL_INDEX) { | 703 | } else if (nic->fw_index == UCODE_EXPERIMENTAL_INDEX) { |
704 | #endif | 704 | #endif |
705 | nic->fw_index = cfg(priv)->ucode_api_max; | 705 | nic->fw_index = cfg->ucode_api_max; |
706 | sprintf(tag, "%d", nic->fw_index); | 706 | sprintf(tag, "%d", nic->fw_index); |
707 | } else { | 707 | } else { |
708 | nic->fw_index--; | 708 | nic->fw_index--; |
709 | sprintf(tag, "%d", nic->fw_index); | 709 | sprintf(tag, "%d", nic->fw_index); |
710 | } | 710 | } |
711 | 711 | ||
712 | if (nic->fw_index < cfg(priv)->ucode_api_min) { | 712 | if (nic->fw_index < cfg->ucode_api_min) { |
713 | IWL_ERR(priv, "no suitable firmware found!\n"); | 713 | IWL_ERR(nic, "no suitable firmware found!\n"); |
714 | return -ENOENT; | 714 | return -ENOENT; |
715 | } | 715 | } |
716 | 716 | ||
717 | sprintf(nic->firmware_name, "%s%s%s", name_pre, tag, ".ucode"); | 717 | sprintf(nic->firmware_name, "%s%s%s", name_pre, tag, ".ucode"); |
718 | 718 | ||
719 | IWL_DEBUG_INFO(priv, "attempting to load firmware %s'%s'\n", | 719 | IWL_DEBUG_INFO(nic, "attempting to load firmware %s'%s'\n", |
720 | (nic->fw_index == UCODE_EXPERIMENTAL_INDEX) | 720 | (nic->fw_index == UCODE_EXPERIMENTAL_INDEX) |
721 | ? "EXPERIMENTAL " : "", | 721 | ? "EXPERIMENTAL " : "", |
722 | nic->firmware_name); | 722 | nic->firmware_name); |
723 | 723 | ||
724 | return request_firmware_nowait(THIS_MODULE, 1, nic->firmware_name, | 724 | return request_firmware_nowait(THIS_MODULE, 1, nic->firmware_name, |
725 | trans(priv)->dev, | 725 | trans(nic)->dev, |
726 | GFP_KERNEL, priv, iwl_ucode_callback); | 726 | GFP_KERNEL, nic, iwl_ucode_callback); |
727 | } | 727 | } |
728 | 728 | ||
729 | struct iwlagn_firmware_pieces { | 729 | struct iwlagn_firmware_pieces { |
@@ -737,11 +737,10 @@ struct iwlagn_firmware_pieces { | |||
737 | u32 inst_evtlog_ptr, inst_evtlog_size, inst_errlog_ptr; | 737 | u32 inst_evtlog_ptr, inst_evtlog_size, inst_errlog_ptr; |
738 | }; | 738 | }; |
739 | 739 | ||
740 | static int iwlagn_load_legacy_firmware(struct iwl_priv *priv, | 740 | static int iwl_parse_v1_v2_firmware(struct iwl_nic *nic, |
741 | const struct firmware *ucode_raw, | 741 | const struct firmware *ucode_raw, |
742 | struct iwlagn_firmware_pieces *pieces) | 742 | struct iwlagn_firmware_pieces *pieces) |
743 | { | 743 | { |
744 | struct iwl_nic *nic = nic(priv); | ||
745 | struct iwl_ucode_header *ucode = (void *)ucode_raw->data; | 744 | struct iwl_ucode_header *ucode = (void *)ucode_raw->data; |
746 | u32 api_ver, hdr_size; | 745 | u32 api_ver, hdr_size; |
747 | const u8 *src; | 746 | const u8 *src; |
@@ -753,7 +752,7 @@ static int iwlagn_load_legacy_firmware(struct iwl_priv *priv, | |||
753 | default: | 752 | default: |
754 | hdr_size = 28; | 753 | hdr_size = 28; |
755 | if (ucode_raw->size < hdr_size) { | 754 | if (ucode_raw->size < hdr_size) { |
756 | IWL_ERR(priv, "File size too small!\n"); | 755 | IWL_ERR(nic, "File size too small!\n"); |
757 | return -EINVAL; | 756 | return -EINVAL; |
758 | } | 757 | } |
759 | pieces->build = le32_to_cpu(ucode->u.v2.build); | 758 | pieces->build = le32_to_cpu(ucode->u.v2.build); |
@@ -768,7 +767,7 @@ static int iwlagn_load_legacy_firmware(struct iwl_priv *priv, | |||
768 | case 2: | 767 | case 2: |
769 | hdr_size = 24; | 768 | hdr_size = 24; |
770 | if (ucode_raw->size < hdr_size) { | 769 | if (ucode_raw->size < hdr_size) { |
771 | IWL_ERR(priv, "File size too small!\n"); | 770 | IWL_ERR(nic, "File size too small!\n"); |
772 | return -EINVAL; | 771 | return -EINVAL; |
773 | } | 772 | } |
774 | pieces->build = 0; | 773 | pieces->build = 0; |
@@ -785,7 +784,7 @@ static int iwlagn_load_legacy_firmware(struct iwl_priv *priv, | |||
785 | pieces->data_size + pieces->init_size + | 784 | pieces->data_size + pieces->init_size + |
786 | pieces->init_data_size) { | 785 | pieces->init_data_size) { |
787 | 786 | ||
788 | IWL_ERR(priv, | 787 | IWL_ERR(nic, |
789 | "uCode file size %d does not match expected size\n", | 788 | "uCode file size %d does not match expected size\n", |
790 | (int)ucode_raw->size); | 789 | (int)ucode_raw->size); |
791 | return -EINVAL; | 790 | return -EINVAL; |
@@ -803,12 +802,11 @@ static int iwlagn_load_legacy_firmware(struct iwl_priv *priv, | |||
803 | return 0; | 802 | return 0; |
804 | } | 803 | } |
805 | 804 | ||
806 | static int iwlagn_load_firmware(struct iwl_priv *priv, | 805 | static int iwl_parse_tlv_firmware(struct iwl_nic *nic, |
807 | const struct firmware *ucode_raw, | 806 | const struct firmware *ucode_raw, |
808 | struct iwlagn_firmware_pieces *pieces, | 807 | struct iwlagn_firmware_pieces *pieces, |
809 | struct iwlagn_ucode_capabilities *capa) | 808 | struct iwlagn_ucode_capabilities *capa) |
810 | { | 809 | { |
811 | struct iwl_nic *nic = nic(priv); | ||
812 | struct iwl_tlv_ucode_header *ucode = (void *)ucode_raw->data; | 810 | struct iwl_tlv_ucode_header *ucode = (void *)ucode_raw->data; |
813 | struct iwl_ucode_tlv *tlv; | 811 | struct iwl_ucode_tlv *tlv; |
814 | size_t len = ucode_raw->size; | 812 | size_t len = ucode_raw->size; |
@@ -821,12 +819,12 @@ static int iwlagn_load_firmware(struct iwl_priv *priv, | |||
821 | const u8 *tlv_data; | 819 | const u8 *tlv_data; |
822 | 820 | ||
823 | if (len < sizeof(*ucode)) { | 821 | if (len < sizeof(*ucode)) { |
824 | IWL_ERR(priv, "uCode has invalid length: %zd\n", len); | 822 | IWL_ERR(nic, "uCode has invalid length: %zd\n", len); |
825 | return -EINVAL; | 823 | return -EINVAL; |
826 | } | 824 | } |
827 | 825 | ||
828 | if (ucode->magic != cpu_to_le32(IWL_TLV_UCODE_MAGIC)) { | 826 | if (ucode->magic != cpu_to_le32(IWL_TLV_UCODE_MAGIC)) { |
829 | IWL_ERR(priv, "invalid uCode magic: 0X%x\n", | 827 | IWL_ERR(nic, "invalid uCode magic: 0X%x\n", |
830 | le32_to_cpu(ucode->magic)); | 828 | le32_to_cpu(ucode->magic)); |
831 | return -EINVAL; | 829 | return -EINVAL; |
832 | } | 830 | } |
@@ -844,7 +842,7 @@ static int iwlagn_load_firmware(struct iwl_priv *priv, | |||
844 | while (wanted_alternative && !(alternatives & BIT(wanted_alternative))) | 842 | while (wanted_alternative && !(alternatives & BIT(wanted_alternative))) |
845 | wanted_alternative--; | 843 | wanted_alternative--; |
846 | if (wanted_alternative && wanted_alternative != tmp) | 844 | if (wanted_alternative && wanted_alternative != tmp) |
847 | IWL_WARN(priv, | 845 | IWL_WARN(nic, |
848 | "uCode alternative %d not available, choosing %d\n", | 846 | "uCode alternative %d not available, choosing %d\n", |
849 | tmp, wanted_alternative); | 847 | tmp, wanted_alternative); |
850 | 848 | ||
@@ -866,7 +864,7 @@ static int iwlagn_load_firmware(struct iwl_priv *priv, | |||
866 | tlv_data = tlv->data; | 864 | tlv_data = tlv->data; |
867 | 865 | ||
868 | if (len < tlv_len) { | 866 | if (len < tlv_len) { |
869 | IWL_ERR(priv, "invalid TLV len: %zd/%u\n", | 867 | IWL_ERR(nic, "invalid TLV len: %zd/%u\n", |
870 | len, tlv_len); | 868 | len, tlv_len); |
871 | return -EINVAL; | 869 | return -EINVAL; |
872 | } | 870 | } |
@@ -899,7 +897,7 @@ static int iwlagn_load_firmware(struct iwl_priv *priv, | |||
899 | pieces->init_data_size = tlv_len; | 897 | pieces->init_data_size = tlv_len; |
900 | break; | 898 | break; |
901 | case IWL_UCODE_TLV_BOOT: | 899 | case IWL_UCODE_TLV_BOOT: |
902 | IWL_ERR(priv, "Found unexpected BOOT ucode\n"); | 900 | IWL_ERR(nic, "Found unexpected BOOT ucode\n"); |
903 | break; | 901 | break; |
904 | case IWL_UCODE_TLV_PROBE_MAX_LEN: | 902 | case IWL_UCODE_TLV_PROBE_MAX_LEN: |
905 | if (tlv_len != sizeof(u32)) | 903 | if (tlv_len != sizeof(u32)) |
@@ -984,22 +982,22 @@ static int iwlagn_load_firmware(struct iwl_priv *priv, | |||
984 | le32_to_cpup((__le32 *)tlv_data); | 982 | le32_to_cpup((__le32 *)tlv_data); |
985 | break; | 983 | break; |
986 | default: | 984 | default: |
987 | IWL_DEBUG_INFO(priv, "unknown TLV: %d\n", tlv_type); | 985 | IWL_DEBUG_INFO(nic, "unknown TLV: %d\n", tlv_type); |
988 | break; | 986 | break; |
989 | } | 987 | } |
990 | } | 988 | } |
991 | 989 | ||
992 | if (len) { | 990 | if (len) { |
993 | IWL_ERR(priv, "invalid TLV after parsing: %zd\n", len); | 991 | IWL_ERR(nic, "invalid TLV after parsing: %zd\n", len); |
994 | iwl_print_hex_dump(priv, IWL_DL_FW, (u8 *)data, len); | 992 | iwl_print_hex_dump(nic, IWL_DL_FW, (u8 *)data, len); |
995 | return -EINVAL; | 993 | return -EINVAL; |
996 | } | 994 | } |
997 | 995 | ||
998 | return 0; | 996 | return 0; |
999 | 997 | ||
1000 | invalid_tlv_len: | 998 | invalid_tlv_len: |
1001 | IWL_ERR(priv, "TLV %d has invalid size: %u\n", tlv_type, tlv_len); | 999 | IWL_ERR(nic, "TLV %d has invalid size: %u\n", tlv_type, tlv_len); |
1002 | iwl_print_hex_dump(priv, IWL_DL_FW, tlv_data, tlv_len); | 1000 | iwl_print_hex_dump(nic, IWL_DL_FW, tlv_data, tlv_len); |
1003 | 1001 | ||
1004 | return -EINVAL; | 1002 | return -EINVAL; |
1005 | } | 1003 | } |
@@ -1012,14 +1010,15 @@ static int iwlagn_load_firmware(struct iwl_priv *priv, | |||
1012 | */ | 1010 | */ |
1013 | static void iwl_ucode_callback(const struct firmware *ucode_raw, void *context) | 1011 | static void iwl_ucode_callback(const struct firmware *ucode_raw, void *context) |
1014 | { | 1012 | { |
1015 | struct iwl_priv *priv = context; | 1013 | struct iwl_nic *nic = context; |
1016 | struct iwl_nic *nic = nic(priv); | 1014 | struct iwl_cfg *cfg = cfg(nic); |
1015 | struct iwl_priv *priv = priv(nic); /* temporary */ | ||
1017 | struct iwl_ucode_header *ucode; | 1016 | struct iwl_ucode_header *ucode; |
1018 | int err; | 1017 | int err; |
1019 | struct iwlagn_firmware_pieces pieces; | 1018 | struct iwlagn_firmware_pieces pieces; |
1020 | const unsigned int api_max = cfg(priv)->ucode_api_max; | 1019 | const unsigned int api_max = cfg->ucode_api_max; |
1021 | unsigned int api_ok = cfg(priv)->ucode_api_ok; | 1020 | unsigned int api_ok = cfg->ucode_api_ok; |
1022 | const unsigned int api_min = cfg(priv)->ucode_api_min; | 1021 | const unsigned int api_min = cfg->ucode_api_min; |
1023 | u32 api_ver; | 1022 | u32 api_ver; |
1024 | char buildstr[25]; | 1023 | char buildstr[25]; |
1025 | u32 build; | 1024 | u32 build; |
@@ -1036,18 +1035,18 @@ static void iwl_ucode_callback(const struct firmware *ucode_raw, void *context) | |||
1036 | 1035 | ||
1037 | if (!ucode_raw) { | 1036 | if (!ucode_raw) { |
1038 | if (nic->fw_index <= api_ok) | 1037 | if (nic->fw_index <= api_ok) |
1039 | IWL_ERR(priv, | 1038 | IWL_ERR(nic, |
1040 | "request for firmware file '%s' failed.\n", | 1039 | "request for firmware file '%s' failed.\n", |
1041 | nic->firmware_name); | 1040 | nic->firmware_name); |
1042 | goto try_again; | 1041 | goto try_again; |
1043 | } | 1042 | } |
1044 | 1043 | ||
1045 | IWL_DEBUG_INFO(priv, "Loaded firmware file '%s' (%zd bytes).\n", | 1044 | IWL_DEBUG_INFO(nic, "Loaded firmware file '%s' (%zd bytes).\n", |
1046 | nic->firmware_name, ucode_raw->size); | 1045 | nic->firmware_name, ucode_raw->size); |
1047 | 1046 | ||
1048 | /* Make sure that we got at least the API version number */ | 1047 | /* Make sure that we got at least the API version number */ |
1049 | if (ucode_raw->size < 4) { | 1048 | if (ucode_raw->size < 4) { |
1050 | IWL_ERR(priv, "File size way too small!\n"); | 1049 | IWL_ERR(nic, "File size way too small!\n"); |
1051 | goto try_again; | 1050 | goto try_again; |
1052 | } | 1051 | } |
1053 | 1052 | ||
@@ -1055,9 +1054,9 @@ static void iwl_ucode_callback(const struct firmware *ucode_raw, void *context) | |||
1055 | ucode = (struct iwl_ucode_header *)ucode_raw->data; | 1054 | ucode = (struct iwl_ucode_header *)ucode_raw->data; |
1056 | 1055 | ||
1057 | if (ucode->ver) | 1056 | if (ucode->ver) |
1058 | err = iwlagn_load_legacy_firmware(priv, ucode_raw, &pieces); | 1057 | err = iwl_parse_v1_v2_firmware(nic, ucode_raw, &pieces); |
1059 | else | 1058 | else |
1060 | err = iwlagn_load_firmware(priv, ucode_raw, &pieces, | 1059 | err = iwl_parse_tlv_firmware(nic, ucode_raw, &pieces, |
1061 | &ucode_capa); | 1060 | &ucode_capa); |
1062 | 1061 | ||
1063 | if (err) | 1062 | if (err) |
@@ -1074,7 +1073,7 @@ static void iwl_ucode_callback(const struct firmware *ucode_raw, void *context) | |||
1074 | /* no api version check required for experimental uCode */ | 1073 | /* no api version check required for experimental uCode */ |
1075 | if (nic->fw_index != UCODE_EXPERIMENTAL_INDEX) { | 1074 | if (nic->fw_index != UCODE_EXPERIMENTAL_INDEX) { |
1076 | if (api_ver < api_min || api_ver > api_max) { | 1075 | if (api_ver < api_min || api_ver > api_max) { |
1077 | IWL_ERR(priv, | 1076 | IWL_ERR(nic, |
1078 | "Driver unable to support your firmware API. " | 1077 | "Driver unable to support your firmware API. " |
1079 | "Driver supports v%u, firmware is v%u.\n", | 1078 | "Driver supports v%u, firmware is v%u.\n", |
1080 | api_max, api_ver); | 1079 | api_max, api_ver); |
@@ -1083,14 +1082,14 @@ static void iwl_ucode_callback(const struct firmware *ucode_raw, void *context) | |||
1083 | 1082 | ||
1084 | if (api_ver < api_ok) { | 1083 | if (api_ver < api_ok) { |
1085 | if (api_ok != api_max) | 1084 | if (api_ok != api_max) |
1086 | IWL_ERR(priv, "Firmware has old API version, " | 1085 | IWL_ERR(nic, "Firmware has old API version, " |
1087 | "expected v%u through v%u, got v%u.\n", | 1086 | "expected v%u through v%u, got v%u.\n", |
1088 | api_ok, api_max, api_ver); | 1087 | api_ok, api_max, api_ver); |
1089 | else | 1088 | else |
1090 | IWL_ERR(priv, "Firmware has old API version, " | 1089 | IWL_ERR(nic, "Firmware has old API version, " |
1091 | "expected v%u, got v%u.\n", | 1090 | "expected v%u, got v%u.\n", |
1092 | api_max, api_ver); | 1091 | api_max, api_ver); |
1093 | IWL_ERR(priv, "New firmware can be obtained from " | 1092 | IWL_ERR(nic, "New firmware can be obtained from " |
1094 | "http://www.intellinuxwireless.org/.\n"); | 1093 | "http://www.intellinuxwireless.org/.\n"); |
1095 | } | 1094 | } |
1096 | } | 1095 | } |
@@ -1102,7 +1101,7 @@ static void iwl_ucode_callback(const struct firmware *ucode_raw, void *context) | |||
1102 | else | 1101 | else |
1103 | buildstr[0] = '\0'; | 1102 | buildstr[0] = '\0'; |
1104 | 1103 | ||
1105 | IWL_INFO(priv, "loaded firmware version %u.%u.%u.%u%s\n", | 1104 | IWL_INFO(nic, "loaded firmware version %u.%u.%u.%u%s\n", |
1106 | IWL_UCODE_MAJOR(nic->fw.ucode_ver), | 1105 | IWL_UCODE_MAJOR(nic->fw.ucode_ver), |
1107 | IWL_UCODE_MINOR(nic->fw.ucode_ver), | 1106 | IWL_UCODE_MINOR(nic->fw.ucode_ver), |
1108 | IWL_UCODE_API(nic->fw.ucode_ver), | 1107 | IWL_UCODE_API(nic->fw.ucode_ver), |
@@ -1124,38 +1123,38 @@ static void iwl_ucode_callback(const struct firmware *ucode_raw, void *context) | |||
1124 | * user just got a corrupted version of the latest API. | 1123 | * user just got a corrupted version of the latest API. |
1125 | */ | 1124 | */ |
1126 | 1125 | ||
1127 | IWL_DEBUG_INFO(priv, "f/w package hdr ucode version raw = 0x%x\n", | 1126 | IWL_DEBUG_INFO(nic, "f/w package hdr ucode version raw = 0x%x\n", |
1128 | nic->fw.ucode_ver); | 1127 | nic->fw.ucode_ver); |
1129 | IWL_DEBUG_INFO(priv, "f/w package hdr runtime inst size = %Zd\n", | 1128 | IWL_DEBUG_INFO(nic, "f/w package hdr runtime inst size = %Zd\n", |
1130 | pieces.inst_size); | 1129 | pieces.inst_size); |
1131 | IWL_DEBUG_INFO(priv, "f/w package hdr runtime data size = %Zd\n", | 1130 | IWL_DEBUG_INFO(nic, "f/w package hdr runtime data size = %Zd\n", |
1132 | pieces.data_size); | 1131 | pieces.data_size); |
1133 | IWL_DEBUG_INFO(priv, "f/w package hdr init inst size = %Zd\n", | 1132 | IWL_DEBUG_INFO(nic, "f/w package hdr init inst size = %Zd\n", |
1134 | pieces.init_size); | 1133 | pieces.init_size); |
1135 | IWL_DEBUG_INFO(priv, "f/w package hdr init data size = %Zd\n", | 1134 | IWL_DEBUG_INFO(nic, "f/w package hdr init data size = %Zd\n", |
1136 | pieces.init_data_size); | 1135 | pieces.init_data_size); |
1137 | 1136 | ||
1138 | /* Verify that uCode images will fit in card's SRAM */ | 1137 | /* Verify that uCode images will fit in card's SRAM */ |
1139 | if (pieces.inst_size > hw_params(priv).max_inst_size) { | 1138 | if (pieces.inst_size > hw_params(nic).max_inst_size) { |
1140 | IWL_ERR(priv, "uCode instr len %Zd too large to fit in\n", | 1139 | IWL_ERR(nic, "uCode instr len %Zd too large to fit in\n", |
1141 | pieces.inst_size); | 1140 | pieces.inst_size); |
1142 | goto try_again; | 1141 | goto try_again; |
1143 | } | 1142 | } |
1144 | 1143 | ||
1145 | if (pieces.data_size > hw_params(priv).max_data_size) { | 1144 | if (pieces.data_size > hw_params(nic).max_data_size) { |
1146 | IWL_ERR(priv, "uCode data len %Zd too large to fit in\n", | 1145 | IWL_ERR(nic, "uCode data len %Zd too large to fit in\n", |
1147 | pieces.data_size); | 1146 | pieces.data_size); |
1148 | goto try_again; | 1147 | goto try_again; |
1149 | } | 1148 | } |
1150 | 1149 | ||
1151 | if (pieces.init_size > hw_params(priv).max_inst_size) { | 1150 | if (pieces.init_size > hw_params(nic).max_inst_size) { |
1152 | IWL_ERR(priv, "uCode init instr len %Zd too large to fit in\n", | 1151 | IWL_ERR(nic, "uCode init instr len %Zd too large to fit in\n", |
1153 | pieces.init_size); | 1152 | pieces.init_size); |
1154 | goto try_again; | 1153 | goto try_again; |
1155 | } | 1154 | } |
1156 | 1155 | ||
1157 | if (pieces.init_data_size > hw_params(priv).max_data_size) { | 1156 | if (pieces.init_data_size > hw_params(nic).max_data_size) { |
1158 | IWL_ERR(priv, "uCode init data len %Zd too large to fit in\n", | 1157 | IWL_ERR(nic, "uCode init data len %Zd too large to fit in\n", |
1159 | pieces.init_data_size); | 1158 | pieces.init_data_size); |
1160 | goto try_again; | 1159 | goto try_again; |
1161 | } | 1160 | } |
@@ -1165,34 +1164,34 @@ static void iwl_ucode_callback(const struct firmware *ucode_raw, void *context) | |||
1165 | /* Runtime instructions and 2 copies of data: | 1164 | /* Runtime instructions and 2 copies of data: |
1166 | * 1) unmodified from disk | 1165 | * 1) unmodified from disk |
1167 | * 2) backup cache for save/restore during power-downs */ | 1166 | * 2) backup cache for save/restore during power-downs */ |
1168 | if (iwl_alloc_fw_desc(nic(priv), &nic(priv)->fw.ucode_rt.code, | 1167 | if (iwl_alloc_fw_desc(nic, &nic->fw.ucode_rt.code, |
1169 | pieces.inst, pieces.inst_size)) | 1168 | pieces.inst, pieces.inst_size)) |
1170 | goto err_pci_alloc; | 1169 | goto err_pci_alloc; |
1171 | if (iwl_alloc_fw_desc(nic(priv), &nic(priv)->fw.ucode_rt.data, | 1170 | if (iwl_alloc_fw_desc(nic, &nic->fw.ucode_rt.data, |
1172 | pieces.data, pieces.data_size)) | 1171 | pieces.data, pieces.data_size)) |
1173 | goto err_pci_alloc; | 1172 | goto err_pci_alloc; |
1174 | 1173 | ||
1175 | /* Initialization instructions and data */ | 1174 | /* Initialization instructions and data */ |
1176 | if (pieces.init_size && pieces.init_data_size) { | 1175 | if (pieces.init_size && pieces.init_data_size) { |
1177 | if (iwl_alloc_fw_desc(nic(priv), | 1176 | if (iwl_alloc_fw_desc(nic, |
1178 | &nic(priv)->fw.ucode_init.code, | 1177 | &nic->fw.ucode_init.code, |
1179 | pieces.init, pieces.init_size)) | 1178 | pieces.init, pieces.init_size)) |
1180 | goto err_pci_alloc; | 1179 | goto err_pci_alloc; |
1181 | if (iwl_alloc_fw_desc(nic(priv), | 1180 | if (iwl_alloc_fw_desc(nic, |
1182 | &nic(priv)->fw.ucode_init.data, | 1181 | &nic->fw.ucode_init.data, |
1183 | pieces.init_data, pieces.init_data_size)) | 1182 | pieces.init_data, pieces.init_data_size)) |
1184 | goto err_pci_alloc; | 1183 | goto err_pci_alloc; |
1185 | } | 1184 | } |
1186 | 1185 | ||
1187 | /* WoWLAN instructions and data */ | 1186 | /* WoWLAN instructions and data */ |
1188 | if (pieces.wowlan_inst_size && pieces.wowlan_data_size) { | 1187 | if (pieces.wowlan_inst_size && pieces.wowlan_data_size) { |
1189 | if (iwl_alloc_fw_desc(nic(priv), | 1188 | if (iwl_alloc_fw_desc(nic, |
1190 | &nic(priv)->fw.ucode_wowlan.code, | 1189 | &nic->fw.ucode_wowlan.code, |
1191 | pieces.wowlan_inst, | 1190 | pieces.wowlan_inst, |
1192 | pieces.wowlan_inst_size)) | 1191 | pieces.wowlan_inst_size)) |
1193 | goto err_pci_alloc; | 1192 | goto err_pci_alloc; |
1194 | if (iwl_alloc_fw_desc(nic(priv), | 1193 | if (iwl_alloc_fw_desc(nic, |
1195 | &nic(priv)->fw.ucode_wowlan.data, | 1194 | &nic->fw.ucode_wowlan.data, |
1196 | pieces.wowlan_data, | 1195 | pieces.wowlan_data, |
1197 | pieces.wowlan_data_size)) | 1196 | pieces.wowlan_data_size)) |
1198 | goto err_pci_alloc; | 1197 | goto err_pci_alloc; |
@@ -1210,14 +1209,14 @@ static void iwl_ucode_callback(const struct firmware *ucode_raw, void *context) | |||
1210 | nic->init_evtlog_size = (pieces.init_evtlog_size - 16)/12; | 1209 | nic->init_evtlog_size = (pieces.init_evtlog_size - 16)/12; |
1211 | else | 1210 | else |
1212 | nic->init_evtlog_size = | 1211 | nic->init_evtlog_size = |
1213 | cfg(priv)->base_params->max_event_log_size; | 1212 | cfg->base_params->max_event_log_size; |
1214 | nic->init_errlog_ptr = pieces.init_errlog_ptr; | 1213 | nic->init_errlog_ptr = pieces.init_errlog_ptr; |
1215 | nic->inst_evtlog_ptr = pieces.inst_evtlog_ptr; | 1214 | nic->inst_evtlog_ptr = pieces.inst_evtlog_ptr; |
1216 | if (pieces.inst_evtlog_size) | 1215 | if (pieces.inst_evtlog_size) |
1217 | nic->inst_evtlog_size = (pieces.inst_evtlog_size - 16)/12; | 1216 | nic->inst_evtlog_size = (pieces.inst_evtlog_size - 16)/12; |
1218 | else | 1217 | else |
1219 | nic->inst_evtlog_size = | 1218 | nic->inst_evtlog_size = |
1220 | cfg(priv)->base_params->max_event_log_size; | 1219 | cfg->base_params->max_event_log_size; |
1221 | nic->inst_errlog_ptr = pieces.inst_errlog_ptr; | 1220 | nic->inst_errlog_ptr = pieces.inst_errlog_ptr; |
1222 | #ifndef CONFIG_IWLWIFI_P2P | 1221 | #ifndef CONFIG_IWLWIFI_P2P |
1223 | ucode_capa.flags &= ~IWL_UCODE_TLV_FLAGS_PAN; | 1222 | ucode_capa.flags &= ~IWL_UCODE_TLV_FLAGS_PAN; |
@@ -1226,7 +1225,7 @@ static void iwl_ucode_callback(const struct firmware *ucode_raw, void *context) | |||
1226 | priv->new_scan_threshold_behaviour = | 1225 | priv->new_scan_threshold_behaviour = |
1227 | !!(ucode_capa.flags & IWL_UCODE_TLV_FLAGS_NEWSCAN); | 1226 | !!(ucode_capa.flags & IWL_UCODE_TLV_FLAGS_NEWSCAN); |
1228 | 1227 | ||
1229 | if (!(cfg(priv)->sku & EEPROM_SKU_CAP_IPAN_ENABLE)) | 1228 | if (!(cfg->sku & EEPROM_SKU_CAP_IPAN_ENABLE)) |
1230 | ucode_capa.flags &= ~IWL_UCODE_TLV_FLAGS_PAN; | 1229 | ucode_capa.flags &= ~IWL_UCODE_TLV_FLAGS_PAN; |
1231 | 1230 | ||
1232 | /* | 1231 | /* |
@@ -1238,10 +1237,10 @@ static void iwl_ucode_callback(const struct firmware *ucode_raw, void *context) | |||
1238 | 1237 | ||
1239 | if (ucode_capa.flags & IWL_UCODE_TLV_FLAGS_PAN) { | 1238 | if (ucode_capa.flags & IWL_UCODE_TLV_FLAGS_PAN) { |
1240 | priv->sta_key_max_num = STA_KEY_MAX_NUM_PAN; | 1239 | priv->sta_key_max_num = STA_KEY_MAX_NUM_PAN; |
1241 | priv->shrd->cmd_queue = IWL_IPAN_CMD_QUEUE_NUM; | 1240 | nic->shrd->cmd_queue = IWL_IPAN_CMD_QUEUE_NUM; |
1242 | } else { | 1241 | } else { |
1243 | priv->sta_key_max_num = STA_KEY_MAX_NUM; | 1242 | priv->sta_key_max_num = STA_KEY_MAX_NUM; |
1244 | priv->shrd->cmd_queue = IWL_DEFAULT_CMD_QUEUE_NUM; | 1243 | nic->shrd->cmd_queue = IWL_DEFAULT_CMD_QUEUE_NUM; |
1245 | } | 1244 | } |
1246 | /* | 1245 | /* |
1247 | * figure out the offset of chain noise reset and gain commands | 1246 | * figure out the offset of chain noise reset and gain commands |
@@ -1271,7 +1270,9 @@ static void iwl_ucode_callback(const struct firmware *ucode_raw, void *context) | |||
1271 | 1270 | ||
1272 | err = iwl_dbgfs_register(priv, DRV_NAME); | 1271 | err = iwl_dbgfs_register(priv, DRV_NAME); |
1273 | if (err) | 1272 | if (err) |
1274 | IWL_ERR(priv, "failed to create debugfs files. Ignoring error: %d\n", err); | 1273 | IWL_ERR(nic, |
1274 | "failed to create debugfs files. Ignoring error: %d\n", | ||
1275 | err); | ||
1275 | 1276 | ||
1276 | /* We have our copies now, allow OS release its copies */ | 1277 | /* We have our copies now, allow OS release its copies */ |
1277 | release_firmware(ucode_raw); | 1278 | release_firmware(ucode_raw); |
@@ -1280,17 +1281,17 @@ static void iwl_ucode_callback(const struct firmware *ucode_raw, void *context) | |||
1280 | 1281 | ||
1281 | try_again: | 1282 | try_again: |
1282 | /* try next, if any */ | 1283 | /* try next, if any */ |
1283 | if (iwl_request_firmware(priv, false)) | 1284 | if (iwl_request_firmware(nic, false)) |
1284 | goto out_unbind; | 1285 | goto out_unbind; |
1285 | release_firmware(ucode_raw); | 1286 | release_firmware(ucode_raw); |
1286 | return; | 1287 | return; |
1287 | 1288 | ||
1288 | err_pci_alloc: | 1289 | err_pci_alloc: |
1289 | IWL_ERR(priv, "failed to allocate pci memory\n"); | 1290 | IWL_ERR(nic, "failed to allocate pci memory\n"); |
1290 | iwl_dealloc_ucode(nic(priv)); | 1291 | iwl_dealloc_ucode(nic); |
1291 | out_unbind: | 1292 | out_unbind: |
1292 | complete(&nic->request_firmware_complete); | 1293 | complete(&nic->request_firmware_complete); |
1293 | device_release_driver(trans(priv)->dev); | 1294 | device_release_driver(trans(nic)->dev); |
1294 | release_firmware(ucode_raw); | 1295 | release_firmware(ucode_raw); |
1295 | } | 1296 | } |
1296 | 1297 | ||