iwlwifi: mvm: refactor temperature notification handling
authorLuciano Coelho <luciano.coelho@intel.com>
Tue, 4 Nov 2014 14:17:46 +0000 (16:17 +0200)
committerEmmanuel Grumbach <emmanuel.grumbach@intel.com>
Tue, 11 Nov 2014 15:15:07 +0000 (17:15 +0200)
Refactor the temperature handling code so that it is easier to reuse
it with other notification flows.

Signed-off-by: Luciano Coelho <luciano.coelho@intel.com>
Reviewed-by: Johannes Berg <johannes.berg@intel.com>
Signed-off-by: Emmanuel Grumbach <emmanuel.grumbach@intel.com>
drivers/net/wireless/iwlwifi/mvm/mvm.h
drivers/net/wireless/iwlwifi/mvm/rx.c
drivers/net/wireless/iwlwifi/mvm/tt.c

index e56abdda0e7dcb3461c2cf8cf1b4b487f1f355a5..9ac2d4c59bc6f99cc96edc016f84e0972c6d23e8 100644 (file)
@@ -1210,6 +1210,7 @@ bool iwl_mvm_is_idle(struct iwl_mvm *mvm);
 
 /* Thermal management and CT-kill */
 void iwl_mvm_tt_tx_backoff(struct iwl_mvm *mvm, u32 backoff);
+void iwl_mvm_tt_temp_changed(struct iwl_mvm *mvm, u32 temp);
 void iwl_mvm_tt_handler(struct iwl_mvm *mvm);
 void iwl_mvm_tt_initialize(struct iwl_mvm *mvm, u32 min_backoff);
 void iwl_mvm_tt_exit(struct iwl_mvm *mvm);
index 3cf40f3f58ec2214323b16aa2708dad1c3430163..93d5b692cf92b48a19edb2e36522406571eb74b5 100644 (file)
@@ -500,29 +500,8 @@ int iwl_mvm_rx_statistics(struct iwl_mvm *mvm,
                .mvm = mvm,
        };
 
-       /*
-        * set temperature debug enabled - ignore FW temperature updates
-        * and use the user set temperature.
-        */
-       if (mvm->temperature_test) {
-               if (mvm->temperature < le32_to_cpu(common->temperature))
-                       IWL_DEBUG_TEMP(mvm,
-                                      "Ignoring FW temperature update that is greater than the debug set temperature (debug temp = %d, fw temp = %d)\n",
-                                      mvm->temperature,
-                                      le32_to_cpu(common->temperature));
-               /*
-                * skip iwl_mvm_tt_handler since we are in
-                * temperature debug mode and we are ignoring
-                * the new temperature value
-                */
-               goto update;
-       }
+       iwl_mvm_tt_temp_changed(mvm, le32_to_cpu(common->temperature));
 
-       if (mvm->temperature != le32_to_cpu(common->temperature)) {
-               mvm->temperature = le32_to_cpu(common->temperature);
-               iwl_mvm_tt_handler(mvm);
-       }
-update:
        iwl_mvm_update_rx_statistics(mvm, stats);
 
        ieee80211_iterate_active_interfaces(mvm->hw,
index d4f2c29025c74d021558b1d52e35c3aeea9cff49..35acf003cce8d7d5f8d56ee3435383f5e0cc52c1 100644 (file)
@@ -95,29 +95,58 @@ static void iwl_mvm_exit_ctkill(struct iwl_mvm *mvm)
        iwl_mvm_set_hw_ctkill_state(mvm, false);
 }
 
-static bool iwl_mvm_temp_notif(struct iwl_notif_wait_data *notif_wait,
-                              struct iwl_rx_packet *pkt, void *data)
+void iwl_mvm_tt_temp_changed(struct iwl_mvm *mvm, u32 temp)
+{
+       /* ignore the notification if we are in test mode */
+       if (mvm->temperature_test)
+               return;
+
+       if (mvm->temperature == temp)
+               return;
+
+       mvm->temperature = temp;
+       iwl_mvm_tt_handler(mvm);
+}
+
+static int iwl_mvm_temp_notif_parse(struct iwl_mvm *mvm,
+                                   struct iwl_rx_packet *pkt)
 {
-       struct iwl_mvm *mvm =
-               container_of(notif_wait, struct iwl_mvm, notif_wait);
-       int *temp = data;
        struct iwl_dts_measurement_notif *notif;
        int len = iwl_rx_packet_payload_len(pkt);
+       int temp;
 
        if (WARN_ON_ONCE(len != sizeof(*notif))) {
                IWL_ERR(mvm, "Invalid DTS_MEASUREMENT_NOTIFICATION\n");
-               return true;
+               return -EINVAL;
        }
 
        notif = (void *)pkt->data;
 
-       *temp = le32_to_cpu(notif->temp);
+       temp = le32_to_cpu(notif->temp);
 
        /* shouldn't be negative, but since it's s32, make sure it isn't */
-       if (WARN_ON_ONCE(*temp < 0))
-               *temp = 0;
+       if (WARN_ON_ONCE(temp < 0))
+               temp = 0;
+
+       IWL_DEBUG_TEMP(mvm, "DTS_MEASUREMENT_NOTIFICATION - %d\n", temp);
+
+       return temp;
+}
+
+static bool iwl_mvm_temp_notif_wait(struct iwl_notif_wait_data *notif_wait,
+                                   struct iwl_rx_packet *pkt, void *data)
+{
+       struct iwl_mvm *mvm =
+               container_of(notif_wait, struct iwl_mvm, notif_wait);
+       int *temp = data;
+       int ret;
+
+       ret = iwl_mvm_temp_notif_parse(mvm, pkt);
+       if (ret < 0)
+               return true;
+
+       *temp = ret;
 
-       IWL_DEBUG_TEMP(mvm, "DTS_MEASUREMENT_NOTIFICATION - %d\n", *temp);
        return true;
 }
 
@@ -141,7 +170,7 @@ int iwl_mvm_get_temp(struct iwl_mvm *mvm)
 
        iwl_init_notification_wait(&mvm->notif_wait, &wait_temp_notif,
                                   temp_notif, ARRAY_SIZE(temp_notif),
-                                  iwl_mvm_temp_notif, &temp);
+                                  iwl_mvm_temp_notif_wait, &temp);
 
        ret = iwl_mvm_get_temp_cmd(mvm);
        if (ret) {
This page took 0.02937 seconds and 5 git commands to generate.