summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRafael J. Wysocki <rafael.j.wysocki@intel.com>2024-10-04 21:33:28 +0200
committerRafael J. Wysocki <rafael.j.wysocki@intel.com>2024-10-22 12:07:47 +0200
commitc4cd42ebd32b57841a0dba4b296692d201802618 (patch)
tree2156b14c0efbc2acf5e647cfa7c3db88cb1b7ec6
parentfa4f9c967969cb04f9a37d567ecd9e1db9e9098f (diff)
thermal: core: Update thermal zones after cooling device binding
If a new cooling device is registered and it is bound to at least one trip point in a given thermal zone, that thermal zone needs to be updated via __thermal_zone_device_update(). Instead of doing this with the help of the need_update atomic field in struct thermal_zone_device, which is not particularly straightforward, make __thermal_zone_cdev_bind() return a bool value indicating whether or not the given thermal zone needs to be updated because a new cooling device has been bound to it and update thermal_zone_cdev_bind() to call __thermal_zone_device_update() when this value is "true". No intentional functional impact. Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com> Link: https://patch.msgid.link/2226302.Icojqenx9y@rjwysocki.net Reviewed-by: Lukasz Luba <lukasz.luba@arm.com>
-rw-r--r--drivers/thermal/thermal_core.c23
1 files changed, 13 insertions, 10 deletions
diff --git a/drivers/thermal/thermal_core.c b/drivers/thermal/thermal_core.c
index 145b43a4dffd..b8c3a9185ae7 100644
--- a/drivers/thermal/thermal_core.c
+++ b/drivers/thermal/thermal_core.c
@@ -935,13 +935,14 @@ void print_bind_err_msg(struct thermal_zone_device *tz,
cdev->type, thermal_zone_trip_id(tz, trip), ret);
}
-static void __thermal_zone_cdev_bind(struct thermal_zone_device *tz,
+static bool __thermal_zone_cdev_bind(struct thermal_zone_device *tz,
struct thermal_cooling_device *cdev)
{
struct thermal_trip_desc *td;
+ bool update_tz = false;
if (!tz->ops.should_bind)
- return;
+ return false;
for_each_trip_desc(tz, td) {
struct thermal_trip *trip = &td->trip;
@@ -956,9 +957,15 @@ static void __thermal_zone_cdev_bind(struct thermal_zone_device *tz,
continue;
ret = thermal_bind_cdev_to_trip(tz, trip, cdev, &c);
- if (ret)
+ if (ret) {
print_bind_err_msg(tz, trip, cdev, ret);
+ continue;
+ }
+
+ update_tz = true;
}
+
+ return update_tz;
}
static void thermal_zone_cdev_bind(struct thermal_zone_device *tz,
@@ -966,7 +973,8 @@ static void thermal_zone_cdev_bind(struct thermal_zone_device *tz,
{
mutex_lock(&tz->lock);
- __thermal_zone_cdev_bind(tz, cdev);
+ if (__thermal_zone_cdev_bind(tz, cdev))
+ __thermal_zone_device_update(tz, THERMAL_EVENT_UNSPECIFIED);
mutex_unlock(&tz->lock);
}
@@ -993,7 +1001,7 @@ __thermal_cooling_device_register(struct device_node *np,
const struct thermal_cooling_device_ops *ops)
{
struct thermal_cooling_device *cdev;
- struct thermal_zone_device *pos = NULL;
+ struct thermal_zone_device *pos;
unsigned long current_state;
int id, ret;
@@ -1069,11 +1077,6 @@ __thermal_cooling_device_register(struct device_node *np,
list_for_each_entry(pos, &thermal_tz_list, node)
thermal_zone_cdev_bind(pos, cdev);
- list_for_each_entry(pos, &thermal_tz_list, node)
- if (atomic_cmpxchg(&pos->need_update, 1, 0))
- thermal_zone_device_update(pos,
- THERMAL_EVENT_UNSPECIFIED);
-
mutex_unlock(&thermal_list_lock);
return cdev;