summaryrefslogtreecommitdiff
path: root/drivers/thermal/gov_bang_bang.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/thermal/gov_bang_bang.c')
-rw-r--r--drivers/thermal/gov_bang_bang.c37
1 files changed, 22 insertions, 15 deletions
diff --git a/drivers/thermal/gov_bang_bang.c b/drivers/thermal/gov_bang_bang.c
index a08bbe33be96..1b121066521f 100644
--- a/drivers/thermal/gov_bang_bang.c
+++ b/drivers/thermal/gov_bang_bang.c
@@ -13,26 +13,28 @@
#include "thermal_core.h"
-static void thermal_zone_trip_update(struct thermal_zone_device *tz, int trip)
+static int thermal_zone_trip_update(struct thermal_zone_device *tz, int trip_id)
{
- int trip_temp, trip_hyst;
+ struct thermal_trip trip;
struct thermal_instance *instance;
+ int ret;
- tz->ops->get_trip_temp(tz, trip, &trip_temp);
+ ret = __thermal_zone_get_trip(tz, trip_id, &trip);
+ if (ret) {
+ pr_warn_once("Failed to retrieve trip point %d\n", trip_id);
+ return ret;
+ }
- if (!tz->ops->get_trip_hyst) {
- pr_warn_once("Undefined get_trip_hyst for thermal zone %s - "
- "running with default hysteresis zero\n", tz->type);
- trip_hyst = 0;
- } else
- tz->ops->get_trip_hyst(tz, trip, &trip_hyst);
+ if (!trip.hysteresis)
+ dev_info_once(&tz->device,
+ "Zero hysteresis value for thermal zone %s\n", tz->type);
dev_dbg(&tz->device, "Trip%d[temp=%d]:temp=%d:hyst=%d\n",
- trip, trip_temp, tz->temperature,
- trip_hyst);
+ trip_id, trip.temperature, tz->temperature,
+ trip.hysteresis);
list_for_each_entry(instance, &tz->thermal_instances, tz_node) {
- if (instance->trip != trip)
+ if (instance->trip != trip_id)
continue;
/* in case fan is in initial state, switch the fan off */
@@ -50,10 +52,10 @@ static void thermal_zone_trip_update(struct thermal_zone_device *tz, int trip)
* enable fan when temperature exceeds trip_temp and disable
* the fan in case it falls below trip_temp minus hysteresis
*/
- if (instance->target == 0 && tz->temperature >= trip_temp)
+ if (instance->target == 0 && tz->temperature >= trip.temperature)
instance->target = 1;
else if (instance->target == 1 &&
- tz->temperature <= trip_temp - trip_hyst)
+ tz->temperature <= trip.temperature - trip.hysteresis)
instance->target = 0;
dev_dbg(&instance->cdev->device, "target=%d\n",
@@ -63,6 +65,8 @@ static void thermal_zone_trip_update(struct thermal_zone_device *tz, int trip)
instance->cdev->updated = false; /* cdev needs update */
mutex_unlock(&instance->cdev->lock);
}
+
+ return 0;
}
/**
@@ -95,10 +99,13 @@ static void thermal_zone_trip_update(struct thermal_zone_device *tz, int trip)
static int bang_bang_control(struct thermal_zone_device *tz, int trip)
{
struct thermal_instance *instance;
+ int ret;
lockdep_assert_held(&tz->lock);
- thermal_zone_trip_update(tz, trip);
+ ret = thermal_zone_trip_update(tz, trip);
+ if (ret)
+ return ret;
list_for_each_entry(instance, &tz->thermal_instances, tz_node)
thermal_cdev_update(instance->cdev);