Received: by 2002:ab2:6a05:0:b0:1f8:1780:a4ed with SMTP id w5csp52523lqo; Thu, 9 May 2024 12:18:07 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCU/XssUjSLnoimQ8vcXadf63NGRmahKXbcWdZ5HErq56imQKMwg0LY/1KDF9XqF9N7qfNYtHGFO18Oj5cAqkDZdQDc3xV8j2RGAlv6Kpg== X-Google-Smtp-Source: AGHT+IHukx7dxBvgBO2UEblxymzb4jbDuzDci7aP60NK2PMM5ozlYveia5i+as7wBua18MCNUTBn X-Received: by 2002:a17:906:eb0f:b0:a59:a83b:d437 with SMTP id a640c23a62f3a-a5a2d58a6a8mr29240466b.32.1715282287566; Thu, 09 May 2024 12:18:07 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1715282287; cv=pass; d=google.com; s=arc-20160816; b=RmpPQlaeFU+tjTIJ1YMOTOO/fdOtDuGP/sF6ZpV9nExHmqxeLa3tzB3l5D3EEJhzjg MsWc3lv6HMKeZmtZTL+VBFqJJ2fvABI1btvDC8fu3CSC5oXjbXK/JyCivVwrun7zpO0Z 52h7d2V4td8NfudV2Mj0k0jpdNYa+hKEVSTVHtzGa3SvqSuoNMjITrj3VA7YvpUc/15j 82X8mgFfgDrezDk9TeY3X8sALpoHgtNZ/3ubRM9m7evQAjJqFRFmDFonUYWL14uTDNvC VV+eKYdkCxkFFpfEYOr6WiCLIU8ACjqDfDW/qSYqInzX7sjqX1gxXCzMqc7RJC7qZg27 3EFQ== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature; bh=80ZTdB3U4YvWERC6mbhl5WFJp5YyD08RKJUQdyA9xbY=; fh=HP39+yda0QHsXMT3XaLy3KM419Yj59UqEZWQZo+gOsI=; b=LS9CO+MSwVBKSxZBCyBPRhDcXcNaREUm8s0NCuRtF0V9VyOugCxMHZTUmYfQzksY/y GemC7SC1h+S1oF8W244Ox2eumWhV6BeZGq+InkgPZNTNUU/k5COaP01oKO0u4vSBMz0N V6Y6461HR51uVJlyINBKKEBE7DtM1INbJPpPk6fXmbWv42MQ5N/rxn5fxMpboOYuaYkK 4JTSbbFnSjEimlkqBocFEWOPLg5bOobEEPgmfowPV0i8/eoARwgVTbExr1TllPNBqyIh N42h5tZA4xRFhl3MnyxlcbrSUgXjC8S2ne08NSUxrMoMkTSmyoRzhSRvwodxx/2pN7PY 7Efw==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@rjwysocki.net header.s=dkim header.b=kUmRIt4R; arc=pass (i=1 spf=pass spfdomain=rjwysocki.net dkim=pass dkdomain=rjwysocki.net); spf=pass (google.com: domain of linux-kernel+bounces-174808-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-174808-linux.lists.archive=gmail.com@vger.kernel.org" Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [2604:1380:4601:e00::3]) by mx.google.com with ESMTPS id a640c23a62f3a-a5a17b21f47si115205966b.314.2024.05.09.12.18.07 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 09 May 2024 12:18:07 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-174808-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) client-ip=2604:1380:4601:e00::3; Authentication-Results: mx.google.com; dkim=pass header.i=@rjwysocki.net header.s=dkim header.b=kUmRIt4R; arc=pass (i=1 spf=pass spfdomain=rjwysocki.net dkim=pass dkdomain=rjwysocki.net); spf=pass (google.com: domain of linux-kernel+bounces-174808-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-174808-linux.lists.archive=gmail.com@vger.kernel.org" Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by am.mirrors.kernel.org (Postfix) with ESMTPS id 250961F2255D for ; Thu, 9 May 2024 19:18:07 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 2A5547FBC4; Thu, 9 May 2024 19:17:52 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=rjwysocki.net header.i=@rjwysocki.net header.b="kUmRIt4R" Received: from cloudserver094114.home.pl (cloudserver094114.home.pl [79.96.170.134]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id DE3ED653; Thu, 9 May 2024 19:17:48 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=79.96.170.134 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1715282271; cv=none; b=HTk9RJiV/MUFu4ilKV03PBBmTRqE5x3D0oq7jeNsAe2PKg9HaUDXiwVzuHPGR+ESkV6zqbVVJDtoEEcsNB89C8Z0BSGgdZd6YmmA6bc96ra9gLA+EEHLJ+r68mLe+LpPdz2lFcZXBsHfms+WM820aSNPsvV7J0Knf44WgoNXnfg= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1715282271; c=relaxed/simple; bh=TsOA66Gxd9P6ysQ1zUnV2UVgf3AWyGQEfUnpoMtH47U=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=pTKPQjT/q+iuoegMYV1Feu/QN5LMxOQkqEvfwCaZxMnSfDXIZrndRmf/1SATTAeknptY0n8EUhYVb6DHeZ4Ub9CT0KJr1mAtFUeFrMeq6y+f1wLtIqxwph0SbPn++ktT1En8qEREpFV9T7Wy/oK79FqOqf8h7WjOUlpcSCp7TXE= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=rjwysocki.net; spf=pass smtp.mailfrom=rjwysocki.net; dkim=pass (2048-bit key) header.d=rjwysocki.net header.i=@rjwysocki.net header.b=kUmRIt4R; arc=none smtp.client-ip=79.96.170.134 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=rjwysocki.net Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=rjwysocki.net Received: from localhost (127.0.0.1) (HELO v370.home.net.pl) by /usr/run/smtp (/usr/run/postfix/private/idea_relay_lmtp) via UNIX with SMTP (IdeaSmtpServer 6.0.0) id 99a7b61e84f11913; Thu, 9 May 2024 21:17:41 +0200 Received: from kreacher.localnet (unknown [195.136.19.94]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by cloudserver094114.home.pl (Postfix) with ESMTPSA id CD22BA524E7; Thu, 9 May 2024 21:17:40 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=rjwysocki.net; s=dkim; t=1715282261; bh=TsOA66Gxd9P6ysQ1zUnV2UVgf3AWyGQEfUnpoMtH47U=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=kUmRIt4RYlSxxlAIvKiABrMyj8MMmrFeSsDoBtXDcuTM4hnKpPy7I1+bGhny3Ih+x BuOz+rwk29f6OEwKnel+pERJA1YLxNgpfvxlGzftmyOR+DuXpzb2X8NWx2saQ0qWcc m54skSN48mTpP8Em6n6ewYryZlZ0UaTPFkEVkRzs7JrZrIsFPaCfhuB7un7ZXMA/lp gQUhiJwz3F00hMzXrdqF8D+Zd+jmFAnINTD+U+CKwIL1ewsIjCbfLaqe0IsoPPSkht HOPK05I4I2DDizL7UTUXnmvIGA/+0AMtI10hWkFgBzeEuB1zvrH18cXSG6jJrkRA2a x7WBsWGq5nvPQ== From: "Rafael J. Wysocki" To: Linux PM Cc: LKML , "Rafael J. Wysocki" , Lukasz Luba , Daniel Lezcano Subject: [PATCH v1 7/7] thermal: trip: Use common set of trip type names Date: Thu, 09 May 2024 21:17:25 +0200 Message-ID: <2272195.iZASKD2KPV@kreacher> In-Reply-To: <12438864.O9o76ZdvQC@kreacher> References: <12438864.O9o76ZdvQC@kreacher> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 7Bit Content-Type: text/plain; charset="UTF-8" X-CLIENT-IP: 195.136.19.94 X-CLIENT-HOSTNAME: 195.136.19.94 X-VADE-SPAMSTATE: clean X-VADE-SPAMCAUSE: gggruggvucftvghtrhhoucdtuddrgedvledrvdefvddgudefvdcutefuodetggdotefrodftvfcurfhrohhfihhlvgemucfjqffogffrnfdpggftiffpkfenuceurghilhhouhhtmecuudehtdenucesvcftvggtihhpihgvnhhtshculddquddttddmnecujfgurhephffvvefufffkjghfggfgtgesthfuredttddtjeenucfhrhhomhepfdftrghfrggvlhculfdrucghhihsohgtkhhifdcuoehrjhifsehrjhifhihsohgtkhhirdhnvghtqeenucggtffrrghtthgvrhhnpedvffeuiedtgfdvtddugeeujedtffetteegfeekffdvfedttddtuefhgeefvdejhfenucfkphepudelhedrudefiedrudelrdelgeenucevlhhushhtvghrufhiiigvpedtnecurfgrrhgrmhepihhnvghtpeduleehrddufeeirdduledrleegpdhhvghlohepkhhrvggrtghhvghrrdhlohgtrghlnhgvthdpmhgrihhlfhhrohhmpedftfgrfhgrvghlucflrdcuhgihshhotghkihdfuceorhhjfiesrhhjfiihshhotghkihdrnhgvtheqpdhnsggprhgtphhtthhopeehpdhrtghpthhtoheplhhinhhugidqphhmsehvghgvrhdrkhgvrhhnvghlrdhorhhgpdhrtghpthhtoheplhhinhhugidqkhgvrhhnvghlsehvghgvrhdrkhgvrhhnvghlrdhorhhgpdhrtghpthhtoheprhgrfhgrvghlsehkvghrnhgvlhdrohhrghdprhgtphhtthhopehluhhkrghsiidrlhhusggrsegrrhhmrdgtohhmpdhrtghpthhtohepuggrnhhivghlrdhlvgii tggrnhhosehlihhnrghrohdrohhrgh X-DCC--Metrics: v370.home.net.pl 1024; Body=5 Fuz1=5 Fuz2=5 From: Rafael J. Wysocki 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 --- 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,