Skip to content

Commit

Permalink
thermal: gov_bang_bang: Split bang_bang_control()
Browse files Browse the repository at this point in the history
Move the setting of the thermal instance target state from
bang_bang_control() into a separate function that will be also called
in a different place going forward.

No intentional functional impact.

Signed-off-by: Rafael J. Wysocki <[email protected]>
Acked-by: Peter Kästle <[email protected]>
Reviewed-by: Zhang Rui <[email protected]>
Cc: 6.10+ <[email protected]> # 6.10+
Link: https://patch.msgid.link/[email protected]
  • Loading branch information
rafaeljw committed Aug 16, 2024
1 parent b9b6ee6 commit 84248e3
Showing 1 changed file with 23 additions and 19 deletions.
42 changes: 23 additions & 19 deletions drivers/thermal/gov_bang_bang.c
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,27 @@

#include "thermal_core.h"

static void bang_bang_set_instance_target(struct thermal_instance *instance,
unsigned int target)
{
if (instance->target != 0 && instance->target != 1 &&
instance->target != THERMAL_NO_TARGET)
pr_debug("Unexpected state %ld of thermal instance %s in bang-bang\n",
instance->target, instance->name);

/*
* Enable the fan when the trip is crossed on the way up and disable it
* when the trip is crossed on the way down.
*/
instance->target = target;

dev_dbg(&instance->cdev->device, "target=%ld\n", instance->target);

mutex_lock(&instance->cdev->lock);
__thermal_cdev_update(instance->cdev);
mutex_unlock(&instance->cdev->lock);
}

/**
* bang_bang_control - controls devices associated with the given zone
* @tz: thermal_zone_device
Expand Down Expand Up @@ -54,25 +75,8 @@ static void bang_bang_control(struct thermal_zone_device *tz,
tz->temperature, trip->hysteresis);

list_for_each_entry(instance, &tz->thermal_instances, tz_node) {
if (instance->trip != trip)
continue;

if (instance->target != 0 && instance->target != 1 &&
instance->target != THERMAL_NO_TARGET)
pr_debug("Unexpected state %ld of thermal instance %s in bang-bang\n",
instance->target, instance->name);

/*
* Enable the fan when the trip is crossed on the way up and
* disable it when the trip is crossed on the way down.
*/
instance->target = crossed_up;

dev_dbg(&instance->cdev->device, "target=%ld\n", instance->target);

mutex_lock(&instance->cdev->lock);
__thermal_cdev_update(instance->cdev);
mutex_unlock(&instance->cdev->lock);
if (instance->trip == trip)
bang_bang_set_instance_target(instance, crossed_up);
}
}

Expand Down

0 comments on commit 84248e3

Please sign in to comment.