ACPI: bus: Introduce wrappers for ACPICA notify handler install/remove

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>
This commit is contained in:
Michal Wilczynski 2023-07-03 11:02:44 +03:00 committed by Rafael J. Wysocki
parent 06c2afb862
commit c542ce36a9
2 changed files with 30 additions and 0 deletions

View 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

View 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 *);