Commit f31a99ce authored by Lv Zheng's avatar Lv Zheng Committed by Rafael J. Wysocki

ACPICA: Events: Deploys acpi_ev_find_region_handler()

ACPICA commit b916a0a0ae9e81db1a85523c63ec6aa32d5c70c8

There are code fragments that can be substituted by
acpi_ev_find_region_handler().

This patch cleans up these code fragments. Lv Zheng.

Link: https://github.com/acpica/acpica/commit/b916a0a0Signed-off-by: default avatarLv Zheng <lv.zheng@intel.com>
Signed-off-by: default avatarBob Moore <robert.moore@intel.com>
Signed-off-by: default avatarRafael J. Wysocki <rafael.j.wysocki@intel.com>
parent 7b738064
...@@ -161,6 +161,11 @@ acpi_ev_delete_gpe_handlers(struct acpi_gpe_xrupt_info *gpe_xrupt_info, ...@@ -161,6 +161,11 @@ acpi_ev_delete_gpe_handlers(struct acpi_gpe_xrupt_info *gpe_xrupt_info,
/* /*
* evhandler - Address space handling * evhandler - Address space handling
*/ */
union acpi_operand_object *acpi_ev_find_region_handler(acpi_adr_space_type
space_id,
union acpi_operand_object
*handler_obj);
u8 u8
acpi_ev_has_default_handler(struct acpi_namespace_node *node, acpi_ev_has_default_handler(struct acpi_namespace_node *node,
acpi_adr_space_type space_id); acpi_adr_space_type space_id);
......
...@@ -48,6 +48,7 @@ ...@@ -48,6 +48,7 @@
#include "acnamesp.h" #include "acnamesp.h"
#include "acparser.h" #include "acparser.h"
#include "acinterp.h" #include "acinterp.h"
#include "acevents.h"
#include "acdebug.h" #include "acdebug.h"
#define _COMPONENT ACPI_CA_DEBUGGER #define _COMPONENT ACPI_CA_DEBUGGER
...@@ -949,28 +950,25 @@ void acpi_db_display_handlers(void) ...@@ -949,28 +950,25 @@ void acpi_db_display_handlers(void)
if (obj_desc) { if (obj_desc) {
for (i = 0; i < ACPI_ARRAY_LENGTH(acpi_gbl_space_id_list); i++) { for (i = 0; i < ACPI_ARRAY_LENGTH(acpi_gbl_space_id_list); i++) {
space_id = acpi_gbl_space_id_list[i]; space_id = acpi_gbl_space_id_list[i];
handler_obj = obj_desc->device.handler;
acpi_os_printf(ACPI_PREDEFINED_PREFIX, acpi_os_printf(ACPI_PREDEFINED_PREFIX,
acpi_ut_get_region_name((u8)space_id), acpi_ut_get_region_name((u8)space_id),
space_id); space_id);
while (handler_obj) { handler_obj =
if (acpi_gbl_space_id_list[i] == acpi_ev_find_region_handler(space_id,
handler_obj->address_space.space_id) { obj_desc->device.
acpi_os_printf handler);
(ACPI_HANDLER_PRESENT_STRING, if (handler_obj) {
(handler_obj->address_space. acpi_os_printf(ACPI_HANDLER_PRESENT_STRING,
handler_flags & (handler_obj->address_space.
ACPI_ADDR_HANDLER_DEFAULT_INSTALLED) handler_flags &
? "Default" : "User", ACPI_ADDR_HANDLER_DEFAULT_INSTALLED)
handler_obj->address_space. ? "Default" : "User",
handler); handler_obj->address_space.
handler);
goto found_handler;
}
handler_obj = handler_obj->address_space.next; goto found_handler;
} }
/* There is no handler for this space_id */ /* There is no handler for this space_id */
......
...@@ -55,10 +55,6 @@ static acpi_status ...@@ -55,10 +55,6 @@ static acpi_status
acpi_ev_install_handler(acpi_handle obj_handle, acpi_ev_install_handler(acpi_handle obj_handle,
u32 level, void *context, void **return_value); u32 level, void *context, void **return_value);
static union acpi_operand_object
*acpi_ev_find_region_handler(acpi_adr_space_type space_id,
union acpi_operand_object *handler_obj);
/* These are the address spaces that will get default handlers */ /* These are the address spaces that will get default handlers */
u8 acpi_gbl_default_address_spaces[ACPI_NUM_DEFAULT_SPACES] = { u8 acpi_gbl_default_address_spaces[ACPI_NUM_DEFAULT_SPACES] = {
...@@ -251,35 +247,30 @@ acpi_ev_install_handler(acpi_handle obj_handle, ...@@ -251,35 +247,30 @@ acpi_ev_install_handler(acpi_handle obj_handle,
/* Check if this Device already has a handler for this address space */ /* Check if this Device already has a handler for this address space */
next_handler_obj = obj_desc->device.handler; next_handler_obj =
while (next_handler_obj) { acpi_ev_find_region_handler(handler_obj->address_space.
space_id,
obj_desc->device.handler);
if (next_handler_obj) {
/* Found a handler, is it for the same address space? */ /* Found a handler, is it for the same address space? */
if (next_handler_obj->address_space.space_id == ACPI_DEBUG_PRINT((ACPI_DB_OPREGION,
handler_obj->address_space.space_id) { "Found handler for region [%s] in device %p(%p) handler %p\n",
ACPI_DEBUG_PRINT((ACPI_DB_OPREGION, acpi_ut_get_region_name(handler_obj->
"Found handler for region [%s] in device %p(%p) " address_space.
"handler %p\n", space_id),
acpi_ut_get_region_name obj_desc, next_handler_obj,
(handler_obj->address_space. handler_obj));
space_id), obj_desc,
next_handler_obj, /*
handler_obj)); * Since the object we found it on was a device, then it means
* that someone has already installed a handler for the branch
/* * of the namespace from this device on. Just bail out telling
* Since the object we found it on was a device, then it * the walk routine to not traverse this branch. This preserves
* means that someone has already installed a handler for * the scoping rule for handlers.
* the branch of the namespace from this device on. Just */
* bail out telling the walk routine to not traverse this return (AE_CTRL_DEPTH);
* branch. This preserves the scoping rule for handlers.
*/
return (AE_CTRL_DEPTH);
}
/* Walk the linked list of handlers attached to this device */
next_handler_obj = next_handler_obj->address_space.next;
} }
/* /*
...@@ -325,9 +316,10 @@ acpi_ev_install_handler(acpi_handle obj_handle, ...@@ -325,9 +316,10 @@ acpi_ev_install_handler(acpi_handle obj_handle,
* *
******************************************************************************/ ******************************************************************************/
static union acpi_operand_object union acpi_operand_object *acpi_ev_find_region_handler(acpi_adr_space_type
*acpi_ev_find_region_handler(acpi_adr_space_type space_id, space_id,
union acpi_operand_object *handler_obj) union acpi_operand_object
*handler_obj)
{ {
/* Walk the handler list for this device */ /* Walk the handler list for this device */
......
...@@ -602,60 +602,49 @@ acpi_ev_initialize_region(union acpi_operand_object *region_obj, ...@@ -602,60 +602,49 @@ acpi_ev_initialize_region(union acpi_operand_object *region_obj,
break; break;
} }
while (handler_obj) { handler_obj =
acpi_ev_find_region_handler(space_id, handler_obj);
if (handler_obj) {
/* Is this handler of the correct type? */ /* Found correct handler */
if (handler_obj->address_space.space_id == ACPI_DEBUG_PRINT((ACPI_DB_OPREGION,
space_id) { "Found handler %p for region %p in obj %p\n",
handler_obj, region_obj,
obj_desc));
/* Found correct handler */ status =
acpi_ev_attach_region(handler_obj,
ACPI_DEBUG_PRINT((ACPI_DB_OPREGION,
"Found handler %p for region %p in obj %p\n",
handler_obj,
region_obj, region_obj,
obj_desc)); acpi_ns_locked);
/*
* Tell all users that this region is usable by
* running the _REG method
*/
if (acpi_ns_locked) {
status = status =
acpi_ev_attach_region(handler_obj, acpi_ut_release_mutex
region_obj, (ACPI_MTX_NAMESPACE);
acpi_ns_locked); if (ACPI_FAILURE(status)) {
return_ACPI_STATUS(status);
/*
* Tell all users that this region is usable by
* running the _REG method
*/
if (acpi_ns_locked) {
status =
acpi_ut_release_mutex
(ACPI_MTX_NAMESPACE);
if (ACPI_FAILURE(status)) {
return_ACPI_STATUS
(status);
}
} }
}
status =
acpi_ev_execute_reg_method(region_obj,
ACPI_REG_CONNECT);
if (acpi_ns_locked) {
status = status =
acpi_ev_execute_reg_method acpi_ut_acquire_mutex
(region_obj, ACPI_REG_CONNECT); (ACPI_MTX_NAMESPACE);
if (ACPI_FAILURE(status)) {
if (acpi_ns_locked) { return_ACPI_STATUS(status);
status =
acpi_ut_acquire_mutex
(ACPI_MTX_NAMESPACE);
if (ACPI_FAILURE(status)) {
return_ACPI_STATUS
(status);
}
} }
return_ACPI_STATUS(AE_OK);
} }
/* Try next handler in the list */ return_ACPI_STATUS(AE_OK);
handler_obj = handler_obj->address_space.next;
} }
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment