+/*******************************************************************************
+ *
+ * FUNCTION: acpi_ns_remove_reference
+ *
+ * PARAMETERS: Node - Named node whose reference count is to be
+ * decremented
+ *
+ * RETURN: None.
+ *
+ * DESCRIPTION: Remove a Node reference. Decrements the reference count
+ * of all parent Nodes up to the root. Any node along
+ * the way that reaches zero references is freed.
+ *
+ ******************************************************************************/
+
+static void acpi_ns_remove_reference(struct acpi_namespace_node *node)
+{
+ struct acpi_namespace_node *parent_node;
+ struct acpi_namespace_node *this_node;
+
+ ACPI_FUNCTION_ENTRY();
+
+ /*
+ * Decrement the reference count(s) of this node and all
+ * nodes up to the root, Delete anything with zero remaining references.
+ */
+ this_node = node;
+ while (this_node) {
+ /* Prepare to move up to parent */
+
+ parent_node = acpi_ns_get_parent_node(this_node);
+
+ /* Decrement the reference count on this node */
+
+ this_node->reference_count--;
+
+ /* Delete the node if no more references */
+
+ if (!this_node->reference_count) {
+ /* Delete all children and delete the node */
+
+ acpi_ns_delete_children(this_node);
+ acpi_ns_delete_node(this_node);
+ }
+
+ this_node = parent_node;
+ }
+}
+