mirror of
https://github.com/BobTheBlinker/android_kernel_motorola_sm6375.git
synced 2026-10-30 11:41:38 -04:00
Thermal: set upper and lower limits
set upper and lower limits when binding a thermal cooling device to a thermal zone device. Signed-off-by: Zhang Rui <[email protected]> Reviewed-by: Rafael J. Wysocki <[email protected]> Reviewed-by: Eduardo Valentin <[email protected]>
This commit is contained in:
parent
74051ba505
commit
9d99842f99
5 changed files with 65 additions and 28 deletions
|
|
@ -729,11 +729,9 @@ static int thermal_notify(struct thermal_zone_device *thermal, int trip,
|
|||
return 0;
|
||||
}
|
||||
|
||||
typedef int (*cb)(struct thermal_zone_device *, int,
|
||||
struct thermal_cooling_device *);
|
||||
static int acpi_thermal_cooling_device_cb(struct thermal_zone_device *thermal,
|
||||
struct thermal_cooling_device *cdev,
|
||||
cb action)
|
||||
bool bind)
|
||||
{
|
||||
struct acpi_device *device = cdev->devdata;
|
||||
struct acpi_thermal *tz = thermal->devdata;
|
||||
|
|
@ -757,11 +755,19 @@ static int acpi_thermal_cooling_device_cb(struct thermal_zone_device *thermal,
|
|||
i++) {
|
||||
handle = tz->trips.passive.devices.handles[i];
|
||||
status = acpi_bus_get_device(handle, &dev);
|
||||
if (ACPI_SUCCESS(status) && (dev == device)) {
|
||||
result = action(thermal, trip, cdev);
|
||||
if (result)
|
||||
goto failed;
|
||||
}
|
||||
if (ACPI_FAILURE(status) || dev != device)
|
||||
continue;
|
||||
if (bind)
|
||||
result =
|
||||
thermal_zone_bind_cooling_device
|
||||
(thermal, trip, cdev,
|
||||
THERMAL_NO_LIMIT, THERMAL_NO_LIMIT);
|
||||
else
|
||||
result =
|
||||
thermal_zone_unbind_cooling_device
|
||||
(thermal, trip, cdev);
|
||||
if (result)
|
||||
goto failed;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -774,11 +780,17 @@ static int acpi_thermal_cooling_device_cb(struct thermal_zone_device *thermal,
|
|||
j++) {
|
||||
handle = tz->trips.active[i].devices.handles[j];
|
||||
status = acpi_bus_get_device(handle, &dev);
|
||||
if (ACPI_SUCCESS(status) && (dev == device)) {
|
||||
result = action(thermal, trip, cdev);
|
||||
if (result)
|
||||
goto failed;
|
||||
}
|
||||
if (ACPI_FAILURE(status) || dev != device)
|
||||
continue;
|
||||
if (bind)
|
||||
result = thermal_zone_bind_cooling_device
|
||||
(thermal, trip, cdev,
|
||||
THERMAL_NO_LIMIT, THERMAL_NO_LIMIT);
|
||||
else
|
||||
result = thermal_zone_unbind_cooling_device
|
||||
(thermal, trip, cdev);
|
||||
if (result)
|
||||
goto failed;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -786,7 +798,14 @@ static int acpi_thermal_cooling_device_cb(struct thermal_zone_device *thermal,
|
|||
handle = tz->devices.handles[i];
|
||||
status = acpi_bus_get_device(handle, &dev);
|
||||
if (ACPI_SUCCESS(status) && (dev == device)) {
|
||||
result = action(thermal, -1, cdev);
|
||||
if (bind)
|
||||
result = thermal_zone_bind_cooling_device
|
||||
(thermal, -1, cdev,
|
||||
THERMAL_NO_LIMIT,
|
||||
THERMAL_NO_LIMIT);
|
||||
else
|
||||
result = thermal_zone_unbind_cooling_device
|
||||
(thermal, -1, cdev);
|
||||
if (result)
|
||||
goto failed;
|
||||
}
|
||||
|
|
@ -800,16 +819,14 @@ static int
|
|||
acpi_thermal_bind_cooling_device(struct thermal_zone_device *thermal,
|
||||
struct thermal_cooling_device *cdev)
|
||||
{
|
||||
return acpi_thermal_cooling_device_cb(thermal, cdev,
|
||||
thermal_zone_bind_cooling_device);
|
||||
return acpi_thermal_cooling_device_cb(thermal, cdev, true);
|
||||
}
|
||||
|
||||
static int
|
||||
acpi_thermal_unbind_cooling_device(struct thermal_zone_device *thermal,
|
||||
struct thermal_cooling_device *cdev)
|
||||
{
|
||||
return acpi_thermal_cooling_device_cb(thermal, cdev,
|
||||
thermal_zone_unbind_cooling_device);
|
||||
return acpi_thermal_cooling_device_cb(thermal, cdev, false);
|
||||
}
|
||||
|
||||
static const struct thermal_zone_device_ops acpi_thermal_zone_ops = {
|
||||
|
|
|
|||
Loading…
Reference in a new issue