]> www.infradead.org Git - users/willy/pagecache.git/commitdiff
ACPI: bus: Introduce wrappers for ACPICA notify handler install/remove
authorMichal Wilczynski <michal.wilczynski@intel.com>
Mon, 3 Jul 2023 08:02:44 +0000 (11:02 +0300)
committerRafael J. Wysocki <rafael.j.wysocki@intel.com>
Fri, 14 Jul 2023 16:58:34 +0000 (18:58 +0200)
Introduce new functions acpi_dev_install_notify_handler() and
acpi_dev_remove_notify_handler(), to install and remove, respectively,
a handler for AML Notify() operations targeted at a given ACPI device
object. They will allow drivers to install Notify() handlers directly
instead of providing an ACPI driver .notify() callback to be invoked
in the context of a Notify() handler installed by the ACPI bus type
code. In particular, this will help platform drivers to provide
Notify() handlers for the ACPI companions of the platform devices
they bind to.

These functions are replacements for acpi_device_install_notify_handler()
and acpi_device_remove_notify_handler(), respectively, and after all
drivers switch over to using them, the old ones will be dropped.

Suggested-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
Signed-off-by: Michal Wilczynski <michal.wilczynski@intel.com>
[ rjw: Subject and changelog edits, whitespace adjustments ]
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
drivers/acpi/bus.c
include/acpi/acpi_bus.h

index 2fc2b43a4ed3877e8a41a6f62d21b55340317723..b5688839be1bfad2c8a478a9e1e9c94fe24fbbef 100644 (file)
@@ -554,6 +554,30 @@ static void acpi_device_remove_notify_handler(struct acpi_device *device,
        acpi_os_wait_events_complete();
 }
 
+int acpi_dev_install_notify_handler(struct acpi_device *adev,
+                                   u32 handler_type,
+                                   acpi_notify_handler handler)
+{
+       acpi_status status;
+
+       status = acpi_install_notify_handler(adev->handle, handler_type,
+                                            handler, adev);
+       if (ACPI_FAILURE(status))
+               return -ENODEV;
+
+       return 0;
+}
+EXPORT_SYMBOL_GPL(acpi_dev_install_notify_handler);
+
+void acpi_dev_remove_notify_handler(struct acpi_device *adev,
+                                   u32 handler_type,
+                                   acpi_notify_handler handler)
+{
+       acpi_remove_notify_handler(adev->handle, handler_type, handler);
+       acpi_os_wait_events_complete();
+}
+EXPORT_SYMBOL_GPL(acpi_dev_remove_notify_handler);
+
 /* Handle events targeting \_SB device (at present only graceful shutdown) */
 
 #define ACPI_SB_NOTIFY_SHUTDOWN_REQUEST 0x81
index c941d99162c09c3f49d815101d1299e067f6aa01..23fbe4a169723e10e107ca9c9e4285281424d629 100644 (file)
@@ -515,6 +515,12 @@ void acpi_bus_private_data_handler(acpi_handle, void *);
 int acpi_bus_get_private_data(acpi_handle, void **);
 int acpi_bus_attach_private_data(acpi_handle, void *);
 void acpi_bus_detach_private_data(acpi_handle);
+int acpi_dev_install_notify_handler(struct acpi_device *adev,
+                                   u32 handler_type,
+                                   acpi_notify_handler handler);
+void acpi_dev_remove_notify_handler(struct acpi_device *adev,
+                                   u32 handler_type,
+                                   acpi_notify_handler handler);
 extern int acpi_notifier_call_chain(struct acpi_device *, u32, u32);
 extern int register_acpi_notifier(struct notifier_block *);
 extern int unregister_acpi_notifier(struct notifier_block *);