Skip to content

Commit fe03626

Browse files
committed
thermal: gov_step_wise: Clean up thermal_zone_trip_update()
Do some assorted cleanups in thermal_zone_trip_update(): * Compute the trend value upfront. * Move old_target definition to the block where it is used. * Adjust white space around diagnostic messages and locking. * Use suitable field formatting in a message to avoid an explicit cast to int. Signed-off-by: Rafael J. Wysocki <[email protected]> Reviewed-by: Lukasz Luba <[email protected]>
1 parent e4065f1 commit fe03626

File tree

1 file changed

+7
-6
lines changed

1 file changed

+7
-6
lines changed

drivers/thermal/gov_step_wise.c

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -65,13 +65,10 @@ static void thermal_zone_trip_update(struct thermal_zone_device *tz,
6565
const struct thermal_trip *trip,
6666
int trip_threshold)
6767
{
68+
enum thermal_trend trend = get_tz_trend(tz, trip);
6869
int trip_id = thermal_zone_trip_id(tz, trip);
69-
enum thermal_trend trend;
7070
struct thermal_instance *instance;
7171
bool throttle = false;
72-
int old_target;
73-
74-
trend = get_tz_trend(tz, trip);
7572

7673
if (tz->temperature >= trip_threshold) {
7774
throttle = true;
@@ -82,13 +79,16 @@ static void thermal_zone_trip_update(struct thermal_zone_device *tz,
8279
trip_id, trip->type, trip_threshold, trend, throttle);
8380

8481
list_for_each_entry(instance, &tz->thermal_instances, tz_node) {
82+
int old_target;
83+
8584
if (instance->trip != trip)
8685
continue;
8786

8887
old_target = instance->target;
8988
instance->target = get_target_state(instance, trend, throttle);
90-
dev_dbg(&instance->cdev->device, "old_target=%d, target=%d\n",
91-
old_target, (int)instance->target);
89+
90+
dev_dbg(&instance->cdev->device, "old_target=%d, target=%ld\n",
91+
old_target, instance->target);
9292

9393
if (instance->initialized && old_target == instance->target)
9494
continue;
@@ -104,6 +104,7 @@ static void thermal_zone_trip_update(struct thermal_zone_device *tz,
104104
}
105105

106106
instance->initialized = true;
107+
107108
mutex_lock(&instance->cdev->lock);
108109
instance->cdev->updated = false; /* cdev needs update */
109110
mutex_unlock(&instance->cdev->lock);

0 commit comments

Comments
 (0)