From: "Rafael J. Wysocki" <rjw@rjwysocki.net>
To: Linux PM <linux-pm@vger.kernel.org>
Cc: LKML <linux-kernel@vger.kernel.org>,
"Rafael J. Wysocki" <rafael@kernel.org>,
Lukasz Luba <lukasz.luba@arm.com>,
Daniel Lezcano <daniel.lezcano@linaro.org>
Subject: [PATCH v1 7/7] thermal: trip: Use common set of trip type names
Date: Thu, 09 May 2024 21:17:25 +0200 [thread overview]
Message-ID: <2272195.iZASKD2KPV@kreacher> (raw)
In-Reply-To: <12438864.O9o76ZdvQC@kreacher>
From: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
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>
---
drivers/thermal/thermal_core.h | 2 ++
drivers/thermal/thermal_debugfs.c | 10 +---------
drivers/thermal/thermal_sysfs.c | 13 +------------
drivers/thermal/thermal_trip.c | 15 +++++++++++++++
4 files changed, 19 insertions(+), 21 deletions(-)
Index: linux-pm/drivers/thermal/thermal_trip.c
===================================================================
--- linux-pm.orig/drivers/thermal/thermal_trip.c
+++ linux-pm/drivers/thermal/thermal_trip.c
@@ -9,6 +9,21 @@
*/
#include "thermal_core.h"
+static const char *trip_type_names[] = {
+ [THERMAL_TRIP_ACTIVE] = "active",
+ [THERMAL_TRIP_PASSIVE] = "passive",
+ [THERMAL_TRIP_HOT] = "hot",
+ [THERMAL_TRIP_CRITICAL] = "critical",
+};
+
+const char *thermal_trip_type_name(enum thermal_trip_type trip_type)
+{
+ if (trip_type < THERMAL_TRIP_ACTIVE || trip_type > THERMAL_TRIP_CRITICAL)
+ return "unknown";
+
+ return trip_type_names[trip_type];
+}
+
int for_each_thermal_trip(struct thermal_zone_device *tz,
int (*cb)(struct thermal_trip *, void *),
void *data)
Index: linux-pm/drivers/thermal/thermal_core.h
===================================================================
--- linux-pm.orig/drivers/thermal/thermal_core.h
+++ linux-pm/drivers/thermal/thermal_core.h
@@ -240,6 +240,8 @@ void thermal_governor_update_tz(struct t
#define trip_to_trip_desc(__trip) \
container_of(__trip, struct thermal_trip_desc, trip)
+const char *thermal_trip_type_name(enum thermal_trip_type trip_type);
+
void __thermal_zone_set_trips(struct thermal_zone_device *tz);
int thermal_zone_trip_id(const struct thermal_zone_device *tz,
const struct thermal_trip *trip);
Index: linux-pm/drivers/thermal/thermal_sysfs.c
===================================================================
--- linux-pm.orig/drivers/thermal/thermal_sysfs.c
+++ linux-pm/drivers/thermal/thermal_sysfs.c
@@ -88,18 +88,7 @@ trip_point_type_show(struct device *dev,
if (sscanf(attr->attr.name, "trip_point_%d_type", &trip_id) != 1)
return -EINVAL;
- switch (tz->trips[trip_id].trip.type) {
- case THERMAL_TRIP_CRITICAL:
- return sprintf(buf, "critical\n");
- case THERMAL_TRIP_HOT:
- return sprintf(buf, "hot\n");
- case THERMAL_TRIP_PASSIVE:
- return sprintf(buf, "passive\n");
- case THERMAL_TRIP_ACTIVE:
- return sprintf(buf, "active\n");
- default:
- return sprintf(buf, "unknown\n");
- }
+ return sprintf(buf, "%s\n", thermal_trip_type_name(tz->trips[trip_id].trip.type));
}
static ssize_t
Index: linux-pm/drivers/thermal/thermal_debugfs.c
===================================================================
--- linux-pm.orig/drivers/thermal/thermal_debugfs.c
+++ linux-pm/drivers/thermal/thermal_debugfs.c
@@ -774,7 +774,6 @@ static int tze_seq_show(struct seq_file
struct thermal_zone_device *tz = thermal_dbg->tz_dbg.tz;
struct thermal_trip_desc *td;
struct tz_episode *tze;
- const char *type;
u64 duration_ms;
int trip_id;
char c;
@@ -818,13 +817,6 @@ static int tze_seq_show(struct seq_file
if (trip_stats->min == INT_MAX)
continue;
- if (trip->type == THERMAL_TRIP_PASSIVE)
- type = "passive";
- else if (trip->type == THERMAL_TRIP_ACTIVE)
- type = "active";
- else
- type = "hot";
-
if (trip_stats->timestamp != KTIME_MAX) {
/* Mitigation in progress. */
ktime_t delta = ktime_sub(ktime_get(),
@@ -840,7 +832,7 @@ static int tze_seq_show(struct seq_file
seq_printf(s, "| %*d | %*s | %*d | %*d | %c%*lld | %*d | %*d |\n",
4 , trip_id,
- 8, type,
+ 8, thermal_trip_type_name(trip->type),
9, trip->temperature,
9, trip->hysteresis,
c, 11, duration_ms,
prev parent reply other threads:[~2024-05-09 19:17 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-05-09 19:02 [PATCH v1 0/7] thermal/debugfs: Assorted improvements for the 6.11 cycle Rafael J. Wysocki
2024-05-09 19:09 ` [PATCH v1 1/7] thermal/debugfs: Use helper to update trip point overstepping duration Rafael J. Wysocki
2024-05-09 19:12 ` [PATCH v1 2/7] thermal/debugfs: Do not extend mitigation episodes beyond system resume Rafael J. Wysocki
2024-05-09 19:13 ` [PATCH v1 3/7] thermal/debugfs: Print mitigation timestamp value in milliseconds Rafael J. Wysocki
2024-05-09 19:14 ` [PATCH v1 4/7] thermal/debugfs: Fix up units in "mitigations" files Rafael J. Wysocki
2024-05-09 19:15 ` [PATCH v1 5/7] thermal/debugfs: Compute maximum temperature for mitigation episode as a whole Rafael J. Wysocki
2024-05-09 19:16 ` [PATCH v1 6/7] thermal/debugfs: Move some statements from under thermal_dbg->lock Rafael J. Wysocki
2024-05-09 19:17 ` Rafael J. Wysocki [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=2272195.iZASKD2KPV@kreacher \
--to=rjw@rjwysocki.net \
--cc=daniel.lezcano@linaro.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-pm@vger.kernel.org \
--cc=lukasz.luba@arm.com \
--cc=rafael@kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).