* [PATCH v2 0/1] hwmon: (asus-ec-sensors) detect unconnected physical sensors
@ 2026-07-11 10:10 Eugene Shalygin
2026-07-11 10:10 ` [PATCH v2 1/1] " Eugene Shalygin
0 siblings, 1 reply; 3+ messages in thread
From: Eugene Shalygin @ 2026-07-11 10:10 UTC (permalink / raw)
To: eugene.shalygin
Cc: Guenter Roeck, open list:ASUS EC HARDWARE MONITOR DRIVER,
open list
v2 changes: make temperature_blank_values array const.
Eugene Shalygin (1):
hwmon: (asus-ec-sensors) detect unconnected physical sensors
drivers/hwmon/asus-ec-sensors.c | 27 +++++++++++++++++++++++++--
1 file changed, 25 insertions(+), 2 deletions(-)
--
2.55.0
^ permalink raw reply [flat|nested] 3+ messages in thread
* [PATCH v2 1/1] hwmon: (asus-ec-sensors) detect unconnected physical sensors
2026-07-11 10:10 [PATCH v2 0/1] hwmon: (asus-ec-sensors) detect unconnected physical sensors Eugene Shalygin
@ 2026-07-11 10:10 ` Eugene Shalygin
2026-07-11 10:18 ` sashiko-bot
0 siblings, 1 reply; 3+ messages in thread
From: Eugene Shalygin @ 2026-07-11 10:10 UTC (permalink / raw)
To: eugene.shalygin
Cc: Guenter Roeck, open list:ASUS EC HARDWARE MONITOR DRIVER,
open list
When there is no temperature sensor connected, reading EC register
returns one of the special values (-62, -60, -40). Test for them
and return -ENODATA to hwmon.
Signed-off-by: Eugene Shalygin <eugene.shalygin@gmail.com>
---
drivers/hwmon/asus-ec-sensors.c | 27 +++++++++++++++++++++++++--
1 file changed, 25 insertions(+), 2 deletions(-)
diff --git a/drivers/hwmon/asus-ec-sensors.c b/drivers/hwmon/asus-ec-sensors.c
index 29a23484cbe7..d805de5da7b2 100644
--- a/drivers/hwmon/asus-ec-sensors.c
+++ b/drivers/hwmon/asus-ec-sensors.c
@@ -67,6 +67,13 @@ static char *mutex_path_override;
/* Moniker for the ACPI global lock (':' is not allowed in ASL identifiers) */
#define ACPI_GLOBAL_LOCK_PSEUDO_PATH ":GLOBAL_LOCK"
+/*
+ * The values for temperature sensor readings without physical sensors connected.
+ * The value varies across generations and is seemingly defined by the EC chip
+ * used in the given board.
+ */
+static const s32 temperature_blank_values[] = {-62, -60, -40};
+
typedef union {
u32 value;
struct {
@@ -1291,6 +1298,17 @@ static int get_cached_value_or_update(const struct device *dev,
return 0;
}
+static bool is_blank_temperature_value(s32 value)
+{
+ size_t i;
+
+ for (i = 0; i < ARRAY_SIZE(temperature_blank_values); ++i) {
+ if (value == temperature_blank_values[i])
+ return true;
+ }
+ return false;
+}
+
/*
* Now follow the functions that implement the hwmon interface
*/
@@ -1298,6 +1316,7 @@ static int get_cached_value_or_update(const struct device *dev,
static int asus_ec_hwmon_read(struct device *dev, enum hwmon_sensor_types type,
u32 attr, int channel, long *val)
{
+ const struct ec_sensor_info *sensor_info;
int ret;
s32 value = 0;
@@ -1310,8 +1329,12 @@ static int asus_ec_hwmon_read(struct device *dev, enum hwmon_sensor_types type,
ret = get_cached_value_or_update(dev, sidx, state, &value);
if (!ret) {
- *val = scale_sensor_value(value,
- get_sensor_info(state, sidx)->type);
+ sensor_info = get_sensor_info(state, sidx);
+ if (sensor_info->type == hwmon_temp &&
+ is_blank_temperature_value(value)) {
+ return -ENODATA;
+ }
+ *val = scale_sensor_value(value, sensor_info->type);
}
return ret;
--
2.55.0
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH v2 1/1] hwmon: (asus-ec-sensors) detect unconnected physical sensors
2026-07-11 10:10 ` [PATCH v2 1/1] " Eugene Shalygin
@ 2026-07-11 10:18 ` sashiko-bot
0 siblings, 0 replies; 3+ messages in thread
From: sashiko-bot @ 2026-07-11 10:18 UTC (permalink / raw)
To: Eugene Shalygin; +Cc: linux-hwmon
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [Medium] Blank temperature check applies to all thermal sensors, causing false `-ENODATA` errors during extreme subzero cooling.
--
--- Patch [1]: [PATCH v2 1/1] hwmon: (asus-ec-sensors) detect unconnected physical sensors ---
commit a1732d7627cd4596df1c72251d94e446dc0be771
Author: Eugene Shalygin <eugene.shalygin@gmail.com>
hwmon: (asus-ec-sensors) detect unconnected physical sensors
This commit adds a check for specific special values (-62, -60, -40)
returned by the EC when a temperature sensor is unconnected. When these
values are detected, the driver now returns -ENODATA instead of the raw
value to the hwmon subsystem.
> diff --git a/drivers/hwmon/asus-ec-sensors.c b/drivers/hwmon/asus-ec-sensors.c
> index 29a23484cbe7b..d805de5da7b24 100644
> --- a/drivers/hwmon/asus-ec-sensors.c
> +++ b/drivers/hwmon/asus-ec-sensors.c
[ ... ]
> @@ -1310,8 +1329,12 @@ static int asus_ec_hwmon_read(struct device *dev, enum hwmon_sensor_types type,
>
> ret = get_cached_value_or_update(dev, sidx, state, &value);
> if (!ret) {
> - *val = scale_sensor_value(value,
> - get_sensor_info(state, sidx)->type);
> + sensor_info = get_sensor_info(state, sidx);
> + if (sensor_info->type == hwmon_temp &&
> + is_blank_temperature_value(value)) {
> + return -ENODATA;
> + }
[Severity: Medium]
Could this check inadvertently cause false read errors for legitimate subzero
temperatures?
Because this filter applies broadly to all hwmon_temp sensors in
asus_ec_hwmon_read(), it appears it would intercept valid extreme negative
temperatures, such as those seen during Liquid Nitrogen cooling setups. For
fixed onboard sensors like the CPU and VRM, values like -40, -60, or -62
might represent either genuine readings or the minimum clamped value of the
sensor's thermistor table.
Does this code risk disrupting monitoring tools and fan control daemons
during extreme subzero cooling by returning -ENODATA instead of the valid
clamped temperature?
> + *val = scale_sensor_value(value, sensor_info->type);
> }
>
> return ret;
--
Sashiko AI review · https://sashiko.dev/#/patchset/20260711101143.571191-2-eugene.shalygin@gmail.com?part=1
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2026-07-11 10:18 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-07-11 10:10 [PATCH v2 0/1] hwmon: (asus-ec-sensors) detect unconnected physical sensors Eugene Shalygin
2026-07-11 10:10 ` [PATCH v2 1/1] " Eugene Shalygin
2026-07-11 10:18 ` sashiko-bot
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.