pswalk.c 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  1. // SPDX-License-Identifier: BSD-3-Clause OR GPL-2.0
  2. /******************************************************************************
  3. *
  4. * Module Name: pswalk - Parser routines to walk parsed op tree(s)
  5. *
  6. * Copyright (C) 2000 - 2018, Intel Corp.
  7. *
  8. *****************************************************************************/
  9. #include <acpi/acpi.h>
  10. #include "accommon.h"
  11. #include "acparser.h"
  12. #define _COMPONENT ACPI_PARSER
  13. ACPI_MODULE_NAME("pswalk")
  14. /*******************************************************************************
  15. *
  16. * FUNCTION: acpi_ps_delete_parse_tree
  17. *
  18. * PARAMETERS: subtree_root - Root of tree (or subtree) to delete
  19. *
  20. * RETURN: None
  21. *
  22. * DESCRIPTION: Delete a portion of or an entire parse tree.
  23. *
  24. ******************************************************************************/
  25. void acpi_ps_delete_parse_tree(union acpi_parse_object *subtree_root)
  26. {
  27. union acpi_parse_object *op = subtree_root;
  28. union acpi_parse_object *next = NULL;
  29. union acpi_parse_object *parent = NULL;
  30. ACPI_FUNCTION_TRACE_PTR(ps_delete_parse_tree, subtree_root);
  31. /* Visit all nodes in the subtree */
  32. while (op) {
  33. /* Check if we are not ascending */
  34. if (op != parent) {
  35. /* Look for an argument or child of the current op */
  36. next = acpi_ps_get_arg(op, 0);
  37. if (next) {
  38. /* Still going downward in tree (Op is not completed yet) */
  39. op = next;
  40. continue;
  41. }
  42. }
  43. /* No more children, this Op is complete. */
  44. next = op->common.next;
  45. parent = op->common.parent;
  46. acpi_ps_free_op(op);
  47. /* If we are back to the starting point, the walk is complete. */
  48. if (op == subtree_root) {
  49. return_VOID;
  50. }
  51. if (next) {
  52. op = next;
  53. } else {
  54. op = parent;
  55. }
  56. }
  57. return_VOID;
  58. }