Skip to content
This repository was archived by the owner on Nov 8, 2023. It is now read-only.

Commit f41f23b

Browse files
committed
thermal: trip: Use common set of trip type names
Use the same set of trip type names in sysfs and in the thermal debug code output. No intentional functional impact. Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com> Acked-by: Daniel Lezcano <daniel.lezcano@linaro.org>
1 parent 8f9025b commit f41f23b

File tree

4 files changed

+19
-21
lines changed

4 files changed

+19
-21
lines changed

drivers/thermal/thermal_core.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -240,6 +240,8 @@ void thermal_governor_update_tz(struct thermal_zone_device *tz,
240240
#define trip_to_trip_desc(__trip) \
241241
container_of(__trip, struct thermal_trip_desc, trip)
242242

243+
const char *thermal_trip_type_name(enum thermal_trip_type trip_type);
244+
243245
void __thermal_zone_set_trips(struct thermal_zone_device *tz);
244246
int thermal_zone_trip_id(const struct thermal_zone_device *tz,
245247
const struct thermal_trip *trip);

drivers/thermal/thermal_debugfs.c

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -784,7 +784,6 @@ static int tze_seq_show(struct seq_file *s, void *v)
784784
struct thermal_zone_device *tz = thermal_dbg->tz_dbg.tz;
785785
struct thermal_trip_desc *td;
786786
struct tz_episode *tze;
787-
const char *type;
788787
u64 duration_ms;
789788
int trip_id;
790789
char c;
@@ -824,13 +823,6 @@ static int tze_seq_show(struct seq_file *s, void *v)
824823
if (trip_stats->trip_temp == THERMAL_TEMP_INVALID)
825824
continue;
826825

827-
if (trip->type == THERMAL_TRIP_PASSIVE)
828-
type = "passive";
829-
else if (trip->type == THERMAL_TRIP_ACTIVE)
830-
type = "active";
831-
else
832-
type = "hot";
833-
834826
if (trip_stats->timestamp != KTIME_MAX) {
835827
/* Mitigation in progress. */
836828
ktime_t delta = ktime_sub(ktime_get(),
@@ -846,7 +838,7 @@ static int tze_seq_show(struct seq_file *s, void *v)
846838

847839
seq_printf(s, "| %*d | %*s | %*d | %*d | %c%*lld | %*d | %*d |\n",
848840
4 , trip_id,
849-
8, type,
841+
8, thermal_trip_type_name(trip->type),
850842
9, trip_stats->trip_temp,
851843
9, trip_stats->trip_hyst,
852844
c, 11, duration_ms,

drivers/thermal/thermal_sysfs.c

Lines changed: 1 addition & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -88,18 +88,7 @@ trip_point_type_show(struct device *dev, struct device_attribute *attr,
8888
if (sscanf(attr->attr.name, "trip_point_%d_type", &trip_id) != 1)
8989
return -EINVAL;
9090

91-
switch (tz->trips[trip_id].trip.type) {
92-
case THERMAL_TRIP_CRITICAL:
93-
return sprintf(buf, "critical\n");
94-
case THERMAL_TRIP_HOT:
95-
return sprintf(buf, "hot\n");
96-
case THERMAL_TRIP_PASSIVE:
97-
return sprintf(buf, "passive\n");
98-
case THERMAL_TRIP_ACTIVE:
99-
return sprintf(buf, "active\n");
100-
default:
101-
return sprintf(buf, "unknown\n");
102-
}
91+
return sprintf(buf, "%s\n", thermal_trip_type_name(tz->trips[trip_id].trip.type));
10392
}
10493

10594
static ssize_t

drivers/thermal/thermal_trip.c

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,21 @@
99
*/
1010
#include "thermal_core.h"
1111

12+
static const char *trip_type_names[] = {
13+
[THERMAL_TRIP_ACTIVE] = "active",
14+
[THERMAL_TRIP_PASSIVE] = "passive",
15+
[THERMAL_TRIP_HOT] = "hot",
16+
[THERMAL_TRIP_CRITICAL] = "critical",
17+
};
18+
19+
const char *thermal_trip_type_name(enum thermal_trip_type trip_type)
20+
{
21+
if (trip_type < THERMAL_TRIP_ACTIVE || trip_type > THERMAL_TRIP_CRITICAL)
22+
return "unknown";
23+
24+
return trip_type_names[trip_type];
25+
}
26+
1227
int for_each_thermal_trip(struct thermal_zone_device *tz,
1328
int (*cb)(struct thermal_trip *, void *),
1429
void *data)

0 commit comments

Comments
 (0)