FreeBSD/sys/contrib/dev/acpica/components/namespace/nsalloc.c
/*******************************************************************************
 *
 * FUNCTION:    AcpiNsDeleteNamespaceByOwner
 *
 * PARAMETERS:  OwnerId     - All nodes with this owner will be deleted
 *
 * RETURN:      Status
 *
 * DESCRIPTION: Delete entries within the namespace that are owned by a
 *              specific ID. Used to delete entire ACPI tables. All
 *              reference counts are updated.
 *
 * MUTEX:       Locks namespace during deletion walk.
 *
 ******************************************************************************/
AcpiNsDeleteNamespaceByOwner
PARAMETERS:  OwnerId     - All nodes with this owner will be deleted

Status

Delete entries within the namespace that are owned by a
specific ID. Used to delete entire ACPI tables. All
reference counts are updated.

Locks namespace during deletion walk.
AcpiNsDeleteNamespaceByOwner PARAMETERS : OwnerId - All nodes with this owner will be deleted Status Delete entries within the namespace that are owned by a specific ID . Used to delete entire ACPI tables . All reference counts are updated . Locks namespace during deletion walk .
void
AcpiNsDeleteNamespaceByOwner (
    ACPI_OWNER_ID            OwnerId)
{
    ACPI_NAMESPACE_NODE     *ChildNode;
    ACPI_NAMESPACE_NODE     *DeletionNode;
    ACPI_NAMESPACE_NODE     *ParentNode;
    UINT32                  Level;
    ACPI_STATUS             Status;
    ACPI_FUNCTION_TRACE_U32 (NsDeleteNamespaceByOwner, OwnerId);
    if (OwnerId == 0)
    {
        return_VOID;
    }
    Status = AcpiUtAcquireMutex (ACPI_MTX_NAMESPACE);
    if (ACPI_FAILURE (Status))
    {
        return_VOID;
    }
    DeletionNode = NULL;
    ParentNode = AcpiGbl_RootNode;
    ChildNode = NULL;
    Level = 1;
    while (Level > 0)
    {
        ChildNode = AcpiNsGetNextNode (ParentNode, ChildNode);
        if (DeletionNode)
        {
            AcpiNsDeleteChildren (DeletionNode);
            AcpiNsRemoveNode (DeletionNode);
            DeletionNode = NULL;
        }
        if (ChildNode)
        {
            if (ChildNode->OwnerId == OwnerId)
            {
                AcpiNsDetachObject (ChildNode);
            }
            if (ChildNode->Child)
            {
                Level++;
                ParentNode = ChildNode;
                ChildNode  = NULL;
            }
            else if (ChildNode->OwnerId == OwnerId)
            {
                DeletionNode = ChildNode;
            }
        }
        else
        {
            Level--;
            if (Level != 0)
            {
                if (ParentNode->OwnerId == OwnerId)
                {
                    DeletionNode = ParentNode;
                }
            }
            ChildNode = ParentNode;
            ParentNode = ParentNode->Parent;
        }
    }
    (void) AcpiUtReleaseMutex (ACPI_MTX_NAMESPACE);
    return_VOID;
}
void AcpiNsDeleteNamespaceByOwner ( ACPI_OWNER_ID OwnerId ) { ACPI_NAMESPACE_NODE * ChildNode ; ACPI_NAMESPACE_NODE * DeletionNode ; ACPI_NAMESPACE_NODE * ParentNode ; UINT32 Level ; ACPI_STATUS Status ; ACPI_FUNCTION_TRACE_U32 ( NsDeleteNamespaceByOwner , OwnerId ) ; if ( OwnerId == 0 ) { return_VOID ; } Status = AcpiUtAcquireMutex ( ACPI_MTX_NAMESPACE ) ; if ( ACPI_FAILURE ( Status ) ) { return_VOID ; } DeletionNode = NULL ; ParentNode = AcpiGbl_RootNode ; ChildNode = NULL ; Level = 1 ; while ( Level > 0 ) { ChildNode = AcpiNsGetNextNode ( ParentNode , ChildNode ) ; if ( DeletionNode ) { AcpiNsDeleteChildren ( DeletionNode ) ; AcpiNsRemoveNode ( DeletionNode ) ; DeletionNode = NULL ; } if ( ChildNode ) { if ( ChildNode -> OwnerId == OwnerId ) { AcpiNsDetachObject ( ChildNode ) ; } if ( ChildNode -> Child ) { Level ++ ; ParentNode = ChildNode ; ChildNode = NULL ; } else if ( ChildNode -> OwnerId == OwnerId ) { DeletionNode = ChildNode ; } } else { Level -- ; if ( Level != 0 ) { if ( ParentNode -> OwnerId == OwnerId ) { DeletionNode = ParentNode ; } } ChildNode = ParentNode ; ParentNode = ParentNode -> Parent ; } } ( void ) AcpiUtReleaseMutex ( ACPI_MTX_NAMESPACE ) ; return_VOID ; }
FUNCTION:    AcpiNsDeleteNamespaceByOwner
 PARAMETERS:  OwnerId     - All nodes with this owner will be deleted
FUNCTION : AcpiNsDeleteNamespaceByOwner PARAMETERS : OwnerId - All nodes with this owner will be deleted
/* Lock namespace for possible update */ /*
     * Traverse the tree of nodes until we bubble back up
     * to where we started.
     */ /*
         * Get the next child of this parent node. When ChildNode is NULL,
         * the first child of the parent is returned
         */ /* Found a matching child node - detach any attached object */ /* Check if this node has any children */ /*
                 * There is at least one child of this node,
                 * visit the node
                 */ /*
             * No more children of this parent node.
             * Move up to the grandparent.
             */ /* New "last child" is this parent node */ /* Move up the tree to the grandparent */