summaryrefslogtreecommitdiff
path: root/drivers/thermal/thermal_core.c
diff options
context:
space:
mode:
authorDaniel Lezcano <daniel.lezcano@linaro.org>2023-01-23 18:27:56 +0300
committerRafael J. Wysocki <rafael.j.wysocki@intel.com>2023-01-25 18:40:39 +0300
commit5b8de18ee9027c647db4c1905f7fd0550d17d67a (patch)
tree4c2d9299e7cbc912759f89ba3eb9840f01116de6 /drivers/thermal/thermal_core.c
parentb57d62862d171e402fca649882f0fec4e25bd312 (diff)
downloadlinux-5b8de18ee9027c647db4c1905f7fd0550d17d67a.tar.xz
thermal/core: Move the thermal trip code to a dedicated file
The thermal_core.c files contains a lot of functions handling different thermal components like the governors, the trip points, the cooling device, the OF cooling device, etc ... This organization does not help to migrate to a more sane code where there is a better self-encapsulation as all the components' internals can be directly accessed from a single file. For the sake of clarity, let's move the thermal trip points code in a dedicated thermal_trip.c file and add a function to browse all the trip points like we do with the thermal zones, the govenors and the cooling devices. The same can be done for the cooling devices and the governor code but that will come later as the current work in the thermal framework is to fix the trip point handling and use a generic trip point structure. No functional changes intended. Signed-off-by: Daniel Lezcano <daniel.lezcano@linaro.org> Reviewed-by: Zhang Rui <rui.zhang@intel.com> Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
Diffstat (limited to 'drivers/thermal/thermal_core.c')
-rw-r--r--drivers/thermal/thermal_core.c87
1 files changed, 0 insertions, 87 deletions
diff --git a/drivers/thermal/thermal_core.c b/drivers/thermal/thermal_core.c
index 99869e9dd68e..2f6ecb7be8de 100644
--- a/drivers/thermal/thermal_core.c
+++ b/drivers/thermal/thermal_core.c
@@ -1156,12 +1156,6 @@ static void thermal_set_delay_jiffies(unsigned long *delay_jiffies, int delay_ms
*delay_jiffies = round_jiffies(*delay_jiffies);
}
-int thermal_zone_get_num_trips(struct thermal_zone_device *tz)
-{
- return tz->num_trips;
-}
-EXPORT_SYMBOL_GPL(thermal_zone_get_num_trips);
-
int thermal_zone_get_crit_temp(struct thermal_zone_device *tz, int *temp)
{
int i, ret = -EINVAL;
@@ -1188,87 +1182,6 @@ int thermal_zone_get_crit_temp(struct thermal_zone_device *tz, int *temp)
}
EXPORT_SYMBOL_GPL(thermal_zone_get_crit_temp);
-int __thermal_zone_get_trip(struct thermal_zone_device *tz, int trip_id,
- struct thermal_trip *trip)
-{
- int ret;
-
- if (!tz || trip_id < 0 || trip_id >= tz->num_trips || !trip)
- return -EINVAL;
-
- if (tz->trips) {
- *trip = tz->trips[trip_id];
- return 0;
- }
-
- if (tz->ops->get_trip_hyst) {
- ret = tz->ops->get_trip_hyst(tz, trip_id, &trip->hysteresis);
- if (ret)
- return ret;
- } else {
- trip->hysteresis = 0;
- }
-
- ret = tz->ops->get_trip_temp(tz, trip_id, &trip->temperature);
- if (ret)
- return ret;
-
- return tz->ops->get_trip_type(tz, trip_id, &trip->type);
-}
-EXPORT_SYMBOL_GPL(__thermal_zone_get_trip);
-
-int thermal_zone_get_trip(struct thermal_zone_device *tz, int trip_id,
- struct thermal_trip *trip)
-{
- int ret;
-
- mutex_lock(&tz->lock);
- ret = __thermal_zone_get_trip(tz, trip_id, trip);
- mutex_unlock(&tz->lock);
-
- return ret;
-}
-EXPORT_SYMBOL_GPL(thermal_zone_get_trip);
-
-int thermal_zone_set_trip(struct thermal_zone_device *tz, int trip_id,
- const struct thermal_trip *trip)
-{
- struct thermal_trip t;
- int ret;
-
- if (!tz->ops->set_trip_temp && !tz->ops->set_trip_hyst && !tz->trips)
- return -EINVAL;
-
- ret = __thermal_zone_get_trip(tz, trip_id, &t);
- if (ret)
- return ret;
-
- if (t.type != trip->type)
- return -EINVAL;
-
- if (t.temperature != trip->temperature && tz->ops->set_trip_temp) {
- ret = tz->ops->set_trip_temp(tz, trip_id, trip->temperature);
- if (ret)
- return ret;
- }
-
- if (t.hysteresis != trip->hysteresis && tz->ops->set_trip_hyst) {
- ret = tz->ops->set_trip_hyst(tz, trip_id, trip->hysteresis);
- if (ret)
- return ret;
- }
-
- if (tz->trips && (t.temperature != trip->temperature || t.hysteresis != trip->hysteresis))
- tz->trips[trip_id] = *trip;
-
- thermal_notify_tz_trip_change(tz->id, trip_id, trip->type,
- trip->temperature, trip->hysteresis);
-
- __thermal_zone_device_update(tz, THERMAL_TRIP_CHANGED);
-
- return 0;
-}
-
/**
* thermal_zone_device_register_with_trips() - register a new thermal zone device
* @type: the thermal zone device type