summaryrefslogtreecommitdiff
path: root/drivers/acpi/thermal.c
diff options
context:
space:
mode:
authorZhang Rui <rui.zhang@intel.com>2012-06-26 16:35:57 +0800
committerSimone Willett <swillett@nvidia.com>2012-11-01 10:56:05 -0700
commit98f80ef93c8634f01ead9e78a8d058c0f7d0ad89 (patch)
treee961afe2581dc06984c6141b4272d25e06aa1e14 /drivers/acpi/thermal.c
parentc1c9df75dfb891cae7e1e023fa7419b97844e13c (diff)
Thermal: set upper and lower limits
set upper and lower limits when binding a thermal cooling device to a thermal zone device. bug 1059470 Change-Id: I90f4c79fa2af79896cb93a528fb4e4263f02587c Signed-off-by: Joshua Primero <jprimero@nvidia.com> Signed-off-by: Zhang Rui <rui.zhang@intel.com> Reviewed-by: Rafael J. Wysocki <rjw@sisk.pl> Reviewed-by: Eduardo Valentin <eduardo.valentin@ti.com> Reviewed-on: http://git-master/r/159962 Reviewed-by: Automatic_Commit_Validation_User Reviewed-by: Diwakar Tundlam <dtundlam@nvidia.com>
Diffstat (limited to 'drivers/acpi/thermal.c')
-rw-r--r--drivers/acpi/thermal.c53
1 files changed, 35 insertions, 18 deletions
diff --git a/drivers/acpi/thermal.c b/drivers/acpi/thermal.c
index 8275e7b06962..b48ec3e34e26 100644
--- a/drivers/acpi/thermal.c
+++ b/drivers/acpi/thermal.c
@@ -727,11 +727,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;
@@ -755,11 +753,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;
}
}
@@ -772,11 +778,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;
}
}
@@ -784,7 +796,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;
}
@@ -798,16 +817,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 = {