Skip to content

Commit 3d2f20a

Browse files
dlezcanoDaniel Lezcano
authored andcommitted
wifi: iwlwifi: Use generic thermal_zone_get_trip() function
The thermal framework gives the possibility to register the trip points with the thermal zone. When that is done, no get_trip_* ops are needed and they can be removed. The get_trip_temp, get_trip_hyst and get_trip_type are handled by the get_trip_point(). The set_trip_temp() generic function does some checks which are no longer needed in the set_trip_point() ops. Convert ops content logic into generic trip points and register them with the thermal zone. Signed-off-by: Daniel Lezcano <[email protected]> Acked-by: Kalle Valo <[email protected]> Acked-by: Gregory Greenman <[email protected]> Link: https://lore.kernel.org/r/[email protected]
1 parent 5f28ecc commit 3d2f20a

File tree

2 files changed

+13
-60
lines changed
  • drivers/net/wireless/intel/iwlwifi/mvm

2 files changed

+13
-60
lines changed

drivers/net/wireless/intel/iwlwifi/mvm/mvm.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -501,7 +501,7 @@ struct iwl_mvm_tt_mgmt {
501501
* @tzone: thermal zone device data
502502
*/
503503
struct iwl_mvm_thermal_device {
504-
s16 temp_trips[IWL_MAX_DTS_TRIPS];
504+
struct thermal_trip trips[IWL_MAX_DTS_TRIPS];
505505
u8 fw_trips_index[IWL_MAX_DTS_TRIPS];
506506
struct thermal_zone_device *tzone;
507507
};

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

Lines changed: 12 additions & 59 deletions
Original file line numberDiff line numberDiff line change
@@ -573,11 +573,11 @@ int iwl_mvm_send_temp_report_ths_cmd(struct iwl_mvm *mvm)
573573
* and uncompressed, the FW should get it compressed and sorted
574574
*/
575575

576-
/* compress temp_trips to cmd array, remove uninitialized values*/
576+
/* compress trips to cmd array, remove uninitialized values*/
577577
for (i = 0; i < IWL_MAX_DTS_TRIPS; i++) {
578-
if (mvm->tz_device.temp_trips[i] != S16_MIN) {
578+
if (mvm->tz_device.trips[i].temperature != INT_MIN) {
579579
cmd.thresholds[idx++] =
580-
cpu_to_le16(mvm->tz_device.temp_trips[i]);
580+
cpu_to_le16((s16)(mvm->tz_device.trips[i].temperature / 1000));
581581
}
582582
}
583583
cmd.num_temps = cpu_to_le32(idx);
@@ -593,8 +593,8 @@ int iwl_mvm_send_temp_report_ths_cmd(struct iwl_mvm *mvm)
593593
*/
594594
for (i = 0; i < idx; i++) {
595595
for (j = 0; j < IWL_MAX_DTS_TRIPS; j++) {
596-
if (le16_to_cpu(cmd.thresholds[i]) ==
597-
mvm->tz_device.temp_trips[j])
596+
if ((int)(le16_to_cpu(cmd.thresholds[i]) * 1000) ==
597+
mvm->tz_device.trips[j].temperature)
598598
mvm->tz_device.fw_trips_index[i] = j;
599599
}
600600
}
@@ -638,37 +638,12 @@ static int iwl_mvm_tzone_get_temp(struct thermal_zone_device *device,
638638
return ret;
639639
}
640640

641-
static int iwl_mvm_tzone_get_trip_temp(struct thermal_zone_device *device,
642-
int trip, int *temp)
643-
{
644-
struct iwl_mvm *mvm = (struct iwl_mvm *)device->devdata;
645-
646-
if (trip < 0 || trip >= IWL_MAX_DTS_TRIPS)
647-
return -EINVAL;
648-
649-
*temp = mvm->tz_device.temp_trips[trip] * 1000;
650-
651-
return 0;
652-
}
653-
654-
static int iwl_mvm_tzone_get_trip_type(struct thermal_zone_device *device,
655-
int trip, enum thermal_trip_type *type)
656-
{
657-
if (trip < 0 || trip >= IWL_MAX_DTS_TRIPS)
658-
return -EINVAL;
659-
660-
*type = THERMAL_TRIP_PASSIVE;
661-
662-
return 0;
663-
}
664-
665641
static int iwl_mvm_tzone_set_trip_temp(struct thermal_zone_device *device,
666642
int trip, int temp)
667643
{
668644
struct iwl_mvm *mvm = (struct iwl_mvm *)device->devdata;
669645
struct iwl_mvm_thermal_device *tzone;
670-
int i, ret;
671-
s16 temperature;
646+
int ret;
672647

673648
mutex_lock(&mvm->mutex);
674649

@@ -678,40 +653,17 @@ static int iwl_mvm_tzone_set_trip_temp(struct thermal_zone_device *device,
678653
goto out;
679654
}
680655

681-
if (trip < 0 || trip >= IWL_MAX_DTS_TRIPS) {
682-
ret = -EINVAL;
683-
goto out;
684-
}
685-
686656
if ((temp / 1000) > S16_MAX) {
687657
ret = -EINVAL;
688658
goto out;
689659
}
690660

691-
temperature = (s16)(temp / 1000);
692661
tzone = &mvm->tz_device;
693-
694662
if (!tzone) {
695663
ret = -EIO;
696664
goto out;
697665
}
698666

699-
/* no updates*/
700-
if (tzone->temp_trips[trip] == temperature) {
701-
ret = 0;
702-
goto out;
703-
}
704-
705-
/* already existing temperature */
706-
for (i = 0; i < IWL_MAX_DTS_TRIPS; i++) {
707-
if (tzone->temp_trips[i] == temperature) {
708-
ret = -EINVAL;
709-
goto out;
710-
}
711-
}
712-
713-
tzone->temp_trips[trip] = temperature;
714-
715667
ret = iwl_mvm_send_temp_report_ths_cmd(mvm);
716668
out:
717669
mutex_unlock(&mvm->mutex);
@@ -720,8 +672,6 @@ static int iwl_mvm_tzone_set_trip_temp(struct thermal_zone_device *device,
720672

721673
static struct thermal_zone_device_ops tzone_ops = {
722674
.get_temp = iwl_mvm_tzone_get_temp,
723-
.get_trip_temp = iwl_mvm_tzone_get_trip_temp,
724-
.get_trip_type = iwl_mvm_tzone_get_trip_type,
725675
.set_trip_temp = iwl_mvm_tzone_set_trip_temp,
726676
};
727677

@@ -743,7 +693,8 @@ static void iwl_mvm_thermal_zone_register(struct iwl_mvm *mvm)
743693
BUILD_BUG_ON(ARRAY_SIZE(name) >= THERMAL_NAME_LENGTH);
744694

745695
sprintf(name, "iwlwifi_%u", atomic_inc_return(&counter) & 0xFF);
746-
mvm->tz_device.tzone = thermal_zone_device_register(name,
696+
mvm->tz_device.tzone = thermal_zone_device_register_with_trips(name,
697+
mvm->tz_device.trips,
747698
IWL_MAX_DTS_TRIPS,
748699
IWL_WRITABLE_TRIPS_MSK,
749700
mvm, &tzone_ops,
@@ -766,8 +717,10 @@ static void iwl_mvm_thermal_zone_register(struct iwl_mvm *mvm)
766717
/* 0 is a valid temperature,
767718
* so initialize the array with S16_MIN which invalid temperature
768719
*/
769-
for (i = 0 ; i < IWL_MAX_DTS_TRIPS; i++)
770-
mvm->tz_device.temp_trips[i] = S16_MIN;
720+
for (i = 0 ; i < IWL_MAX_DTS_TRIPS; i++) {
721+
mvm->tz_device.trips[i].temperature = INT_MIN;
722+
mvm->tz_device.trips[i].type = THERMAL_TRIP_PASSIVE;
723+
}
771724
}
772725

773726
static int iwl_mvm_tcool_get_max_state(struct thermal_cooling_device *cdev,

0 commit comments

Comments
 (0)