[RFC PATCH 21/26] wifi: iwlwifi: mvm: Migrate to thermal_zone_device_register()

From: AngeloGioacchino Del Regno
Date: Thu Dec 21 2023 - 07:55:07 EST


The thermal API has a new thermal_zone_device_register() function which
is deprecating the older thermal_zone_device_register_with_trips() and
thermal_tripless_zone_device_register().

Migrate to the new thermal zone device registration function.

Signed-off-by: AngeloGioacchino Del Regno <angelogioacchino.delregno@xxxxxxxxxxxxx>
---
drivers/net/wireless/intel/iwlwifi/mvm/tt.c | 27 ++++++++++++---------
1 file changed, 16 insertions(+), 11 deletions(-)

diff --git a/drivers/net/wireless/intel/iwlwifi/mvm/tt.c b/drivers/net/wireless/intel/iwlwifi/mvm/tt.c
index dee9c367dcd3..268ff6ca3cac 100644
--- a/drivers/net/wireless/intel/iwlwifi/mvm/tt.c
+++ b/drivers/net/wireless/intel/iwlwifi/mvm/tt.c
@@ -674,8 +674,14 @@ static struct thermal_zone_device_ops tzone_ops = {
static void iwl_mvm_thermal_zone_register(struct iwl_mvm *mvm)
{
int i, ret;
- char name[16];
static atomic_t counter = ATOMIC_INIT(0);
+ struct thermal_zone_device_params tzdp = {
+ .ops = &tzone_ops,
+ .devdata = mvm,
+ .trips = mvm->tz_device.trips,
+ .num_trips = IWL_MAX_DTS_TRIPS,
+ .mask = IWL_WRITABLE_TRIPS_MSK,
+ };

if (!iwl_mvm_is_tt_in_fw(mvm)) {
mvm->tz_device.tzone = NULL;
@@ -683,28 +689,25 @@ static void iwl_mvm_thermal_zone_register(struct iwl_mvm *mvm)
return;
}

- BUILD_BUG_ON(ARRAY_SIZE(name) >= THERMAL_NAME_LENGTH);
+ tzdp.type = kasprintf("iwlwifi_%u", atomic_inc_return(&counter) & 0xFF);
+ if (!tzdp.type)
+ return -ENOMEM;

- sprintf(name, "iwlwifi_%u", atomic_inc_return(&counter) & 0xFF);
- mvm->tz_device.tzone = thermal_zone_device_register_with_trips(name,
- mvm->tz_device.trips,
- IWL_MAX_DTS_TRIPS,
- IWL_WRITABLE_TRIPS_MSK,
- mvm, &tzone_ops,
- NULL, 0, 0);
+ mvm->tz_device.tzone = thermal_zone_device_register(&tzdp);
+ kfree(tzdp.type);
if (IS_ERR(mvm->tz_device.tzone)) {
IWL_DEBUG_TEMP(mvm,
"Failed to register to thermal zone (err = %ld)\n",
PTR_ERR(mvm->tz_device.tzone));
mvm->tz_device.tzone = NULL;
- return;
+ goto err_free;
}

ret = thermal_zone_device_enable(mvm->tz_device.tzone);
if (ret) {
IWL_DEBUG_TEMP(mvm, "Failed to enable thermal zone\n");
thermal_zone_device_unregister(mvm->tz_device.tzone);
- return;
+ goto err_free;
}

/* 0 is a valid temperature,
@@ -714,6 +717,8 @@ static void iwl_mvm_thermal_zone_register(struct iwl_mvm *mvm)
mvm->tz_device.trips[i].temperature = INT_MIN;
mvm->tz_device.trips[i].type = THERMAL_TRIP_PASSIVE;
}
+
+ return;
}

static int iwl_mvm_tcool_get_max_state(struct thermal_cooling_device *cdev,
--
2.43.0