@@ -188,6 +188,8 @@ struct acpi_object_method {
u32 aml_length;
u8 thread_count;
acpi_owner_id owner_id;
+ acpi_osd_exec_callback notify;
+ void *context;
};
/******************************************************************************
@@ -420,6 +420,11 @@ acpi_ds_call_control_method(struct acpi_thread_state *thread,
}
}
+ if (obj_desc->method.notify) {
+ acpi_os_execute(OSL_NOTIFY_HANDLER, obj_desc->method.notify,
+ obj_desc->method.context);
+ }
+
return_ACPI_STATUS(status);
cleanup:
@@ -653,6 +653,109 @@ ACPI_EXPORT_SYMBOL(acpi_remove_notify_handler)
/*******************************************************************************
*
+ * FUNCTION: acpi_install_method_handler
+ *
+ * PARAMETERS: Oathname - The method for which notifies will be handled
+ * Handler - Address of the handler
+ * Context - Value passed to the handler on each call
+ *
+ * RETURN: Status
+ *
+ * DESCRIPTION: Install a handler for notifies on ACPI method execution
+ *
+ ******************************************************************************/
+
+acpi_status
+acpi_install_method_handler (acpi_handle handle, acpi_method_handler handler,
+ void *context)
+{
+ struct acpi_namespace_node *node;
+ union acpi_operand_object *method;
+ acpi_status status;
+
+ if (!handle || !handler)
+ return_ACPI_STATUS(AE_BAD_PARAMETER);
+
+ status = acpi_ut_acquire_mutex(ACPI_MTX_NAMESPACE);
+
+ if (ACPI_FAILURE(status))
+ return_ACPI_STATUS(status);
+
+ node = acpi_ns_validate_handle(handle);
+
+ if (!node) {
+ status = AE_BAD_PARAMETER;
+ goto unlock_and_exit;
+ }
+
+ method = acpi_ns_get_attached_object(node);
+
+ if (method->method.notify) {
+ status = AE_ALREADY_EXISTS;
+ goto unlock_and_exit;
+ }
+
+ method->method.notify = handler;
+ method->method.context = context;
+
+unlock_and_exit:
+ acpi_ut_release_mutex(ACPI_MTX_NAMESPACE);
+ return_ACPI_STATUS(status);
+}
+ACPI_EXPORT_SYMBOL(acpi_install_method_handler)
+
+/*******************************************************************************
+ *
+ * FUNCTION: acpi_remove_method_handler
+ *
+ * PARAMETERS: Pathname - The method for which notifies will be handled
+ * Handler - Address of the handler
+ *
+ * RETURN: Status
+ *
+ * DESCRIPTION: Remove a handler for notifies on ACPI method execution
+ *
+ ******************************************************************************/
+
+acpi_status
+acpi_remove_method_handler (acpi_handle handle, acpi_method_handler handler)
+{
+ struct acpi_namespace_node *node;
+ union acpi_operand_object *method;
+ acpi_status status;
+
+ if (!handle || !handler)
+ return_ACPI_STATUS(AE_BAD_PARAMETER);
+
+ status = acpi_ut_acquire_mutex(ACPI_MTX_NAMESPACE);
+ if (ACPI_FAILURE(status))
+ return_ACPI_STATUS(status);
+
+ node = acpi_ns_validate_handle(handle);
+
+ if (!node) {
+ status = AE_BAD_PARAMETER;
+ goto unlock_and_exit;
+ }
+
+ method = acpi_ns_get_attached_object(node);
+
+ if (method->method.notify != handler) {
+ status = AE_BAD_PARAMETER;
+ goto unlock_and_exit;
+ }
+
+ method->method.notify = NULL;
+ method->method.context = NULL;
+
+unlock_and_exit:
+ acpi_ut_release_mutex(ACPI_MTX_NAMESPACE);
+ return_ACPI_STATUS(status);
+}
+ACPI_EXPORT_SYMBOL(acpi_remove_method_handler)
+
+/*******************************************************************************
+ *
* FUNCTION: acpi_install_gpe_handler
*
* PARAMETERS: gpe_device - Namespace node for the GPE (NULL for FADT
@@ -240,6 +240,13 @@ acpi_remove_notify_handler(acpi_handle device,
u32 handler_type, acpi_notify_handler handler);
acpi_status
+acpi_install_method_handler(acpi_handle handle, acpi_method_handler handler,
+ void *context);
+
+acpi_status
+acpi_remove_method_handler(acpi_handle handle, acpi_method_handler handler);
+
+acpi_status
acpi_install_address_space_handler(acpi_handle device,
acpi_adr_space_type space_id,
acpi_adr_space_handler handler,
@@ -916,6 +916,8 @@ void (*acpi_notify_handler) (acpi_handle device, u32 value, void *context);
typedef
void (*acpi_object_handler) (acpi_handle object, void *data);
+typedef void (*acpi_method_handler) (void *context);
+
typedef acpi_status(*acpi_init_handler) (acpi_handle object, u32 function);
#define ACPI_INIT_DEVICE_INI 1