aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/net/wireless/iwlwifi/iwl-ucode.c
diff options
context:
space:
mode:
authorJohannes Berg <johannes.berg@intel.com>2012-03-15 16:26:45 -0400
committerJohn W. Linville <linville@tuxdriver.com>2012-04-09 16:37:16 -0400
commite1f0c501c01e4e26a91750a98d6f7616dfa4e169 (patch)
tree939fac562c197eaf0845814138eb32ec46b1cc27 /drivers/net/wireless/iwlwifi/iwl-ucode.c
parentdb662d478695a967b9d0a4c9893278e797b73f6c (diff)
iwlwifi: simplify calibration collection
The calibration results all come in while we're waiting for the calibration complete notification. As a consequence, there's no need to install a global RX handler for them, we can use the newly extended notification wait framework for this and make the code easier to follow. It is now quite explicit that we are processing the calibration results while waiting for the complete notification, before this was implicit and developers had to know this to understand why we wait for the calibration complete notification and what happens while we wait. 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-ucode.c')
-rw-r--r--drivers/net/wireless/iwlwifi/iwl-ucode.c46
1 files changed, 27 insertions, 19 deletions
diff --git a/drivers/net/wireless/iwlwifi/iwl-ucode.c b/drivers/net/wireless/iwlwifi/iwl-ucode.c
index 44b0e72ca7fb..a5b218959347 100644
--- a/drivers/net/wireless/iwlwifi/iwl-ucode.c
+++ b/drivers/net/wireless/iwlwifi/iwl-ucode.c
@@ -174,24 +174,6 @@ static int iwl_send_calib_cfg(struct iwl_priv *priv)
174 return iwl_dvm_send_cmd(priv, &cmd); 174 return iwl_dvm_send_cmd(priv, &cmd);
175} 175}
176 176
177int iwlagn_rx_calib_result(struct iwl_priv *priv,
178 struct iwl_rx_cmd_buffer *rxb,
179 struct iwl_device_cmd *cmd)
180{
181 struct iwl_rx_packet *pkt = rxb_addr(rxb);
182 struct iwl_calib_hdr *hdr = (struct iwl_calib_hdr *)pkt->data;
183 int len = le32_to_cpu(pkt->len_n_flags) & FH_RSCSR_FRAME_SIZE_MSK;
184
185 /* reduce the size of the length field itself */
186 len -= 4;
187
188 if (iwl_calib_set(priv, hdr, len))
189 IWL_ERR(priv, "Failed to record calibration data %d\n",
190 hdr->op_code);
191
192 return 0;
193}
194
195int iwl_init_alive_start(struct iwl_priv *priv) 177int iwl_init_alive_start(struct iwl_priv *priv)
196{ 178{
197 int ret; 179 int ret;
@@ -522,10 +504,36 @@ int iwl_load_ucode_wait_alive(struct iwl_priv *priv,
522 return 0; 504 return 0;
523} 505}
524 506
507static bool iwlagn_wait_calib(struct iwl_notif_wait_data *notif_wait,
508 struct iwl_rx_packet *pkt, void *data)
509{
510 struct iwl_priv *priv = data;
511 struct iwl_calib_hdr *hdr;
512 int len;
513
514 if (pkt->hdr.cmd != CALIBRATION_RES_NOTIFICATION) {
515 WARN_ON(pkt->hdr.cmd != CALIBRATION_COMPLETE_NOTIFICATION);
516 return true;
517 }
518
519 hdr = (struct iwl_calib_hdr *)pkt->data;
520 len = le32_to_cpu(pkt->len_n_flags) & FH_RSCSR_FRAME_SIZE_MSK;
521
522 /* reduce the size by the length field itself */
523 len -= sizeof(__le32);
524
525 if (iwl_calib_set(priv, hdr, len))
526 IWL_ERR(priv, "Failed to record calibration data %d\n",
527 hdr->op_code);
528
529 return false;
530}
531
525int iwl_run_init_ucode(struct iwl_priv *priv) 532int iwl_run_init_ucode(struct iwl_priv *priv)
526{ 533{
527 struct iwl_notification_wait calib_wait; 534 struct iwl_notification_wait calib_wait;
528 static const u8 calib_complete[] = { 535 static const u8 calib_complete[] = {
536 CALIBRATION_RES_NOTIFICATION,
529 CALIBRATION_COMPLETE_NOTIFICATION 537 CALIBRATION_COMPLETE_NOTIFICATION
530 }; 538 };
531 int ret; 539 int ret;
@@ -541,7 +549,7 @@ int iwl_run_init_ucode(struct iwl_priv *priv)
541 549
542 iwl_init_notification_wait(&priv->notif_wait, &calib_wait, 550 iwl_init_notification_wait(&priv->notif_wait, &calib_wait,
543 calib_complete, ARRAY_SIZE(calib_complete), 551 calib_complete, ARRAY_SIZE(calib_complete),
544 NULL, NULL); 552 iwlagn_wait_calib, priv);
545 553
546 /* Will also start the device */ 554 /* Will also start the device */
547 ret = iwl_load_ucode_wait_alive(priv, IWL_UCODE_INIT); 555 ret = iwl_load_ucode_wait_alive(priv, IWL_UCODE_INIT);