diff options
author | Michele Di Giorgio <[email protected]> | 2016-05-11 10:49:07 +0100 |
---|---|---|
committer | Zhang Rui <[email protected]> | 2016-05-16 13:21:11 +0800 |
commit | 191b07541fcdd1de1ccc71d00bc28ca5060dd484 (patch) | |
tree | 92a7a40aff62481b8bef2949827287932cb9d1cc | |
parent | 04974df8049fc4240d22759a91e035082ccd18b4 (diff) |
thermal: check validity get_trip_hyst function pointer in bang-bang governor
Bang-bang thermal governor uses trip point hysteresis to make decisions.
Hysteresis is a required property in the device tree for trip points, but it is
an optional thermal zone device operation. Hence, we need to check whether the
function pointer is valid or not.
If it is not available, we assume the hysteresis to be zero. Consequently, a
highly varying temperature will make the governor continuosly switch a cooling
device ON and OFF.
CC: Zhang Rui <[email protected]>
CC: Eduardo Valentin <[email protected]>
CC: Peter Feuerer <[email protected]>
Signed-off-by: Michele Di Giorgio <[email protected]>
Signed-off-by: Zhang Rui <[email protected]>
-rw-r--r-- | drivers/thermal/gov_bang_bang.c | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/drivers/thermal/gov_bang_bang.c b/drivers/thermal/gov_bang_bang.c index 70836c5b89bc..fc52016d4e85 100644 --- a/drivers/thermal/gov_bang_bang.c +++ b/drivers/thermal/gov_bang_bang.c @@ -29,7 +29,13 @@ static void thermal_zone_trip_update(struct thermal_zone_device *tz, int trip) struct thermal_instance *instance; tz->ops->get_trip_temp(tz, trip, &trip_temp); - tz->ops->get_trip_hyst(tz, trip, &trip_hyst); + + 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); dev_dbg(&tz->device, "Trip%d[temp=%d]:temp=%d:hyst=%d\n", trip, trip_temp, tz->temperature, |