Skip to content

Commit

Permalink
ACPICA: Module-level code: enable _REG execution in same scope
Browse files Browse the repository at this point in the history
This change enables the execution of _REG methods that appear
in the same scope as the module-level code, in resonse to an
operation region declaration within the module-level code.

Signed-off-by: Lin Ming <ming.m.lin@intel.com>
Signed-off-by: Bob Moore <robert.moore@intel.com>
Signed-off-by: Len Brown <len.brown@intel.com>
  • Loading branch information
Lin Ming authored and Len Brown committed Dec 15, 2009
1 parent 465da9e commit e31c32c
Show file tree
Hide file tree
Showing 6 changed files with 36 additions and 4 deletions.
6 changes: 5 additions & 1 deletion drivers/acpi/acpica/acobject.h
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,11 @@ struct acpi_object_method {
u8 sync_level;
union acpi_operand_object *mutex;
u8 *aml_start;
ACPI_INTERNAL_METHOD implementation;
union {
ACPI_INTERNAL_METHOD implementation;
union acpi_operand_object *handler;
} extra;

u32 aml_length;
u8 thread_count;
acpi_owner_id owner_id;
Expand Down
2 changes: 1 addition & 1 deletion drivers/acpi/acpica/dsmethod.c
Original file line number Diff line number Diff line change
Expand Up @@ -414,7 +414,7 @@ acpi_ds_call_control_method(struct acpi_thread_state *thread,
/* Invoke an internal method if necessary */

if (obj_desc->method.method_flags & AML_METHOD_INTERNAL_ONLY) {
status = obj_desc->method.implementation(next_walk_state);
status = obj_desc->method.extra.implementation(next_walk_state);
if (status == AE_OK) {
status = AE_CTRL_TERMINATE;
}
Expand Down
15 changes: 15 additions & 0 deletions drivers/acpi/acpica/evrgnini.c
Original file line number Diff line number Diff line change
Expand Up @@ -575,6 +575,21 @@ acpi_ev_initialize_region(union acpi_operand_object *region_obj,
handler_obj = obj_desc->thermal_zone.handler;
break;

case ACPI_TYPE_METHOD:
/*
* If we are executing module level code, the original
* Node's object was replaced by this Method object and we
* saved the handler in the method object.
*
* See acpi_ns_exec_module_code
*/
if (obj_desc->method.
flags & AOPOBJ_MODULE_LEVEL) {
handler_obj =
obj_desc->method.extra.handler;
}
break;

default:
/* Ignore other objects */
break;
Expand Down
2 changes: 1 addition & 1 deletion drivers/acpi/acpica/nsaccess.c
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,7 @@ acpi_status acpi_ns_root_initialize(void)

obj_desc->method.method_flags =
AML_METHOD_INTERNAL_ONLY;
obj_desc->method.implementation =
obj_desc->method.extra.implementation =
acpi_ut_osi_implementation;
#endif
break;
Expand Down
12 changes: 12 additions & 0 deletions drivers/acpi/acpica/nseval.c
Original file line number Diff line number Diff line change
Expand Up @@ -381,6 +381,18 @@ acpi_ns_exec_module_code(union acpi_operand_object *method_obj,
method_obj->method.next_object);
type = acpi_ns_get_type(parent_node);

/*
* Get the region handler and save it in the method object. We may need
* this if an operation region declaration causes a _REG method to be run.
*
* We can't do this in acpi_ps_link_module_code because
* acpi_gbl_root_node->Object is NULL at PASS1.
*/
if ((type == ACPI_TYPE_DEVICE) && parent_node->object) {
method_obj->method.extra.handler =
parent_node->object->device.handler;
}

/* Must clear next_object (acpi_ns_attach_object needs the field) */

method_obj->method.next_object = NULL;
Expand Down
3 changes: 2 additions & 1 deletion drivers/acpi/acpica/psxface.c
Original file line number Diff line number Diff line change
Expand Up @@ -287,7 +287,8 @@ acpi_status acpi_ps_execute_method(struct acpi_evaluate_info *info)
/* Invoke an internal method if necessary */

if (info->obj_desc->method.method_flags & AML_METHOD_INTERNAL_ONLY) {
status = info->obj_desc->method.implementation(walk_state);
status =
info->obj_desc->method.extra.implementation(walk_state);
info->return_object = walk_state->return_desc;

/* Cleanup states */
Expand Down

0 comments on commit e31c32c

Please sign in to comment.