Skip to content

Commit 8b95bed

Browse files
committed
thermal/debugfs: Use helper to update trip point overstepping duration
Add a helper for updating trip point overstepping duration to be called from thermal_debug_tz_trip_down(). Subsequently, it will also be used during resume from system-wide suspend. No intentional functional impact. Signed-off-by: Rafael J. Wysocki <[email protected]> Acked-by: Daniel Lezcano <[email protected]>
1 parent b684682 commit 8b95bed

File tree

1 file changed

+13
-9
lines changed

1 file changed

+13
-9
lines changed

drivers/thermal/thermal_debugfs.c

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -653,14 +653,24 @@ void thermal_debug_tz_trip_up(struct thermal_zone_device *tz,
653653
mutex_unlock(&thermal_dbg->lock);
654654
}
655655

656+
static void tz_episode_close_trip(struct tz_episode *tze, int trip_id, ktime_t now)
657+
{
658+
struct trip_stats *trip_stats = &tze->trip_stats[trip_id];
659+
ktime_t delta = ktime_sub(now, trip_stats->timestamp);
660+
661+
trip_stats->duration = ktime_add(delta, trip_stats->duration);
662+
/* Mark the end of mitigation for this trip point. */
663+
trip_stats->timestamp = KTIME_MAX;
664+
}
665+
656666
void thermal_debug_tz_trip_down(struct thermal_zone_device *tz,
657667
const struct thermal_trip *trip)
658668
{
659669
struct thermal_debugfs *thermal_dbg = tz->debugfs;
670+
int trip_id = thermal_zone_trip_id(tz, trip);
671+
ktime_t now = ktime_get();
660672
struct tz_episode *tze;
661673
struct tz_debugfs *tz_dbg;
662-
ktime_t delta, now = ktime_get();
663-
int trip_id = thermal_zone_trip_id(tz, trip);
664674
int i;
665675

666676
if (!thermal_dbg)
@@ -695,13 +705,7 @@ void thermal_debug_tz_trip_down(struct thermal_zone_device *tz,
695705

696706
tze = list_first_entry(&tz_dbg->tz_episodes, struct tz_episode, node);
697707

698-
delta = ktime_sub(now, tze->trip_stats[trip_id].timestamp);
699-
700-
tze->trip_stats[trip_id].duration =
701-
ktime_add(delta, tze->trip_stats[trip_id].duration);
702-
703-
/* Mark the end of mitigation for this trip point. */
704-
tze->trip_stats[trip_id].timestamp = KTIME_MAX;
708+
tz_episode_close_trip(tze, trip_id, now);
705709

706710
/*
707711
* This event closes the mitigation as we are crossing the

0 commit comments

Comments
 (0)