[PATCH v1 2/3] hwmon: (acpi_power_meter) Register ACPI notify handler directly
From: Rafael J. Wysocki
Date: Sun Mar 01 2026 - 08:19:51 EST
From: "Rafael J. Wysocki" <rafael.j.wysocki@xxxxxxxxx>
To facilitate subsequent conversion of the driver to a platform one,
make it install an ACPI notify handler directly instead of using
a .notify() callback in struct acpi_driver.
No intentional functional impact.
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@xxxxxxxxx>
---
drivers/hwmon/acpi_power_meter.c | 14 ++++++++++++--
1 file changed, 12 insertions(+), 2 deletions(-)
diff --git a/drivers/hwmon/acpi_power_meter.c b/drivers/hwmon/acpi_power_meter.c
index 49e57c20ef70..c010f55f7c7b 100644
--- a/drivers/hwmon/acpi_power_meter.c
+++ b/drivers/hwmon/acpi_power_meter.c
@@ -814,8 +814,9 @@ static int read_capabilities(struct acpi_power_meter_resource *resource)
}
/* Handle ACPI event notifications */
-static void acpi_power_meter_notify(struct acpi_device *device, u32 event)
+static void acpi_power_meter_notify(acpi_handle handle, u32 event, void *data)
{
+ struct acpi_device *device = data;
struct acpi_power_meter_resource *resource = acpi_driver_data(device);
int res;
@@ -936,9 +937,16 @@ static int acpi_power_meter_add(struct acpi_device *device)
goto exit_remove;
}
+ res = acpi_dev_install_notify_handler(device, ACPI_DEVICE_NOTIFY,
+ acpi_power_meter_notify, device);
+ if (res)
+ goto exit_hwmon;
+
res = 0;
goto exit;
+exit_hwmon:
+ hwmon_device_unregister(resource->hwmon_dev);
exit_remove:
remove_domain_devices(resource);
exit_free_capability:
@@ -953,6 +961,9 @@ static void acpi_power_meter_remove(struct acpi_device *device)
{
struct acpi_power_meter_resource *resource = acpi_driver_data(device);
+ acpi_dev_remove_notify_handler(device, ACPI_DEVICE_NOTIFY,
+ acpi_power_meter_notify);
+
if (!IS_ERR(resource->hwmon_dev))
hwmon_device_unregister(resource->hwmon_dev);
@@ -984,7 +995,6 @@ static struct acpi_driver acpi_power_meter_driver = {
.ops = {
.add = acpi_power_meter_add,
.remove = acpi_power_meter_remove,
- .notify = acpi_power_meter_notify,
},
.drv.pm = pm_sleep_ptr(&acpi_power_meter_pm),
};
--
2.51.0