]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
hwmon: (acpi_power_meter) Register ACPI notify handler directly
authorRafael J. Wysocki <rafael.j.wysocki@intel.com>
Sun, 1 Mar 2026 13:18:05 +0000 (14:18 +0100)
committerGuenter Roeck <linux@roeck-us.net>
Tue, 31 Mar 2026 02:45:05 +0000 (19:45 -0700)
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@intel.com>
Link: https://lore.kernel.org/r/2405555.ElGaqSPkdT@rafael.j.wysocki
Signed-off-by: Guenter Roeck <linux@roeck-us.net>
drivers/hwmon/acpi_power_meter.c

index 49e57c20ef7079e987952b142a7a4544a1a6706b..c010f55f7c7ba162080d2fa8837a791bb6454925 100644 (file)
@@ -814,8 +814,9 @@ end:
 }
 
 /* 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),
 };