mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Daniel Schaefer via B4 Relay <devnull+dhs.frame.work@kernel.org>
To: "Thomas Weißschuh" <linux@weissschuh.net>,
	"Guenter Roeck" <linux@roeck-us.net>,
	"Benson Leung" <bleung@chromium.org>
Cc: Guenter Roeck <groeck@chromium.org>,
	chrome-platform@lists.linux.dev,  linux-hwmon@vger.kernel.org,
	linux-kernel@vger.kernel.org,  Tzung-Bi Shih <tzungbi@kernel.org>,
	linux@frame.work,  Daniel Schaefer <dhs@frame.work>
Subject: [PATCH] hwmon: (cros_ec): Hide unconfigured temperature thresholds
Date: Wed, 29 Jul 2026 00:38:16 +0800	[thread overview]
Message-ID: <20260729-crosec-hwmon-warn-default-v1-1-d1eb39656a60@frame.work> (raw)

From: Daniel Schaefer <dhs@frame.work>

The EC reports a threshold of 0 K for host thresholds that are not
configured. Most Framework Computer systems don't use all thresholds.
E.g. temp_host_warn is left unset and stays at its -273 C / 0 K
default), see the EC code in zephyr/shim/src/thermal.c:

  DT_PROP_OR(node_id, temp_host_warn,  -273)

Previously these unconfigured thresholds were exposed as sysfs limits
that read back as -273.15 C, which userspace (e.g. s-tui) interpreted as
a real, permanently-exceeded limit.

To avoid this we can hide the sysfs attribute for that threshold.
See truncated example below.

Before:

> sensors cros_ec-isa-000c
cpu_f75303@4d:       +36.9°C  (crit = +74.8°C, emerg = +84.8°C)

After:

> sensors cros_ec-isa-000c
cpu_f75303@4d:       +36.9°C  (high = -273.1°C, crit = +74.8°C)
                              (emerg = +84.8°C)

Cc: Tzung-Bi Shih <tzungbi@kernel.org>
Cc: Thomas Weißschuh <linux@weissschuh.net>
Cc: linux@frame.work
Signed-off-by: Daniel Schaefer <dhs@frame.work>
---
 drivers/hwmon/cros_ec_hwmon.c | 14 ++++++++++++--
 1 file changed, 12 insertions(+), 2 deletions(-)

diff --git a/drivers/hwmon/cros_ec_hwmon.c b/drivers/hwmon/cros_ec_hwmon.c
index 03bfcc40bb7c..57158443dafe 100644
--- a/drivers/hwmon/cros_ec_hwmon.c
+++ b/drivers/hwmon/cros_ec_hwmon.c
@@ -319,6 +319,7 @@ static umode_t cros_ec_hwmon_is_visible(const void *data, enum hwmon_sensor_type
 					u32 attr, int channel)
 {
 	const struct cros_ec_hwmon_priv *priv = data;
+	u32 threshold;
 	u16 speed;
 
 	if (type == hwmon_fan) {
@@ -334,8 +335,17 @@ static umode_t cros_ec_hwmon_is_visible(const void *data, enum hwmon_sensor_type
 	} else if (type == hwmon_temp) {
 		if (priv->temp_sensor_names[channel]) {
 			if (cros_ec_hwmon_attr_is_temp_threshold(attr)) {
-				if (priv->temp_threshold_supported)
-					return 0444;
+				if (!priv->temp_threshold_supported)
+					return 0;
+
+				if (cros_ec_hwmon_read_temp_threshold(priv->cros_ec, channel,
+								      cros_ec_hwmon_attr_to_thres(attr),
+								      &threshold) != 0)
+					return 0;
+				if (threshold == 0)
+					return 0;
+
+				return 0444;
 			} else {
 				return 0444;
 			}

---
base-commit: 58717b2a1365d06c8c64b72aa948541b53fe31eb
change-id: 20260729-crosec-hwmon-warn-default-9f3ca86ed809

Best regards,
-- 
Daniel Schaefer <dhs@frame.work>



             reply	other threads:[~2026-07-28 16:38 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-07-28 16:38 Daniel Schaefer via B4 Relay [this message]
2026-07-28 16:50 ` Guenter Roeck
2026-07-28 16:55   ` Daniel Schaefer
2026-07-29 15:35 ` Thomas Weißschuh

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=20260729-crosec-hwmon-warn-default-v1-1-d1eb39656a60@frame.work \
    --to=devnull+dhs.frame.work@kernel.org \
    --cc=bleung@chromium.org \
    --cc=chrome-platform@lists.linux.dev \
    --cc=dhs@frame.work \
    --cc=groeck@chromium.org \
    --cc=linux-hwmon@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux@frame.work \
    --cc=linux@roeck-us.net \
    --cc=linux@weissschuh.net \
    --cc=tzungbi@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

all inboxes | Powered by JetHome®