* [PATCH] hwmon: (acpi_power_meter) Fix 18.45 TW bug
@ 2026-10-06 23:45 Armin Wolf
2026-10-19 20:53 ` Guenter Roeck
0 siblings, 1 reply; 3+ messages in thread
From: Armin Wolf @ 2026-10-06 23:45 UTC (permalink / raw)
To: linux; +Cc: github, linux-hwmon, linux-kernel
The ACPI specification says:
"If an error occurs while obtaining the meter reading or if the value
is not available then an Integer with all bits set is returned"
This integer can also be 64-bit wide on ACPI 2.0 and later systems,
so we have to check for that too.
Compile-tested only.
Reported-by: Grant Slater <github@firefishy.com>
Closes: https://github.com/lm-sensors/lm-sensors/issues/460
Fixes: 1fefca6c57fb ("hwmon: (acpi_power_meter) Fix 4.29 MW bug")
Signed-off-by: Armin Wolf <W_Armin@gmx.de>
---
drivers/hwmon/acpi_power_meter.c | 10 ++++++++--
1 file changed, 8 insertions(+), 2 deletions(-)
diff --git a/drivers/hwmon/acpi_power_meter.c b/drivers/hwmon/acpi_power_meter.c
index d8e871509405..3891962f03db 100644
--- a/drivers/hwmon/acpi_power_meter.c
+++ b/drivers/hwmon/acpi_power_meter.c
@@ -10,6 +10,7 @@
#include <linux/hwmon.h>
#include <linux/hwmon-sysfs.h>
#include <linux/jiffies.h>
+#include <linux/limits.h>
#include <linux/mutex.h>
#include <linux/dmi.h>
#include <linux/slab.h>
@@ -30,7 +31,12 @@
#define POWER_METER_CAN_NOTIFY (1 << 3)
#define POWER_METER_IS_BATTERY (1 << 8)
#define UNKNOWN_HYSTERESIS 0xFFFFFFFF
-#define UNKNOWN_POWER 0xFFFFFFFF
+/*
+ * ACPI integers can either be 32-bit or 64-bit wide, so
+ * we have to check for both values.
+ */
+#define UNKNOWN_POWER_32 U32_MAX
+#define UNKNOWN_POWER_64 U64_MAX
#define METER_NOTIFY_CONFIG 0x80
#define METER_NOTIFY_TRIP 0x81
@@ -452,7 +458,7 @@ static int power_meter_read(struct device *dev, enum hwmon_sensor_types type,
ret = update_meter(res);
if (ret)
return ret;
- if (res->power == UNKNOWN_POWER)
+ if (res->power == UNKNOWN_POWER_32 || res->power == UNKNOWN_POWER_64)
return -ENODATA;
*val = res->power * 1000;
break;
--
2.55.0
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] hwmon: (acpi_power_meter) Fix 18.45 TW bug
2026-10-06 23:45 [PATCH] hwmon: (acpi_power_meter) Fix 18.45 TW bug Armin Wolf
@ 2026-10-19 20:53 ` Guenter Roeck
2026-10-19 22:49 ` Armin Wolf
0 siblings, 1 reply; 3+ messages in thread
From: Guenter Roeck @ 2026-10-19 20:53 UTC (permalink / raw)
To: Armin Wolf; +Cc: github, linux-hwmon, linux-kernel
On Wed, Oct 07, 2026 at 01:45:34AM +0200, Armin Wolf wrote:
> The ACPI specification says:
>
> "If an error occurs while obtaining the meter reading or if the value
> is not available then an Integer with all bits set is returned"
>
> This integer can also be 64-bit wide on ACPI 2.0 and later systems,
> so we have to check for that too.
>
> Compile-tested only.
>
> Reported-by: Grant Slater <github@firefishy.com>
> Closes: https://github.com/lm-sensors/lm-sensors/issues/460
> Fixes: 1fefca6c57fb ("hwmon: (acpi_power_meter) Fix 4.29 MW bug")
> Signed-off-by: Armin Wolf <W_Armin@gmx.de>
Applied.
Thanks,
Guenter
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] hwmon: (acpi_power_meter) Fix 18.45 TW bug
2026-10-19 20:53 ` Guenter Roeck
@ 2026-10-19 22:49 ` Armin Wolf
0 siblings, 0 replies; 3+ messages in thread
From: Armin Wolf @ 2026-10-19 22:49 UTC (permalink / raw)
To: Guenter Roeck; +Cc: github, linux-hwmon, linux-kernel
Am 19.10.26 um 22:53 schrieb Guenter Roeck:
> On Wed, Oct 07, 2026 at 01:45:34AM +0200, Armin Wolf wrote:
>> The ACPI specification says:
>>
>> "If an error occurs while obtaining the meter reading or if the value
>> is not available then an Integer with all bits set is returned"
>>
>> This integer can also be 64-bit wide on ACPI 2.0 and later systems,
>> so we have to check for that too.
>>
>> Compile-tested only.
>>
>> Reported-by: Grant Slater <github@firefishy.com>
>> Closes: https://github.com/lm-sensors/lm-sensors/issues/460
>> Fixes: 1fefca6c57fb ("hwmon: (acpi_power_meter) Fix 4.29 MW bug")
>> Signed-off-by: Armin Wolf <W_Armin@gmx.de>
> Applied.
>
> Thanks,
> Guenter
Thank you :)
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2026-10-19 22:49 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-10-06 23:45 [PATCH] hwmon: (acpi_power_meter) Fix 18.45 TW bug Armin Wolf
2026-10-19 20:53 ` Guenter Roeck
2026-10-19 22:49 ` Armin Wolf
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®