aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/acpi/dispatcher/dswstate.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/acpi/dispatcher/dswstate.c')
-rw-r--r--drivers/acpi/dispatcher/dswstate.c72
1 files changed, 39 insertions, 33 deletions
diff --git a/drivers/acpi/dispatcher/dswstate.c b/drivers/acpi/dispatcher/dswstate.c
index fa78cb74ee36..7817e5522679 100644
--- a/drivers/acpi/dispatcher/dswstate.c
+++ b/drivers/acpi/dispatcher/dswstate.c
@@ -66,7 +66,6 @@ void *acpi_ds_obj_stack_get_value(u32 index,
66#endif 66#endif
67 67
68#ifdef ACPI_FUTURE_USAGE 68#ifdef ACPI_FUTURE_USAGE
69
70/******************************************************************************* 69/*******************************************************************************
71 * 70 *
72 * FUNCTION: acpi_ds_result_remove 71 * FUNCTION: acpi_ds_result_remove
@@ -88,7 +87,7 @@ acpi_ds_result_remove(union acpi_operand_object **object,
88{ 87{
89 union acpi_generic_state *state; 88 union acpi_generic_state *state;
90 89
91 ACPI_FUNCTION_NAME("ds_result_remove"); 90 ACPI_FUNCTION_NAME(ds_result_remove);
92 91
93 state = walk_state->results; 92 state = walk_state->results;
94 if (!state) { 93 if (!state) {
@@ -128,7 +127,6 @@ acpi_ds_result_remove(union acpi_operand_object **object,
128 127
129 return (AE_OK); 128 return (AE_OK);
130} 129}
131
132#endif /* ACPI_FUTURE_USAGE */ 130#endif /* ACPI_FUTURE_USAGE */
133 131
134/******************************************************************************* 132/*******************************************************************************
@@ -152,7 +150,7 @@ acpi_ds_result_pop(union acpi_operand_object ** object,
152 acpi_native_uint index; 150 acpi_native_uint index;
153 union acpi_generic_state *state; 151 union acpi_generic_state *state;
154 152
155 ACPI_FUNCTION_NAME("ds_result_pop"); 153 ACPI_FUNCTION_NAME(ds_result_pop);
156 154
157 state = walk_state->results; 155 state = walk_state->results;
158 if (!state) { 156 if (!state) {
@@ -170,6 +168,7 @@ acpi_ds_result_pop(union acpi_operand_object ** object,
170 state->results.num_results--; 168 state->results.num_results--;
171 169
172 for (index = ACPI_OBJ_NUM_OPERANDS; index; index--) { 170 for (index = ACPI_OBJ_NUM_OPERANDS; index; index--) {
171
173 /* Check for a valid result object */ 172 /* Check for a valid result object */
174 173
175 if (state->results.obj_desc[index - 1]) { 174 if (state->results.obj_desc[index - 1]) {
@@ -213,7 +212,7 @@ acpi_ds_result_pop_from_bottom(union acpi_operand_object ** object,
213 acpi_native_uint index; 212 acpi_native_uint index;
214 union acpi_generic_state *state; 213 union acpi_generic_state *state;
215 214
216 ACPI_FUNCTION_NAME("ds_result_pop_from_bottom"); 215 ACPI_FUNCTION_NAME(ds_result_pop_from_bottom);
217 216
218 state = walk_state->results; 217 state = walk_state->results;
219 if (!state) { 218 if (!state) {
@@ -278,7 +277,7 @@ acpi_ds_result_push(union acpi_operand_object * object,
278{ 277{
279 union acpi_generic_state *state; 278 union acpi_generic_state *state;
280 279
281 ACPI_FUNCTION_NAME("ds_result_push"); 280 ACPI_FUNCTION_NAME(ds_result_push);
282 281
283 state = walk_state->results; 282 state = walk_state->results;
284 if (!state) { 283 if (!state) {
@@ -331,14 +330,14 @@ acpi_status acpi_ds_result_stack_push(struct acpi_walk_state * walk_state)
331{ 330{
332 union acpi_generic_state *state; 331 union acpi_generic_state *state;
333 332
334 ACPI_FUNCTION_NAME("ds_result_stack_push"); 333 ACPI_FUNCTION_NAME(ds_result_stack_push);
335 334
336 state = acpi_ut_create_generic_state(); 335 state = acpi_ut_create_generic_state();
337 if (!state) { 336 if (!state) {
338 return (AE_NO_MEMORY); 337 return (AE_NO_MEMORY);
339 } 338 }
340 339
341 state->common.data_type = ACPI_DESC_TYPE_STATE_RESULT; 340 state->common.descriptor_type = ACPI_DESC_TYPE_STATE_RESULT;
342 acpi_ut_push_generic_state(&walk_state->results, state); 341 acpi_ut_push_generic_state(&walk_state->results, state);
343 342
344 ACPI_DEBUG_PRINT((ACPI_DB_EXEC, "Results=%p State=%p\n", 343 ACPI_DEBUG_PRINT((ACPI_DB_EXEC, "Results=%p State=%p\n",
@@ -363,7 +362,7 @@ acpi_status acpi_ds_result_stack_pop(struct acpi_walk_state * walk_state)
363{ 362{
364 union acpi_generic_state *state; 363 union acpi_generic_state *state;
365 364
366 ACPI_FUNCTION_NAME("ds_result_stack_pop"); 365 ACPI_FUNCTION_NAME(ds_result_stack_pop);
367 366
368 /* Check for stack underflow */ 367 /* Check for stack underflow */
369 368
@@ -376,7 +375,7 @@ acpi_status acpi_ds_result_stack_pop(struct acpi_walk_state * walk_state)
376 state = acpi_ut_pop_generic_state(&walk_state->results); 375 state = acpi_ut_pop_generic_state(&walk_state->results);
377 376
378 ACPI_DEBUG_PRINT((ACPI_DB_EXEC, 377 ACPI_DEBUG_PRINT((ACPI_DB_EXEC,
379 "Result=%p remaining_results=%X State=%p\n", 378 "Result=%p RemainingResults=%X State=%p\n",
380 state, state->results.num_results, walk_state)); 379 state, state->results.num_results, walk_state));
381 380
382 acpi_ut_delete_generic_state(state); 381 acpi_ut_delete_generic_state(state);
@@ -400,7 +399,7 @@ acpi_status acpi_ds_result_stack_pop(struct acpi_walk_state * walk_state)
400acpi_status 399acpi_status
401acpi_ds_obj_stack_push(void *object, struct acpi_walk_state * walk_state) 400acpi_ds_obj_stack_push(void *object, struct acpi_walk_state * walk_state)
402{ 401{
403 ACPI_FUNCTION_NAME("ds_obj_stack_push"); 402 ACPI_FUNCTION_NAME(ds_obj_stack_push);
404 403
405 /* Check for stack overflow */ 404 /* Check for stack overflow */
406 405
@@ -445,9 +444,10 @@ acpi_ds_obj_stack_pop(u32 pop_count, struct acpi_walk_state * walk_state)
445{ 444{
446 u32 i; 445 u32 i;
447 446
448 ACPI_FUNCTION_NAME("ds_obj_stack_pop"); 447 ACPI_FUNCTION_NAME(ds_obj_stack_pop);
449 448
450 for (i = 0; i < pop_count; i++) { 449 for (i = 0; i < pop_count; i++) {
450
451 /* Check for stack underflow */ 451 /* Check for stack underflow */
452 452
453 if (walk_state->num_operands == 0) { 453 if (walk_state->num_operands == 0) {
@@ -491,9 +491,10 @@ acpi_ds_obj_stack_pop_and_delete(u32 pop_count,
491 u32 i; 491 u32 i;
492 union acpi_operand_object *obj_desc; 492 union acpi_operand_object *obj_desc;
493 493
494 ACPI_FUNCTION_NAME("ds_obj_stack_pop_and_delete"); 494 ACPI_FUNCTION_NAME(ds_obj_stack_pop_and_delete);
495 495
496 for (i = 0; i < pop_count; i++) { 496 for (i = 0; i < pop_count; i++) {
497
497 /* Check for stack underflow */ 498 /* Check for stack underflow */
498 499
499 if (walk_state->num_operands == 0) { 500 if (walk_state->num_operands == 0) {
@@ -538,13 +539,13 @@ acpi_ds_obj_stack_pop_and_delete(u32 pop_count,
538struct acpi_walk_state *acpi_ds_get_current_walk_state(struct acpi_thread_state 539struct acpi_walk_state *acpi_ds_get_current_walk_state(struct acpi_thread_state
539 *thread) 540 *thread)
540{ 541{
541 ACPI_FUNCTION_NAME("ds_get_current_walk_state"); 542 ACPI_FUNCTION_NAME(ds_get_current_walk_state);
542 543
543 if (!thread) { 544 if (!thread) {
544 return (NULL); 545 return (NULL);
545 } 546 }
546 547
547 ACPI_DEBUG_PRINT((ACPI_DB_PARSE, "Current walk_state %p\n", 548 ACPI_DEBUG_PRINT((ACPI_DB_PARSE, "Current WalkState %p\n",
548 thread->walk_state_list)); 549 thread->walk_state_list));
549 550
550 return (thread->walk_state_list); 551 return (thread->walk_state_list);
@@ -567,7 +568,7 @@ void
567acpi_ds_push_walk_state(struct acpi_walk_state *walk_state, 568acpi_ds_push_walk_state(struct acpi_walk_state *walk_state,
568 struct acpi_thread_state *thread) 569 struct acpi_thread_state *thread)
569{ 570{
570 ACPI_FUNCTION_TRACE("ds_push_walk_state"); 571 ACPI_FUNCTION_TRACE(ds_push_walk_state);
571 572
572 walk_state->next = thread->walk_state_list; 573 walk_state->next = thread->walk_state_list;
573 thread->walk_state_list = walk_state; 574 thread->walk_state_list = walk_state;
@@ -593,11 +594,12 @@ struct acpi_walk_state *acpi_ds_pop_walk_state(struct acpi_thread_state *thread)
593{ 594{
594 struct acpi_walk_state *walk_state; 595 struct acpi_walk_state *walk_state;
595 596
596 ACPI_FUNCTION_TRACE("ds_pop_walk_state"); 597 ACPI_FUNCTION_TRACE(ds_pop_walk_state);
597 598
598 walk_state = thread->walk_state_list; 599 walk_state = thread->walk_state_list;
599 600
600 if (walk_state) { 601 if (walk_state) {
602
601 /* Next walk state becomes the current walk state */ 603 /* Next walk state becomes the current walk state */
602 604
603 thread->walk_state_list = walk_state->next; 605 thread->walk_state_list = walk_state->next;
@@ -618,7 +620,7 @@ struct acpi_walk_state *acpi_ds_pop_walk_state(struct acpi_thread_state *thread)
618 * 620 *
619 * PARAMETERS: owner_id - ID for object creation 621 * PARAMETERS: owner_id - ID for object creation
620 * Origin - Starting point for this walk 622 * Origin - Starting point for this walk
621 * mth_desc - Method object 623 * method_desc - Method object
622 * Thread - Current thread state 624 * Thread - Current thread state
623 * 625 *
624 * RETURN: Pointer to the new walk state. 626 * RETURN: Pointer to the new walk state.
@@ -632,24 +634,24 @@ struct acpi_walk_state *acpi_ds_create_walk_state(acpi_owner_id owner_id,
632 union acpi_parse_object 634 union acpi_parse_object
633 *origin, 635 *origin,
634 union acpi_operand_object 636 union acpi_operand_object
635 *mth_desc, 637 *method_desc,
636 struct acpi_thread_state 638 struct acpi_thread_state
637 *thread) 639 *thread)
638{ 640{
639 struct acpi_walk_state *walk_state; 641 struct acpi_walk_state *walk_state;
640 acpi_status status; 642 acpi_status status;
641 643
642 ACPI_FUNCTION_TRACE("ds_create_walk_state"); 644 ACPI_FUNCTION_TRACE(ds_create_walk_state);
643 645
644 walk_state = ACPI_MEM_CALLOCATE(sizeof(struct acpi_walk_state)); 646 walk_state = ACPI_ALLOCATE_ZEROED(sizeof(struct acpi_walk_state));
645 if (!walk_state) { 647 if (!walk_state) {
646 return_PTR(NULL); 648 return_PTR(NULL);
647 } 649 }
648 650
649 walk_state->data_type = ACPI_DESC_TYPE_WALK; 651 walk_state->descriptor_type = ACPI_DESC_TYPE_WALK;
652 walk_state->method_desc = method_desc;
650 walk_state->owner_id = owner_id; 653 walk_state->owner_id = owner_id;
651 walk_state->origin = origin; 654 walk_state->origin = origin;
652 walk_state->method_desc = mth_desc;
653 walk_state->thread = thread; 655 walk_state->thread = thread;
654 656
655 walk_state->parser_state.start_op = origin; 657 walk_state->parser_state.start_op = origin;
@@ -664,7 +666,7 @@ struct acpi_walk_state *acpi_ds_create_walk_state(acpi_owner_id owner_id,
664 666
665 status = acpi_ds_result_stack_push(walk_state); 667 status = acpi_ds_result_stack_push(walk_state);
666 if (ACPI_FAILURE(status)) { 668 if (ACPI_FAILURE(status)) {
667 ACPI_MEM_FREE(walk_state); 669 ACPI_FREE(walk_state);
668 return_PTR(NULL); 670 return_PTR(NULL);
669 } 671 }
670 672
@@ -701,13 +703,13 @@ acpi_ds_init_aml_walk(struct acpi_walk_state *walk_state,
701 struct acpi_namespace_node *method_node, 703 struct acpi_namespace_node *method_node,
702 u8 * aml_start, 704 u8 * aml_start,
703 u32 aml_length, 705 u32 aml_length,
704 struct acpi_parameter_info *info, u8 pass_number) 706 struct acpi_evaluate_info *info, u8 pass_number)
705{ 707{
706 acpi_status status; 708 acpi_status status;
707 struct acpi_parse_state *parser_state = &walk_state->parser_state; 709 struct acpi_parse_state *parser_state = &walk_state->parser_state;
708 union acpi_parse_object *extra_op; 710 union acpi_parse_object *extra_op;
709 711
710 ACPI_FUNCTION_TRACE("ds_init_aml_walk"); 712 ACPI_FUNCTION_TRACE(ds_init_aml_walk);
711 713
712 walk_state->parser_state.aml = 714 walk_state->parser_state.aml =
713 walk_state->parser_state.aml_start = aml_start; 715 walk_state->parser_state.aml_start = aml_start;
@@ -778,6 +780,7 @@ acpi_ds_init_aml_walk(struct acpi_walk_state *walk_state,
778 } 780 }
779 781
780 if (parser_state->start_node) { 782 if (parser_state->start_node) {
783
781 /* Push start scope on scope stack and make it current */ 784 /* Push start scope on scope stack and make it current */
782 785
783 status = 786 status =
@@ -810,21 +813,24 @@ void acpi_ds_delete_walk_state(struct acpi_walk_state *walk_state)
810{ 813{
811 union acpi_generic_state *state; 814 union acpi_generic_state *state;
812 815
813 ACPI_FUNCTION_TRACE_PTR("ds_delete_walk_state", walk_state); 816 ACPI_FUNCTION_TRACE_PTR(ds_delete_walk_state, walk_state);
814 817
815 if (!walk_state) { 818 if (!walk_state) {
816 return; 819 return;
817 } 820 }
818 821
819 if (walk_state->data_type != ACPI_DESC_TYPE_WALK) { 822 if (walk_state->descriptor_type != ACPI_DESC_TYPE_WALK) {
820 ACPI_ERROR((AE_INFO, "%p is not a valid walk state", 823 ACPI_ERROR((AE_INFO, "%p is not a valid walk state",
821 walk_state)); 824 walk_state));
822 return; 825 return;
823 } 826 }
824 827
828 /* There should not be any open scopes */
829
825 if (walk_state->parser_state.scope) { 830 if (walk_state->parser_state.scope) {
826 ACPI_ERROR((AE_INFO, "%p walk still has a scope list", 831 ACPI_ERROR((AE_INFO, "%p walk still has a scope list",
827 walk_state)); 832 walk_state));
833 acpi_ps_cleanup_scope(&walk_state->parser_state);
828 } 834 }
829 835
830 /* Always must free any linked control states */ 836 /* Always must free any linked control states */
@@ -854,7 +860,7 @@ void acpi_ds_delete_walk_state(struct acpi_walk_state *walk_state)
854 acpi_ut_delete_generic_state(state); 860 acpi_ut_delete_generic_state(state);
855 } 861 }
856 862
857 ACPI_MEM_FREE(walk_state); 863 ACPI_FREE(walk_state);
858 return_VOID; 864 return_VOID;
859} 865}
860 866
@@ -879,7 +885,7 @@ acpi_ds_result_insert(void *object,
879{ 885{
880 union acpi_generic_state *state; 886 union acpi_generic_state *state;
881 887
882 ACPI_FUNCTION_NAME("ds_result_insert"); 888 ACPI_FUNCTION_NAME(ds_result_insert);
883 889
884 state = walk_state->results; 890 state = walk_state->results;
885 if (!state) { 891 if (!state) {
@@ -937,7 +943,7 @@ acpi_status acpi_ds_obj_stack_delete_all(struct acpi_walk_state * walk_state)
937{ 943{
938 u32 i; 944 u32 i;
939 945
940 ACPI_FUNCTION_TRACE_PTR("ds_obj_stack_delete_all", walk_state); 946 ACPI_FUNCTION_TRACE_PTR(ds_obj_stack_delete_all, walk_state);
941 947
942 /* The stack size is configurable, but fixed */ 948 /* The stack size is configurable, but fixed */
943 949
@@ -969,7 +975,7 @@ acpi_status
969acpi_ds_obj_stack_pop_object(union acpi_operand_object **object, 975acpi_ds_obj_stack_pop_object(union acpi_operand_object **object,
970 struct acpi_walk_state *walk_state) 976 struct acpi_walk_state *walk_state)
971{ 977{
972 ACPI_FUNCTION_NAME("ds_obj_stack_pop_object"); 978 ACPI_FUNCTION_NAME(ds_obj_stack_pop_object);
973 979
974 /* Check for stack underflow */ 980 /* Check for stack underflow */
975 981
@@ -1025,7 +1031,7 @@ acpi_ds_obj_stack_pop_object(union acpi_operand_object **object,
1025void *acpi_ds_obj_stack_get_value(u32 index, struct acpi_walk_state *walk_state) 1031void *acpi_ds_obj_stack_get_value(u32 index, struct acpi_walk_state *walk_state)
1026{ 1032{
1027 1033
1028 ACPI_FUNCTION_TRACE_PTR("ds_obj_stack_get_value", walk_state); 1034 ACPI_FUNCTION_TRACE_PTR(ds_obj_stack_get_value, walk_state);
1029 1035
1030 /* Can't do it if the stack is empty */ 1036 /* Can't do it if the stack is empty */
1031 1037