aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/net/wireless/iwlwifi/iwl-drv.c
diff options
context:
space:
mode:
authorDavid Spinadel <david.spinadel@intel.com>2012-03-10 16:00:12 -0500
committerJohn W. Linville <linville@tuxdriver.com>2012-03-12 14:22:06 -0400
commit0cedacc5797bbae5b07e5e861fbe7b8e33f2ef78 (patch)
tree46958e660f25227ddef25c2c47da293b3aeb74ba /drivers/net/wireless/iwlwifi/iwl-drv.c
parentb5ea1624833b816184aa262c190f2774b8d2ea63 (diff)
iwlwifi: more modularity in fw images and sections
Changed iwl_firmware_pieces structure to support an array of separate images, and an array of sections for each image. In fw_sec and fw_desc structures, added a field for offset from the HW address, to support 16.0 uCode that provides an offset instead of any other data about the section. This field is filled with default values when parsing instruction or data section. Signed-off-by: David Spinadel <david.spinadel@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/net/wireless/iwlwifi/iwl-drv.c')
-rw-r--r--drivers/net/wireless/iwlwifi/iwl-drv.c280
1 files changed, 204 insertions, 76 deletions
diff --git a/drivers/net/wireless/iwlwifi/iwl-drv.c b/drivers/net/wireless/iwlwifi/iwl-drv.c
index 29a3ae48df6d..a21af3df6c8a 100644
--- a/drivers/net/wireless/iwlwifi/iwl-drv.c
+++ b/drivers/net/wireless/iwlwifi/iwl-drv.c
@@ -69,6 +69,7 @@
69#include "iwl-trans.h" 69#include "iwl-trans.h"
70#include "iwl-shared.h" 70#include "iwl-shared.h"
71#include "iwl-op-mode.h" 71#include "iwl-op-mode.h"
72#include "iwl-agn-hw.h"
72 73
73/* private includes */ 74/* private includes */
74#include "iwl-fw-file.h" 75#include "iwl-fw-file.h"
@@ -96,6 +97,16 @@ struct iwl_drv {
96 97
97 98
98 99
100/*
101 * struct fw_sec: Just for the image parsing proccess.
102 * For the fw storage we are using struct fw_desc.
103 */
104struct fw_sec {
105 const void *data; /* the sec data */
106 size_t size; /* section size */
107 u32 offset; /* offset of writing in the device */
108};
109
99static void iwl_free_fw_desc(struct iwl_drv *drv, struct fw_desc *desc) 110static void iwl_free_fw_desc(struct iwl_drv *drv, struct fw_desc *desc)
100{ 111{
101 if (desc->v_addr) 112 if (desc->v_addr)
@@ -119,20 +130,21 @@ static void iwl_dealloc_ucode(struct iwl_drv *drv)
119} 130}
120 131
121static int iwl_alloc_fw_desc(struct iwl_drv *drv, struct fw_desc *desc, 132static int iwl_alloc_fw_desc(struct iwl_drv *drv, struct fw_desc *desc,
122 const void *data, size_t len) 133 struct fw_sec *sec)
123{ 134{
124 if (!len) { 135 if (!sec || !sec->size) {
125 desc->v_addr = NULL; 136 desc->v_addr = NULL;
126 return -EINVAL; 137 return -EINVAL;
127 } 138 }
128 139
129 desc->v_addr = dma_alloc_coherent(trans(drv)->dev, len, 140 desc->v_addr = dma_alloc_coherent(trans(drv)->dev, sec->size,
130 &desc->p_addr, GFP_KERNEL); 141 &desc->p_addr, GFP_KERNEL);
131 if (!desc->v_addr) 142 if (!desc->v_addr)
132 return -ENOMEM; 143 return -ENOMEM;
133 144
134 desc->len = len; 145 desc->len = sec->size;
135 memcpy(desc->v_addr, data, len); 146 desc->offset = sec->offset;
147 memcpy(desc->v_addr, sec->data, sec->size);
136 return 0; 148 return 0;
137} 149}
138 150
@@ -177,18 +189,77 @@ static int iwl_request_firmware(struct iwl_drv *drv, bool first)
177 GFP_KERNEL, drv, iwl_ucode_callback); 189 GFP_KERNEL, drv, iwl_ucode_callback);
178} 190}
179 191
180struct iwlagn_firmware_pieces { 192/*
181 const void *inst, *data, *init, *init_data, *wowlan_inst, *wowlan_data; 193 * enumeration of ucode section.
182 size_t inst_size, data_size, init_size, init_data_size, 194 * This enumeration is used for legacy tlv style (before 16.0 uCode).
183 wowlan_inst_size, wowlan_data_size; 195 */
196enum iwl_ucode_sec {
197 IWL_UCODE_SECTION_INST,
198 IWL_UCODE_SECTION_DATA,
199};
200/*
201 * For 16.0 uCode and above, there is no differentiation between section,
202 * just an offset to the HW address.
203 */
204#define UCODE_SECTION_MAX 4
205
206struct fw_img_parsing {
207 struct fw_sec sec[UCODE_SECTION_MAX];
208 int sec_counter;
209};
210
211struct iwl_firmware_pieces {
212 struct fw_img_parsing img[IWL_UCODE_TYPE_MAX];
184 213
185 u32 init_evtlog_ptr, init_evtlog_size, init_errlog_ptr; 214 u32 init_evtlog_ptr, init_evtlog_size, init_errlog_ptr;
186 u32 inst_evtlog_ptr, inst_evtlog_size, inst_errlog_ptr; 215 u32 inst_evtlog_ptr, inst_evtlog_size, inst_errlog_ptr;
187}; 216};
188 217
218/*
219 * These functions are just to extract uCode section data from the pieces
220 * structure.
221 */
222static struct fw_sec *get_sec(struct iwl_firmware_pieces *pieces,
223 enum iwl_ucode_type type,
224 int sec)
225{
226 return &pieces->img[type].sec[sec];
227}
228
229static void set_sec_data(struct iwl_firmware_pieces *pieces,
230 enum iwl_ucode_type type,
231 int sec,
232 const void *data)
233{
234 pieces->img[type].sec[sec].data = data;
235}
236
237static void set_sec_size(struct iwl_firmware_pieces *pieces,
238 enum iwl_ucode_type type,
239 int sec,
240 size_t size)
241{
242 pieces->img[type].sec[sec].size = size;
243}
244
245static size_t get_sec_size(struct iwl_firmware_pieces *pieces,
246 enum iwl_ucode_type type,
247 int sec)
248{
249 return pieces->img[type].sec[sec].size;
250}
251
252static void set_sec_offset(struct iwl_firmware_pieces *pieces,
253 enum iwl_ucode_type type,
254 int sec,
255 u32 offset)
256{
257 pieces->img[type].sec[sec].offset = offset;
258}
259
189static int iwl_parse_v1_v2_firmware(struct iwl_drv *drv, 260static int iwl_parse_v1_v2_firmware(struct iwl_drv *drv,
190 const struct firmware *ucode_raw, 261 const struct firmware *ucode_raw,
191 struct iwlagn_firmware_pieces *pieces) 262 struct iwl_firmware_pieces *pieces)
192{ 263{
193 struct iwl_ucode_header *ucode = (void *)ucode_raw->data; 264 struct iwl_ucode_header *ucode = (void *)ucode_raw->data;
194 u32 api_ver, hdr_size, build; 265 u32 api_ver, hdr_size, build;
@@ -206,11 +277,14 @@ static int iwl_parse_v1_v2_firmware(struct iwl_drv *drv,
206 return -EINVAL; 277 return -EINVAL;
207 } 278 }
208 build = le32_to_cpu(ucode->u.v2.build); 279 build = le32_to_cpu(ucode->u.v2.build);
209 pieces->inst_size = le32_to_cpu(ucode->u.v2.inst_size); 280 set_sec_size(pieces, IWL_UCODE_REGULAR, IWL_UCODE_SECTION_INST,
210 pieces->data_size = le32_to_cpu(ucode->u.v2.data_size); 281 le32_to_cpu(ucode->u.v2.inst_size));
211 pieces->init_size = le32_to_cpu(ucode->u.v2.init_size); 282 set_sec_size(pieces, IWL_UCODE_REGULAR, IWL_UCODE_SECTION_DATA,
212 pieces->init_data_size = 283 le32_to_cpu(ucode->u.v2.data_size));
213 le32_to_cpu(ucode->u.v2.init_data_size); 284 set_sec_size(pieces, IWL_UCODE_INIT, IWL_UCODE_SECTION_INST,
285 le32_to_cpu(ucode->u.v2.init_size));
286 set_sec_size(pieces, IWL_UCODE_INIT, IWL_UCODE_SECTION_DATA,
287 le32_to_cpu(ucode->u.v2.init_data_size));
214 src = ucode->u.v2.data; 288 src = ucode->u.v2.data;
215 break; 289 break;
216 case 0: 290 case 0:
@@ -222,11 +296,14 @@ static int iwl_parse_v1_v2_firmware(struct iwl_drv *drv,
222 return -EINVAL; 296 return -EINVAL;
223 } 297 }
224 build = 0; 298 build = 0;
225 pieces->inst_size = le32_to_cpu(ucode->u.v1.inst_size); 299 set_sec_size(pieces, IWL_UCODE_REGULAR, IWL_UCODE_SECTION_INST,
226 pieces->data_size = le32_to_cpu(ucode->u.v1.data_size); 300 le32_to_cpu(ucode->u.v1.inst_size));
227 pieces->init_size = le32_to_cpu(ucode->u.v1.init_size); 301 set_sec_size(pieces, IWL_UCODE_REGULAR, IWL_UCODE_SECTION_DATA,
228 pieces->init_data_size = 302 le32_to_cpu(ucode->u.v1.data_size));
229 le32_to_cpu(ucode->u.v1.init_data_size); 303 set_sec_size(pieces, IWL_UCODE_INIT, IWL_UCODE_SECTION_INST,
304 le32_to_cpu(ucode->u.v1.init_size));
305 set_sec_size(pieces, IWL_UCODE_INIT, IWL_UCODE_SECTION_DATA,
306 le32_to_cpu(ucode->u.v1.init_data_size));
230 src = ucode->u.v1.data; 307 src = ucode->u.v1.data;
231 break; 308 break;
232 } 309 }
@@ -248,9 +325,12 @@ static int iwl_parse_v1_v2_firmware(struct iwl_drv *drv,
248 buildstr); 325 buildstr);
249 326
250 /* Verify size of file vs. image size info in file's header */ 327 /* Verify size of file vs. image size info in file's header */
251 if (ucode_raw->size != hdr_size + pieces->inst_size + 328
252 pieces->data_size + pieces->init_size + 329 if (ucode_raw->size != hdr_size +
253 pieces->init_data_size) { 330 get_sec_size(pieces, IWL_UCODE_REGULAR, IWL_UCODE_SECTION_INST) +
331 get_sec_size(pieces, IWL_UCODE_REGULAR, IWL_UCODE_SECTION_DATA) +
332 get_sec_size(pieces, IWL_UCODE_INIT, IWL_UCODE_SECTION_INST) +
333 get_sec_size(pieces, IWL_UCODE_INIT, IWL_UCODE_SECTION_DATA)) {
254 334
255 IWL_ERR(drv, 335 IWL_ERR(drv,
256 "uCode file size %d does not match expected size\n", 336 "uCode file size %d does not match expected size\n",
@@ -258,21 +338,29 @@ static int iwl_parse_v1_v2_firmware(struct iwl_drv *drv,
258 return -EINVAL; 338 return -EINVAL;
259 } 339 }
260 340
261 pieces->inst = src;
262 src += pieces->inst_size;
263 pieces->data = src;
264 src += pieces->data_size;
265 pieces->init = src;
266 src += pieces->init_size;
267 pieces->init_data = src;
268 src += pieces->init_data_size;
269 341
342 set_sec_data(pieces, IWL_UCODE_REGULAR, IWL_UCODE_SECTION_INST, src);
343 src += get_sec_size(pieces, IWL_UCODE_REGULAR, IWL_UCODE_SECTION_INST);
344 set_sec_offset(pieces, IWL_UCODE_REGULAR, IWL_UCODE_SECTION_INST,
345 IWLAGN_RTC_INST_LOWER_BOUND);
346 set_sec_data(pieces, IWL_UCODE_REGULAR, IWL_UCODE_SECTION_DATA, src);
347 src += get_sec_size(pieces, IWL_UCODE_REGULAR, IWL_UCODE_SECTION_DATA);
348 set_sec_offset(pieces, IWL_UCODE_REGULAR, IWL_UCODE_SECTION_DATA,
349 IWLAGN_RTC_DATA_LOWER_BOUND);
350 set_sec_data(pieces, IWL_UCODE_INIT, IWL_UCODE_SECTION_INST, src);
351 src += get_sec_size(pieces, IWL_UCODE_INIT, IWL_UCODE_SECTION_INST);
352 set_sec_offset(pieces, IWL_UCODE_INIT, IWL_UCODE_SECTION_INST,
353 IWLAGN_RTC_INST_LOWER_BOUND);
354 set_sec_data(pieces, IWL_UCODE_INIT, IWL_UCODE_SECTION_DATA, src);
355 src += get_sec_size(pieces, IWL_UCODE_INIT, IWL_UCODE_SECTION_DATA);
356 set_sec_offset(pieces, IWL_UCODE_INIT, IWL_UCODE_SECTION_DATA,
357 IWLAGN_RTC_DATA_LOWER_BOUND);
270 return 0; 358 return 0;
271} 359}
272 360
273static int iwl_parse_tlv_firmware(struct iwl_drv *drv, 361static int iwl_parse_tlv_firmware(struct iwl_drv *drv,
274 const struct firmware *ucode_raw, 362 const struct firmware *ucode_raw,
275 struct iwlagn_firmware_pieces *pieces, 363 struct iwl_firmware_pieces *pieces,
276 struct iwl_ucode_capabilities *capa) 364 struct iwl_ucode_capabilities *capa)
277{ 365{
278 struct iwl_tlv_ucode_header *ucode = (void *)ucode_raw->data; 366 struct iwl_tlv_ucode_header *ucode = (void *)ucode_raw->data;
@@ -368,20 +456,40 @@ static int iwl_parse_tlv_firmware(struct iwl_drv *drv,
368 456
369 switch (tlv_type) { 457 switch (tlv_type) {
370 case IWL_UCODE_TLV_INST: 458 case IWL_UCODE_TLV_INST:
371 pieces->inst = tlv_data; 459 set_sec_data(pieces, IWL_UCODE_REGULAR,
372 pieces->inst_size = tlv_len; 460 IWL_UCODE_SECTION_INST, tlv_data);
461 set_sec_size(pieces, IWL_UCODE_REGULAR,
462 IWL_UCODE_SECTION_INST, tlv_len);
463 set_sec_offset(pieces, IWL_UCODE_REGULAR,
464 IWL_UCODE_SECTION_INST,
465 IWLAGN_RTC_INST_LOWER_BOUND);
373 break; 466 break;
374 case IWL_UCODE_TLV_DATA: 467 case IWL_UCODE_TLV_DATA:
375 pieces->data = tlv_data; 468 set_sec_data(pieces, IWL_UCODE_REGULAR,
376 pieces->data_size = tlv_len; 469 IWL_UCODE_SECTION_DATA, tlv_data);
470 set_sec_size(pieces, IWL_UCODE_REGULAR,
471 IWL_UCODE_SECTION_DATA, tlv_len);
472 set_sec_offset(pieces, IWL_UCODE_REGULAR,
473 IWL_UCODE_SECTION_DATA,
474 IWLAGN_RTC_DATA_LOWER_BOUND);
377 break; 475 break;
378 case IWL_UCODE_TLV_INIT: 476 case IWL_UCODE_TLV_INIT:
379 pieces->init = tlv_data; 477 set_sec_data(pieces, IWL_UCODE_INIT,
380 pieces->init_size = tlv_len; 478 IWL_UCODE_SECTION_INST, tlv_data);
479 set_sec_size(pieces, IWL_UCODE_INIT,
480 IWL_UCODE_SECTION_INST, tlv_len);
481 set_sec_offset(pieces, IWL_UCODE_INIT,
482 IWL_UCODE_SECTION_INST,
483 IWLAGN_RTC_INST_LOWER_BOUND);
381 break; 484 break;
382 case IWL_UCODE_TLV_INIT_DATA: 485 case IWL_UCODE_TLV_INIT_DATA:
383 pieces->init_data = tlv_data; 486 set_sec_data(pieces, IWL_UCODE_INIT,
384 pieces->init_data_size = tlv_len; 487 IWL_UCODE_SECTION_DATA, tlv_data);
488 set_sec_size(pieces, IWL_UCODE_INIT,
489 IWL_UCODE_SECTION_DATA, tlv_len);
490 set_sec_offset(pieces, IWL_UCODE_INIT,
491 IWL_UCODE_SECTION_DATA,
492 IWLAGN_RTC_DATA_LOWER_BOUND);
385 break; 493 break;
386 case IWL_UCODE_TLV_BOOT: 494 case IWL_UCODE_TLV_BOOT:
387 IWL_ERR(drv, "Found unexpected BOOT ucode\n"); 495 IWL_ERR(drv, "Found unexpected BOOT ucode\n");
@@ -455,12 +563,22 @@ static int iwl_parse_tlv_firmware(struct iwl_drv *drv,
455 drv->fw.enhance_sensitivity_table = true; 563 drv->fw.enhance_sensitivity_table = true;
456 break; 564 break;
457 case IWL_UCODE_TLV_WOWLAN_INST: 565 case IWL_UCODE_TLV_WOWLAN_INST:
458 pieces->wowlan_inst = tlv_data; 566 set_sec_data(pieces, IWL_UCODE_WOWLAN,
459 pieces->wowlan_inst_size = tlv_len; 567 IWL_UCODE_SECTION_INST, tlv_data);
568 set_sec_size(pieces, IWL_UCODE_WOWLAN,
569 IWL_UCODE_SECTION_INST, tlv_len);
570 set_sec_offset(pieces, IWL_UCODE_WOWLAN,
571 IWL_UCODE_SECTION_INST,
572 IWLAGN_RTC_INST_LOWER_BOUND);
460 break; 573 break;
461 case IWL_UCODE_TLV_WOWLAN_DATA: 574 case IWL_UCODE_TLV_WOWLAN_DATA:
462 pieces->wowlan_data = tlv_data; 575 set_sec_data(pieces, IWL_UCODE_WOWLAN,
463 pieces->wowlan_data_size = tlv_len; 576 IWL_UCODE_SECTION_DATA, tlv_data);
577 set_sec_size(pieces, IWL_UCODE_WOWLAN,
578 IWL_UCODE_SECTION_DATA, tlv_len);
579 set_sec_offset(pieces, IWL_UCODE_WOWLAN,
580 IWL_UCODE_SECTION_DATA,
581 IWLAGN_RTC_DATA_LOWER_BOUND);
464 break; 582 break;
465 case IWL_UCODE_TLV_PHY_CALIBRATION_SIZE: 583 case IWL_UCODE_TLV_PHY_CALIBRATION_SIZE:
466 if (tlv_len != sizeof(u32)) 584 if (tlv_len != sizeof(u32))
@@ -502,7 +620,7 @@ static void iwl_ucode_callback(const struct firmware *ucode_raw, void *context)
502 struct iwl_fw *fw = &drv->fw; 620 struct iwl_fw *fw = &drv->fw;
503 struct iwl_ucode_header *ucode; 621 struct iwl_ucode_header *ucode;
504 int err; 622 int err;
505 struct iwlagn_firmware_pieces pieces; 623 struct iwl_firmware_pieces pieces;
506 const unsigned int api_max = cfg->ucode_api_max; 624 const unsigned int api_max = cfg->ucode_api_max;
507 unsigned int api_ok = cfg->ucode_api_ok; 625 unsigned int api_ok = cfg->ucode_api_ok;
508 const unsigned int api_min = cfg->ucode_api_min; 626 const unsigned int api_min = cfg->ucode_api_min;
@@ -588,36 +706,46 @@ static void iwl_ucode_callback(const struct firmware *ucode_raw, void *context)
588 IWL_DEBUG_INFO(drv, "f/w package hdr ucode version raw = 0x%x\n", 706 IWL_DEBUG_INFO(drv, "f/w package hdr ucode version raw = 0x%x\n",
589 drv->fw.ucode_ver); 707 drv->fw.ucode_ver);
590 IWL_DEBUG_INFO(drv, "f/w package hdr runtime inst size = %Zd\n", 708 IWL_DEBUG_INFO(drv, "f/w package hdr runtime inst size = %Zd\n",
591 pieces.inst_size); 709 get_sec_size(&pieces, IWL_UCODE_REGULAR,
710 IWL_UCODE_SECTION_INST));
592 IWL_DEBUG_INFO(drv, "f/w package hdr runtime data size = %Zd\n", 711 IWL_DEBUG_INFO(drv, "f/w package hdr runtime data size = %Zd\n",
593 pieces.data_size); 712 get_sec_size(&pieces, IWL_UCODE_REGULAR,
713 IWL_UCODE_SECTION_DATA));
594 IWL_DEBUG_INFO(drv, "f/w package hdr init inst size = %Zd\n", 714 IWL_DEBUG_INFO(drv, "f/w package hdr init inst size = %Zd\n",
595 pieces.init_size); 715 get_sec_size(&pieces, IWL_UCODE_INIT, IWL_UCODE_SECTION_INST));
596 IWL_DEBUG_INFO(drv, "f/w package hdr init data size = %Zd\n", 716 IWL_DEBUG_INFO(drv, "f/w package hdr init data size = %Zd\n",
597 pieces.init_data_size); 717 get_sec_size(&pieces, IWL_UCODE_INIT, IWL_UCODE_SECTION_DATA));
598 718
599 /* Verify that uCode images will fit in card's SRAM */ 719 /* Verify that uCode images will fit in card's SRAM */
600 if (pieces.inst_size > cfg->max_inst_size) { 720 if (get_sec_size(&pieces, IWL_UCODE_REGULAR, IWL_UCODE_SECTION_INST) >
721 cfg->max_inst_size) {
601 IWL_ERR(drv, "uCode instr len %Zd too large to fit in\n", 722 IWL_ERR(drv, "uCode instr len %Zd too large to fit in\n",
602 pieces.inst_size); 723 get_sec_size(&pieces, IWL_UCODE_REGULAR,
724 IWL_UCODE_SECTION_INST));
603 goto try_again; 725 goto try_again;
604 } 726 }
605 727
606 if (pieces.data_size > cfg->max_data_size) { 728 if (get_sec_size(&pieces, IWL_UCODE_REGULAR, IWL_UCODE_SECTION_DATA) >
729 cfg->max_data_size) {
607 IWL_ERR(drv, "uCode data len %Zd too large to fit in\n", 730 IWL_ERR(drv, "uCode data len %Zd too large to fit in\n",
608 pieces.data_size); 731 get_sec_size(&pieces, IWL_UCODE_REGULAR,
732 IWL_UCODE_SECTION_DATA));
609 goto try_again; 733 goto try_again;
610 } 734 }
611 735
612 if (pieces.init_size > cfg->max_inst_size) { 736 if (get_sec_size(&pieces, IWL_UCODE_INIT, IWL_UCODE_SECTION_INST) >
737 cfg->max_inst_size) {
613 IWL_ERR(drv, "uCode init instr len %Zd too large to fit in\n", 738 IWL_ERR(drv, "uCode init instr len %Zd too large to fit in\n",
614 pieces.init_size); 739 get_sec_size(&pieces, IWL_UCODE_INIT,
740 IWL_UCODE_SECTION_INST));
615 goto try_again; 741 goto try_again;
616 } 742 }
617 743
618 if (pieces.init_data_size > cfg->max_data_size) { 744 if (get_sec_size(&pieces, IWL_UCODE_INIT, IWL_UCODE_SECTION_DATA) >
745 cfg->max_data_size) {
619 IWL_ERR(drv, "uCode init data len %Zd too large to fit in\n", 746 IWL_ERR(drv, "uCode init data len %Zd too large to fit in\n",
620 pieces.init_data_size); 747 get_sec_size(&pieces, IWL_UCODE_REGULAR,
748 IWL_UCODE_SECTION_DATA));
621 goto try_again; 749 goto try_again;
622 } 750 }
623 751
@@ -627,35 +755,35 @@ static void iwl_ucode_callback(const struct firmware *ucode_raw, void *context)
627 * 1) unmodified from disk 755 * 1) unmodified from disk
628 * 2) backup cache for save/restore during power-downs */ 756 * 2) backup cache for save/restore during power-downs */
629 if (iwl_alloc_fw_desc(drv, &drv->fw.ucode_rt.code, 757 if (iwl_alloc_fw_desc(drv, &drv->fw.ucode_rt.code,
630 pieces.inst, pieces.inst_size)) 758 get_sec(&pieces, IWL_UCODE_REGULAR, IWL_UCODE_SECTION_INST)))
631 goto err_pci_alloc; 759 goto err_pci_alloc;
632 if (iwl_alloc_fw_desc(drv, &drv->fw.ucode_rt.data, 760 if (iwl_alloc_fw_desc(drv, &drv->fw.ucode_rt.data,
633 pieces.data, pieces.data_size)) 761 get_sec(&pieces, IWL_UCODE_REGULAR, IWL_UCODE_SECTION_DATA)))
634 goto err_pci_alloc; 762 goto err_pci_alloc;
635 763
636 /* Initialization instructions and data */ 764 /* Initialization instructions and data */
637 if (pieces.init_size && pieces.init_data_size) { 765 if (get_sec_size(&pieces, IWL_UCODE_INIT, IWL_UCODE_SECTION_INST) &&
638 if (iwl_alloc_fw_desc(drv, 766 get_sec_size(&pieces, IWL_UCODE_INIT, IWL_UCODE_SECTION_DATA)) {
639 &drv->fw.ucode_init.code, 767 if (iwl_alloc_fw_desc(drv, &drv->fw.ucode_init.code,
640 pieces.init, pieces.init_size)) 768 get_sec(&pieces, IWL_UCODE_INIT,
769 IWL_UCODE_SECTION_INST)))
641 goto err_pci_alloc; 770 goto err_pci_alloc;
642 if (iwl_alloc_fw_desc(drv, 771 if (iwl_alloc_fw_desc(drv, &drv->fw.ucode_init.data,
643 &drv->fw.ucode_init.data, 772 get_sec(&pieces, IWL_UCODE_INIT,
644 pieces.init_data, pieces.init_data_size)) 773 IWL_UCODE_SECTION_DATA)))
645 goto err_pci_alloc; 774 goto err_pci_alloc;
646 } 775 }
647 776
648 /* WoWLAN instructions and data */ 777 /* WoWLAN instructions and data */
649 if (pieces.wowlan_inst_size && pieces.wowlan_data_size) { 778 if (get_sec_size(&pieces, IWL_UCODE_WOWLAN, IWL_UCODE_SECTION_INST) &&
650 if (iwl_alloc_fw_desc(drv, 779 get_sec_size(&pieces, IWL_UCODE_WOWLAN, IWL_UCODE_SECTION_DATA)) {
651 &drv->fw.ucode_wowlan.code, 780 if (iwl_alloc_fw_desc(drv, &drv->fw.ucode_wowlan.code,
652 pieces.wowlan_inst, 781 get_sec(&pieces, IWL_UCODE_WOWLAN,
653 pieces.wowlan_inst_size)) 782 IWL_UCODE_SECTION_INST)))
654 goto err_pci_alloc; 783 goto err_pci_alloc;
655 if (iwl_alloc_fw_desc(drv, 784 if (iwl_alloc_fw_desc(drv, &drv->fw.ucode_wowlan.data,
656 &drv->fw.ucode_wowlan.data, 785 get_sec(&pieces, IWL_UCODE_WOWLAN,
657 pieces.wowlan_data, 786 IWL_UCODE_SECTION_DATA)))
658 pieces.wowlan_data_size))
659 goto err_pci_alloc; 787 goto err_pci_alloc;
660 } 788 }
661 789