On Mon, Sep 26, 2022 at 4:06 PM Daniel Lezcano
<daniel.lezcano@xxxxxxxxxx> wrote:
The governors are using the ops->get_trip_* functions, Replace these
calls with thermal_zone_get_trip().
Signed-off-by: Daniel Lezcano <daniel.lezcano@xxxxxxxxxx>
Reviewed-by: Zhang Rui <rui.zhang@xxxxxxxxx>
Reviewed-by: Lukasz Luba <lukasz.luba@xxxxxxx> # IPA
---
drivers/thermal/gov_bang_bang.c | 29 ++++++++-------
drivers/thermal/gov_fair_share.c | 18 ++++------
drivers/thermal/gov_power_allocator.c | 51 ++++++++++++---------------
drivers/thermal/gov_step_wise.c | 22 ++++++------
4 files changed, 53 insertions(+), 67 deletions(-)
diff --git a/drivers/thermal/gov_bang_bang.c b/drivers/thermal/gov_bang_bang.c
index a08bbe33be96..f5b85e5ea707 100644
--- a/drivers/thermal/gov_bang_bang.c
+++ b/drivers/thermal/gov_bang_bang.c
@@ -13,26 +13,25 @@
#include "thermal_core.h"
-static void thermal_zone_trip_update(struct thermal_zone_device *tz, int trip)
+static void 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);
-
- 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);
+ ret = __thermal_zone_get_trip(tz, trip_id, &trip);
+ if (ret)
+ pr_warn_once("Failed to retrieve trip point %d\n", trip_id);
Does it even make sense to continue beyond this point if ret is nonzero?
All of the contents of trip can be garbage then AFAICS.
+
+ if (!trip.hysteresis)
+ pr_warn_once("Zero hysteresis value for thermal zone %s\n", tz->type);
Why do you want to warn about this? Haven't we declared already that
zero hysteresis is valid and normal?
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 */