Skip to content

Commit bbcf90c

Browse files
andrzejtpdlezcano
authored andcommitted
thermal: Explicitly enable non-changing thermal zone devices
Some thermal zone devices never change their state, so they should be always enabled. Signed-off-by: Andrzej Pietrasiewicz <[email protected]> Reviewed-by: Bartlomiej Zolnierkiewicz <[email protected]> Signed-off-by: Daniel Lezcano <[email protected]> Link: https://lore.kernel.org/r/[email protected]
1 parent 7f4957b commit bbcf90c

File tree

14 files changed

+87
-4
lines changed

14 files changed

+87
-4
lines changed

drivers/net/ethernet/chelsio/cxgb4/cxgb4_thermal.c

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,14 @@ int cxgb4_thermal_init(struct adapter *adap)
9292
ch_thermal->tzdev = NULL;
9393
return ret;
9494
}
95+
96+
ret = thermal_zone_device_enable(ch_thermal->tzdev);
97+
if (ret) {
98+
dev_err(adap->pdev_dev, "Failed to enable thermal zone\n");
99+
thermal_zone_device_unregister(adap->ch_thermal.tzdev);
100+
return ret;
101+
}
102+
95103
return 0;
96104
}
97105

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

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -733,7 +733,7 @@ static struct thermal_zone_device_ops tzone_ops = {
733733

734734
static void iwl_mvm_thermal_zone_register(struct iwl_mvm *mvm)
735735
{
736-
int i;
736+
int i, ret;
737737
char name[16];
738738
static atomic_t counter = ATOMIC_INIT(0);
739739

@@ -759,6 +759,13 @@ static void iwl_mvm_thermal_zone_register(struct iwl_mvm *mvm)
759759
return;
760760
}
761761

762+
ret = thermal_zone_device_enable(mvm->tz_device.tzone);
763+
if (ret) {
764+
IWL_DEBUG_TEMP(mvm, "Failed to enable thermal zone\n");
765+
thermal_zone_device_unregister(mvm->tz_device.tzone);
766+
return;
767+
}
768+
762769
/* 0 is a valid temperature,
763770
* so initialize the array with S16_MIN which invalid temperature
764771
*/

drivers/platform/x86/intel_mid_thermal.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -493,6 +493,12 @@ static int mid_thermal_probe(struct platform_device *pdev)
493493
ret = PTR_ERR(pinfo->tzd[i]);
494494
goto err;
495495
}
496+
ret = thermal_zone_device_enable(pinfo->tzd[i]);
497+
if (ret) {
498+
kfree(td_info);
499+
thermal_zone_device_unregister(pinfo->tzd[i]);
500+
goto err;
501+
}
496502
}
497503

498504
pinfo->pdev = pdev;

drivers/power/supply/power_supply_core.c

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -939,7 +939,7 @@ static struct thermal_zone_device_ops psy_tzd_ops = {
939939

940940
static int psy_register_thermal(struct power_supply *psy)
941941
{
942-
int i;
942+
int i, ret;
943943

944944
if (psy->desc->no_thermal)
945945
return 0;
@@ -949,7 +949,12 @@ static int psy_register_thermal(struct power_supply *psy)
949949
if (psy->desc->properties[i] == POWER_SUPPLY_PROP_TEMP) {
950950
psy->tzd = thermal_zone_device_register(psy->desc->name,
951951
0, 0, psy, &psy_tzd_ops, NULL, 0, 0);
952-
return PTR_ERR_OR_ZERO(psy->tzd);
952+
if (IS_ERR(psy->tzd))
953+
return PTR_ERR(psy->tzd);
954+
ret = thermal_zone_device_enable(psy->tzd);
955+
if (ret)
956+
thermal_zone_device_unregister(psy->tzd);
957+
return ret;
953958
}
954959
}
955960
return 0;

drivers/thermal/armada_thermal.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -874,6 +874,12 @@ static int armada_thermal_probe(struct platform_device *pdev)
874874
return PTR_ERR(tz);
875875
}
876876

877+
ret = thermal_zone_device_enable(tz);
878+
if (ret) {
879+
thermal_zone_device_unregister(tz);
880+
return ret;
881+
}
882+
877883
drvdata->type = LEGACY;
878884
drvdata->data.tz = tz;
879885
platform_set_drvdata(pdev, drvdata);

drivers/thermal/dove_thermal.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -153,6 +153,12 @@ static int dove_thermal_probe(struct platform_device *pdev)
153153
return PTR_ERR(thermal);
154154
}
155155

156+
ret = thermal_zone_device_enable(thermal);
157+
if (ret) {
158+
thermal_zone_device_unregister(thermal);
159+
return ret;
160+
}
161+
156162
platform_set_drvdata(pdev, thermal);
157163

158164
return 0;

drivers/thermal/intel/int340x_thermal/int340x_thermal_zone.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -259,9 +259,14 @@ struct int34x_thermal_zone *int340x_thermal_zone_add(struct acpi_device *adev,
259259
ret = PTR_ERR(int34x_thermal_zone->zone);
260260
goto err_thermal_zone;
261261
}
262+
ret = thermal_zone_device_enable(int34x_thermal_zone->zone);
263+
if (ret)
264+
goto err_enable;
262265

263266
return int34x_thermal_zone;
264267

268+
err_enable:
269+
thermal_zone_device_unregister(int34x_thermal_zone->zone);
265270
err_thermal_zone:
266271
acpi_lpat_free_conversion_table(int34x_thermal_zone->lpat_table);
267272
kfree(int34x_thermal_zone->aux_trips);

drivers/thermal/intel/intel_pch_thermal.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -352,9 +352,14 @@ static int intel_pch_thermal_probe(struct pci_dev *pdev,
352352
err = PTR_ERR(ptd->tzd);
353353
goto error_cleanup;
354354
}
355+
err = thermal_zone_device_enable(ptd->tzd);
356+
if (err)
357+
goto err_unregister;
355358

356359
return 0;
357360

361+
err_unregister:
362+
thermal_zone_device_unregister(ptd->tzd);
358363
error_cleanup:
359364
iounmap(ptd->hw_base);
360365
error_release:

drivers/thermal/intel/intel_soc_dts_iosf.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -329,6 +329,9 @@ static int add_dts_thermal_zone(int id, struct intel_soc_dts_sensor_entry *dts,
329329
ret = PTR_ERR(dts->tzone);
330330
goto err_ret;
331331
}
332+
ret = thermal_zone_device_enable(dts->tzone);
333+
if (ret)
334+
goto err_enable;
332335

333336
ret = soc_dts_enable(id);
334337
if (ret)

drivers/thermal/intel/x86_pkg_temp_thermal.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -363,6 +363,12 @@ static int pkg_temp_thermal_device_add(unsigned int cpu)
363363
kfree(zonedev);
364364
return err;
365365
}
366+
err = thermal_zone_device_enable(zonedev->tzone);
367+
if (err) {
368+
thermal_zone_device_unregister(zonedev->tzone);
369+
kfree(zonedev);
370+
return err;
371+
}
366372
/* Store MSR value for package thermal interrupt, to restore at exit */
367373
rdmsr(MSR_IA32_PACKAGE_THERM_INTERRUPT, zonedev->msr_pkg_therm_low,
368374
zonedev->msr_pkg_therm_high);

0 commit comments

Comments
 (0)