Skip to content

Commit c542ce3

Browse files
mwilczyrafaeljw
authored andcommitted
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>
1 parent 06c2afb commit c542ce3

2 files changed

Lines changed: 30 additions & 0 deletions

File tree

drivers/acpi/bus.c

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -554,6 +554,30 @@ static void acpi_device_remove_notify_handler(struct acpi_device *device,
554554
acpi_os_wait_events_complete();
555555
}
556556

557+
int acpi_dev_install_notify_handler(struct acpi_device *adev,
558+
u32 handler_type,
559+
acpi_notify_handler handler)
560+
{
561+
acpi_status status;
562+
563+
status = acpi_install_notify_handler(adev->handle, handler_type,
564+
handler, adev);
565+
if (ACPI_FAILURE(status))
566+
return -ENODEV;
567+
568+
return 0;
569+
}
570+
EXPORT_SYMBOL_GPL(acpi_dev_install_notify_handler);
571+
572+
void acpi_dev_remove_notify_handler(struct acpi_device *adev,
573+
u32 handler_type,
574+
acpi_notify_handler handler)
575+
{
576+
acpi_remove_notify_handler(adev->handle, handler_type, handler);
577+
acpi_os_wait_events_complete();
578+
}
579+
EXPORT_SYMBOL_GPL(acpi_dev_remove_notify_handler);
580+
557581
/* Handle events targeting \_SB device (at present only graceful shutdown) */
558582

559583
#define ACPI_SB_NOTIFY_SHUTDOWN_REQUEST 0x81

include/acpi/acpi_bus.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -515,6 +515,12 @@ void acpi_bus_private_data_handler(acpi_handle, void *);
515515
int acpi_bus_get_private_data(acpi_handle, void **);
516516
int acpi_bus_attach_private_data(acpi_handle, void *);
517517
void acpi_bus_detach_private_data(acpi_handle);
518+
int acpi_dev_install_notify_handler(struct acpi_device *adev,
519+
u32 handler_type,
520+
acpi_notify_handler handler);
521+
void acpi_dev_remove_notify_handler(struct acpi_device *adev,
522+
u32 handler_type,
523+
acpi_notify_handler handler);
518524
extern int acpi_notifier_call_chain(struct acpi_device *, u32, u32);
519525
extern int register_acpi_notifier(struct notifier_block *);
520526
extern int unregister_acpi_notifier(struct notifier_block *);

0 commit comments

Comments
 (0)