1 /*******************************************************************************
2 *
3 * Module Name: nsalloc - Namespace allocation and deletion utilities
4 *
5 ******************************************************************************/
6
7 /*
8 * Copyright (C) 2000 - 2011, Intel Corp.
9 * All rights reserved.
10 *
11 * Redistribution and use in source and binary forms, with or without
12 * modification, are permitted provided that the following conditions
13 * are met:
14 * 1. Redistributions of source code must retain the above copyright
15 * notice, this list of conditions, and the following disclaimer,
16 * without modification.
17 * 2. Redistributions in binary form must reproduce at minimum a disclaimer
18 * substantially similar to the "NO WARRANTY" disclaimer below
19 * ("Disclaimer") and any redistribution must be conditioned upon
20 * including a substantially similar Disclaimer requirement for further
21 * binary redistribution.
22 * 3. Neither the names of the above-listed copyright holders nor the names
23 * of any contributors may be used to endorse or promote products derived
24 * from this software without specific prior written permission.
25 *
26 * Alternatively, this software may be distributed under the terms of the
27 * GNU General Public License ("GPL") version 2 as published by the Free
28 * Software Foundation.
104 /*******************************************************************************
105 *
106 * FUNCTION: AcpiNsDeleteNode
107 *
108 * PARAMETERS: Node - Node to be deleted
109 *
110 * RETURN: None
111 *
112 * DESCRIPTION: Delete a namespace node. All node deletions must come through
113 * here. Detaches any attached objects, including any attached
114 * data. If a handler is associated with attached data, it is
115 * invoked before the node is deleted.
116 *
117 ******************************************************************************/
118
119 void
120 AcpiNsDeleteNode (
121 ACPI_NAMESPACE_NODE *Node)
122 {
123 ACPI_OPERAND_OBJECT *ObjDesc;
124
125
126 ACPI_FUNCTION_NAME (NsDeleteNode);
127
128
129 /* Detach an object if there is one */
130
131 AcpiNsDetachObject (Node);
132
133 /*
134 * Delete an attached data object if present (an object that was created
135 * and attached via AcpiAttachData). Note: After any normal object is
136 * detached above, the only possible remaining object is a data object.
137 */
138 ObjDesc = Node->Object;
139 if (ObjDesc &&
140 (ObjDesc->Common.Type == ACPI_TYPE_LOCAL_DATA))
141 {
142 /* Invoke the attached data deletion handler if present */
143
144 if (ObjDesc->Data.Handler)
145 {
146 ObjDesc->Data.Handler (Node, ObjDesc->Data.Pointer);
147 }
148
149 AcpiUtRemoveReference (ObjDesc);
150 }
151
152 /* Now we can delete the node */
153
154 (void) AcpiOsReleaseObject (AcpiGbl_NamespaceCache, Node);
155
156 ACPI_MEM_TRACKING (AcpiGbl_NsNodeList->TotalFreed++);
157 ACPI_DEBUG_PRINT ((ACPI_DB_ALLOCATIONS, "Node %p, Remaining %X\n",
158 Node, AcpiGbl_CurrentNodeCount));
159 }
160
161
162 /*******************************************************************************
163 *
164 * FUNCTION: AcpiNsRemoveNode
165 *
166 * PARAMETERS: Node - Node to be removed/deleted
167 *
168 * RETURN: None
169 *
170 * DESCRIPTION: Remove (unlink) and delete a namespace node
171 *
567 {
568 if (ParentNode->OwnerId == OwnerId)
569 {
570 DeletionNode = ParentNode;
571 }
572 }
573
574 /* New "last child" is this parent node */
575
576 ChildNode = ParentNode;
577
578 /* Move up the tree to the grandparent */
579
580 ParentNode = ParentNode->Parent;
581 }
582 }
583
584 (void) AcpiUtReleaseMutex (ACPI_MTX_NAMESPACE);
585 return_VOID;
586 }
587
588
|
1 /*******************************************************************************
2 *
3 * Module Name: nsalloc - Namespace allocation and deletion utilities
4 *
5 ******************************************************************************/
6
7 /*
8 * Copyright (C) 2000 - 2013, Intel Corp.
9 * All rights reserved.
10 *
11 * Redistribution and use in source and binary forms, with or without
12 * modification, are permitted provided that the following conditions
13 * are met:
14 * 1. Redistributions of source code must retain the above copyright
15 * notice, this list of conditions, and the following disclaimer,
16 * without modification.
17 * 2. Redistributions in binary form must reproduce at minimum a disclaimer
18 * substantially similar to the "NO WARRANTY" disclaimer below
19 * ("Disclaimer") and any redistribution must be conditioned upon
20 * including a substantially similar Disclaimer requirement for further
21 * binary redistribution.
22 * 3. Neither the names of the above-listed copyright holders nor the names
23 * of any contributors may be used to endorse or promote products derived
24 * from this software without specific prior written permission.
25 *
26 * Alternatively, this software may be distributed under the terms of the
27 * GNU General Public License ("GPL") version 2 as published by the Free
28 * Software Foundation.
104 /*******************************************************************************
105 *
106 * FUNCTION: AcpiNsDeleteNode
107 *
108 * PARAMETERS: Node - Node to be deleted
109 *
110 * RETURN: None
111 *
112 * DESCRIPTION: Delete a namespace node. All node deletions must come through
113 * here. Detaches any attached objects, including any attached
114 * data. If a handler is associated with attached data, it is
115 * invoked before the node is deleted.
116 *
117 ******************************************************************************/
118
119 void
120 AcpiNsDeleteNode (
121 ACPI_NAMESPACE_NODE *Node)
122 {
123 ACPI_OPERAND_OBJECT *ObjDesc;
124 ACPI_OPERAND_OBJECT *NextDesc;
125
126
127 ACPI_FUNCTION_NAME (NsDeleteNode);
128
129
130 /* Detach an object if there is one */
131
132 AcpiNsDetachObject (Node);
133
134 /*
135 * Delete an attached data object list if present (objects that were
136 * attached via AcpiAttachData). Note: After any normal object is
137 * detached above, the only possible remaining object(s) are data
138 * objects, in a linked list.
139 */
140 ObjDesc = Node->Object;
141 while (ObjDesc &&
142 (ObjDesc->Common.Type == ACPI_TYPE_LOCAL_DATA))
143 {
144 /* Invoke the attached data deletion handler if present */
145
146 if (ObjDesc->Data.Handler)
147 {
148 ObjDesc->Data.Handler (Node, ObjDesc->Data.Pointer);
149 }
150
151 NextDesc = ObjDesc->Common.NextObject;
152 AcpiUtRemoveReference (ObjDesc);
153 ObjDesc = NextDesc;
154 }
155
156 /* Special case for the statically allocated root node */
157
158 if (Node == AcpiGbl_RootNode)
159 {
160 return;
161 }
162
163 /* Now we can delete the node */
164
165 (void) AcpiOsReleaseObject (AcpiGbl_NamespaceCache, Node);
166
167 ACPI_MEM_TRACKING (AcpiGbl_NsNodeList->TotalFreed++);
168 ACPI_DEBUG_PRINT ((ACPI_DB_ALLOCATIONS, "Node %p, Remaining %X\n",
169 Node, AcpiGbl_CurrentNodeCount));
170 }
171
172
173 /*******************************************************************************
174 *
175 * FUNCTION: AcpiNsRemoveNode
176 *
177 * PARAMETERS: Node - Node to be removed/deleted
178 *
179 * RETURN: None
180 *
181 * DESCRIPTION: Remove (unlink) and delete a namespace node
182 *
578 {
579 if (ParentNode->OwnerId == OwnerId)
580 {
581 DeletionNode = ParentNode;
582 }
583 }
584
585 /* New "last child" is this parent node */
586
587 ChildNode = ParentNode;
588
589 /* Move up the tree to the grandparent */
590
591 ParentNode = ParentNode->Parent;
592 }
593 }
594
595 (void) AcpiUtReleaseMutex (ACPI_MTX_NAMESPACE);
596 return_VOID;
597 }
|