thermal: Use mode helpers in drivers
Use thermal_zone_device_{en|dis}able() and thermal_zone_device_is_enabled(). Consequently, all set_mode() implementations in drivers: - can stop modifying tzd's "mode" member, - shall stop taking tzd's lock, as it is taken in the helpers - shall stop calling thermal_zone_device_update() as it is called in the helpers - can assume they are called when the mode truly changes, so checks to verify that can be dropped Not providing set_mode() by a driver no longer prevents the core from being able to set tzd's mode, so the relevant check in mode_store() is removed. Other comments: - acpi/thermal.c: tz->thermal_zone->mode will be updated only after we return from set_mode(), so use function parameter in thermal_set_mode() instead, no need to call acpi_thermal_check() in set_mode() - thermal/imx_thermal.c: regmap writes and mode assignment are done in thermal_zone_device_{en|dis}able() and set_mode() callback - thermal/intel/intel_quark_dts_thermal.c: soc_dts_{en|dis}able() are a part of set_mode() callback, so they don't need to modify tzd->mode, and don't need to fall back to the opposite mode if unsuccessful, as the return value will be propagated to thermal_zone_device_{en|dis}able() and ultimately tzd's member will not be changed in thermal_zone_device_set_mode(). - thermal/of-thermal.c: no need to set zone->mode to DISABLED in of_parse_thermal_zones() as a tzd is kzalloc'ed so mode is DISABLED anyway Signed-off-by: Andrzej Pietrasiewicz <andrzej.p@collabora.com> [for acerhdf] Acked-by: Peter Kaestle <peter@piie.net> Reviewed-by: Amit Kucheria <amit.kucheria@linaro.org> Reviewed-by: Bartlomiej Zolnierkiewicz <b.zolnierkie@samsung.com> Signed-off-by: Daniel Lezcano <daniel.lezcano@linaro.org> Link: https://lore.kernel.org/r/20200629122925.21729-8-andrzej.p@collabora.com
This commit is contained in:

committed by
Daniel Lezcano

szülő
ac5d9ecc74
commit
7f4957be0d
@@ -499,7 +499,7 @@ static void acpi_thermal_check(void *data)
|
||||
{
|
||||
struct acpi_thermal *tz = data;
|
||||
|
||||
if (tz->thermal_zone->mode != THERMAL_DEVICE_ENABLED)
|
||||
if (!thermal_zone_device_is_enabled(tz->thermal_zone))
|
||||
return;
|
||||
|
||||
thermal_zone_device_update(tz->thermal_zone,
|
||||
@@ -542,14 +542,11 @@ static int thermal_set_mode(struct thermal_zone_device *thermal,
|
||||
if (mode == THERMAL_DEVICE_DISABLED)
|
||||
pr_warn("thermal zone will be disabled\n");
|
||||
|
||||
if (mode != tz->thermal_zone->mode) {
|
||||
tz->thermal_zone->mode = mode;
|
||||
ACPI_DEBUG_PRINT((ACPI_DB_INFO,
|
||||
"%s kernel ACPI thermal control\n",
|
||||
tz->thermal_zone->mode == THERMAL_DEVICE_ENABLED ?
|
||||
"Enable" : "Disable"));
|
||||
acpi_thermal_check(tz);
|
||||
}
|
||||
ACPI_DEBUG_PRINT((ACPI_DB_INFO,
|
||||
"%s kernel ACPI thermal control\n",
|
||||
mode == THERMAL_DEVICE_ENABLED ?
|
||||
"Enable" : "Disable"));
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -897,13 +894,17 @@ static int acpi_thermal_register_thermal_zone(struct acpi_thermal *tz)
|
||||
goto remove_dev_link;
|
||||
}
|
||||
|
||||
tz->thermal_zone->mode = THERMAL_DEVICE_ENABLED;
|
||||
result = thermal_zone_device_enable(tz->thermal_zone);
|
||||
if (result)
|
||||
goto acpi_bus_detach;
|
||||
|
||||
dev_info(&tz->device->dev, "registered as thermal_zone%d\n",
|
||||
tz->thermal_zone->id);
|
||||
|
||||
return 0;
|
||||
|
||||
acpi_bus_detach:
|
||||
acpi_bus_detach_private_data(tz->device->handle);
|
||||
remove_dev_link:
|
||||
sysfs_remove_link(&tz->thermal_zone->device.kobj, "device");
|
||||
remove_tz_link:
|
||||
|
Reference in New Issue
Block a user