aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/net/wireless/iwlwifi/iwl-drv.c
diff options
context:
space:
mode:
authorJohannes Berg <johannes.berg@intel.com>2012-03-06 16:30:38 -0500
committerJohn W. Linville <linville@tuxdriver.com>2012-03-07 13:51:48 -0500
commit965974a631756ab2729469b9ecadfe61ee44dfc5 (patch)
tree274997cbbead08d5b8f3c988a5cc85e969df6b4a /drivers/net/wireless/iwlwifi/iwl-drv.c
parent0692fe41b36159be5d8c7d4eef0699e79c383c85 (diff)
iwlwifi: remove iwl-wifi.h
This file was recently introduced, but then directly abused -- it contained private data that shouldn't have been used by anything but the implementation of firmware requests and some very core code. Now that it is no longer accessed by any code but the code in iwl-drv.c, we can dissolve it. Also rename the iwl_nic struct to iwl_drv to better reflect where and how it is used. Signed-off-by: Johannes Berg <johannes.berg@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.c272
1 files changed, 147 insertions, 125 deletions
diff --git a/drivers/net/wireless/iwlwifi/iwl-drv.c b/drivers/net/wireless/iwlwifi/iwl-drv.c
index 351b2f908383..f1beeab1e601 100644
--- a/drivers/net/wireless/iwlwifi/iwl-drv.c
+++ b/drivers/net/wireless/iwlwifi/iwl-drv.c
@@ -67,36 +67,58 @@
67 67
68#include "iwl-drv.h" 68#include "iwl-drv.h"
69#include "iwl-trans.h" 69#include "iwl-trans.h"
70#include "iwl-wifi.h"
71#include "iwl-shared.h" 70#include "iwl-shared.h"
72#include "iwl-op-mode.h" 71#include "iwl-op-mode.h"
73 72
74/* private includes */ 73/* private includes */
75#include "iwl-ucode.h" 74#include "iwl-ucode.h"
76 75
77static void iwl_free_fw_desc(struct iwl_nic *nic, struct fw_desc *desc) 76/**
77 * struct iwl_drv - drv common data
78 * @fw: the iwl_fw structure
79 * @shrd: pointer to common shared structure
80 * @op_mode: the running op_mode
81 * @fw_index: firmware revision to try loading
82 * @firmware_name: composite filename of ucode file to load
83 * @request_firmware_complete: the firmware has been obtained from user space
84 */
85struct iwl_drv {
86 struct iwl_fw fw;
87
88 struct iwl_shared *shrd;
89 struct iwl_op_mode *op_mode;
90
91 int fw_index; /* firmware we're trying to load */
92 char firmware_name[25]; /* name of firmware file to load */
93
94 struct completion request_firmware_complete;
95};
96
97
98
99static void iwl_free_fw_desc(struct iwl_drv *drv, struct fw_desc *desc)
78{ 100{
79 if (desc->v_addr) 101 if (desc->v_addr)
80 dma_free_coherent(trans(nic)->dev, desc->len, 102 dma_free_coherent(trans(drv)->dev, desc->len,
81 desc->v_addr, desc->p_addr); 103 desc->v_addr, desc->p_addr);
82 desc->v_addr = NULL; 104 desc->v_addr = NULL;
83 desc->len = 0; 105 desc->len = 0;
84} 106}
85 107
86static void iwl_free_fw_img(struct iwl_nic *nic, struct fw_img *img) 108static void iwl_free_fw_img(struct iwl_drv *drv, struct fw_img *img)
87{ 109{
88 iwl_free_fw_desc(nic, &img->code); 110 iwl_free_fw_desc(drv, &img->code);
89 iwl_free_fw_desc(nic, &img->data); 111 iwl_free_fw_desc(drv, &img->data);
90} 112}
91 113
92static void iwl_dealloc_ucode(struct iwl_nic *nic) 114static void iwl_dealloc_ucode(struct iwl_drv *drv)
93{ 115{
94 iwl_free_fw_img(nic, &nic->fw.ucode_rt); 116 iwl_free_fw_img(drv, &drv->fw.ucode_rt);
95 iwl_free_fw_img(nic, &nic->fw.ucode_init); 117 iwl_free_fw_img(drv, &drv->fw.ucode_init);
96 iwl_free_fw_img(nic, &nic->fw.ucode_wowlan); 118 iwl_free_fw_img(drv, &drv->fw.ucode_wowlan);
97} 119}
98 120
99static int iwl_alloc_fw_desc(struct iwl_nic *nic, struct fw_desc *desc, 121static int iwl_alloc_fw_desc(struct iwl_drv *drv, struct fw_desc *desc,
100 const void *data, size_t len) 122 const void *data, size_t len)
101{ 123{
102 if (!len) { 124 if (!len) {
@@ -104,7 +126,7 @@ static int iwl_alloc_fw_desc(struct iwl_nic *nic, struct fw_desc *desc,
104 return -EINVAL; 126 return -EINVAL;
105 } 127 }
106 128
107 desc->v_addr = dma_alloc_coherent(trans(nic)->dev, len, 129 desc->v_addr = dma_alloc_coherent(trans(drv)->dev, len,
108 &desc->p_addr, GFP_KERNEL); 130 &desc->p_addr, GFP_KERNEL);
109 if (!desc->v_addr) 131 if (!desc->v_addr)
110 return -ENOMEM; 132 return -ENOMEM;
@@ -119,40 +141,40 @@ static void iwl_ucode_callback(const struct firmware *ucode_raw, void *context);
119#define UCODE_EXPERIMENTAL_INDEX 100 141#define UCODE_EXPERIMENTAL_INDEX 100
120#define UCODE_EXPERIMENTAL_TAG "exp" 142#define UCODE_EXPERIMENTAL_TAG "exp"
121 143
122static int iwl_request_firmware(struct iwl_nic *nic, bool first) 144static int iwl_request_firmware(struct iwl_drv *drv, bool first)
123{ 145{
124 const struct iwl_cfg *cfg = cfg(nic); 146 const struct iwl_cfg *cfg = cfg(drv);
125 const char *name_pre = cfg->fw_name_pre; 147 const char *name_pre = cfg->fw_name_pre;
126 char tag[8]; 148 char tag[8];
127 149
128 if (first) { 150 if (first) {
129#ifdef CONFIG_IWLWIFI_DEBUG_EXPERIMENTAL_UCODE 151#ifdef CONFIG_IWLWIFI_DEBUG_EXPERIMENTAL_UCODE
130 nic->fw_index = UCODE_EXPERIMENTAL_INDEX; 152 drv->fw_index = UCODE_EXPERIMENTAL_INDEX;
131 strcpy(tag, UCODE_EXPERIMENTAL_TAG); 153 strcpy(tag, UCODE_EXPERIMENTAL_TAG);
132 } else if (nic->fw_index == UCODE_EXPERIMENTAL_INDEX) { 154 } else if (drv->fw_index == UCODE_EXPERIMENTAL_INDEX) {
133#endif 155#endif
134 nic->fw_index = cfg->ucode_api_max; 156 drv->fw_index = cfg->ucode_api_max;
135 sprintf(tag, "%d", nic->fw_index); 157 sprintf(tag, "%d", drv->fw_index);
136 } else { 158 } else {
137 nic->fw_index--; 159 drv->fw_index--;
138 sprintf(tag, "%d", nic->fw_index); 160 sprintf(tag, "%d", drv->fw_index);
139 } 161 }
140 162
141 if (nic->fw_index < cfg->ucode_api_min) { 163 if (drv->fw_index < cfg->ucode_api_min) {
142 IWL_ERR(nic, "no suitable firmware found!\n"); 164 IWL_ERR(drv, "no suitable firmware found!\n");
143 return -ENOENT; 165 return -ENOENT;
144 } 166 }
145 167
146 sprintf(nic->firmware_name, "%s%s%s", name_pre, tag, ".ucode"); 168 sprintf(drv->firmware_name, "%s%s%s", name_pre, tag, ".ucode");
147 169
148 IWL_DEBUG_INFO(nic, "attempting to load firmware %s'%s'\n", 170 IWL_DEBUG_INFO(drv, "attempting to load firmware %s'%s'\n",
149 (nic->fw_index == UCODE_EXPERIMENTAL_INDEX) 171 (drv->fw_index == UCODE_EXPERIMENTAL_INDEX)
150 ? "EXPERIMENTAL " : "", 172 ? "EXPERIMENTAL " : "",
151 nic->firmware_name); 173 drv->firmware_name);
152 174
153 return request_firmware_nowait(THIS_MODULE, 1, nic->firmware_name, 175 return request_firmware_nowait(THIS_MODULE, 1, drv->firmware_name,
154 trans(nic)->dev, 176 trans(drv)->dev,
155 GFP_KERNEL, nic, iwl_ucode_callback); 177 GFP_KERNEL, drv, iwl_ucode_callback);
156} 178}
157 179
158struct iwlagn_firmware_pieces { 180struct iwlagn_firmware_pieces {
@@ -164,7 +186,7 @@ struct iwlagn_firmware_pieces {
164 u32 inst_evtlog_ptr, inst_evtlog_size, inst_errlog_ptr; 186 u32 inst_evtlog_ptr, inst_evtlog_size, inst_errlog_ptr;
165}; 187};
166 188
167static int iwl_parse_v1_v2_firmware(struct iwl_nic *nic, 189static int iwl_parse_v1_v2_firmware(struct iwl_drv *drv,
168 const struct firmware *ucode_raw, 190 const struct firmware *ucode_raw,
169 struct iwlagn_firmware_pieces *pieces) 191 struct iwlagn_firmware_pieces *pieces)
170{ 192{
@@ -173,14 +195,14 @@ static int iwl_parse_v1_v2_firmware(struct iwl_nic *nic,
173 char buildstr[25]; 195 char buildstr[25];
174 const u8 *src; 196 const u8 *src;
175 197
176 nic->fw.ucode_ver = le32_to_cpu(ucode->ver); 198 drv->fw.ucode_ver = le32_to_cpu(ucode->ver);
177 api_ver = IWL_UCODE_API(nic->fw.ucode_ver); 199 api_ver = IWL_UCODE_API(drv->fw.ucode_ver);
178 200
179 switch (api_ver) { 201 switch (api_ver) {
180 default: 202 default:
181 hdr_size = 28; 203 hdr_size = 28;
182 if (ucode_raw->size < hdr_size) { 204 if (ucode_raw->size < hdr_size) {
183 IWL_ERR(nic, "File size too small!\n"); 205 IWL_ERR(drv, "File size too small!\n");
184 return -EINVAL; 206 return -EINVAL;
185 } 207 }
186 build = le32_to_cpu(ucode->u.v2.build); 208 build = le32_to_cpu(ucode->u.v2.build);
@@ -196,7 +218,7 @@ static int iwl_parse_v1_v2_firmware(struct iwl_nic *nic,
196 case 2: 218 case 2:
197 hdr_size = 24; 219 hdr_size = 24;
198 if (ucode_raw->size < hdr_size) { 220 if (ucode_raw->size < hdr_size) {
199 IWL_ERR(nic, "File size too small!\n"); 221 IWL_ERR(drv, "File size too small!\n");
200 return -EINVAL; 222 return -EINVAL;
201 } 223 }
202 build = 0; 224 build = 0;
@@ -211,18 +233,18 @@ static int iwl_parse_v1_v2_firmware(struct iwl_nic *nic,
211 233
212 if (build) 234 if (build)
213 sprintf(buildstr, " build %u%s", build, 235 sprintf(buildstr, " build %u%s", build,
214 (nic->fw_index == UCODE_EXPERIMENTAL_INDEX) 236 (drv->fw_index == UCODE_EXPERIMENTAL_INDEX)
215 ? " (EXP)" : ""); 237 ? " (EXP)" : "");
216 else 238 else
217 buildstr[0] = '\0'; 239 buildstr[0] = '\0';
218 240
219 snprintf(nic->fw.fw_version, 241 snprintf(drv->fw.fw_version,
220 sizeof(nic->fw.fw_version), 242 sizeof(drv->fw.fw_version),
221 "%u.%u.%u.%u%s", 243 "%u.%u.%u.%u%s",
222 IWL_UCODE_MAJOR(nic->fw.ucode_ver), 244 IWL_UCODE_MAJOR(drv->fw.ucode_ver),
223 IWL_UCODE_MINOR(nic->fw.ucode_ver), 245 IWL_UCODE_MINOR(drv->fw.ucode_ver),
224 IWL_UCODE_API(nic->fw.ucode_ver), 246 IWL_UCODE_API(drv->fw.ucode_ver),
225 IWL_UCODE_SERIAL(nic->fw.ucode_ver), 247 IWL_UCODE_SERIAL(drv->fw.ucode_ver),
226 buildstr); 248 buildstr);
227 249
228 /* Verify size of file vs. image size info in file's header */ 250 /* Verify size of file vs. image size info in file's header */
@@ -230,7 +252,7 @@ static int iwl_parse_v1_v2_firmware(struct iwl_nic *nic,
230 pieces->data_size + pieces->init_size + 252 pieces->data_size + pieces->init_size +
231 pieces->init_data_size) { 253 pieces->init_data_size) {
232 254
233 IWL_ERR(nic, 255 IWL_ERR(drv,
234 "uCode file size %d does not match expected size\n", 256 "uCode file size %d does not match expected size\n",
235 (int)ucode_raw->size); 257 (int)ucode_raw->size);
236 return -EINVAL; 258 return -EINVAL;
@@ -248,7 +270,7 @@ static int iwl_parse_v1_v2_firmware(struct iwl_nic *nic,
248 return 0; 270 return 0;
249} 271}
250 272
251static int iwl_parse_tlv_firmware(struct iwl_nic *nic, 273static int iwl_parse_tlv_firmware(struct iwl_drv *drv,
252 const struct firmware *ucode_raw, 274 const struct firmware *ucode_raw,
253 struct iwlagn_firmware_pieces *pieces, 275 struct iwlagn_firmware_pieces *pieces,
254 struct iwl_ucode_capabilities *capa) 276 struct iwl_ucode_capabilities *capa)
@@ -267,12 +289,12 @@ static int iwl_parse_tlv_firmware(struct iwl_nic *nic,
267 u32 build; 289 u32 build;
268 290
269 if (len < sizeof(*ucode)) { 291 if (len < sizeof(*ucode)) {
270 IWL_ERR(nic, "uCode has invalid length: %zd\n", len); 292 IWL_ERR(drv, "uCode has invalid length: %zd\n", len);
271 return -EINVAL; 293 return -EINVAL;
272 } 294 }
273 295
274 if (ucode->magic != cpu_to_le32(IWL_TLV_UCODE_MAGIC)) { 296 if (ucode->magic != cpu_to_le32(IWL_TLV_UCODE_MAGIC)) {
275 IWL_ERR(nic, "invalid uCode magic: 0X%x\n", 297 IWL_ERR(drv, "invalid uCode magic: 0X%x\n",
276 le32_to_cpu(ucode->magic)); 298 le32_to_cpu(ucode->magic));
277 return -EINVAL; 299 return -EINVAL;
278 } 300 }
@@ -290,27 +312,27 @@ static int iwl_parse_tlv_firmware(struct iwl_nic *nic,
290 while (wanted_alternative && !(alternatives & BIT(wanted_alternative))) 312 while (wanted_alternative && !(alternatives & BIT(wanted_alternative)))
291 wanted_alternative--; 313 wanted_alternative--;
292 if (wanted_alternative && wanted_alternative != tmp) 314 if (wanted_alternative && wanted_alternative != tmp)
293 IWL_WARN(nic, 315 IWL_WARN(drv,
294 "uCode alternative %d not available, choosing %d\n", 316 "uCode alternative %d not available, choosing %d\n",
295 tmp, wanted_alternative); 317 tmp, wanted_alternative);
296 318
297 nic->fw.ucode_ver = le32_to_cpu(ucode->ver); 319 drv->fw.ucode_ver = le32_to_cpu(ucode->ver);
298 build = le32_to_cpu(ucode->build); 320 build = le32_to_cpu(ucode->build);
299 321
300 if (build) 322 if (build)
301 sprintf(buildstr, " build %u%s", build, 323 sprintf(buildstr, " build %u%s", build,
302 (nic->fw_index == UCODE_EXPERIMENTAL_INDEX) 324 (drv->fw_index == UCODE_EXPERIMENTAL_INDEX)
303 ? " (EXP)" : ""); 325 ? " (EXP)" : "");
304 else 326 else
305 buildstr[0] = '\0'; 327 buildstr[0] = '\0';
306 328
307 snprintf(nic->fw.fw_version, 329 snprintf(drv->fw.fw_version,
308 sizeof(nic->fw.fw_version), 330 sizeof(drv->fw.fw_version),
309 "%u.%u.%u.%u%s", 331 "%u.%u.%u.%u%s",
310 IWL_UCODE_MAJOR(nic->fw.ucode_ver), 332 IWL_UCODE_MAJOR(drv->fw.ucode_ver),
311 IWL_UCODE_MINOR(nic->fw.ucode_ver), 333 IWL_UCODE_MINOR(drv->fw.ucode_ver),
312 IWL_UCODE_API(nic->fw.ucode_ver), 334 IWL_UCODE_API(drv->fw.ucode_ver),
313 IWL_UCODE_SERIAL(nic->fw.ucode_ver), 335 IWL_UCODE_SERIAL(drv->fw.ucode_ver),
314 buildstr); 336 buildstr);
315 337
316 data = ucode->data; 338 data = ucode->data;
@@ -329,7 +351,7 @@ static int iwl_parse_tlv_firmware(struct iwl_nic *nic,
329 tlv_data = tlv->data; 351 tlv_data = tlv->data;
330 352
331 if (len < tlv_len) { 353 if (len < tlv_len) {
332 IWL_ERR(nic, "invalid TLV len: %zd/%u\n", 354 IWL_ERR(drv, "invalid TLV len: %zd/%u\n",
333 len, tlv_len); 355 len, tlv_len);
334 return -EINVAL; 356 return -EINVAL;
335 } 357 }
@@ -362,7 +384,7 @@ static int iwl_parse_tlv_firmware(struct iwl_nic *nic,
362 pieces->init_data_size = tlv_len; 384 pieces->init_data_size = tlv_len;
363 break; 385 break;
364 case IWL_UCODE_TLV_BOOT: 386 case IWL_UCODE_TLV_BOOT:
365 IWL_ERR(nic, "Found unexpected BOOT ucode\n"); 387 IWL_ERR(drv, "Found unexpected BOOT ucode\n");
366 break; 388 break;
367 case IWL_UCODE_TLV_PROBE_MAX_LEN: 389 case IWL_UCODE_TLV_PROBE_MAX_LEN:
368 if (tlv_len != sizeof(u32)) 390 if (tlv_len != sizeof(u32))
@@ -430,7 +452,7 @@ static int iwl_parse_tlv_firmware(struct iwl_nic *nic,
430 case IWL_UCODE_TLV_ENHANCE_SENS_TBL: 452 case IWL_UCODE_TLV_ENHANCE_SENS_TBL:
431 if (tlv_len) 453 if (tlv_len)
432 goto invalid_tlv_len; 454 goto invalid_tlv_len;
433 nic->fw.enhance_sensitivity_table = true; 455 drv->fw.enhance_sensitivity_table = true;
434 break; 456 break;
435 case IWL_UCODE_TLV_WOWLAN_INST: 457 case IWL_UCODE_TLV_WOWLAN_INST:
436 pieces->wowlan_inst = tlv_data; 458 pieces->wowlan_inst = tlv_data;
@@ -447,22 +469,22 @@ static int iwl_parse_tlv_firmware(struct iwl_nic *nic,
447 le32_to_cpup((__le32 *)tlv_data); 469 le32_to_cpup((__le32 *)tlv_data);
448 break; 470 break;
449 default: 471 default:
450 IWL_DEBUG_INFO(nic, "unknown TLV: %d\n", tlv_type); 472 IWL_DEBUG_INFO(drv, "unknown TLV: %d\n", tlv_type);
451 break; 473 break;
452 } 474 }
453 } 475 }
454 476
455 if (len) { 477 if (len) {
456 IWL_ERR(nic, "invalid TLV after parsing: %zd\n", len); 478 IWL_ERR(drv, "invalid TLV after parsing: %zd\n", len);
457 iwl_print_hex_dump(nic, IWL_DL_FW, (u8 *)data, len); 479 iwl_print_hex_dump(drv, IWL_DL_FW, (u8 *)data, len);
458 return -EINVAL; 480 return -EINVAL;
459 } 481 }
460 482
461 return 0; 483 return 0;
462 484
463 invalid_tlv_len: 485 invalid_tlv_len:
464 IWL_ERR(nic, "TLV %d has invalid size: %u\n", tlv_type, tlv_len); 486 IWL_ERR(drv, "TLV %d has invalid size: %u\n", tlv_type, tlv_len);
465 iwl_print_hex_dump(nic, IWL_DL_FW, tlv_data, tlv_len); 487 iwl_print_hex_dump(drv, IWL_DL_FW, tlv_data, tlv_len);
466 488
467 return -EINVAL; 489 return -EINVAL;
468} 490}
@@ -475,9 +497,9 @@ static int iwl_parse_tlv_firmware(struct iwl_nic *nic,
475 */ 497 */
476static void iwl_ucode_callback(const struct firmware *ucode_raw, void *context) 498static void iwl_ucode_callback(const struct firmware *ucode_raw, void *context)
477{ 499{
478 struct iwl_nic *nic = context; 500 struct iwl_drv *drv = context;
479 const struct iwl_cfg *cfg = cfg(nic); 501 const struct iwl_cfg *cfg = cfg(drv);
480 struct iwl_fw *fw = &nic->fw; 502 struct iwl_fw *fw = &drv->fw;
481 struct iwl_ucode_header *ucode; 503 struct iwl_ucode_header *ucode;
482 int err; 504 int err;
483 struct iwlagn_firmware_pieces pieces; 505 struct iwlagn_firmware_pieces pieces;
@@ -496,19 +518,19 @@ static void iwl_ucode_callback(const struct firmware *ucode_raw, void *context)
496 memset(&pieces, 0, sizeof(pieces)); 518 memset(&pieces, 0, sizeof(pieces));
497 519
498 if (!ucode_raw) { 520 if (!ucode_raw) {
499 if (nic->fw_index <= api_ok) 521 if (drv->fw_index <= api_ok)
500 IWL_ERR(nic, 522 IWL_ERR(drv,
501 "request for firmware file '%s' failed.\n", 523 "request for firmware file '%s' failed.\n",
502 nic->firmware_name); 524 drv->firmware_name);
503 goto try_again; 525 goto try_again;
504 } 526 }
505 527
506 IWL_DEBUG_INFO(nic, "Loaded firmware file '%s' (%zd bytes).\n", 528 IWL_DEBUG_INFO(drv, "Loaded firmware file '%s' (%zd bytes).\n",
507 nic->firmware_name, ucode_raw->size); 529 drv->firmware_name, ucode_raw->size);
508 530
509 /* Make sure that we got at least the API version number */ 531 /* Make sure that we got at least the API version number */
510 if (ucode_raw->size < 4) { 532 if (ucode_raw->size < 4) {
511 IWL_ERR(nic, "File size way too small!\n"); 533 IWL_ERR(drv, "File size way too small!\n");
512 goto try_again; 534 goto try_again;
513 } 535 }
514 536
@@ -516,15 +538,15 @@ static void iwl_ucode_callback(const struct firmware *ucode_raw, void *context)
516 ucode = (struct iwl_ucode_header *)ucode_raw->data; 538 ucode = (struct iwl_ucode_header *)ucode_raw->data;
517 539
518 if (ucode->ver) 540 if (ucode->ver)
519 err = iwl_parse_v1_v2_firmware(nic, ucode_raw, &pieces); 541 err = iwl_parse_v1_v2_firmware(drv, ucode_raw, &pieces);
520 else 542 else
521 err = iwl_parse_tlv_firmware(nic, ucode_raw, &pieces, 543 err = iwl_parse_tlv_firmware(drv, ucode_raw, &pieces,
522 &fw->ucode_capa); 544 &fw->ucode_capa);
523 545
524 if (err) 546 if (err)
525 goto try_again; 547 goto try_again;
526 548
527 api_ver = IWL_UCODE_API(nic->fw.ucode_ver); 549 api_ver = IWL_UCODE_API(drv->fw.ucode_ver);
528 550
529 /* 551 /*
530 * api_ver should match the api version forming part of the 552 * api_ver should match the api version forming part of the
@@ -532,9 +554,9 @@ static void iwl_ucode_callback(const struct firmware *ucode_raw, void *context)
532 * on the API version read from firmware header from here on forward 554 * on the API version read from firmware header from here on forward
533 */ 555 */
534 /* no api version check required for experimental uCode */ 556 /* no api version check required for experimental uCode */
535 if (nic->fw_index != UCODE_EXPERIMENTAL_INDEX) { 557 if (drv->fw_index != UCODE_EXPERIMENTAL_INDEX) {
536 if (api_ver < api_min || api_ver > api_max) { 558 if (api_ver < api_min || api_ver > api_max) {
537 IWL_ERR(nic, 559 IWL_ERR(drv,
538 "Driver unable to support your firmware API. " 560 "Driver unable to support your firmware API. "
539 "Driver supports v%u, firmware is v%u.\n", 561 "Driver supports v%u, firmware is v%u.\n",
540 api_max, api_ver); 562 api_max, api_ver);
@@ -543,19 +565,19 @@ static void iwl_ucode_callback(const struct firmware *ucode_raw, void *context)
543 565
544 if (api_ver < api_ok) { 566 if (api_ver < api_ok) {
545 if (api_ok != api_max) 567 if (api_ok != api_max)
546 IWL_ERR(nic, "Firmware has old API version, " 568 IWL_ERR(drv, "Firmware has old API version, "
547 "expected v%u through v%u, got v%u.\n", 569 "expected v%u through v%u, got v%u.\n",
548 api_ok, api_max, api_ver); 570 api_ok, api_max, api_ver);
549 else 571 else
550 IWL_ERR(nic, "Firmware has old API version, " 572 IWL_ERR(drv, "Firmware has old API version, "
551 "expected v%u, got v%u.\n", 573 "expected v%u, got v%u.\n",
552 api_max, api_ver); 574 api_max, api_ver);
553 IWL_ERR(nic, "New firmware can be obtained from " 575 IWL_ERR(drv, "New firmware can be obtained from "
554 "http://www.intellinuxwireless.org/.\n"); 576 "http://www.intellinuxwireless.org/.\n");
555 } 577 }
556 } 578 }
557 579
558 IWL_INFO(nic, "loaded firmware version %s", nic->fw.fw_version); 580 IWL_INFO(drv, "loaded firmware version %s", drv->fw.fw_version);
559 581
560 /* 582 /*
561 * For any of the failures below (before allocating pci memory) 583 * For any of the failures below (before allocating pci memory)
@@ -563,38 +585,38 @@ static void iwl_ucode_callback(const struct firmware *ucode_raw, void *context)
563 * user just got a corrupted version of the latest API. 585 * user just got a corrupted version of the latest API.
564 */ 586 */
565 587
566 IWL_DEBUG_INFO(nic, "f/w package hdr ucode version raw = 0x%x\n", 588 IWL_DEBUG_INFO(drv, "f/w package hdr ucode version raw = 0x%x\n",
567 nic->fw.ucode_ver); 589 drv->fw.ucode_ver);
568 IWL_DEBUG_INFO(nic, "f/w package hdr runtime inst size = %Zd\n", 590 IWL_DEBUG_INFO(drv, "f/w package hdr runtime inst size = %Zd\n",
569 pieces.inst_size); 591 pieces.inst_size);
570 IWL_DEBUG_INFO(nic, "f/w package hdr runtime data size = %Zd\n", 592 IWL_DEBUG_INFO(drv, "f/w package hdr runtime data size = %Zd\n",
571 pieces.data_size); 593 pieces.data_size);
572 IWL_DEBUG_INFO(nic, "f/w package hdr init inst size = %Zd\n", 594 IWL_DEBUG_INFO(drv, "f/w package hdr init inst size = %Zd\n",
573 pieces.init_size); 595 pieces.init_size);
574 IWL_DEBUG_INFO(nic, "f/w package hdr init data size = %Zd\n", 596 IWL_DEBUG_INFO(drv, "f/w package hdr init data size = %Zd\n",
575 pieces.init_data_size); 597 pieces.init_data_size);
576 598
577 /* Verify that uCode images will fit in card's SRAM */ 599 /* Verify that uCode images will fit in card's SRAM */
578 if (pieces.inst_size > cfg->max_inst_size) { 600 if (pieces.inst_size > cfg->max_inst_size) {
579 IWL_ERR(nic, "uCode instr len %Zd too large to fit in\n", 601 IWL_ERR(drv, "uCode instr len %Zd too large to fit in\n",
580 pieces.inst_size); 602 pieces.inst_size);
581 goto try_again; 603 goto try_again;
582 } 604 }
583 605
584 if (pieces.data_size > cfg->max_data_size) { 606 if (pieces.data_size > cfg->max_data_size) {
585 IWL_ERR(nic, "uCode data len %Zd too large to fit in\n", 607 IWL_ERR(drv, "uCode data len %Zd too large to fit in\n",
586 pieces.data_size); 608 pieces.data_size);
587 goto try_again; 609 goto try_again;
588 } 610 }
589 611
590 if (pieces.init_size > cfg->max_inst_size) { 612 if (pieces.init_size > cfg->max_inst_size) {
591 IWL_ERR(nic, "uCode init instr len %Zd too large to fit in\n", 613 IWL_ERR(drv, "uCode init instr len %Zd too large to fit in\n",
592 pieces.init_size); 614 pieces.init_size);
593 goto try_again; 615 goto try_again;
594 } 616 }
595 617
596 if (pieces.init_data_size > cfg->max_data_size) { 618 if (pieces.init_data_size > cfg->max_data_size) {
597 IWL_ERR(nic, "uCode init data len %Zd too large to fit in\n", 619 IWL_ERR(drv, "uCode init data len %Zd too large to fit in\n",
598 pieces.init_data_size); 620 pieces.init_data_size);
599 goto try_again; 621 goto try_again;
600 } 622 }
@@ -604,34 +626,34 @@ static void iwl_ucode_callback(const struct firmware *ucode_raw, void *context)
604 /* Runtime instructions and 2 copies of data: 626 /* Runtime instructions and 2 copies of data:
605 * 1) unmodified from disk 627 * 1) unmodified from disk
606 * 2) backup cache for save/restore during power-downs */ 628 * 2) backup cache for save/restore during power-downs */
607 if (iwl_alloc_fw_desc(nic, &nic->fw.ucode_rt.code, 629 if (iwl_alloc_fw_desc(drv, &drv->fw.ucode_rt.code,
608 pieces.inst, pieces.inst_size)) 630 pieces.inst, pieces.inst_size))
609 goto err_pci_alloc; 631 goto err_pci_alloc;
610 if (iwl_alloc_fw_desc(nic, &nic->fw.ucode_rt.data, 632 if (iwl_alloc_fw_desc(drv, &drv->fw.ucode_rt.data,
611 pieces.data, pieces.data_size)) 633 pieces.data, pieces.data_size))
612 goto err_pci_alloc; 634 goto err_pci_alloc;
613 635
614 /* Initialization instructions and data */ 636 /* Initialization instructions and data */
615 if (pieces.init_size && pieces.init_data_size) { 637 if (pieces.init_size && pieces.init_data_size) {
616 if (iwl_alloc_fw_desc(nic, 638 if (iwl_alloc_fw_desc(drv,
617 &nic->fw.ucode_init.code, 639 &drv->fw.ucode_init.code,
618 pieces.init, pieces.init_size)) 640 pieces.init, pieces.init_size))
619 goto err_pci_alloc; 641 goto err_pci_alloc;
620 if (iwl_alloc_fw_desc(nic, 642 if (iwl_alloc_fw_desc(drv,
621 &nic->fw.ucode_init.data, 643 &drv->fw.ucode_init.data,
622 pieces.init_data, pieces.init_data_size)) 644 pieces.init_data, pieces.init_data_size))
623 goto err_pci_alloc; 645 goto err_pci_alloc;
624 } 646 }
625 647
626 /* WoWLAN instructions and data */ 648 /* WoWLAN instructions and data */
627 if (pieces.wowlan_inst_size && pieces.wowlan_data_size) { 649 if (pieces.wowlan_inst_size && pieces.wowlan_data_size) {
628 if (iwl_alloc_fw_desc(nic, 650 if (iwl_alloc_fw_desc(drv,
629 &nic->fw.ucode_wowlan.code, 651 &drv->fw.ucode_wowlan.code,
630 pieces.wowlan_inst, 652 pieces.wowlan_inst,
631 pieces.wowlan_inst_size)) 653 pieces.wowlan_inst_size))
632 goto err_pci_alloc; 654 goto err_pci_alloc;
633 if (iwl_alloc_fw_desc(nic, 655 if (iwl_alloc_fw_desc(drv,
634 &nic->fw.ucode_wowlan.data, 656 &drv->fw.ucode_wowlan.data,
635 pieces.wowlan_data, 657 pieces.wowlan_data,
636 pieces.wowlan_data_size)) 658 pieces.wowlan_data_size))
637 goto err_pci_alloc; 659 goto err_pci_alloc;
@@ -670,11 +692,11 @@ static void iwl_ucode_callback(const struct firmware *ucode_raw, void *context)
670 692
671 /* We have our copies now, allow OS release its copies */ 693 /* We have our copies now, allow OS release its copies */
672 release_firmware(ucode_raw); 694 release_firmware(ucode_raw);
673 complete(&nic->request_firmware_complete); 695 complete(&drv->request_firmware_complete);
674 696
675 nic->op_mode = iwl_dvm_ops.start(nic->shrd->trans, &nic->fw); 697 drv->op_mode = iwl_dvm_ops.start(drv->shrd->trans, &drv->fw);
676 698
677 if (!nic->op_mode) 699 if (!drv->op_mode)
678 goto out_unbind; 700 goto out_unbind;
679 701
680 return; 702 return;
@@ -682,43 +704,43 @@ static void iwl_ucode_callback(const struct firmware *ucode_raw, void *context)
682 try_again: 704 try_again:
683 /* try next, if any */ 705 /* try next, if any */
684 release_firmware(ucode_raw); 706 release_firmware(ucode_raw);
685 if (iwl_request_firmware(nic, false)) 707 if (iwl_request_firmware(drv, false))
686 goto out_unbind; 708 goto out_unbind;
687 return; 709 return;
688 710
689 err_pci_alloc: 711 err_pci_alloc:
690 IWL_ERR(nic, "failed to allocate pci memory\n"); 712 IWL_ERR(drv, "failed to allocate pci memory\n");
691 iwl_dealloc_ucode(nic); 713 iwl_dealloc_ucode(drv);
692 release_firmware(ucode_raw); 714 release_firmware(ucode_raw);
693 out_unbind: 715 out_unbind:
694 complete(&nic->request_firmware_complete); 716 complete(&drv->request_firmware_complete);
695 device_release_driver(trans(nic)->dev); 717 device_release_driver(trans(drv)->dev);
696} 718}
697 719
698int iwl_drv_start(struct iwl_shared *shrd, 720int iwl_drv_start(struct iwl_shared *shrd,
699 struct iwl_trans *trans, const struct iwl_cfg *cfg) 721 struct iwl_trans *trans, const struct iwl_cfg *cfg)
700{ 722{
701 struct iwl_nic *nic; 723 struct iwl_drv *drv;
702 int ret; 724 int ret;
703 725
704 shrd->cfg = cfg; 726 shrd->cfg = cfg;
705 727
706 nic = kzalloc(sizeof(*nic), GFP_KERNEL); 728 drv = kzalloc(sizeof(*drv), GFP_KERNEL);
707 if (!nic) { 729 if (!drv) {
708 dev_printk(KERN_ERR, trans->dev, "Couldn't allocate iwl_nic"); 730 dev_printk(KERN_ERR, trans->dev, "Couldn't allocate iwl_drv");
709 return -ENOMEM; 731 return -ENOMEM;
710 } 732 }
711 nic->shrd = shrd; 733 drv->shrd = shrd;
712 shrd->nic = nic; 734 shrd->drv = drv;
713 735
714 init_completion(&nic->request_firmware_complete); 736 init_completion(&drv->request_firmware_complete);
715 737
716 ret = iwl_request_firmware(nic, true); 738 ret = iwl_request_firmware(drv, true);
717 739
718 if (ret) { 740 if (ret) {
719 dev_printk(KERN_ERR, trans->dev, "Couldn't request the fw"); 741 dev_printk(KERN_ERR, trans->dev, "Couldn't request the fw");
720 kfree(nic); 742 kfree(drv);
721 shrd->nic = NULL; 743 shrd->drv = NULL;
722 } 744 }
723 745
724 return ret; 746 return ret;
@@ -726,16 +748,16 @@ int iwl_drv_start(struct iwl_shared *shrd,
726 748
727void iwl_drv_stop(struct iwl_shared *shrd) 749void iwl_drv_stop(struct iwl_shared *shrd)
728{ 750{
729 struct iwl_nic *nic = shrd->nic; 751 struct iwl_drv *drv = shrd->drv;
730 752
731 wait_for_completion(&nic->request_firmware_complete); 753 wait_for_completion(&drv->request_firmware_complete);
732 754
733 /* op_mode can be NULL if its start failed */ 755 /* op_mode can be NULL if its start failed */
734 if (nic->op_mode) 756 if (drv->op_mode)
735 iwl_op_mode_stop(nic->op_mode); 757 iwl_op_mode_stop(drv->op_mode);
736 758
737 iwl_dealloc_ucode(nic); 759 iwl_dealloc_ucode(drv);
738 760
739 kfree(nic); 761 kfree(drv);
740 shrd->nic = NULL; 762 shrd->drv = NULL;
741} 763}