]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
ACPI: PAD: Switch over to devres-based resource management
authorRafael J. Wysocki <rafael.j.wysocki@intel.com>
Thu, 21 May 2026 14:07:29 +0000 (16:07 +0200)
committerRafael J. Wysocki <rafael.j.wysocki@intel.com>
Mon, 25 May 2026 14:43:52 +0000 (16:43 +0200)
Use the newly introduced devm_acpi_install_notify_handler() for
installing an ACPI notify handler and since that function checks the
ACPI companion of the owner device against NULL internally, remove the
the explicit ACPI companion check from acpi_pad_probe().

However, to prevent the notify handler from running acpi_pad_idle_cpus()
with the number of idle CPUs greater than zero after acpi_pad_remove()
has returned, add a bool static variable for synchronization between
the two.

Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
Link: https://patch.msgid.link/1964581.CQOukoFCf9@rafael.j.wysocki
drivers/acpi/acpi_pad.c

index 48c00ee61ed224c88d90b4ad51d08630b84bdfe3..5792f93d35342be2d355cb473da4d2ae585e5b47 100644 (file)
@@ -31,6 +31,8 @@
 static DEFINE_MUTEX(isolated_cpus_lock);
 static DEFINE_MUTEX(round_robin_lock);
 
+static bool acpi_pad_teardown;
+
 static unsigned int power_saving_mwait_eax;
 
 static unsigned char tsc_detected_unstable;
@@ -359,6 +361,9 @@ static int acpi_pad_pur(acpi_handle handle)
        union acpi_object *package;
        int num = -1;
 
+       if (unlikely(acpi_pad_teardown))
+               return -1;
+
        if (ACPI_FAILURE(acpi_evaluate_object(handle, "_PUR", NULL, &buffer)))
                return num;
 
@@ -418,22 +423,16 @@ static void acpi_pad_notify(acpi_handle handle, u32 event, void *data)
 
 static int acpi_pad_probe(struct platform_device *pdev)
 {
-       struct acpi_device *adev;
+       acpi_pad_teardown = false;
 
-       adev = ACPI_COMPANION(&pdev->dev);
-       if (!adev)
-               return -ENODEV;
-
-       return acpi_dev_install_notify_handler(adev, ACPI_DEVICE_NOTIFY,
-                                              acpi_pad_notify, &pdev->dev);
+       return devm_acpi_install_notify_handler(&pdev->dev, ACPI_DEVICE_NOTIFY,
+                                               acpi_pad_notify, &pdev->dev);
 }
 
 static void acpi_pad_remove(struct platform_device *pdev)
 {
-       acpi_dev_remove_notify_handler(ACPI_COMPANION(&pdev->dev),
-                                      ACPI_DEVICE_NOTIFY, acpi_pad_notify);
-
        mutex_lock(&isolated_cpus_lock);
+       acpi_pad_teardown = true;
        acpi_pad_idle_cpus(0);
        mutex_unlock(&isolated_cpus_lock);
 }