diff options
author | Lv Zheng <lv.zheng@intel.com> | 2015-12-29 01:02:00 -0500 |
---|---|---|
committer | Rafael J. Wysocki <rafael.j.wysocki@intel.com> | 2015-12-31 21:47:37 -0500 |
commit | f31a99cefd05f798eee8b592e22175ff3fe1876b (patch) | |
tree | 6256bae4642ea41ae3f82fc55fc6db8ffa9c2e8e | |
parent | 7b73806485ada16059ecc1851793dbe865181c53 (diff) |
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/b916a0a0
Signed-off-by: Lv Zheng <lv.zheng@intel.com>
Signed-off-by: Bob Moore <robert.moore@intel.com>
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
-rw-r--r-- | drivers/acpi/acpica/acevents.h | 5 | ||||
-rw-r--r-- | drivers/acpi/acpica/dbdisply.c | 30 | ||||
-rw-r--r-- | drivers/acpi/acpica/evhandler.c | 58 | ||||
-rw-r--r-- | drivers/acpi/acpica/evrgnini.c | 73 |
4 files changed, 75 insertions, 91 deletions
diff --git a/drivers/acpi/acpica/acevents.h b/drivers/acpi/acpica/acevents.h index 228704b78657..42975abf1e03 100644 --- a/drivers/acpi/acpica/acevents.h +++ b/drivers/acpi/acpica/acevents.h | |||
@@ -161,6 +161,11 @@ acpi_ev_delete_gpe_handlers(struct acpi_gpe_xrupt_info *gpe_xrupt_info, | |||
161 | /* | 161 | /* |
162 | * evhandler - Address space handling | 162 | * evhandler - Address space handling |
163 | */ | 163 | */ |
164 | union acpi_operand_object *acpi_ev_find_region_handler(acpi_adr_space_type | ||
165 | space_id, | ||
166 | union acpi_operand_object | ||
167 | *handler_obj); | ||
168 | |||
164 | u8 | 169 | u8 |
165 | acpi_ev_has_default_handler(struct acpi_namespace_node *node, | 170 | acpi_ev_has_default_handler(struct acpi_namespace_node *node, |
166 | acpi_adr_space_type space_id); | 171 | acpi_adr_space_type space_id); |
diff --git a/drivers/acpi/acpica/dbdisply.c b/drivers/acpi/acpica/dbdisply.c index 390a7ca1c170..a66b4ae443c9 100644 --- a/drivers/acpi/acpica/dbdisply.c +++ b/drivers/acpi/acpica/dbdisply.c | |||
@@ -48,6 +48,7 @@ | |||
48 | #include "acnamesp.h" | 48 | #include "acnamesp.h" |
49 | #include "acparser.h" | 49 | #include "acparser.h" |
50 | #include "acinterp.h" | 50 | #include "acinterp.h" |
51 | #include "acevents.h" | ||
51 | #include "acdebug.h" | 52 | #include "acdebug.h" |
52 | 53 | ||
53 | #define _COMPONENT ACPI_CA_DEBUGGER | 54 | #define _COMPONENT ACPI_CA_DEBUGGER |
@@ -949,28 +950,25 @@ void acpi_db_display_handlers(void) | |||
949 | if (obj_desc) { | 950 | if (obj_desc) { |
950 | for (i = 0; i < ACPI_ARRAY_LENGTH(acpi_gbl_space_id_list); i++) { | 951 | for (i = 0; i < ACPI_ARRAY_LENGTH(acpi_gbl_space_id_list); i++) { |
951 | space_id = acpi_gbl_space_id_list[i]; | 952 | space_id = acpi_gbl_space_id_list[i]; |
952 | handler_obj = obj_desc->device.handler; | ||
953 | 953 | ||
954 | acpi_os_printf(ACPI_PREDEFINED_PREFIX, | 954 | acpi_os_printf(ACPI_PREDEFINED_PREFIX, |
955 | acpi_ut_get_region_name((u8)space_id), | 955 | acpi_ut_get_region_name((u8)space_id), |
956 | space_id); | 956 | space_id); |
957 | 957 | ||
958 | while (handler_obj) { | 958 | handler_obj = |
959 | if (acpi_gbl_space_id_list[i] == | 959 | acpi_ev_find_region_handler(space_id, |
960 | handler_obj->address_space.space_id) { | 960 | obj_desc->device. |
961 | acpi_os_printf | 961 | handler); |
962 | (ACPI_HANDLER_PRESENT_STRING, | 962 | if (handler_obj) { |
963 | (handler_obj->address_space. | 963 | acpi_os_printf(ACPI_HANDLER_PRESENT_STRING, |
964 | handler_flags & | 964 | (handler_obj->address_space. |
965 | ACPI_ADDR_HANDLER_DEFAULT_INSTALLED) | 965 | handler_flags & |
966 | ? "Default" : "User", | 966 | ACPI_ADDR_HANDLER_DEFAULT_INSTALLED) |
967 | handler_obj->address_space. | 967 | ? "Default" : "User", |
968 | handler); | 968 | handler_obj->address_space. |
969 | 969 | handler); | |
970 | goto found_handler; | ||
971 | } | ||
972 | 970 | ||
973 | handler_obj = handler_obj->address_space.next; | 971 | goto found_handler; |
974 | } | 972 | } |
975 | 973 | ||
976 | /* There is no handler for this space_id */ | 974 | /* There is no handler for this space_id */ |
diff --git a/drivers/acpi/acpica/evhandler.c b/drivers/acpi/acpica/evhandler.c index 5d6a3b590645..6a7fc1163bc9 100644 --- a/drivers/acpi/acpica/evhandler.c +++ b/drivers/acpi/acpica/evhandler.c | |||
@@ -55,10 +55,6 @@ static acpi_status | |||
55 | acpi_ev_install_handler(acpi_handle obj_handle, | 55 | acpi_ev_install_handler(acpi_handle obj_handle, |
56 | u32 level, void *context, void **return_value); | 56 | u32 level, void *context, void **return_value); |
57 | 57 | ||
58 | static union acpi_operand_object | ||
59 | *acpi_ev_find_region_handler(acpi_adr_space_type space_id, | ||
60 | union acpi_operand_object *handler_obj); | ||
61 | |||
62 | /* These are the address spaces that will get default handlers */ | 58 | /* These are the address spaces that will get default handlers */ |
63 | 59 | ||
64 | u8 acpi_gbl_default_address_spaces[ACPI_NUM_DEFAULT_SPACES] = { | 60 | u8 acpi_gbl_default_address_spaces[ACPI_NUM_DEFAULT_SPACES] = { |
@@ -251,35 +247,30 @@ acpi_ev_install_handler(acpi_handle obj_handle, | |||
251 | 247 | ||
252 | /* Check if this Device already has a handler for this address space */ | 248 | /* Check if this Device already has a handler for this address space */ |
253 | 249 | ||
254 | next_handler_obj = obj_desc->device.handler; | 250 | next_handler_obj = |
255 | while (next_handler_obj) { | 251 | acpi_ev_find_region_handler(handler_obj->address_space. |
252 | space_id, | ||
253 | obj_desc->device.handler); | ||
254 | if (next_handler_obj) { | ||
256 | 255 | ||
257 | /* Found a handler, is it for the same address space? */ | 256 | /* Found a handler, is it for the same address space? */ |
258 | 257 | ||
259 | if (next_handler_obj->address_space.space_id == | 258 | ACPI_DEBUG_PRINT((ACPI_DB_OPREGION, |
260 | handler_obj->address_space.space_id) { | 259 | "Found handler for region [%s] in device %p(%p) handler %p\n", |
261 | ACPI_DEBUG_PRINT((ACPI_DB_OPREGION, | 260 | acpi_ut_get_region_name(handler_obj-> |
262 | "Found handler for region [%s] in device %p(%p) " | 261 | address_space. |
263 | "handler %p\n", | 262 | space_id), |
264 | acpi_ut_get_region_name | 263 | obj_desc, next_handler_obj, |
265 | (handler_obj->address_space. | 264 | handler_obj)); |
266 | space_id), obj_desc, | 265 | |
267 | next_handler_obj, | 266 | /* |
268 | handler_obj)); | 267 | * Since the object we found it on was a device, then it means |
269 | 268 | * that someone has already installed a handler for the branch | |
270 | /* | 269 | * of the namespace from this device on. Just bail out telling |
271 | * Since the object we found it on was a device, then it | 270 | * the walk routine to not traverse this branch. This preserves |
272 | * means that someone has already installed a handler for | 271 | * the scoping rule for handlers. |
273 | * the branch of the namespace from this device on. Just | 272 | */ |
274 | * bail out telling the walk routine to not traverse this | 273 | return (AE_CTRL_DEPTH); |
275 | * branch. This preserves the scoping rule for handlers. | ||
276 | */ | ||
277 | return (AE_CTRL_DEPTH); | ||
278 | } | ||
279 | |||
280 | /* Walk the linked list of handlers attached to this device */ | ||
281 | |||
282 | next_handler_obj = next_handler_obj->address_space.next; | ||
283 | } | 274 | } |
284 | 275 | ||
285 | /* | 276 | /* |
@@ -325,9 +316,10 @@ acpi_ev_install_handler(acpi_handle obj_handle, | |||
325 | * | 316 | * |
326 | ******************************************************************************/ | 317 | ******************************************************************************/ |
327 | 318 | ||
328 | static union acpi_operand_object | 319 | union acpi_operand_object *acpi_ev_find_region_handler(acpi_adr_space_type |
329 | *acpi_ev_find_region_handler(acpi_adr_space_type space_id, | 320 | space_id, |
330 | union acpi_operand_object *handler_obj) | 321 | union acpi_operand_object |
322 | *handler_obj) | ||
331 | { | 323 | { |
332 | 324 | ||
333 | /* Walk the handler list for this device */ | 325 | /* Walk the handler list for this device */ |
diff --git a/drivers/acpi/acpica/evrgnini.c b/drivers/acpi/acpica/evrgnini.c index 6181f5a2af4f..4df81b5a1751 100644 --- a/drivers/acpi/acpica/evrgnini.c +++ b/drivers/acpi/acpica/evrgnini.c | |||
@@ -602,60 +602,49 @@ acpi_ev_initialize_region(union acpi_operand_object *region_obj, | |||
602 | break; | 602 | break; |
603 | } | 603 | } |
604 | 604 | ||
605 | while (handler_obj) { | 605 | handler_obj = |
606 | acpi_ev_find_region_handler(space_id, handler_obj); | ||
607 | if (handler_obj) { | ||
606 | 608 | ||
607 | /* Is this handler of the correct type? */ | 609 | /* Found correct handler */ |
608 | 610 | ||
609 | if (handler_obj->address_space.space_id == | 611 | ACPI_DEBUG_PRINT((ACPI_DB_OPREGION, |
610 | space_id) { | 612 | "Found handler %p for region %p in obj %p\n", |
613 | handler_obj, region_obj, | ||
614 | obj_desc)); | ||
611 | 615 | ||
612 | /* Found correct handler */ | 616 | status = |
613 | 617 | acpi_ev_attach_region(handler_obj, | |
614 | ACPI_DEBUG_PRINT((ACPI_DB_OPREGION, | ||
615 | "Found handler %p for region %p in obj %p\n", | ||
616 | handler_obj, | ||
617 | region_obj, | 618 | region_obj, |
618 | obj_desc)); | 619 | acpi_ns_locked); |
619 | 620 | ||
621 | /* | ||
622 | * Tell all users that this region is usable by | ||
623 | * running the _REG method | ||
624 | */ | ||
625 | if (acpi_ns_locked) { | ||
620 | status = | 626 | status = |
621 | acpi_ev_attach_region(handler_obj, | 627 | acpi_ut_release_mutex |
622 | region_obj, | 628 | (ACPI_MTX_NAMESPACE); |
623 | acpi_ns_locked); | 629 | if (ACPI_FAILURE(status)) { |
624 | 630 | return_ACPI_STATUS(status); | |
625 | /* | ||
626 | * Tell all users that this region is usable by | ||
627 | * running the _REG method | ||
628 | */ | ||
629 | if (acpi_ns_locked) { | ||
630 | status = | ||
631 | acpi_ut_release_mutex | ||
632 | (ACPI_MTX_NAMESPACE); | ||
633 | if (ACPI_FAILURE(status)) { | ||
634 | return_ACPI_STATUS | ||
635 | (status); | ||
636 | } | ||
637 | } | 631 | } |
632 | } | ||
638 | 633 | ||
634 | status = | ||
635 | acpi_ev_execute_reg_method(region_obj, | ||
636 | ACPI_REG_CONNECT); | ||
637 | |||
638 | if (acpi_ns_locked) { | ||
639 | status = | 639 | status = |
640 | acpi_ev_execute_reg_method | 640 | acpi_ut_acquire_mutex |
641 | (region_obj, ACPI_REG_CONNECT); | 641 | (ACPI_MTX_NAMESPACE); |
642 | 642 | if (ACPI_FAILURE(status)) { | |
643 | if (acpi_ns_locked) { | 643 | return_ACPI_STATUS(status); |
644 | status = | ||
645 | acpi_ut_acquire_mutex | ||
646 | (ACPI_MTX_NAMESPACE); | ||
647 | if (ACPI_FAILURE(status)) { | ||
648 | return_ACPI_STATUS | ||
649 | (status); | ||
650 | } | ||
651 | } | 644 | } |
652 | |||
653 | return_ACPI_STATUS(AE_OK); | ||
654 | } | 645 | } |
655 | 646 | ||
656 | /* Try next handler in the list */ | 647 | return_ACPI_STATUS(AE_OK); |
657 | |||
658 | handler_obj = handler_obj->address_space.next; | ||
659 | } | 648 | } |
660 | } | 649 | } |
661 | 650 | ||