Merge branches 'work.misc' and 'work.dcache' of git://git.kernel.org/pub/scm/linux...
[sfrench/cifs-2.6.git] / drivers / acpi / acpica / psloop.c
1 // SPDX-License-Identifier: BSD-3-Clause OR GPL-2.0
2 /******************************************************************************
3  *
4  * Module Name: psloop - Main AML parse loop
5  *
6  * Copyright (C) 2000 - 2018, Intel Corp.
7  *
8  *****************************************************************************/
9
10 /*
11  * Parse the AML and build an operation tree as most interpreters, (such as
12  * Perl) do. Parsing is done by hand rather than with a YACC generated parser
13  * to tightly constrain stack and dynamic memory usage. Parsing is kept
14  * flexible and the code fairly compact by parsing based on a list of AML
15  * opcode templates in aml_op_info[].
16  */
17
18 #include <acpi/acpi.h>
19 #include "accommon.h"
20 #include "acinterp.h"
21 #include "acparser.h"
22 #include "acdispat.h"
23 #include "amlcode.h"
24 #include "acconvert.h"
25
26 #define _COMPONENT          ACPI_PARSER
27 ACPI_MODULE_NAME("psloop")
28
29 /* Local prototypes */
30 static acpi_status
31 acpi_ps_get_arguments(struct acpi_walk_state *walk_state,
32                       u8 * aml_op_start, union acpi_parse_object *op);
33
34 static void
35 acpi_ps_link_module_code(union acpi_parse_object *parent_op,
36                          u8 *aml_start, u32 aml_length, acpi_owner_id owner_id);
37
38 /*******************************************************************************
39  *
40  * FUNCTION:    acpi_ps_get_arguments
41  *
42  * PARAMETERS:  walk_state          - Current state
43  *              aml_op_start        - Op start in AML
44  *              op                  - Current Op
45  *
46  * RETURN:      Status
47  *
48  * DESCRIPTION: Get arguments for passed Op.
49  *
50  ******************************************************************************/
51
52 static acpi_status
53 acpi_ps_get_arguments(struct acpi_walk_state *walk_state,
54                       u8 * aml_op_start, union acpi_parse_object *op)
55 {
56         acpi_status status = AE_OK;
57         union acpi_parse_object *arg = NULL;
58         const struct acpi_opcode_info *op_info;
59
60         ACPI_FUNCTION_TRACE_PTR(ps_get_arguments, walk_state);
61
62         ACPI_DEBUG_PRINT((ACPI_DB_PARSE,
63                           "Get arguments for opcode [%s]\n",
64                           op->common.aml_op_name));
65
66         switch (op->common.aml_opcode) {
67         case AML_BYTE_OP:       /* AML_BYTEDATA_ARG */
68         case AML_WORD_OP:       /* AML_WORDDATA_ARG */
69         case AML_DWORD_OP:      /* AML_DWORDATA_ARG */
70         case AML_QWORD_OP:      /* AML_QWORDATA_ARG */
71         case AML_STRING_OP:     /* AML_ASCIICHARLIST_ARG */
72
73                 /* Fill in constant or string argument directly */
74
75                 acpi_ps_get_next_simple_arg(&(walk_state->parser_state),
76                                             GET_CURRENT_ARG_TYPE(walk_state->
77                                                                  arg_types),
78                                             op);
79                 break;
80
81         case AML_INT_NAMEPATH_OP:       /* AML_NAMESTRING_ARG */
82
83                 status = acpi_ps_get_next_namepath(walk_state,
84                                                    &(walk_state->parser_state),
85                                                    op,
86                                                    ACPI_POSSIBLE_METHOD_CALL);
87                 if (ACPI_FAILURE(status)) {
88                         return_ACPI_STATUS(status);
89                 }
90
91                 walk_state->arg_types = 0;
92                 break;
93
94         default:
95                 /*
96                  * Op is not a constant or string, append each argument to the Op
97                  */
98                 while (GET_CURRENT_ARG_TYPE(walk_state->arg_types) &&
99                        !walk_state->arg_count) {
100                         walk_state->aml = walk_state->parser_state.aml;
101
102                         switch (op->common.aml_opcode) {
103                         case AML_METHOD_OP:
104                         case AML_BUFFER_OP:
105                         case AML_PACKAGE_OP:
106                         case AML_VARIABLE_PACKAGE_OP:
107                         case AML_WHILE_OP:
108
109                                 break;
110
111                         default:
112
113                                 ASL_CV_CAPTURE_COMMENTS(walk_state);
114                                 break;
115                         }
116
117                         status =
118                             acpi_ps_get_next_arg(walk_state,
119                                                  &(walk_state->parser_state),
120                                                  GET_CURRENT_ARG_TYPE
121                                                  (walk_state->arg_types), &arg);
122                         if (ACPI_FAILURE(status)) {
123                                 return_ACPI_STATUS(status);
124                         }
125
126                         if (arg) {
127                                 acpi_ps_append_arg(op, arg);
128                         }
129
130                         INCREMENT_ARG_LIST(walk_state->arg_types);
131                 }
132
133                 ACPI_DEBUG_PRINT((ACPI_DB_PARSE,
134                                   "Final argument count: %8.8X pass %u\n",
135                                   walk_state->arg_count,
136                                   walk_state->pass_number));
137
138                 /*
139                  * This case handles the legacy option that groups all module-level
140                  * code blocks together and defers execution until all of the tables
141                  * are loaded. Execute all of these blocks at this time.
142                  * Execute any module-level code that was detected during the table
143                  * load phase.
144                  *
145                  * Note: this option is deprecated and will be eliminated in the
146                  * future. Use of this option can cause problems with AML code that
147                  * depends upon in-order immediate execution of module-level code.
148                  */
149                 if (acpi_gbl_group_module_level_code &&
150                     (walk_state->pass_number <= ACPI_IMODE_LOAD_PASS2) &&
151                     ((walk_state->parse_flags & ACPI_PARSE_DISASSEMBLE) == 0)) {
152                         /*
153                          * We want to skip If/Else/While constructs during Pass1 because we
154                          * want to actually conditionally execute the code during Pass2.
155                          *
156                          * Except for disassembly, where we always want to walk the
157                          * If/Else/While packages
158                          */
159                         switch (op->common.aml_opcode) {
160                         case AML_IF_OP:
161                         case AML_ELSE_OP:
162                         case AML_WHILE_OP:
163                                 /*
164                                  * Currently supported module-level opcodes are:
165                                  * IF/ELSE/WHILE. These appear to be the most common,
166                                  * and easiest to support since they open an AML
167                                  * package.
168                                  */
169                                 if (walk_state->pass_number ==
170                                     ACPI_IMODE_LOAD_PASS1) {
171                                         acpi_ps_link_module_code(op->common.
172                                                                  parent,
173                                                                  aml_op_start,
174                                                                  (u32)
175                                                                  (walk_state->
176                                                                  parser_state.
177                                                                  pkg_end -
178                                                                  aml_op_start),
179                                                                  walk_state->
180                                                                  owner_id);
181                                 }
182
183                                 ACPI_DEBUG_PRINT((ACPI_DB_PARSE,
184                                                   "Pass1: Skipping an If/Else/While body\n"));
185
186                                 /* Skip body of if/else/while in pass 1 */
187
188                                 walk_state->parser_state.aml =
189                                     walk_state->parser_state.pkg_end;
190                                 walk_state->arg_count = 0;
191                                 break;
192
193                         default:
194                                 /*
195                                  * Check for an unsupported executable opcode at module
196                                  * level. We must be in PASS1, the parent must be a SCOPE,
197                                  * The opcode class must be EXECUTE, and the opcode must
198                                  * not be an argument to another opcode.
199                                  */
200                                 if ((walk_state->pass_number ==
201                                      ACPI_IMODE_LOAD_PASS1)
202                                     && (op->common.parent->common.aml_opcode ==
203                                         AML_SCOPE_OP)) {
204                                         op_info =
205                                             acpi_ps_get_opcode_info(op->common.
206                                                                     aml_opcode);
207                                         if ((op_info->class ==
208                                              AML_CLASS_EXECUTE) && (!arg)) {
209                                                 ACPI_WARNING((AE_INFO,
210                                                               "Unsupported module-level executable opcode "
211                                                               "0x%.2X at table offset 0x%.4X",
212                                                               op->common.
213                                                               aml_opcode,
214                                                               (u32)
215                                                               (ACPI_PTR_DIFF
216                                                                (aml_op_start,
217                                                                 walk_state->
218                                                                 parser_state.
219                                                                 aml_start) +
220                                                                sizeof(struct
221                                                                       acpi_table_header))));
222                                         }
223                                 }
224                                 break;
225                         }
226                 }
227
228                 /* Special processing for certain opcodes */
229
230                 switch (op->common.aml_opcode) {
231                 case AML_METHOD_OP:
232                         /*
233                          * Skip parsing of control method because we don't have enough
234                          * info in the first pass to parse it correctly.
235                          *
236                          * Save the length and address of the body
237                          */
238                         op->named.data = walk_state->parser_state.aml;
239                         op->named.length = (u32)
240                             (walk_state->parser_state.pkg_end -
241                              walk_state->parser_state.aml);
242
243                         /* Skip body of method */
244
245                         walk_state->parser_state.aml =
246                             walk_state->parser_state.pkg_end;
247                         walk_state->arg_count = 0;
248                         break;
249
250                 case AML_BUFFER_OP:
251                 case AML_PACKAGE_OP:
252                 case AML_VARIABLE_PACKAGE_OP:
253
254                         if ((op->common.parent) &&
255                             (op->common.parent->common.aml_opcode ==
256                              AML_NAME_OP)
257                             && (walk_state->pass_number <=
258                                 ACPI_IMODE_LOAD_PASS2)) {
259                                 ACPI_DEBUG_PRINT((ACPI_DB_PARSE,
260                                                   "Setup Package/Buffer: Pass %u, AML Ptr: %p\n",
261                                                   walk_state->pass_number,
262                                                   aml_op_start));
263
264                                 /*
265                                  * Skip parsing of Buffers and Packages because we don't have
266                                  * enough info in the first pass to parse them correctly.
267                                  */
268                                 op->named.data = aml_op_start;
269                                 op->named.length = (u32)
270                                     (walk_state->parser_state.pkg_end -
271                                      aml_op_start);
272
273                                 /* Skip body */
274
275                                 walk_state->parser_state.aml =
276                                     walk_state->parser_state.pkg_end;
277                                 walk_state->arg_count = 0;
278                         }
279                         break;
280
281                 case AML_WHILE_OP:
282
283                         if (walk_state->control_state) {
284                                 walk_state->control_state->control.package_end =
285                                     walk_state->parser_state.pkg_end;
286                         }
287                         break;
288
289                 default:
290
291                         /* No action for all other opcodes */
292
293                         break;
294                 }
295
296                 break;
297         }
298
299         return_ACPI_STATUS(AE_OK);
300 }
301
302 /*******************************************************************************
303  *
304  * FUNCTION:    acpi_ps_link_module_code
305  *
306  * PARAMETERS:  parent_op           - Parent parser op
307  *              aml_start           - Pointer to the AML
308  *              aml_length          - Length of executable AML
309  *              owner_id            - owner_id of module level code
310  *
311  * RETURN:      None.
312  *
313  * DESCRIPTION: Wrap the module-level code with a method object and link the
314  *              object to the global list. Note, the mutex field of the method
315  *              object is used to link multiple module-level code objects.
316  *
317  * NOTE: In this legacy option, each block of detected executable AML
318  * code that is outside of any control method is wrapped with a temporary
319  * control method object and placed on a global list below.
320  *
321  * This function executes the module-level code for all tables only after
322  * all of the tables have been loaded. It is a legacy option and is
323  * not compatible with other ACPI implementations. See acpi_ns_load_table.
324  *
325  * This function will be removed when the legacy option is removed.
326  *
327  ******************************************************************************/
328
329 static void
330 acpi_ps_link_module_code(union acpi_parse_object *parent_op,
331                          u8 *aml_start, u32 aml_length, acpi_owner_id owner_id)
332 {
333         union acpi_operand_object *prev;
334         union acpi_operand_object *next;
335         union acpi_operand_object *method_obj;
336         struct acpi_namespace_node *parent_node;
337
338         ACPI_FUNCTION_TRACE(ps_link_module_code);
339
340         /* Get the tail of the list */
341
342         prev = next = acpi_gbl_module_code_list;
343         while (next) {
344                 prev = next;
345                 next = next->method.mutex;
346         }
347
348         /*
349          * Insert the module level code into the list. Merge it if it is
350          * adjacent to the previous element.
351          */
352         if (!prev ||
353             ((prev->method.aml_start + prev->method.aml_length) != aml_start)) {
354
355                 /* Create, initialize, and link a new temporary method object */
356
357                 method_obj = acpi_ut_create_internal_object(ACPI_TYPE_METHOD);
358                 if (!method_obj) {
359                         return_VOID;
360                 }
361
362                 ACPI_DEBUG_PRINT((ACPI_DB_PARSE,
363                                   "Create/Link new code block: %p\n",
364                                   method_obj));
365
366                 if (parent_op->common.node) {
367                         parent_node = parent_op->common.node;
368                 } else {
369                         parent_node = acpi_gbl_root_node;
370                 }
371
372                 method_obj->method.aml_start = aml_start;
373                 method_obj->method.aml_length = aml_length;
374                 method_obj->method.owner_id = owner_id;
375                 method_obj->method.info_flags |= ACPI_METHOD_MODULE_LEVEL;
376
377                 /*
378                  * Save the parent node in next_object. This is cheating, but we
379                  * don't want to expand the method object.
380                  */
381                 method_obj->method.next_object =
382                     ACPI_CAST_PTR(union acpi_operand_object, parent_node);
383
384                 if (!prev) {
385                         acpi_gbl_module_code_list = method_obj;
386                 } else {
387                         prev->method.mutex = method_obj;
388                 }
389         } else {
390                 ACPI_DEBUG_PRINT((ACPI_DB_PARSE,
391                                   "Appending to existing code block: %p\n",
392                                   prev));
393
394                 prev->method.aml_length += aml_length;
395         }
396
397         return_VOID;
398 }
399
400 /*******************************************************************************
401  *
402  * FUNCTION:    acpi_ps_parse_loop
403  *
404  * PARAMETERS:  walk_state          - Current state
405  *
406  * RETURN:      Status
407  *
408  * DESCRIPTION: Parse AML (pointed to by the current parser state) and return
409  *              a tree of ops.
410  *
411  ******************************************************************************/
412
413 acpi_status acpi_ps_parse_loop(struct acpi_walk_state *walk_state)
414 {
415         acpi_status status = AE_OK;
416         union acpi_parse_object *op = NULL;     /* current op */
417         struct acpi_parse_state *parser_state;
418         u8 *aml_op_start = NULL;
419
420         ACPI_FUNCTION_TRACE_PTR(ps_parse_loop, walk_state);
421
422         if (walk_state->descending_callback == NULL) {
423                 return_ACPI_STATUS(AE_BAD_PARAMETER);
424         }
425
426         parser_state = &walk_state->parser_state;
427         walk_state->arg_types = 0;
428
429 #if (!defined (ACPI_NO_METHOD_EXECUTION) && !defined (ACPI_CONSTANT_EVAL_ONLY))
430
431         if (walk_state->walk_type & ACPI_WALK_METHOD_RESTART) {
432
433                 /* We are restarting a preempted control method */
434
435                 if (acpi_ps_has_completed_scope(parser_state)) {
436                         /*
437                          * We must check if a predicate to an IF or WHILE statement
438                          * was just completed
439                          */
440                         if ((parser_state->scope->parse_scope.op) &&
441                             ((parser_state->scope->parse_scope.op->common.
442                               aml_opcode == AML_IF_OP)
443                              || (parser_state->scope->parse_scope.op->common.
444                                  aml_opcode == AML_WHILE_OP))
445                             && (walk_state->control_state)
446                             && (walk_state->control_state->common.state ==
447                                 ACPI_CONTROL_PREDICATE_EXECUTING)) {
448                                 /*
449                                  * A predicate was just completed, get the value of the
450                                  * predicate and branch based on that value
451                                  */
452                                 walk_state->op = NULL;
453                                 status =
454                                     acpi_ds_get_predicate_value(walk_state,
455                                                                 ACPI_TO_POINTER
456                                                                 (TRUE));
457                                 if (ACPI_FAILURE(status)
458                                     && ((status & AE_CODE_MASK) !=
459                                         AE_CODE_CONTROL)) {
460                                         if (status == AE_AML_NO_RETURN_VALUE) {
461                                                 ACPI_EXCEPTION((AE_INFO, status,
462                                                                 "Invoked method did not return a value"));
463                                         }
464
465                                         ACPI_EXCEPTION((AE_INFO, status,
466                                                         "GetPredicate Failed"));
467                                         return_ACPI_STATUS(status);
468                                 }
469
470                                 status =
471                                     acpi_ps_next_parse_state(walk_state, op,
472                                                              status);
473                         }
474
475                         acpi_ps_pop_scope(parser_state, &op,
476                                           &walk_state->arg_types,
477                                           &walk_state->arg_count);
478                         ACPI_DEBUG_PRINT((ACPI_DB_PARSE,
479                                           "Popped scope, Op=%p\n", op));
480                 } else if (walk_state->prev_op) {
481
482                         /* We were in the middle of an op */
483
484                         op = walk_state->prev_op;
485                         walk_state->arg_types = walk_state->prev_arg_types;
486                 }
487         }
488 #endif
489
490         /* Iterative parsing loop, while there is more AML to process: */
491
492         while ((parser_state->aml < parser_state->aml_end) || (op)) {
493                 ASL_CV_CAPTURE_COMMENTS(walk_state);
494
495                 aml_op_start = parser_state->aml;
496                 if (!op) {
497                         status =
498                             acpi_ps_create_op(walk_state, aml_op_start, &op);
499                         if (ACPI_FAILURE(status)) {
500                                 /*
501                                  * ACPI_PARSE_MODULE_LEVEL means that we are loading a table by
502                                  * executing it as a control method. However, if we encounter
503                                  * an error while loading the table, we need to keep trying to
504                                  * load the table rather than aborting the table load. Set the
505                                  * status to AE_OK to proceed with the table load.
506                                  */
507                                 if ((walk_state->
508                                      parse_flags & ACPI_PARSE_MODULE_LEVEL)
509                                     && status == AE_ALREADY_EXISTS) {
510                                         status = AE_OK;
511                                 }
512                                 if (status == AE_CTRL_PARSE_CONTINUE) {
513                                         continue;
514                                 }
515
516                                 if (status == AE_CTRL_PARSE_PENDING) {
517                                         status = AE_OK;
518                                 }
519
520                                 if (status == AE_CTRL_TERMINATE) {
521                                         return_ACPI_STATUS(status);
522                                 }
523
524                                 status =
525                                     acpi_ps_complete_op(walk_state, &op,
526                                                         status);
527                                 if (ACPI_FAILURE(status)) {
528                                         return_ACPI_STATUS(status);
529                                 }
530                                 if (walk_state->opcode == AML_SCOPE_OP) {
531                                         /*
532                                          * If the scope op fails to parse, skip the body of the
533                                          * scope op because the parse failure indicates that the
534                                          * device may not exist.
535                                          */
536                                         walk_state->parser_state.aml =
537                                             walk_state->aml + 1;
538                                         walk_state->parser_state.aml =
539                                             acpi_ps_get_next_package_end
540                                             (&walk_state->parser_state);
541                                         walk_state->aml =
542                                             walk_state->parser_state.aml;
543                                         ACPI_ERROR((AE_INFO,
544                                                     "Skipping Scope block"));
545                                 }
546
547                                 continue;
548                         }
549
550                         acpi_ex_start_trace_opcode(op, walk_state);
551                 }
552
553                 /*
554                  * Start arg_count at zero because we don't know if there are
555                  * any args yet
556                  */
557                 walk_state->arg_count = 0;
558
559                 switch (op->common.aml_opcode) {
560                 case AML_BYTE_OP:
561                 case AML_WORD_OP:
562                 case AML_DWORD_OP:
563                 case AML_QWORD_OP:
564
565                         break;
566
567                 default:
568
569                         ASL_CV_CAPTURE_COMMENTS(walk_state);
570                         break;
571                 }
572
573                 /* Are there any arguments that must be processed? */
574
575                 if (walk_state->arg_types) {
576
577                         /* Get arguments */
578
579                         status =
580                             acpi_ps_get_arguments(walk_state, aml_op_start, op);
581                         if (ACPI_FAILURE(status)) {
582                                 status =
583                                     acpi_ps_complete_op(walk_state, &op,
584                                                         status);
585                                 if (ACPI_FAILURE(status)) {
586                                         return_ACPI_STATUS(status);
587                                 }
588                                 if ((walk_state->control_state) &&
589                                     ((walk_state->control_state->control.
590                                       opcode == AML_IF_OP)
591                                      || (walk_state->control_state->control.
592                                          opcode == AML_WHILE_OP))) {
593                                         /*
594                                          * If the if/while op fails to parse, we will skip parsing
595                                          * the body of the op.
596                                          */
597                                         parser_state->aml =
598                                             walk_state->control_state->control.
599                                             aml_predicate_start + 1;
600                                         parser_state->aml =
601                                             acpi_ps_get_next_package_end
602                                             (parser_state);
603                                         walk_state->aml = parser_state->aml;
604
605                                         ACPI_ERROR((AE_INFO,
606                                                     "Skipping While/If block"));
607                                         if (*walk_state->aml == AML_ELSE_OP) {
608                                                 ACPI_ERROR((AE_INFO,
609                                                             "Skipping Else block"));
610                                                 walk_state->parser_state.aml =
611                                                     walk_state->aml + 1;
612                                                 walk_state->parser_state.aml =
613                                                     acpi_ps_get_next_package_end
614                                                     (parser_state);
615                                                 walk_state->aml =
616                                                     parser_state->aml;
617                                         }
618                                         ACPI_FREE(acpi_ut_pop_generic_state
619                                                   (&walk_state->control_state));
620                                 }
621                                 op = NULL;
622                                 continue;
623                         }
624                 }
625
626                 /* Check for arguments that need to be processed */
627
628                 ACPI_DEBUG_PRINT((ACPI_DB_PARSE,
629                                   "Parseloop: argument count: %8.8X\n",
630                                   walk_state->arg_count));
631
632                 if (walk_state->arg_count) {
633                         /*
634                          * There are arguments (complex ones), push Op and
635                          * prepare for argument
636                          */
637                         status = acpi_ps_push_scope(parser_state, op,
638                                                     walk_state->arg_types,
639                                                     walk_state->arg_count);
640                         if (ACPI_FAILURE(status)) {
641                                 status =
642                                     acpi_ps_complete_op(walk_state, &op,
643                                                         status);
644                                 if (ACPI_FAILURE(status)) {
645                                         return_ACPI_STATUS(status);
646                                 }
647
648                                 continue;
649                         }
650
651                         op = NULL;
652                         continue;
653                 }
654
655                 /*
656                  * All arguments have been processed -- Op is complete,
657                  * prepare for next
658                  */
659                 walk_state->op_info =
660                     acpi_ps_get_opcode_info(op->common.aml_opcode);
661                 if (walk_state->op_info->flags & AML_NAMED) {
662                         if (op->common.aml_opcode == AML_REGION_OP ||
663                             op->common.aml_opcode == AML_DATA_REGION_OP) {
664                                 /*
665                                  * Skip parsing of control method or opregion body,
666                                  * because we don't have enough info in the first pass
667                                  * to parse them correctly.
668                                  *
669                                  * Completed parsing an op_region declaration, we now
670                                  * know the length.
671                                  */
672                                 op->named.length =
673                                     (u32) (parser_state->aml - op->named.data);
674                         }
675                 }
676
677                 if (walk_state->op_info->flags & AML_CREATE) {
678                         /*
679                          * Backup to beginning of create_XXXfield declaration (1 for
680                          * Opcode)
681                          *
682                          * body_length is unknown until we parse the body
683                          */
684                         op->named.length =
685                             (u32) (parser_state->aml - op->named.data);
686                 }
687
688                 if (op->common.aml_opcode == AML_BANK_FIELD_OP) {
689                         /*
690                          * Backup to beginning of bank_field declaration
691                          *
692                          * body_length is unknown until we parse the body
693                          */
694                         op->named.length =
695                             (u32) (parser_state->aml - op->named.data);
696                 }
697
698                 /* This op complete, notify the dispatcher */
699
700                 if (walk_state->ascending_callback != NULL) {
701                         walk_state->op = op;
702                         walk_state->opcode = op->common.aml_opcode;
703
704                         status = walk_state->ascending_callback(walk_state);
705                         status =
706                             acpi_ps_next_parse_state(walk_state, op, status);
707                         if (status == AE_CTRL_PENDING) {
708                                 status = AE_OK;
709                         } else
710                             if ((walk_state->
711                                  parse_flags & ACPI_PARSE_MODULE_LEVEL)
712                                 && status != AE_CTRL_TRANSFER
713                                 && ACPI_FAILURE(status)) {
714                                 /*
715                                  * ACPI_PARSE_MODULE_LEVEL flag means that we are currently
716                                  * loading a table by executing it as a control method.
717                                  * However, if we encounter an error while loading the table,
718                                  * we need to keep trying to load the table rather than
719                                  * aborting the table load (setting the status to AE_OK
720                                  * continues the table load). If we get a failure at this
721                                  * point, it means that the dispatcher got an error while
722                                  * processing Op (most likely an AML operand error) or a
723                                  * control method was called from module level and the
724                                  * dispatcher returned AE_CTRL_TRANSFER. In the latter case,
725                                  * leave the status alone, there's nothing wrong with it.
726                                  */
727                                 status = AE_OK;
728                         }
729                 }
730
731                 status = acpi_ps_complete_op(walk_state, &op, status);
732                 if (ACPI_FAILURE(status)) {
733                         return_ACPI_STATUS(status);
734                 }
735
736         }                       /* while parser_state->Aml */
737
738         status = acpi_ps_complete_final_op(walk_state, op, status);
739         return_ACPI_STATUS(status);
740 }