Skip to content

Commit 85af331

Browse files
committed
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>
1 parent 61d8843 commit 85af331

File tree

1 file changed

+25
-15
lines changed
  • drivers/net/wireless/intel/iwlwifi/mvm

1 file changed

+25
-15
lines changed

drivers/net/wireless/intel/iwlwifi/mvm/tt.c

Lines changed: 25 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -555,38 +555,48 @@ static int compare_temps(const void *a, const void *b)
555555
return ((s16)le16_to_cpu(*(__le16 *)a) -
556556
(s16)le16_to_cpu(*(__le16 *)b));
557557
}
558+
559+
struct iwl_trip_walk_data {
560+
__le16 *thresholds;
561+
int count;
562+
};
563+
564+
static int iwl_trip_temp_cb(struct thermal_trip *trip, void *arg)
565+
{
566+
struct iwl_trip_walk_data *twd = arg;
567+
568+
if (trip->temperature == THERMAL_TEMP_INVALID)
569+
return 0;
570+
571+
twd->thresholds[twd->count++] = cpu_to_le16((s16)(trip->temperature / 1000));
572+
return 0;
573+
}
558574
#endif
559575

560576
int iwl_mvm_send_temp_report_ths_cmd(struct iwl_mvm *mvm)
561577
{
562578
struct temp_report_ths_cmd cmd = {0};
563579
int ret;
564580
#ifdef CONFIG_THERMAL
565-
int i, idx = 0;
581+
struct iwl_trip_walk_data twd = { .thresholds = cmd.thresholds, .count = 0 };
566582

567583
lockdep_assert_held(&mvm->mutex);
568584

569585
if (!mvm->tz_device.tzone)
570586
goto send;
571587

572-
/* The driver holds array of temperature trips that are unsorted
573-
* and uncompressed, the FW should get it compressed and sorted
588+
/*
589+
* The thermal core holds an array of temperature trips that are
590+
* unsorted and uncompressed, the FW should get it compressed and
591+
* sorted.
574592
*/
575593

576594
/* compress trips to cmd array, remove uninitialized values*/
577-
for (i = 0; i < IWL_MAX_DTS_TRIPS; i++) {
578-
if (mvm->tz_device.trips[i].temperature != THERMAL_TEMP_INVALID) {
579-
cmd.thresholds[idx++] =
580-
cpu_to_le16((s16)(mvm->tz_device.trips[i].temperature / 1000));
581-
}
582-
}
583-
cmd.num_temps = cpu_to_le32(idx);
584-
585-
if (!idx)
586-
goto send;
595+
for_each_thermal_trip(mvm->tz_device.tzone, iwl_trip_temp_cb, &twd);
587596

588-
/*sort cmd array*/
589-
sort(cmd.thresholds, idx, sizeof(s16), compare_temps, NULL);
597+
cmd.num_temps = cpu_to_le32(twd.count);
598+
if (twd.count)
599+
sort(cmd.thresholds, twd.count, sizeof(s16), compare_temps, NULL);
590600

591601
send:
592602
#endif

0 commit comments

Comments
 (0)