diff options
Diffstat (limited to 'drivers/acpi/thermal.c')
-rw-r--r-- | drivers/acpi/thermal.c | 42 |
1 files changed, 23 insertions, 19 deletions
diff --git a/drivers/acpi/thermal.c b/drivers/acpi/thermal.c index 383c7029d3ce..7a85eff590d8 100644 --- a/drivers/acpi/thermal.c +++ b/drivers/acpi/thermal.c @@ -171,7 +171,7 @@ struct acpi_thermal { struct acpi_thermal_trips trips; struct acpi_handle_list devices; struct thermal_zone_device *thermal_zone; - int tz_enabled; + enum thermal_device_mode mode; int kelvin_offset; struct work_struct thermal_check_work; struct mutex thermal_check_lock; @@ -496,6 +496,17 @@ static int acpi_thermal_get_trip_points(struct acpi_thermal *tz) return 0; } +static void acpi_thermal_check(void *data) +{ + struct acpi_thermal *tz = data; + + if (tz->mode != THERMAL_DEVICE_ENABLED) + return; + + thermal_zone_device_update(tz->thermal_zone, + THERMAL_EVENT_UNSPECIFIED); +} + /* sys I/F for generic thermal sysfs support */ static int thermal_get_temp(struct thermal_zone_device *thermal, int *temp) @@ -523,8 +534,7 @@ static int thermal_get_mode(struct thermal_zone_device *thermal, if (!tz) return -EINVAL; - *mode = tz->tz_enabled ? THERMAL_DEVICE_ENABLED : - THERMAL_DEVICE_DISABLED; + *mode = tz->mode; return 0; } @@ -535,28 +545,26 @@ static int thermal_set_mode(struct thermal_zone_device *thermal, enum thermal_device_mode mode) { struct acpi_thermal *tz = thermal->devdata; - int enable; if (!tz) return -EINVAL; + if (mode != THERMAL_DEVICE_DISABLED && + mode != THERMAL_DEVICE_ENABLED) + return -EINVAL; /* * enable/disable thermal management from ACPI thermal driver */ - if (mode == THERMAL_DEVICE_ENABLED) - enable = 1; - else if (mode == THERMAL_DEVICE_DISABLED) { - enable = 0; + if (mode == THERMAL_DEVICE_DISABLED) pr_warn("thermal zone will be disabled\n"); - } else - return -EINVAL; - if (enable != tz->tz_enabled) { - tz->tz_enabled = enable; + if (mode != tz->mode) { + tz->mode = mode; ACPI_DEBUG_PRINT((ACPI_DB_INFO, "%s kernel ACPI thermal control\n", - tz->tz_enabled ? "Enable" : "Disable")); - acpi_thermal_check_fn(&tz->thermal_check_work); + tz->mode == THERMAL_DEVICE_ENABLED ? + "Enable" : "Disable")); + acpi_thermal_check(tz); } return 0; } @@ -904,7 +912,7 @@ static int acpi_thermal_register_thermal_zone(struct acpi_thermal *tz) if (ACPI_FAILURE(status)) return -ENODEV; - tz->tz_enabled = 1; + tz->mode = THERMAL_DEVICE_ENABLED; dev_info(&tz->device->dev, "registered as thermal_zone%d\n", tz->thermal_zone->id); @@ -1052,8 +1060,6 @@ static void acpi_thermal_check_fn(struct work_struct *work) struct acpi_thermal *tz = container_of(work, struct acpi_thermal, thermal_check_work); - if (!tz->tz_enabled) - return; /* * In general, it is not sufficient to check the pending bit, because * subsequent instances of this function may be queued after one of them @@ -1153,8 +1159,6 @@ static int acpi_thermal_resume(struct device *dev) return -EINVAL; for (i = 0; i < ACPI_THERMAL_MAX_ACTIVE; i++) { - if (!(&tz->trips.active[i])) - break; if (!tz->trips.active[i].flags.valid) break; tz->trips.active[i].flags.enabled = 1; |