summaryrefslogtreecommitdiff
path: root/drivers/net/wireless/intel/iwlwifi/mvm/tt.c
diff options
context:
space:
mode:
authorRafael J. Wysocki <rafael.j.wysocki@intel.com>2024-02-07 20:12:38 +0100
committerRafael J. Wysocki <rafael.j.wysocki@intel.com>2024-02-08 14:54:55 +0100
commit85af3310df34b0931daba8732d5b2c64a81c3b8d (patch)
tree4665a21737cdff8663a1a38f2e08b7ba60dd2ab5 /drivers/net/wireless/intel/iwlwifi/mvm/tt.c
parent61d88437546f5f40b6411aac17c55d0298c7a19d (diff)
iwlwifi: mvm: Use for_each_thermal_trip() for walking trip points
The code walking trip points in iwl_mvm_send_temp_report_ths_cmd() reads the trip table passed to thermal_zone_device_register_with_trips() in order to get the current trip temperatures, but this is not guaranteed to work in the future, because the thermal zone will store trip points information internally. For this reason, make iwl_mvm_send_temp_report_ths_cmd() use for_each_thermal_trip() as appropriate for walking trip points in a given thermal zone. No intentional functional impact, but it is requisite for future thermal core improvements. Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com> Acked-by: Miri Korenblit <Miriam.rachel.korenblit@intel.com>
Diffstat (limited to 'drivers/net/wireless/intel/iwlwifi/mvm/tt.c')
-rw-r--r--drivers/net/wireless/intel/iwlwifi/mvm/tt.c40
1 files changed, 25 insertions, 15 deletions
diff --git a/drivers/net/wireless/intel/iwlwifi/mvm/tt.c b/drivers/net/wireless/intel/iwlwifi/mvm/tt.c
index 4fcbf02b415e..d2a00cbcbc42 100644
--- a/drivers/net/wireless/intel/iwlwifi/mvm/tt.c
+++ b/drivers/net/wireless/intel/iwlwifi/mvm/tt.c
@@ -555,6 +555,22 @@ static int compare_temps(const void *a, const void *b)
return ((s16)le16_to_cpu(*(__le16 *)a) -
(s16)le16_to_cpu(*(__le16 *)b));
}
+
+struct iwl_trip_walk_data {
+ __le16 *thresholds;
+ int count;
+};
+
+static int iwl_trip_temp_cb(struct thermal_trip *trip, void *arg)
+{
+ struct iwl_trip_walk_data *twd = arg;
+
+ if (trip->temperature == THERMAL_TEMP_INVALID)
+ return 0;
+
+ twd->thresholds[twd->count++] = cpu_to_le16((s16)(trip->temperature / 1000));
+ return 0;
+}
#endif
int iwl_mvm_send_temp_report_ths_cmd(struct iwl_mvm *mvm)
@@ -562,31 +578,25 @@ int iwl_mvm_send_temp_report_ths_cmd(struct iwl_mvm *mvm)
struct temp_report_ths_cmd cmd = {0};
int ret;
#ifdef CONFIG_THERMAL
- int i, idx = 0;
+ struct iwl_trip_walk_data twd = { .thresholds = cmd.thresholds, .count = 0 };
lockdep_assert_held(&mvm->mutex);
if (!mvm->tz_device.tzone)
goto send;
- /* The driver holds array of temperature trips that are unsorted
- * and uncompressed, the FW should get it compressed and sorted
+ /*
+ * The thermal core holds an array of temperature trips that are
+ * unsorted and uncompressed, the FW should get it compressed and
+ * sorted.
*/
/* compress trips to cmd array, remove uninitialized values*/
- for (i = 0; i < IWL_MAX_DTS_TRIPS; i++) {
- if (mvm->tz_device.trips[i].temperature != THERMAL_TEMP_INVALID) {
- cmd.thresholds[idx++] =
- cpu_to_le16((s16)(mvm->tz_device.trips[i].temperature / 1000));
- }
- }
- cmd.num_temps = cpu_to_le32(idx);
-
- if (!idx)
- goto send;
+ for_each_thermal_trip(mvm->tz_device.tzone, iwl_trip_temp_cb, &twd);
- /*sort cmd array*/
- sort(cmd.thresholds, idx, sizeof(s16), compare_temps, NULL);
+ cmd.num_temps = cpu_to_le32(twd.count);
+ if (twd.count)
+ sort(cmd.thresholds, twd.count, sizeof(s16), compare_temps, NULL);
send:
#endif