wifi: iwlwifi: Fix thermal zone registration for kernel < 6.3
PATCH 1/1 wifi: iwlwifi: Fix thermal zone registration for kernel < 6.3
This is a backport-iwlwifi-only fix; upstream does not need it.
Before commit 7c3d5c20dc16 ("thermal/core: Add a generic thermal_zone_get_trip() function"), merged in 6.3, thermal_zone_device_register_with_trips() rejects a zone with trips unless both .get_trip_temp and .get_trip_type are provided, even when a trips array is passed. As a result, both mvm and mld fail to register their thermal zone on older kernels. Provide the callbacks for kernels older than 6.3.
Signed-off-by Abraham Zukor <[email protected]>
---
Build-tested against v5.15 and v6.1 (mvm and mld); runtime-tested on 5.15. 6.2-6.4 aren't buildable in this tree any more (no guard(rcu) compat).
.../net/wireless/intel/iwlwifi/mld/thermal.c | 40 ++++++++++++++++--- drivers/net/wireless/intel/iwlwifi/mvm/tt.c | 34 ++++++++++++++++ 2 files changed, 69 insertions(+), 5 deletions(-)
drivers/net/wireless/intel/iwlwifi/mld/thermal.c +35 -5
@@ -238,11 +238,6 @@ unlock:return ret; } -static struct thermal_zone_device_ops tzone_ops = { - .get_temp = iwl_mld_tzone_get_temp, - .set_trip_temp = iwl_mld_tzone_set_trip_temp, -}; - #if LINUX_VERSION_IS_LESS(6,9,0) static struct thermal_trip trips[IWL_MAX_DTS_TRIPS] = { [0 ... IWL_MAX_DTS_TRIPS - 1] = {
@@ -253,6 +248,41 @@ static struct thermal_trip trips[IWL_MAX_DTS_TRIPS] = { };#endif +#if LINUX_VERSION_IS_LESS (6 ,3 ,0 ) +static int iwl_mld_tzone_get_trip_temp (struct thermal_zone_device *device, +int trip,int *temp) +{ +if (trip <0 || trip >=IWL_MAX_DTS_TRIPS ) +return -EINVAL ; + + *temp = trips[trip].temperature; +if (*temp ==THERMAL_TEMP_INVALID ) +return -EINVAL ; + +return 0 ; +} + +static int iwl_mld_tzone_get_trip_type (struct thermal_zone_device *device, +int trip,enum thermal_trip_type *type) +{ +if (trip <0 || trip >=IWL_MAX_DTS_TRIPS ) +return -EINVAL ; + + *type = trips[trip].type; + +return 0 ; +} +#endif /* LINUX_VERSION_IS_LESS(6,3,0) */ + +static struct thermal_zone_device_ops tzone_ops = { + .get_temp = iwl_mld_tzone_get_temp, + .set_trip_temp = iwl_mld_tzone_set_trip_temp, +#if LINUX_VERSION_IS_LESS(6,3,0) + .get_trip_temp = iwl_mld_tzone_get_trip_temp, + .get_trip_type = iwl_mld_tzone_get_trip_type, +#endif /* LINUX_VERSION_IS_LESS(6,3,0) */ +}; +static void iwl_mld_thermal_zone_register (struct iwl_mld *mld) {int ret;
drivers/net/wireless/intel/iwlwifi/mvm/tt.c +34 -0
@@ -652,9 +652,43 @@ static int iwl_mvm_tzone_set_trip_temp(struct thermal_zone_device *device,return iwl_mvm_send_temp_report_ths_cmd (mvm); } +#if LINUX_VERSION_IS_LESS (6 ,3 ,0 ) +static int iwl_mvm_tzone_get_trip_temp (struct thermal_zone_device *device, +int trip,int *temp) +{ +struct iwl_mvm *mvm =thermal_zone_device_priv (device); + +if (trip <0 || trip >=IWL_MAX_DTS_TRIPS ) +return -EINVAL ; + + *temp = mvm->tz_device.trips[trip].temperature; +if (*temp ==THERMAL_TEMP_INVALID ) +return -EINVAL ; + +return 0 ; +} + +static int iwl_mvm_tzone_get_trip_type (struct thermal_zone_device *device, +int trip,enum thermal_trip_type *type) +{ +struct iwl_mvm *mvm =thermal_zone_device_priv (device); + +if (trip <0 || trip >=IWL_MAX_DTS_TRIPS ) +return -EINVAL ; + + *type = mvm->tz_device.trips[trip].type; + +return 0 ; +} +#endif /* LINUX_VERSION_IS_LESS(6,3,0) */ +static struct thermal_zone_device_ops tzone_ops = { .get_temp = iwl_mvm_tzone_get_temp, .set_trip_temp = iwl_mvm_tzone_set_trip_temp, +#if LINUX_VERSION_IS_LESS(6,3,0) + .get_trip_temp = iwl_mvm_tzone_get_trip_temp, + .get_trip_type = iwl_mvm_tzone_get_trip_type, +#endif /* LINUX_VERSION_IS_LESS(6,3,0) */ };static void iwl_mvm_thermal_zone_register (struct iwl_mvm *mvm)
Signature · 1 line
2.55.0