[PATCH] hwmon: (acpi_power_meter) Fix a check for the return value of read_domain_devices().

From: Kazuhiro Abe
Date: Wed Jan 15 2025 - 02:36:13 EST


After commit fabb1f813ec0 ("hwmon: (acpi_power_meter) Fix fail to load
module on platform without _PMD method"),
the acpi_power_meter driver fails to load if the platform has _PMD method.

To address this, add a check for successful read_domain_devices().
Tested on Nvidia Grace machine.

Fixes: fabb1f813ec0 ("hwmon: (acpi_power_meter) Fix fail to load module on platform without _PMD method")
Signed-off-by: Kazuhiro Abe <fj1078ii@xxxxxxxxxxxxxxxxx>
---
drivers/hwmon/acpi_power_meter.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/hwmon/acpi_power_meter.c b/drivers/hwmon/acpi_power_meter.c
index 2f1c9d97ad21..dbf2c606fe15 100644
--- a/drivers/hwmon/acpi_power_meter.c
+++ b/drivers/hwmon/acpi_power_meter.c
@@ -682,7 +682,7 @@ static int setup_attrs(struct acpi_power_meter_resource *resource)

/* _PMD method is optional. */
res = read_domain_devices(resource);
- if (res != -ENODEV)
+ if ((res != 0) && (res != -ENODEV))
return res;

if (resource->caps.flags & POWER_METER_CAN_MEASURE) {
--
2.34.1