aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJohannes Berg <johannes.berg@intel.com>2012-03-06 16:30:36 -0500
committerJohn W. Linville <linville@tuxdriver.com>2012-03-07 13:51:47 -0500
commite19918855dc4822a24787a6d0048205b011e5ecb (patch)
treec4c73413748f42dfb3fe6d451f1d12166b7965d7
parent3d4f96997263d97cd4d60373f1ed8184ee6df31b (diff)
iwlwifi: move ucode loading to op_mode
uCode loading belongs to the op_mode, as it is dependent on various things there and the commands sent during it are specific to it. Move the prototypes to iwl-agn.h to indicate this. To make this possible, also move all the calibration handling (which is op_mode dependent after all). 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>
-rw-r--r--drivers/net/wireless/iwlwifi/iwl-agn-calib.c26
-rw-r--r--drivers/net/wireless/iwlwifi/iwl-agn-lib.c2
-rw-r--r--drivers/net/wireless/iwlwifi/iwl-agn-rx.c2
-rw-r--r--drivers/net/wireless/iwlwifi/iwl-agn.c9
-rw-r--r--drivers/net/wireless/iwlwifi/iwl-agn.h10
-rw-r--r--drivers/net/wireless/iwlwifi/iwl-dev.h2
-rw-r--r--drivers/net/wireless/iwlwifi/iwl-mac80211.c4
-rw-r--r--drivers/net/wireless/iwlwifi/iwl-shared.h14
-rw-r--r--drivers/net/wireless/iwlwifi/iwl-testmode.c8
-rw-r--r--drivers/net/wireless/iwlwifi/iwl-trans-pcie.c1
-rw-r--r--drivers/net/wireless/iwlwifi/iwl-trans.h19
-rw-r--r--drivers/net/wireless/iwlwifi/iwl-ucode.c205
-rw-r--r--drivers/net/wireless/iwlwifi/iwl-wifi.h8
13 files changed, 150 insertions, 160 deletions
diff --git a/drivers/net/wireless/iwlwifi/iwl-agn-calib.c b/drivers/net/wireless/iwlwifi/iwl-agn-calib.c
index 84fc5ce91b35..29f94597b55f 100644
--- a/drivers/net/wireless/iwlwifi/iwl-agn-calib.c
+++ b/drivers/net/wireless/iwlwifi/iwl-agn-calib.c
@@ -75,6 +75,14 @@
75 * INIT calibrations framework 75 * INIT calibrations framework
76 *****************************************************************************/ 76 *****************************************************************************/
77 77
78/* Opaque calibration results */
79struct iwl_calib_result {
80 struct list_head list;
81 size_t cmd_len;
82 struct iwl_calib_hdr hdr;
83 /* data follows */
84};
85
78struct statistics_general_data { 86struct statistics_general_data {
79 u32 beacon_silence_rssi_a; 87 u32 beacon_silence_rssi_a;
80 u32 beacon_silence_rssi_b; 88 u32 beacon_silence_rssi_b;
@@ -84,7 +92,7 @@ struct statistics_general_data {
84 u32 beacon_energy_c; 92 u32 beacon_energy_c;
85}; 93};
86 94
87int iwl_send_calib_results(struct iwl_trans *trans) 95int iwl_send_calib_results(struct iwl_priv *priv)
88{ 96{
89 struct iwl_host_cmd hcmd = { 97 struct iwl_host_cmd hcmd = {
90 .id = REPLY_PHY_CALIBRATION_CMD, 98 .id = REPLY_PHY_CALIBRATION_CMD,
@@ -92,15 +100,15 @@ int iwl_send_calib_results(struct iwl_trans *trans)
92 }; 100 };
93 struct iwl_calib_result *res; 101 struct iwl_calib_result *res;
94 102
95 list_for_each_entry(res, &trans->calib_results, list) { 103 list_for_each_entry(res, &priv->calib_results, list) {
96 int ret; 104 int ret;
97 105
98 hcmd.len[0] = res->cmd_len; 106 hcmd.len[0] = res->cmd_len;
99 hcmd.data[0] = &res->hdr; 107 hcmd.data[0] = &res->hdr;
100 hcmd.dataflags[0] = IWL_HCMD_DFL_NOCOPY; 108 hcmd.dataflags[0] = IWL_HCMD_DFL_NOCOPY;
101 ret = iwl_trans_send_cmd(trans, &hcmd); 109 ret = iwl_trans_send_cmd(trans(priv), &hcmd);
102 if (ret) { 110 if (ret) {
103 IWL_ERR(trans, "Error %d on calib cmd %d\n", 111 IWL_ERR(priv, "Error %d on calib cmd %d\n",
104 ret, res->hdr.op_code); 112 ret, res->hdr.op_code);
105 return ret; 113 return ret;
106 } 114 }
@@ -109,7 +117,7 @@ int iwl_send_calib_results(struct iwl_trans *trans)
109 return 0; 117 return 0;
110} 118}
111 119
112int iwl_calib_set(struct iwl_trans *trans, 120int iwl_calib_set(struct iwl_priv *priv,
113 const struct iwl_calib_hdr *cmd, int len) 121 const struct iwl_calib_hdr *cmd, int len)
114{ 122{
115 struct iwl_calib_result *res, *tmp; 123 struct iwl_calib_result *res, *tmp;
@@ -121,7 +129,7 @@ int iwl_calib_set(struct iwl_trans *trans,
121 memcpy(&res->hdr, cmd, len); 129 memcpy(&res->hdr, cmd, len);
122 res->cmd_len = len; 130 res->cmd_len = len;
123 131
124 list_for_each_entry(tmp, &trans->calib_results, list) { 132 list_for_each_entry(tmp, &priv->calib_results, list) {
125 if (tmp->hdr.op_code == res->hdr.op_code) { 133 if (tmp->hdr.op_code == res->hdr.op_code) {
126 list_replace(&tmp->list, &res->list); 134 list_replace(&tmp->list, &res->list);
127 kfree(tmp); 135 kfree(tmp);
@@ -130,16 +138,16 @@ int iwl_calib_set(struct iwl_trans *trans,
130 } 138 }
131 139
132 /* wasn't in list already */ 140 /* wasn't in list already */
133 list_add_tail(&res->list, &trans->calib_results); 141 list_add_tail(&res->list, &priv->calib_results);
134 142
135 return 0; 143 return 0;
136} 144}
137 145
138void iwl_calib_free_results(struct iwl_trans *trans) 146void iwl_calib_free_results(struct iwl_priv *priv)
139{ 147{
140 struct iwl_calib_result *res, *tmp; 148 struct iwl_calib_result *res, *tmp;
141 149
142 list_for_each_entry_safe(res, tmp, &trans->calib_results, list) { 150 list_for_each_entry_safe(res, tmp, &priv->calib_results, list) {
143 list_del(&res->list); 151 list_del(&res->list);
144 kfree(res); 152 kfree(res);
145 } 153 }
diff --git a/drivers/net/wireless/iwlwifi/iwl-agn-lib.c b/drivers/net/wireless/iwlwifi/iwl-agn-lib.c
index e96af5133e06..45b060a45d9d 100644
--- a/drivers/net/wireless/iwlwifi/iwl-agn-lib.c
+++ b/drivers/net/wireless/iwlwifi/iwl-agn-lib.c
@@ -1195,7 +1195,7 @@ int iwlagn_suspend(struct iwl_priv *priv,
1195 1195
1196 priv->wowlan = true; 1196 priv->wowlan = true;
1197 1197
1198 ret = iwl_load_ucode_wait_alive(trans(priv), IWL_UCODE_WOWLAN); 1198 ret = iwl_load_ucode_wait_alive(priv, IWL_UCODE_WOWLAN);
1199 if (ret) 1199 if (ret)
1200 goto out; 1200 goto out;
1201 1201
diff --git a/drivers/net/wireless/iwlwifi/iwl-agn-rx.c b/drivers/net/wireless/iwlwifi/iwl-agn-rx.c
index 8e025e0df50d..d16e73d1b5c9 100644
--- a/drivers/net/wireless/iwlwifi/iwl-agn-rx.c
+++ b/drivers/net/wireless/iwlwifi/iwl-agn-rx.c
@@ -1177,7 +1177,7 @@ int iwl_rx_dispatch(struct iwl_op_mode *op_mode, struct iwl_rx_cmd_buffer *rxb,
1177 pkt->hdr.cmd); 1177 pkt->hdr.cmd);
1178 w->triggered = true; 1178 w->triggered = true;
1179 if (w->fn) 1179 if (w->fn)
1180 w->fn(trans(priv), pkt, w->fn_data); 1180 w->fn(priv, pkt, w->fn_data);
1181 } 1181 }
1182 spin_unlock(&priv->shrd->notif_wait_lock); 1182 spin_unlock(&priv->shrd->notif_wait_lock);
1183 1183
diff --git a/drivers/net/wireless/iwlwifi/iwl-agn.c b/drivers/net/wireless/iwlwifi/iwl-agn.c
index 8bb3f173bfa0..f53308fb428e 100644
--- a/drivers/net/wireless/iwlwifi/iwl-agn.c
+++ b/drivers/net/wireless/iwlwifi/iwl-agn.c
@@ -671,14 +671,14 @@ int iwl_alive_start(struct iwl_priv *priv)
671 priv->bt_valid = IWLAGN_BT_VALID_ENABLE_FLAGS; 671 priv->bt_valid = IWLAGN_BT_VALID_ENABLE_FLAGS;
672 priv->cur_rssi_ctx = NULL; 672 priv->cur_rssi_ctx = NULL;
673 673
674 iwl_send_prio_tbl(trans(priv)); 674 iwl_send_prio_tbl(priv);
675 675
676 /* FIXME: w/a to force change uCode BT state machine */ 676 /* FIXME: w/a to force change uCode BT state machine */
677 ret = iwl_send_bt_env(trans(priv), IWL_BT_COEX_ENV_OPEN, 677 ret = iwl_send_bt_env(priv, IWL_BT_COEX_ENV_OPEN,
678 BT_COEX_PRIO_TBL_EVT_INIT_CALIB2); 678 BT_COEX_PRIO_TBL_EVT_INIT_CALIB2);
679 if (ret) 679 if (ret)
680 return ret; 680 return ret;
681 ret = iwl_send_bt_env(trans(priv), IWL_BT_COEX_ENV_CLOSE, 681 ret = iwl_send_bt_env(priv, IWL_BT_COEX_ENV_CLOSE,
682 BT_COEX_PRIO_TBL_EVT_INIT_CALIB2); 682 BT_COEX_PRIO_TBL_EVT_INIT_CALIB2);
683 if (ret) 683 if (ret)
684 return ret; 684 return ret;
@@ -1040,7 +1040,7 @@ static int iwl_init_drv(struct iwl_priv *priv)
1040 1040
1041 mutex_init(&priv->shrd->mutex); 1041 mutex_init(&priv->shrd->mutex);
1042 1042
1043 INIT_LIST_HEAD(&trans(priv)->calib_results); 1043 INIT_LIST_HEAD(&priv->calib_results);
1044 1044
1045 priv->ieee_channels = NULL; 1045 priv->ieee_channels = NULL;
1046 priv->ieee_rates = NULL; 1046 priv->ieee_rates = NULL;
@@ -1105,6 +1105,7 @@ static void iwl_uninit_drv(struct iwl_priv *priv)
1105 kfree(priv->scan_cmd); 1105 kfree(priv->scan_cmd);
1106 kfree(priv->beacon_cmd); 1106 kfree(priv->beacon_cmd);
1107 kfree(rcu_dereference_raw(priv->noa_data)); 1107 kfree(rcu_dereference_raw(priv->noa_data));
1108 iwl_calib_free_results(priv);
1108#ifdef CONFIG_IWLWIFI_DEBUGFS 1109#ifdef CONFIG_IWLWIFI_DEBUGFS
1109 kfree(priv->wowlan_sram); 1110 kfree(priv->wowlan_sram);
1110#endif 1111#endif
diff --git a/drivers/net/wireless/iwlwifi/iwl-agn.h b/drivers/net/wireless/iwlwifi/iwl-agn.h
index 70100f9a2e5c..2a90d779eecf 100644
--- a/drivers/net/wireless/iwlwifi/iwl-agn.h
+++ b/drivers/net/wireless/iwlwifi/iwl-agn.h
@@ -113,6 +113,16 @@ int iwlagn_rx_calib_result(struct iwl_priv *priv,
113 struct iwl_rx_cmd_buffer *rxb, 113 struct iwl_rx_cmd_buffer *rxb,
114 struct iwl_device_cmd *cmd); 114 struct iwl_device_cmd *cmd);
115void iwl_init_context(struct iwl_priv *priv, u32 ucode_flags); 115void iwl_init_context(struct iwl_priv *priv, u32 ucode_flags);
116int iwl_send_bt_env(struct iwl_priv *priv, u8 action, u8 type);
117void iwl_send_prio_tbl(struct iwl_priv *priv);
118int iwl_init_alive_start(struct iwl_priv *priv);
119int iwl_run_init_ucode(struct iwl_priv *priv);
120int iwl_load_ucode_wait_alive(struct iwl_priv *priv,
121 enum iwl_ucode_type ucode_type);
122int iwl_send_calib_results(struct iwl_priv *priv);
123int iwl_calib_set(struct iwl_priv *priv,
124 const struct iwl_calib_hdr *cmd, int len);
125void iwl_calib_free_results(struct iwl_priv *priv);
116 126
117/* lib */ 127/* lib */
118int iwlagn_send_tx_power(struct iwl_priv *priv); 128int iwlagn_send_tx_power(struct iwl_priv *priv);
diff --git a/drivers/net/wireless/iwlwifi/iwl-dev.h b/drivers/net/wireless/iwlwifi/iwl-dev.h
index 5957209b2f37..7199748faaab 100644
--- a/drivers/net/wireless/iwlwifi/iwl-dev.h
+++ b/drivers/net/wireless/iwlwifi/iwl-dev.h
@@ -724,6 +724,8 @@ struct iwl_priv {
724 struct ieee80211_rate *ieee_rates; 724 struct ieee80211_rate *ieee_rates;
725 struct kmem_cache *tx_cmd_pool; 725 struct kmem_cache *tx_cmd_pool;
726 726
727 struct list_head calib_results;
728
727 struct workqueue_struct *workqueue; 729 struct workqueue_struct *workqueue;
728 730
729 enum ieee80211_band band; 731 enum ieee80211_band band;
diff --git a/drivers/net/wireless/iwlwifi/iwl-mac80211.c b/drivers/net/wireless/iwlwifi/iwl-mac80211.c
index 7f937151a8af..37330addce79 100644
--- a/drivers/net/wireless/iwlwifi/iwl-mac80211.c
+++ b/drivers/net/wireless/iwlwifi/iwl-mac80211.c
@@ -278,13 +278,13 @@ static int __iwl_up(struct iwl_priv *priv)
278 } 278 }
279 } 279 }
280 280
281 ret = iwl_run_init_ucode(trans(priv)); 281 ret = iwl_run_init_ucode(priv);
282 if (ret) { 282 if (ret) {
283 IWL_ERR(priv, "Failed to run INIT ucode: %d\n", ret); 283 IWL_ERR(priv, "Failed to run INIT ucode: %d\n", ret);
284 goto error; 284 goto error;
285 } 285 }
286 286
287 ret = iwl_load_ucode_wait_alive(trans(priv), IWL_UCODE_REGULAR); 287 ret = iwl_load_ucode_wait_alive(priv, IWL_UCODE_REGULAR);
288 if (ret) { 288 if (ret) {
289 IWL_ERR(priv, "Failed to start RT ucode: %d\n", ret); 289 IWL_ERR(priv, "Failed to start RT ucode: %d\n", ret);
290 goto error; 290 goto error;
diff --git a/drivers/net/wireless/iwlwifi/iwl-shared.h b/drivers/net/wireless/iwlwifi/iwl-shared.h
index ef80e0386c30..dc5544653bc0 100644
--- a/drivers/net/wireless/iwlwifi/iwl-shared.h
+++ b/drivers/net/wireless/iwlwifi/iwl-shared.h
@@ -233,7 +233,7 @@ enum iwl_ucode_type {
233struct iwl_notification_wait { 233struct iwl_notification_wait {
234 struct list_head list; 234 struct list_head list;
235 235
236 void (*fn)(struct iwl_trans *trans, struct iwl_rx_packet *pkt, 236 void (*fn)(struct iwl_priv *priv, struct iwl_rx_packet *pkt,
237 void *data); 237 void *data);
238 void *fn_data; 238 void *fn_data;
239 239
@@ -472,12 +472,12 @@ bool iwl_check_for_ct_kill(struct iwl_priv *priv);
472void iwl_abort_notification_waits(struct iwl_shared *shrd); 472void iwl_abort_notification_waits(struct iwl_shared *shrd);
473void __acquires(wait_entry) 473void __acquires(wait_entry)
474iwl_init_notification_wait(struct iwl_shared *shrd, 474iwl_init_notification_wait(struct iwl_shared *shrd,
475 struct iwl_notification_wait *wait_entry, 475 struct iwl_notification_wait *wait_entry,
476 u8 cmd, 476 u8 cmd,
477 void (*fn)(struct iwl_trans *trans, 477 void (*fn)(struct iwl_priv *priv,
478 struct iwl_rx_packet *pkt, 478 struct iwl_rx_packet *pkt,
479 void *data), 479 void *data),
480 void *fn_data); 480 void *fn_data);
481int __must_check __releases(wait_entry) 481int __must_check __releases(wait_entry)
482iwl_wait_notification(struct iwl_shared *shrd, 482iwl_wait_notification(struct iwl_shared *shrd,
483 struct iwl_notification_wait *wait_entry, 483 struct iwl_notification_wait *wait_entry,
diff --git a/drivers/net/wireless/iwlwifi/iwl-testmode.c b/drivers/net/wireless/iwlwifi/iwl-testmode.c
index b24b166a9482..ec803ea08675 100644
--- a/drivers/net/wireless/iwlwifi/iwl-testmode.c
+++ b/drivers/net/wireless/iwlwifi/iwl-testmode.c
@@ -422,7 +422,7 @@ static int iwl_testmode_cfg_init_calib(struct iwl_priv *priv)
422 iwl_init_notification_wait(priv->shrd, &calib_wait, 422 iwl_init_notification_wait(priv->shrd, &calib_wait,
423 CALIBRATION_COMPLETE_NOTIFICATION, 423 CALIBRATION_COMPLETE_NOTIFICATION,
424 NULL, NULL); 424 NULL, NULL);
425 ret = iwl_init_alive_start(trans(priv)); 425 ret = iwl_init_alive_start(priv);
426 if (ret) { 426 if (ret) {
427 IWL_ERR(priv, "Fail init calibration: %d\n", ret); 427 IWL_ERR(priv, "Fail init calibration: %d\n", ret);
428 goto cfg_init_calib_error; 428 goto cfg_init_calib_error;
@@ -484,7 +484,7 @@ static int iwl_testmode_driver(struct ieee80211_hw *hw, struct nlattr **tb)
484 break; 484 break;
485 485
486 case IWL_TM_CMD_APP2DEV_LOAD_INIT_FW: 486 case IWL_TM_CMD_APP2DEV_LOAD_INIT_FW:
487 status = iwl_load_ucode_wait_alive(trans, IWL_UCODE_INIT); 487 status = iwl_load_ucode_wait_alive(priv, IWL_UCODE_INIT);
488 if (status) 488 if (status)
489 IWL_ERR(priv, "Error loading init ucode: %d\n", status); 489 IWL_ERR(priv, "Error loading init ucode: %d\n", status);
490 break; 490 break;
@@ -495,7 +495,7 @@ static int iwl_testmode_driver(struct ieee80211_hw *hw, struct nlattr **tb)
495 break; 495 break;
496 496
497 case IWL_TM_CMD_APP2DEV_LOAD_RUNTIME_FW: 497 case IWL_TM_CMD_APP2DEV_LOAD_RUNTIME_FW:
498 status = iwl_load_ucode_wait_alive(trans, IWL_UCODE_REGULAR); 498 status = iwl_load_ucode_wait_alive(priv, IWL_UCODE_REGULAR);
499 if (status) { 499 if (status) {
500 IWL_ERR(priv, 500 IWL_ERR(priv,
501 "Error loading runtime ucode: %d\n", status); 501 "Error loading runtime ucode: %d\n", status);
@@ -510,7 +510,7 @@ static int iwl_testmode_driver(struct ieee80211_hw *hw, struct nlattr **tb)
510 case IWL_TM_CMD_APP2DEV_LOAD_WOWLAN_FW: 510 case IWL_TM_CMD_APP2DEV_LOAD_WOWLAN_FW:
511 iwl_scan_cancel_timeout(priv, 200); 511 iwl_scan_cancel_timeout(priv, 200);
512 iwl_trans_stop_device(trans); 512 iwl_trans_stop_device(trans);
513 status = iwl_load_ucode_wait_alive(trans, IWL_UCODE_WOWLAN); 513 status = iwl_load_ucode_wait_alive(priv, IWL_UCODE_WOWLAN);
514 if (status) { 514 if (status) {
515 IWL_ERR(priv, 515 IWL_ERR(priv,
516 "Error loading WOWLAN ucode: %d\n", status); 516 "Error loading WOWLAN ucode: %d\n", status);
diff --git a/drivers/net/wireless/iwlwifi/iwl-trans-pcie.c b/drivers/net/wireless/iwlwifi/iwl-trans-pcie.c
index 3ae2fd720ed8..f49aa181f4af 100644
--- a/drivers/net/wireless/iwlwifi/iwl-trans-pcie.c
+++ b/drivers/net/wireless/iwlwifi/iwl-trans-pcie.c
@@ -1632,7 +1632,6 @@ static void iwl_trans_pcie_free(struct iwl_trans *trans)
1632 struct iwl_trans_pcie *trans_pcie = 1632 struct iwl_trans_pcie *trans_pcie =
1633 IWL_TRANS_GET_PCIE_TRANS(trans); 1633 IWL_TRANS_GET_PCIE_TRANS(trans);
1634 1634
1635 iwl_calib_free_results(trans);
1636 iwl_trans_pcie_tx_free(trans); 1635 iwl_trans_pcie_tx_free(trans);
1637#ifndef CONFIG_IWLWIFI_IDI 1636#ifndef CONFIG_IWLWIFI_IDI
1638 iwl_trans_pcie_rx_free(trans); 1637 iwl_trans_pcie_rx_free(trans);
diff --git a/drivers/net/wireless/iwlwifi/iwl-trans.h b/drivers/net/wireless/iwlwifi/iwl-trans.h
index b09192a028de..6fa0c860a5e2 100644
--- a/drivers/net/wireless/iwlwifi/iwl-trans.h
+++ b/drivers/net/wireless/iwlwifi/iwl-trans.h
@@ -315,14 +315,6 @@ struct iwl_trans_ops {
315 u32 (*read32)(struct iwl_trans *trans, u32 ofs); 315 u32 (*read32)(struct iwl_trans *trans, u32 ofs);
316}; 316};
317 317
318/* Opaque calibration results */
319struct iwl_calib_result {
320 struct list_head list;
321 size_t cmd_len;
322 struct iwl_calib_hdr hdr;
323 /* data follows */
324};
325
326/** 318/**
327 * enum iwl_trans_state - state of the transport layer 319 * enum iwl_trans_state - state of the transport layer
328 * 320 *
@@ -349,7 +341,6 @@ enum iwl_trans_state {
349 * @ucode_write_complete: indicates that the ucode has been copied. 341 * @ucode_write_complete: indicates that the ucode has been copied.
350 * @nvm_device_type: indicates OTP or eeprom 342 * @nvm_device_type: indicates OTP or eeprom
351 * @pm_support: set to true in start_hw if link pm is supported 343 * @pm_support: set to true in start_hw if link pm is supported
352 * @calib_results: list head for init calibration results
353 */ 344 */
354struct iwl_trans { 345struct iwl_trans {
355 const struct iwl_trans_ops *ops; 346 const struct iwl_trans_ops *ops;
@@ -369,8 +360,6 @@ struct iwl_trans {
369 int nvm_device_type; 360 int nvm_device_type;
370 bool pm_support; 361 bool pm_support;
371 362
372 struct list_head calib_results;
373
374 /* pointer to trans specific struct */ 363 /* pointer to trans specific struct */
375 /*Ensure that this pointer will always be aligned to sizeof pointer */ 364 /*Ensure that this pointer will always be aligned to sizeof pointer */
376 char trans_specific[0] __aligned(sizeof(void *)); 365 char trans_specific[0] __aligned(sizeof(void *));
@@ -574,14 +563,6 @@ static inline u32 iwl_trans_read32(struct iwl_trans *trans, u32 ofs)
574} 563}
575 564
576/***************************************************** 565/*****************************************************
577* Utils functions
578******************************************************/
579int iwl_send_calib_results(struct iwl_trans *trans);
580int iwl_calib_set(struct iwl_trans *trans,
581 const struct iwl_calib_hdr *cmd, int len);
582void iwl_calib_free_results(struct iwl_trans *trans);
583
584/*****************************************************
585* Transport layers implementations + their allocation function 566* Transport layers implementations + their allocation function
586******************************************************/ 567******************************************************/
587struct pci_dev; 568struct pci_dev;
diff --git a/drivers/net/wireless/iwlwifi/iwl-ucode.c b/drivers/net/wireless/iwlwifi/iwl-ucode.c
index 64a9c5ce5f89..340575a01ead 100644
--- a/drivers/net/wireless/iwlwifi/iwl-ucode.c
+++ b/drivers/net/wireless/iwlwifi/iwl-ucode.c
@@ -80,16 +80,16 @@ static struct iwl_wimax_coex_event_entry cu_priorities[COEX_NUM_OF_EVENTS] = {
80 * 80 *
81 ******************************************************************************/ 81 ******************************************************************************/
82 82
83static inline struct fw_img *iwl_get_ucode_image(struct iwl_nic *nic, 83static inline struct fw_img *iwl_get_ucode_image(struct iwl_priv *priv,
84 enum iwl_ucode_type ucode_type) 84 enum iwl_ucode_type ucode_type)
85{ 85{
86 switch (ucode_type) { 86 switch (ucode_type) {
87 case IWL_UCODE_INIT: 87 case IWL_UCODE_INIT:
88 return &nic->fw.ucode_init; 88 return &nic(priv)->fw.ucode_init;
89 case IWL_UCODE_WOWLAN: 89 case IWL_UCODE_WOWLAN:
90 return &nic->fw.ucode_wowlan; 90 return &nic(priv)->fw.ucode_wowlan;
91 case IWL_UCODE_REGULAR: 91 case IWL_UCODE_REGULAR:
92 return &nic->fw.ucode_rt; 92 return &nic(priv)->fw.ucode_rt;
93 case IWL_UCODE_NONE: 93 case IWL_UCODE_NONE:
94 break; 94 break;
95 } 95 }
@@ -99,23 +99,23 @@ static inline struct fw_img *iwl_get_ucode_image(struct iwl_nic *nic,
99/* 99/*
100 * Calibration 100 * Calibration
101 */ 101 */
102static int iwl_set_Xtal_calib(struct iwl_trans *trans) 102static int iwl_set_Xtal_calib(struct iwl_priv *priv)
103{ 103{
104 struct iwl_calib_xtal_freq_cmd cmd; 104 struct iwl_calib_xtal_freq_cmd cmd;
105 __le16 *xtal_calib = 105 __le16 *xtal_calib =
106 (__le16 *)iwl_eeprom_query_addr(trans->shrd, EEPROM_XTAL); 106 (__le16 *)iwl_eeprom_query_addr(priv->shrd, EEPROM_XTAL);
107 107
108 iwl_set_calib_hdr(&cmd.hdr, IWL_PHY_CALIBRATE_CRYSTAL_FRQ_CMD); 108 iwl_set_calib_hdr(&cmd.hdr, IWL_PHY_CALIBRATE_CRYSTAL_FRQ_CMD);
109 cmd.cap_pin1 = le16_to_cpu(xtal_calib[0]); 109 cmd.cap_pin1 = le16_to_cpu(xtal_calib[0]);
110 cmd.cap_pin2 = le16_to_cpu(xtal_calib[1]); 110 cmd.cap_pin2 = le16_to_cpu(xtal_calib[1]);
111 return iwl_calib_set(trans, (void *)&cmd, sizeof(cmd)); 111 return iwl_calib_set(priv, (void *)&cmd, sizeof(cmd));
112} 112}
113 113
114static int iwl_set_temperature_offset_calib(struct iwl_trans *trans) 114static int iwl_set_temperature_offset_calib(struct iwl_priv *priv)
115{ 115{
116 struct iwl_calib_temperature_offset_cmd cmd; 116 struct iwl_calib_temperature_offset_cmd cmd;
117 __le16 *offset_calib = 117 __le16 *offset_calib =
118 (__le16 *)iwl_eeprom_query_addr(trans->shrd, 118 (__le16 *)iwl_eeprom_query_addr(priv->shrd,
119 EEPROM_RAW_TEMPERATURE); 119 EEPROM_RAW_TEMPERATURE);
120 120
121 memset(&cmd, 0, sizeof(cmd)); 121 memset(&cmd, 0, sizeof(cmd));
@@ -124,48 +124,48 @@ static int iwl_set_temperature_offset_calib(struct iwl_trans *trans)
124 if (!(cmd.radio_sensor_offset)) 124 if (!(cmd.radio_sensor_offset))
125 cmd.radio_sensor_offset = DEFAULT_RADIO_SENSOR_OFFSET; 125 cmd.radio_sensor_offset = DEFAULT_RADIO_SENSOR_OFFSET;
126 126
127 IWL_DEBUG_CALIB(trans, "Radio sensor offset: %d\n", 127 IWL_DEBUG_CALIB(priv, "Radio sensor offset: %d\n",
128 le16_to_cpu(cmd.radio_sensor_offset)); 128 le16_to_cpu(cmd.radio_sensor_offset));
129 return iwl_calib_set(trans, (void *)&cmd, sizeof(cmd)); 129 return iwl_calib_set(priv, (void *)&cmd, sizeof(cmd));
130} 130}
131 131
132static int iwl_set_temperature_offset_calib_v2(struct iwl_trans *trans) 132static int iwl_set_temperature_offset_calib_v2(struct iwl_priv *priv)
133{ 133{
134 struct iwl_calib_temperature_offset_v2_cmd cmd; 134 struct iwl_calib_temperature_offset_v2_cmd cmd;
135 __le16 *offset_calib_high = (__le16 *)iwl_eeprom_query_addr(trans->shrd, 135 __le16 *offset_calib_high = (__le16 *)iwl_eeprom_query_addr(priv->shrd,
136 EEPROM_KELVIN_TEMPERATURE); 136 EEPROM_KELVIN_TEMPERATURE);
137 __le16 *offset_calib_low = 137 __le16 *offset_calib_low =
138 (__le16 *)iwl_eeprom_query_addr(trans->shrd, 138 (__le16 *)iwl_eeprom_query_addr(priv->shrd,
139 EEPROM_RAW_TEMPERATURE); 139 EEPROM_RAW_TEMPERATURE);
140 struct iwl_eeprom_calib_hdr *hdr; 140 struct iwl_eeprom_calib_hdr *hdr;
141 141
142 memset(&cmd, 0, sizeof(cmd)); 142 memset(&cmd, 0, sizeof(cmd));
143 iwl_set_calib_hdr(&cmd.hdr, IWL_PHY_CALIBRATE_TEMP_OFFSET_CMD); 143 iwl_set_calib_hdr(&cmd.hdr, IWL_PHY_CALIBRATE_TEMP_OFFSET_CMD);
144 hdr = (struct iwl_eeprom_calib_hdr *)iwl_eeprom_query_addr(trans->shrd, 144 hdr = (struct iwl_eeprom_calib_hdr *)iwl_eeprom_query_addr(priv->shrd,
145 EEPROM_CALIB_ALL); 145 EEPROM_CALIB_ALL);
146 memcpy(&cmd.radio_sensor_offset_high, offset_calib_high, 146 memcpy(&cmd.radio_sensor_offset_high, offset_calib_high,
147 sizeof(*offset_calib_high)); 147 sizeof(*offset_calib_high));
148 memcpy(&cmd.radio_sensor_offset_low, offset_calib_low, 148 memcpy(&cmd.radio_sensor_offset_low, offset_calib_low,
149 sizeof(*offset_calib_low)); 149 sizeof(*offset_calib_low));
150 if (!(cmd.radio_sensor_offset_low)) { 150 if (!(cmd.radio_sensor_offset_low)) {
151 IWL_DEBUG_CALIB(trans, "no info in EEPROM, use default\n"); 151 IWL_DEBUG_CALIB(priv, "no info in EEPROM, use default\n");
152 cmd.radio_sensor_offset_low = DEFAULT_RADIO_SENSOR_OFFSET; 152 cmd.radio_sensor_offset_low = DEFAULT_RADIO_SENSOR_OFFSET;
153 cmd.radio_sensor_offset_high = DEFAULT_RADIO_SENSOR_OFFSET; 153 cmd.radio_sensor_offset_high = DEFAULT_RADIO_SENSOR_OFFSET;
154 } 154 }
155 memcpy(&cmd.burntVoltageRef, &hdr->voltage, 155 memcpy(&cmd.burntVoltageRef, &hdr->voltage,
156 sizeof(hdr->voltage)); 156 sizeof(hdr->voltage));
157 157
158 IWL_DEBUG_CALIB(trans, "Radio sensor offset high: %d\n", 158 IWL_DEBUG_CALIB(priv, "Radio sensor offset high: %d\n",
159 le16_to_cpu(cmd.radio_sensor_offset_high)); 159 le16_to_cpu(cmd.radio_sensor_offset_high));
160 IWL_DEBUG_CALIB(trans, "Radio sensor offset low: %d\n", 160 IWL_DEBUG_CALIB(priv, "Radio sensor offset low: %d\n",
161 le16_to_cpu(cmd.radio_sensor_offset_low)); 161 le16_to_cpu(cmd.radio_sensor_offset_low));
162 IWL_DEBUG_CALIB(trans, "Voltage Ref: %d\n", 162 IWL_DEBUG_CALIB(priv, "Voltage Ref: %d\n",
163 le16_to_cpu(cmd.burntVoltageRef)); 163 le16_to_cpu(cmd.burntVoltageRef));
164 164
165 return iwl_calib_set(trans, (void *)&cmd, sizeof(cmd)); 165 return iwl_calib_set(priv, (void *)&cmd, sizeof(cmd));
166} 166}
167 167
168static int iwl_send_calib_cfg(struct iwl_trans *trans) 168static int iwl_send_calib_cfg(struct iwl_priv *priv)
169{ 169{
170 struct iwl_calib_cfg_cmd calib_cfg_cmd; 170 struct iwl_calib_cfg_cmd calib_cfg_cmd;
171 struct iwl_host_cmd cmd = { 171 struct iwl_host_cmd cmd = {
@@ -181,7 +181,7 @@ static int iwl_send_calib_cfg(struct iwl_trans *trans)
181 calib_cfg_cmd.ucd_calib_cfg.flags = 181 calib_cfg_cmd.ucd_calib_cfg.flags =
182 IWL_CALIB_CFG_FLAG_SEND_COMPLETE_NTFY_MSK; 182 IWL_CALIB_CFG_FLAG_SEND_COMPLETE_NTFY_MSK;
183 183
184 return iwl_trans_send_cmd(trans, &cmd); 184 return iwl_trans_send_cmd(trans(priv), &cmd);
185} 185}
186 186
187int iwlagn_rx_calib_result(struct iwl_priv *priv, 187int iwlagn_rx_calib_result(struct iwl_priv *priv,
@@ -195,33 +195,33 @@ int iwlagn_rx_calib_result(struct iwl_priv *priv,
195 /* reduce the size of the length field itself */ 195 /* reduce the size of the length field itself */
196 len -= 4; 196 len -= 4;
197 197
198 if (iwl_calib_set(trans(priv), hdr, len)) 198 if (iwl_calib_set(priv, hdr, len))
199 IWL_ERR(priv, "Failed to record calibration data %d\n", 199 IWL_ERR(priv, "Failed to record calibration data %d\n",
200 hdr->op_code); 200 hdr->op_code);
201 201
202 return 0; 202 return 0;
203} 203}
204 204
205int iwl_init_alive_start(struct iwl_trans *trans) 205int iwl_init_alive_start(struct iwl_priv *priv)
206{ 206{
207 int ret; 207 int ret;
208 208
209 if (cfg(trans)->bt_params && 209 if (cfg(priv)->bt_params &&
210 cfg(trans)->bt_params->advanced_bt_coexist) { 210 cfg(priv)->bt_params->advanced_bt_coexist) {
211 /* 211 /*
212 * Tell uCode we are ready to perform calibration 212 * Tell uCode we are ready to perform calibration
213 * need to perform this before any calibration 213 * need to perform this before any calibration
214 * no need to close the envlope since we are going 214 * no need to close the envlope since we are going
215 * to load the runtime uCode later. 215 * to load the runtime uCode later.
216 */ 216 */
217 ret = iwl_send_bt_env(trans, IWL_BT_COEX_ENV_OPEN, 217 ret = iwl_send_bt_env(priv, IWL_BT_COEX_ENV_OPEN,
218 BT_COEX_PRIO_TBL_EVT_INIT_CALIB2); 218 BT_COEX_PRIO_TBL_EVT_INIT_CALIB2);
219 if (ret) 219 if (ret)
220 return ret; 220 return ret;
221 221
222 } 222 }
223 223
224 ret = iwl_send_calib_cfg(trans); 224 ret = iwl_send_calib_cfg(priv);
225 if (ret) 225 if (ret)
226 return ret; 226 return ret;
227 227
@@ -229,21 +229,21 @@ int iwl_init_alive_start(struct iwl_trans *trans)
229 * temperature offset calibration is only needed for runtime ucode, 229 * temperature offset calibration is only needed for runtime ucode,
230 * so prepare the value now. 230 * so prepare the value now.
231 */ 231 */
232 if (cfg(trans)->need_temp_offset_calib) { 232 if (cfg(priv)->need_temp_offset_calib) {
233 if (cfg(trans)->temp_offset_v2) 233 if (cfg(priv)->temp_offset_v2)
234 return iwl_set_temperature_offset_calib_v2(trans); 234 return iwl_set_temperature_offset_calib_v2(priv);
235 else 235 else
236 return iwl_set_temperature_offset_calib(trans); 236 return iwl_set_temperature_offset_calib(priv);
237 } 237 }
238 238
239 return 0; 239 return 0;
240} 240}
241 241
242static int iwl_send_wimax_coex(struct iwl_trans *trans) 242static int iwl_send_wimax_coex(struct iwl_priv *priv)
243{ 243{
244 struct iwl_wimax_coex_cmd coex_cmd; 244 struct iwl_wimax_coex_cmd coex_cmd;
245 245
246 if (cfg(trans)->base_params->support_wimax_coexist) { 246 if (cfg(priv)->base_params->support_wimax_coexist) {
247 /* UnMask wake up src at associated sleep */ 247 /* UnMask wake up src at associated sleep */
248 coex_cmd.flags = COEX_FLAGS_ASSOC_WA_UNMASK_MSK; 248 coex_cmd.flags = COEX_FLAGS_ASSOC_WA_UNMASK_MSK;
249 249
@@ -262,7 +262,7 @@ static int iwl_send_wimax_coex(struct iwl_trans *trans)
262 /* coexistence is disabled */ 262 /* coexistence is disabled */
263 memset(&coex_cmd, 0, sizeof(coex_cmd)); 263 memset(&coex_cmd, 0, sizeof(coex_cmd));
264 } 264 }
265 return iwl_trans_send_cmd_pdu(trans, 265 return iwl_trans_send_cmd_pdu(trans(priv),
266 COEX_PRIORITY_TABLE_CMD, CMD_SYNC, 266 COEX_PRIORITY_TABLE_CMD, CMD_SYNC,
267 sizeof(coex_cmd), &coex_cmd); 267 sizeof(coex_cmd), &coex_cmd);
268} 268}
@@ -289,37 +289,36 @@ static const u8 iwl_bt_prio_tbl[BT_COEX_PRIO_TBL_EVT_MAX] = {
289 0, 0, 0, 0, 0, 0, 0 289 0, 0, 0, 0, 0, 0, 0
290}; 290};
291 291
292void iwl_send_prio_tbl(struct iwl_trans *trans) 292void iwl_send_prio_tbl(struct iwl_priv *priv)
293{ 293{
294 struct iwl_bt_coex_prio_table_cmd prio_tbl_cmd; 294 struct iwl_bt_coex_prio_table_cmd prio_tbl_cmd;
295 295
296 memcpy(prio_tbl_cmd.prio_tbl, iwl_bt_prio_tbl, 296 memcpy(prio_tbl_cmd.prio_tbl, iwl_bt_prio_tbl,
297 sizeof(iwl_bt_prio_tbl)); 297 sizeof(iwl_bt_prio_tbl));
298 if (iwl_trans_send_cmd_pdu(trans, 298 if (iwl_trans_send_cmd_pdu(trans(priv),
299 REPLY_BT_COEX_PRIO_TABLE, CMD_SYNC, 299 REPLY_BT_COEX_PRIO_TABLE, CMD_SYNC,
300 sizeof(prio_tbl_cmd), &prio_tbl_cmd)) 300 sizeof(prio_tbl_cmd), &prio_tbl_cmd))
301 IWL_ERR(trans, "failed to send BT prio tbl command\n"); 301 IWL_ERR(priv, "failed to send BT prio tbl command\n");
302} 302}
303 303
304int iwl_send_bt_env(struct iwl_trans *trans, u8 action, u8 type) 304int iwl_send_bt_env(struct iwl_priv *priv, u8 action, u8 type)
305{ 305{
306 struct iwl_bt_coex_prot_env_cmd env_cmd; 306 struct iwl_bt_coex_prot_env_cmd env_cmd;
307 int ret; 307 int ret;
308 308
309 env_cmd.action = action; 309 env_cmd.action = action;
310 env_cmd.type = type; 310 env_cmd.type = type;
311 ret = iwl_trans_send_cmd_pdu(trans, 311 ret = iwl_trans_send_cmd_pdu(trans(priv),
312 REPLY_BT_COEX_PROT_ENV, CMD_SYNC, 312 REPLY_BT_COEX_PROT_ENV, CMD_SYNC,
313 sizeof(env_cmd), &env_cmd); 313 sizeof(env_cmd), &env_cmd);
314 if (ret) 314 if (ret)
315 IWL_ERR(trans, "failed to send BT env command\n"); 315 IWL_ERR(priv, "failed to send BT env command\n");
316 return ret; 316 return ret;
317} 317}
318 318
319 319
320static int iwl_alive_notify(struct iwl_trans *trans) 320static int iwl_alive_notify(struct iwl_priv *priv)
321{ 321{
322 struct iwl_priv *priv = priv(trans);
323 struct iwl_rxon_context *ctx; 322 struct iwl_rxon_context *ctx;
324 int ret; 323 int ret;
325 324
@@ -332,21 +331,21 @@ static int iwl_alive_notify(struct iwl_trans *trans)
332 if (!priv->tx_cmd_pool) 331 if (!priv->tx_cmd_pool)
333 return -ENOMEM; 332 return -ENOMEM;
334 333
335 iwl_trans_fw_alive(trans); 334 iwl_trans_fw_alive(trans(priv));
336 for_each_context(priv, ctx) 335 for_each_context(priv, ctx)
337 ctx->last_tx_rejected = false; 336 ctx->last_tx_rejected = false;
338 337
339 ret = iwl_send_wimax_coex(trans); 338 ret = iwl_send_wimax_coex(priv);
340 if (ret) 339 if (ret)
341 return ret; 340 return ret;
342 341
343 if (!cfg(priv)->no_xtal_calib) { 342 if (!cfg(priv)->no_xtal_calib) {
344 ret = iwl_set_Xtal_calib(trans); 343 ret = iwl_set_Xtal_calib(priv);
345 if (ret) 344 if (ret)
346 return ret; 345 return ret;
347 } 346 }
348 347
349 return iwl_send_calib_results(trans); 348 return iwl_send_calib_results(priv);
350} 349}
351 350
352 351
@@ -355,24 +354,23 @@ static int iwl_alive_notify(struct iwl_trans *trans)
355 * using sample data 100 bytes apart. If these sample points are good, 354 * using sample data 100 bytes apart. If these sample points are good,
356 * it's a pretty good bet that everything between them is good, too. 355 * it's a pretty good bet that everything between them is good, too.
357 */ 356 */
358static int iwl_verify_inst_sparse(struct iwl_nic *nic, 357static int iwl_verify_inst_sparse(struct iwl_priv *priv,
359 struct fw_desc *fw_desc) 358 struct fw_desc *fw_desc)
360{ 359{
361 struct iwl_trans *trans = trans(nic);
362 __le32 *image = (__le32 *)fw_desc->v_addr; 360 __le32 *image = (__le32 *)fw_desc->v_addr;
363 u32 len = fw_desc->len; 361 u32 len = fw_desc->len;
364 u32 val; 362 u32 val;
365 u32 i; 363 u32 i;
366 364
367 IWL_DEBUG_FW(nic, "ucode inst image size is %u\n", len); 365 IWL_DEBUG_FW(priv, "ucode inst image size is %u\n", len);
368 366
369 for (i = 0; i < len; i += 100, image += 100/sizeof(u32)) { 367 for (i = 0; i < len; i += 100, image += 100/sizeof(u32)) {
370 /* read data comes through single port, auto-incr addr */ 368 /* read data comes through single port, auto-incr addr */
371 /* NOTE: Use the debugless read so we don't flood kernel log 369 /* NOTE: Use the debugless read so we don't flood kernel log
372 * if IWL_DL_IO is set */ 370 * if IWL_DL_IO is set */
373 iwl_write_direct32(trans, HBUS_TARG_MEM_RADDR, 371 iwl_write_direct32(trans(priv), HBUS_TARG_MEM_RADDR,
374 i + IWLAGN_RTC_INST_LOWER_BOUND); 372 i + IWLAGN_RTC_INST_LOWER_BOUND);
375 val = iwl_read32(trans, HBUS_TARG_MEM_RDAT); 373 val = iwl_read32(trans(priv), HBUS_TARG_MEM_RDAT);
376 if (val != le32_to_cpu(*image)) 374 if (val != le32_to_cpu(*image))
377 return -EIO; 375 return -EIO;
378 } 376 }
@@ -380,28 +378,27 @@ static int iwl_verify_inst_sparse(struct iwl_nic *nic,
380 return 0; 378 return 0;
381} 379}
382 380
383static void iwl_print_mismatch_inst(struct iwl_nic *nic, 381static void iwl_print_mismatch_inst(struct iwl_priv *priv,
384 struct fw_desc *fw_desc) 382 struct fw_desc *fw_desc)
385{ 383{
386 struct iwl_trans *trans = trans(nic);
387 __le32 *image = (__le32 *)fw_desc->v_addr; 384 __le32 *image = (__le32 *)fw_desc->v_addr;
388 u32 len = fw_desc->len; 385 u32 len = fw_desc->len;
389 u32 val; 386 u32 val;
390 u32 offs; 387 u32 offs;
391 int errors = 0; 388 int errors = 0;
392 389
393 IWL_DEBUG_FW(nic, "ucode inst image size is %u\n", len); 390 IWL_DEBUG_FW(priv, "ucode inst image size is %u\n", len);
394 391
395 iwl_write_direct32(trans, HBUS_TARG_MEM_RADDR, 392 iwl_write_direct32(trans(priv), HBUS_TARG_MEM_RADDR,
396 IWLAGN_RTC_INST_LOWER_BOUND); 393 IWLAGN_RTC_INST_LOWER_BOUND);
397 394
398 for (offs = 0; 395 for (offs = 0;
399 offs < len && errors < 20; 396 offs < len && errors < 20;
400 offs += sizeof(u32), image++) { 397 offs += sizeof(u32), image++) {
401 /* read data comes through single port, auto-incr addr */ 398 /* read data comes through single port, auto-incr addr */
402 val = iwl_read32(trans, HBUS_TARG_MEM_RDAT); 399 val = iwl_read32(trans(priv), HBUS_TARG_MEM_RDAT);
403 if (val != le32_to_cpu(*image)) { 400 if (val != le32_to_cpu(*image)) {
404 IWL_ERR(nic, "uCode INST section at " 401 IWL_ERR(priv, "uCode INST section at "
405 "offset 0x%x, is 0x%x, s/b 0x%x\n", 402 "offset 0x%x, is 0x%x, s/b 0x%x\n",
406 offs, val, le32_to_cpu(*image)); 403 offs, val, le32_to_cpu(*image));
407 errors++; 404 errors++;
@@ -413,24 +410,24 @@ static void iwl_print_mismatch_inst(struct iwl_nic *nic,
413 * iwl_verify_ucode - determine which instruction image is in SRAM, 410 * iwl_verify_ucode - determine which instruction image is in SRAM,
414 * and verify its contents 411 * and verify its contents
415 */ 412 */
416static int iwl_verify_ucode(struct iwl_nic *nic, 413static int iwl_verify_ucode(struct iwl_priv *priv,
417 enum iwl_ucode_type ucode_type) 414 enum iwl_ucode_type ucode_type)
418{ 415{
419 struct fw_img *img = iwl_get_ucode_image(nic, ucode_type); 416 struct fw_img *img = iwl_get_ucode_image(priv, ucode_type);
420 417
421 if (!img) { 418 if (!img) {
422 IWL_ERR(nic, "Invalid ucode requested (%d)\n", ucode_type); 419 IWL_ERR(priv, "Invalid ucode requested (%d)\n", ucode_type);
423 return -EINVAL; 420 return -EINVAL;
424 } 421 }
425 422
426 if (!iwl_verify_inst_sparse(nic, &img->code)) { 423 if (!iwl_verify_inst_sparse(priv, &img->code)) {
427 IWL_DEBUG_FW(nic, "uCode is good in inst SRAM\n"); 424 IWL_DEBUG_FW(priv, "uCode is good in inst SRAM\n");
428 return 0; 425 return 0;
429 } 426 }
430 427
431 IWL_ERR(nic, "UCODE IMAGE IN INSTRUCTION SRAM NOT VALID!!\n"); 428 IWL_ERR(priv, "UCODE IMAGE IN INSTRUCTION SRAM NOT VALID!!\n");
432 429
433 iwl_print_mismatch_inst(nic, &img->code); 430 iwl_print_mismatch_inst(priv, &img->code);
434 return -EIO; 431 return -EIO;
435} 432}
436 433
@@ -439,7 +436,7 @@ struct iwl_alive_data {
439 u8 subtype; 436 u8 subtype;
440}; 437};
441 438
442static void iwl_alive_fn(struct iwl_trans *trans, 439static void iwl_alive_fn(struct iwl_priv *priv,
443 struct iwl_rx_packet *pkt, 440 struct iwl_rx_packet *pkt,
444 void *data) 441 void *data)
445{ 442{
@@ -448,14 +445,14 @@ static void iwl_alive_fn(struct iwl_trans *trans,
448 445
449 palive = &pkt->u.alive_frame; 446 palive = &pkt->u.alive_frame;
450 447
451 IWL_DEBUG_FW(trans, "Alive ucode status 0x%08X revision " 448 IWL_DEBUG_FW(priv, "Alive ucode status 0x%08X revision "
452 "0x%01X 0x%01X\n", 449 "0x%01X 0x%01X\n",
453 palive->is_valid, palive->ver_type, 450 palive->is_valid, palive->ver_type,
454 palive->ver_subtype); 451 palive->ver_subtype);
455 452
456 trans->shrd->device_pointers.error_event_table = 453 priv->shrd->device_pointers.error_event_table =
457 le32_to_cpu(palive->error_event_table_ptr); 454 le32_to_cpu(palive->error_event_table_ptr);
458 trans->shrd->device_pointers.log_event_table = 455 priv->shrd->device_pointers.log_event_table =
459 le32_to_cpu(palive->log_event_table_ptr); 456 le32_to_cpu(palive->log_event_table_ptr);
460 457
461 alive_data->subtype = palive->ver_subtype; 458 alive_data->subtype = palive->ver_subtype;
@@ -464,12 +461,12 @@ static void iwl_alive_fn(struct iwl_trans *trans,
464 461
465/* notification wait support */ 462/* notification wait support */
466void iwl_init_notification_wait(struct iwl_shared *shrd, 463void iwl_init_notification_wait(struct iwl_shared *shrd,
467 struct iwl_notification_wait *wait_entry, 464 struct iwl_notification_wait *wait_entry,
468 u8 cmd, 465 u8 cmd,
469 void (*fn)(struct iwl_trans *trans, 466 void (*fn)(struct iwl_priv *priv,
470 struct iwl_rx_packet *pkt, 467 struct iwl_rx_packet *pkt,
471 void *data), 468 void *data),
472 void *fn_data) 469 void *fn_data)
473{ 470{
474 wait_entry->fn = fn; 471 wait_entry->fn = fn;
475 wait_entry->fn_data = fn_data; 472 wait_entry->fn_data = fn_data;
@@ -529,7 +526,7 @@ void iwl_abort_notification_waits(struct iwl_shared *shrd)
529#define UCODE_ALIVE_TIMEOUT HZ 526#define UCODE_ALIVE_TIMEOUT HZ
530#define UCODE_CALIB_TIMEOUT (2*HZ) 527#define UCODE_CALIB_TIMEOUT (2*HZ)
531 528
532int iwl_load_ucode_wait_alive(struct iwl_trans *trans, 529int iwl_load_ucode_wait_alive(struct iwl_priv *priv,
533 enum iwl_ucode_type ucode_type) 530 enum iwl_ucode_type ucode_type)
534{ 531{
535 struct iwl_notification_wait alive_wait; 532 struct iwl_notification_wait alive_wait;
@@ -538,20 +535,20 @@ int iwl_load_ucode_wait_alive(struct iwl_trans *trans,
538 int ret; 535 int ret;
539 enum iwl_ucode_type old_type; 536 enum iwl_ucode_type old_type;
540 537
541 iwl_init_notification_wait(trans->shrd, &alive_wait, REPLY_ALIVE, 538 iwl_init_notification_wait(priv->shrd, &alive_wait, REPLY_ALIVE,
542 iwl_alive_fn, &alive_data); 539 iwl_alive_fn, &alive_data);
543 540
544 old_type = trans->shrd->ucode_type; 541 old_type = priv->shrd->ucode_type;
545 trans->shrd->ucode_type = ucode_type; 542 priv->shrd->ucode_type = ucode_type;
546 fw = iwl_get_ucode_image(nic(trans), ucode_type); 543 fw = iwl_get_ucode_image(priv, ucode_type);
547 544
548 if (!fw) 545 if (!fw)
549 return -EINVAL; 546 return -EINVAL;
550 547
551 ret = iwl_trans_start_fw(trans, fw); 548 ret = iwl_trans_start_fw(trans(priv), fw);
552 if (ret) { 549 if (ret) {
553 trans->shrd->ucode_type = old_type; 550 priv->shrd->ucode_type = old_type;
554 iwl_remove_notification(trans->shrd, &alive_wait); 551 iwl_remove_notification(priv->shrd, &alive_wait);
555 return ret; 552 return ret;
556 } 553 }
557 554
@@ -559,16 +556,16 @@ int iwl_load_ucode_wait_alive(struct iwl_trans *trans,
559 * Some things may run in the background now, but we 556 * Some things may run in the background now, but we
560 * just wait for the ALIVE notification here. 557 * just wait for the ALIVE notification here.
561 */ 558 */
562 ret = iwl_wait_notification(trans->shrd, &alive_wait, 559 ret = iwl_wait_notification(priv->shrd, &alive_wait,
563 UCODE_ALIVE_TIMEOUT); 560 UCODE_ALIVE_TIMEOUT);
564 if (ret) { 561 if (ret) {
565 trans->shrd->ucode_type = old_type; 562 priv->shrd->ucode_type = old_type;
566 return ret; 563 return ret;
567 } 564 }
568 565
569 if (!alive_data.valid) { 566 if (!alive_data.valid) {
570 IWL_ERR(trans, "Loaded ucode is not valid!\n"); 567 IWL_ERR(priv, "Loaded ucode is not valid!\n");
571 trans->shrd->ucode_type = old_type; 568 priv->shrd->ucode_type = old_type;
572 return -EIO; 569 return -EIO;
573 } 570 }
574 571
@@ -578,9 +575,9 @@ int iwl_load_ucode_wait_alive(struct iwl_trans *trans,
578 * skip it for WoWLAN. 575 * skip it for WoWLAN.
579 */ 576 */
580 if (ucode_type != IWL_UCODE_WOWLAN) { 577 if (ucode_type != IWL_UCODE_WOWLAN) {
581 ret = iwl_verify_ucode(nic(trans), ucode_type); 578 ret = iwl_verify_ucode(priv, ucode_type);
582 if (ret) { 579 if (ret) {
583 trans->shrd->ucode_type = old_type; 580 priv->shrd->ucode_type = old_type;
584 return ret; 581 return ret;
585 } 582 }
586 583
@@ -588,41 +585,41 @@ int iwl_load_ucode_wait_alive(struct iwl_trans *trans,
588 msleep(5); 585 msleep(5);
589 } 586 }
590 587
591 ret = iwl_alive_notify(trans); 588 ret = iwl_alive_notify(priv);
592 if (ret) { 589 if (ret) {
593 IWL_WARN(trans, 590 IWL_WARN(priv,
594 "Could not complete ALIVE transition: %d\n", ret); 591 "Could not complete ALIVE transition: %d\n", ret);
595 trans->shrd->ucode_type = old_type; 592 priv->shrd->ucode_type = old_type;
596 return ret; 593 return ret;
597 } 594 }
598 595
599 return 0; 596 return 0;
600} 597}
601 598
602int iwl_run_init_ucode(struct iwl_trans *trans) 599int iwl_run_init_ucode(struct iwl_priv *priv)
603{ 600{
604 struct iwl_notification_wait calib_wait; 601 struct iwl_notification_wait calib_wait;
605 int ret; 602 int ret;
606 603
607 lockdep_assert_held(&trans->shrd->mutex); 604 lockdep_assert_held(&priv->shrd->mutex);
608 605
609 /* No init ucode required? Curious, but maybe ok */ 606 /* No init ucode required? Curious, but maybe ok */
610 if (!nic(trans)->fw.ucode_init.code.len) 607 if (!nic(priv)->fw.ucode_init.code.len)
611 return 0; 608 return 0;
612 609
613 if (trans->shrd->ucode_type != IWL_UCODE_NONE) 610 if (priv->shrd->ucode_type != IWL_UCODE_NONE)
614 return 0; 611 return 0;
615 612
616 iwl_init_notification_wait(trans->shrd, &calib_wait, 613 iwl_init_notification_wait(priv->shrd, &calib_wait,
617 CALIBRATION_COMPLETE_NOTIFICATION, 614 CALIBRATION_COMPLETE_NOTIFICATION,
618 NULL, NULL); 615 NULL, NULL);
619 616
620 /* Will also start the device */ 617 /* Will also start the device */
621 ret = iwl_load_ucode_wait_alive(trans, IWL_UCODE_INIT); 618 ret = iwl_load_ucode_wait_alive(priv, IWL_UCODE_INIT);
622 if (ret) 619 if (ret)
623 goto error; 620 goto error;
624 621
625 ret = iwl_init_alive_start(trans); 622 ret = iwl_init_alive_start(priv);
626 if (ret) 623 if (ret)
627 goto error; 624 goto error;
628 625
@@ -630,15 +627,15 @@ int iwl_run_init_ucode(struct iwl_trans *trans)
630 * Some things may run in the background now, but we 627 * Some things may run in the background now, but we
631 * just wait for the calibration complete notification. 628 * just wait for the calibration complete notification.
632 */ 629 */
633 ret = iwl_wait_notification(trans->shrd, &calib_wait, 630 ret = iwl_wait_notification(priv->shrd, &calib_wait,
634 UCODE_CALIB_TIMEOUT); 631 UCODE_CALIB_TIMEOUT);
635 632
636 goto out; 633 goto out;
637 634
638 error: 635 error:
639 iwl_remove_notification(trans->shrd, &calib_wait); 636 iwl_remove_notification(priv->shrd, &calib_wait);
640 out: 637 out:
641 /* Whatever happened, stop the device */ 638 /* Whatever happened, stop the device */
642 iwl_trans_stop_device(trans); 639 iwl_trans_stop_device(trans(priv));
643 return ret; 640 return ret;
644} 641}
diff --git a/drivers/net/wireless/iwlwifi/iwl-wifi.h b/drivers/net/wireless/iwlwifi/iwl-wifi.h
index d157931e1e95..753e338e77d0 100644
--- a/drivers/net/wireless/iwlwifi/iwl-wifi.h
+++ b/drivers/net/wireless/iwlwifi/iwl-wifi.h
@@ -95,12 +95,4 @@ struct iwl_nic {
95 95
96 struct completion request_firmware_complete; 96 struct completion request_firmware_complete;
97}; 97};
98
99
100int iwl_send_bt_env(struct iwl_trans *trans, u8 action, u8 type);
101void iwl_send_prio_tbl(struct iwl_trans *trans);
102int iwl_init_alive_start(struct iwl_trans *trans);
103int iwl_run_init_ucode(struct iwl_trans *trans);
104int iwl_load_ucode_wait_alive(struct iwl_trans *trans,
105 enum iwl_ucode_type ucode_type);
106#endif /* __iwl_wifi_h__ */ 98#endif /* __iwl_wifi_h__ */