]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
ACPI: bus: Clean up devm_acpi_install_notify_handler()
authorRafael J. Wysocki <rafael.j.wysocki@intel.com>
Wed, 3 Jun 2026 18:26:24 +0000 (20:26 +0200)
committerRafael J. Wysocki <rafael.j.wysocki@intel.com>
Mon, 8 Jun 2026 12:05:39 +0000 (14:05 +0200)
Add a pointer to the struct acpi_device used for installing the ACPI
notify handler to struct acpi_notify_handler_devres so it need not
be retrieved from the owner device via ACPI_COMPANION() in
devm_acpi_notify_handler_release().

While at it, drop the function name from one of the messages printed
by devm_acpi_install_notify_handler() for consistency and fix up white
space in its kerneldoc comment.

No intentional functional impact.

Suggested-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
Reviewed-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Link: https://patch.msgid.link/2841496.mvXUDI8C0e@rafael.j.wysocki
drivers/acpi/bus.c

index e9eee0d1f0dafc452880ef3ed416d2e40ae7e76f..b0e7181ae3042a7640cf4e71516634594cd03c16 100644 (file)
@@ -680,6 +680,7 @@ void acpi_dev_remove_notify_handler(struct acpi_device *adev,
 EXPORT_SYMBOL_GPL(acpi_dev_remove_notify_handler);
 
 struct acpi_notify_handler_devres {
+       struct acpi_device *adev;
        acpi_notify_handler handler;
        u32 handler_type;
 };
@@ -688,13 +689,12 @@ static void devm_acpi_notify_handler_release(struct device *dev, void *res)
 {
        struct acpi_notify_handler_devres *dr = res;
 
-       acpi_dev_remove_notify_handler(ACPI_COMPANION(dev), dr->handler_type,
-                                      dr->handler);
+       acpi_dev_remove_notify_handler(dr->adev, dr->handler_type, dr->handler);
 }
 
 /**
  * devm_acpi_install_notify_handler - Install an ACPI notify handler for a
- *                                   managed device
+ *                                   managed device
  * @dev: Device to install a notify handler for
  * @handler_type: Type of the notify handler
  * @handler: Handler function to install
@@ -725,7 +725,7 @@ int devm_acpi_install_notify_handler(struct device *dev, u32 handler_type,
 
        adev = ACPI_COMPANION(dev);
        if (!adev)
-               return dev_err_probe(dev, -ENODEV, "No ACPI companion in %s()\n", __func__);
+               return dev_err_probe(dev, -ENODEV, "No ACPI companion\n");
 
        dr = devres_alloc(devm_acpi_notify_handler_release, sizeof(*dr), GFP_KERNEL);
        if (!dr)
@@ -737,6 +737,7 @@ int devm_acpi_install_notify_handler(struct device *dev, u32 handler_type,
                return dev_err_probe(dev, ret, "Failed to install an ACPI notify handler\n");
        }
 
+       dr->adev = adev;
        dr->handler = handler;
        dr->handler_type = handler_type;
        devres_add(dev, dr);