aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/acpi/parser/psparse.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/acpi/parser/psparse.c')
-rw-r--r--drivers/acpi/parser/psparse.c35
1 files changed, 16 insertions, 19 deletions
diff --git a/drivers/acpi/parser/psparse.c b/drivers/acpi/parser/psparse.c
index a9f3229f4106..7ee2f2e77525 100644
--- a/drivers/acpi/parser/psparse.c
+++ b/drivers/acpi/parser/psparse.c
@@ -106,6 +106,7 @@ u16 acpi_ps_peek_opcode(struct acpi_parse_state * parser_state)
106 opcode = (u16) ACPI_GET8(aml); 106 opcode = (u16) ACPI_GET8(aml);
107 107
108 if (opcode == AML_EXTENDED_OP_PREFIX) { 108 if (opcode == AML_EXTENDED_OP_PREFIX) {
109
109 /* Extended opcode, get the second opcode byte */ 110 /* Extended opcode, get the second opcode byte */
110 111
111 aml++; 112 aml++;
@@ -137,7 +138,7 @@ acpi_ps_complete_this_op(struct acpi_walk_state * walk_state,
137 const struct acpi_opcode_info *parent_info; 138 const struct acpi_opcode_info *parent_info;
138 union acpi_parse_object *replacement_op = NULL; 139 union acpi_parse_object *replacement_op = NULL;
139 140
140 ACPI_FUNCTION_TRACE_PTR("ps_complete_this_op", op); 141 ACPI_FUNCTION_TRACE_PTR(ps_complete_this_op, op);
141 142
142 /* Check for null Op, can happen if AML code is corrupt */ 143 /* Check for null Op, can happen if AML code is corrupt */
143 144
@@ -158,6 +159,7 @@ acpi_ps_complete_this_op(struct acpi_walk_state * walk_state,
158 if (op->common.parent) { 159 if (op->common.parent) {
159 prev = op->common.parent->common.value.arg; 160 prev = op->common.parent->common.value.arg;
160 if (!prev) { 161 if (!prev) {
162
161 /* Nothing more to do */ 163 /* Nothing more to do */
162 164
163 goto cleanup; 165 goto cleanup;
@@ -245,6 +247,7 @@ acpi_ps_complete_this_op(struct acpi_walk_state * walk_state,
245 /* We must unlink this op from the parent tree */ 247 /* We must unlink this op from the parent tree */
246 248
247 if (prev == op) { 249 if (prev == op) {
250
248 /* This op is the first in the list */ 251 /* This op is the first in the list */
249 252
250 if (replacement_op) { 253 if (replacement_op) {
@@ -265,6 +268,7 @@ acpi_ps_complete_this_op(struct acpi_walk_state * walk_state,
265 268
266 else 269 else
267 while (prev) { 270 while (prev) {
271
268 /* Traverse all siblings in the parent's argument list */ 272 /* Traverse all siblings in the parent's argument list */
269 273
270 next = prev->common.next; 274 next = prev->common.next;
@@ -329,7 +333,7 @@ acpi_ps_next_parse_state(struct acpi_walk_state *walk_state,
329 struct acpi_parse_state *parser_state = &walk_state->parser_state; 333 struct acpi_parse_state *parser_state = &walk_state->parser_state;
330 acpi_status status = AE_CTRL_PENDING; 334 acpi_status status = AE_CTRL_PENDING;
331 335
332 ACPI_FUNCTION_TRACE_PTR("ps_next_parse_state", op); 336 ACPI_FUNCTION_TRACE_PTR(ps_next_parse_state, op);
333 337
334 switch (callback_status) { 338 switch (callback_status) {
335 case AE_CTRL_TERMINATE: 339 case AE_CTRL_TERMINATE:
@@ -449,10 +453,10 @@ acpi_status acpi_ps_parse_aml(struct acpi_walk_state *walk_state)
449 struct acpi_thread_state *prev_walk_list = acpi_gbl_current_walk_list; 453 struct acpi_thread_state *prev_walk_list = acpi_gbl_current_walk_list;
450 struct acpi_walk_state *previous_walk_state; 454 struct acpi_walk_state *previous_walk_state;
451 455
452 ACPI_FUNCTION_TRACE("ps_parse_aml"); 456 ACPI_FUNCTION_TRACE(ps_parse_aml);
453 457
454 ACPI_DEBUG_PRINT((ACPI_DB_PARSE, 458 ACPI_DEBUG_PRINT((ACPI_DB_PARSE,
455 "Entered with walk_state=%p Aml=%p size=%X\n", 459 "Entered with WalkState=%p Aml=%p size=%X\n",
456 walk_state, walk_state->parser_state.aml, 460 walk_state, walk_state->parser_state.aml,
457 walk_state->parser_state.aml_size)); 461 walk_state->parser_state.aml_size));
458 462
@@ -460,6 +464,7 @@ acpi_status acpi_ps_parse_aml(struct acpi_walk_state *walk_state)
460 464
461 thread = acpi_ut_create_thread_state(); 465 thread = acpi_ut_create_thread_state();
462 if (!thread) { 466 if (!thread) {
467 acpi_ds_delete_walk_state(walk_state);
463 return_ACPI_STATUS(AE_NO_MEMORY); 468 return_ACPI_STATUS(AE_NO_MEMORY);
464 } 469 }
465 470
@@ -510,6 +515,7 @@ acpi_status acpi_ps_parse_aml(struct acpi_walk_state *walk_state)
510 } else if (status == AE_CTRL_TERMINATE) { 515 } else if (status == AE_CTRL_TERMINATE) {
511 status = AE_OK; 516 status = AE_OK;
512 } else if ((status != AE_OK) && (walk_state->method_desc)) { 517 } else if ((status != AE_OK) && (walk_state->method_desc)) {
518
513 /* Either the method parse or actual execution failed */ 519 /* Either the method parse or actual execution failed */
514 520
515 ACPI_ERROR_METHOD("Method parse/execution failed", 521 ACPI_ERROR_METHOD("Method parse/execution failed",
@@ -550,20 +556,9 @@ acpi_status acpi_ps_parse_aml(struct acpi_walk_state *walk_state)
550 */ 556 */
551 if (((walk_state->parse_flags & ACPI_PARSE_MODE_MASK) == 557 if (((walk_state->parse_flags & ACPI_PARSE_MODE_MASK) ==
552 ACPI_PARSE_EXECUTE) || (ACPI_FAILURE(status))) { 558 ACPI_PARSE_EXECUTE) || (ACPI_FAILURE(status))) {
553 if (walk_state->method_desc) { 559 acpi_ds_terminate_control_method(walk_state->
554 /* Decrement the thread count on the method parse tree */ 560 method_desc,
555 561 walk_state);
556 if (walk_state->method_desc->method.
557 thread_count) {
558 walk_state->method_desc->method.
559 thread_count--;
560 } else {
561 ACPI_ERROR((AE_INFO,
562 "Invalid zero thread count in method"));
563 }
564 }
565
566 acpi_ds_terminate_control_method(walk_state);
567 } 562 }
568 563
569 /* Delete this walk state and all linked control states */ 564 /* Delete this walk state and all linked control states */
@@ -572,7 +567,7 @@ acpi_status acpi_ps_parse_aml(struct acpi_walk_state *walk_state)
572 previous_walk_state = walk_state; 567 previous_walk_state = walk_state;
573 568
574 ACPI_DEBUG_PRINT((ACPI_DB_PARSE, 569 ACPI_DEBUG_PRINT((ACPI_DB_PARSE,
575 "return_value=%p, implicit_value=%p State=%p\n", 570 "ReturnValue=%p, ImplicitValue=%p State=%p\n",
576 walk_state->return_desc, 571 walk_state->return_desc,
577 walk_state->implicit_return_obj, walk_state)); 572 walk_state->implicit_return_obj, walk_state));
578 573
@@ -633,12 +628,14 @@ acpi_status acpi_ps_parse_aml(struct acpi_walk_state *walk_state)
633 } 628 }
634 } else { 629 } else {
635 if (previous_walk_state->return_desc) { 630 if (previous_walk_state->return_desc) {
631
636 /* Caller doesn't want it, must delete it */ 632 /* Caller doesn't want it, must delete it */
637 633
638 acpi_ut_remove_reference(previous_walk_state-> 634 acpi_ut_remove_reference(previous_walk_state->
639 return_desc); 635 return_desc);
640 } 636 }
641 if (previous_walk_state->implicit_return_obj) { 637 if (previous_walk_state->implicit_return_obj) {
638
642 /* Caller doesn't want it, must delete it */ 639 /* Caller doesn't want it, must delete it */
643 640
644 acpi_ut_remove_reference(previous_walk_state-> 641 acpi_ut_remove_reference(previous_walk_state->