aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/acpi/namespace/nsalloc.c
diff options
context:
space:
mode:
authorRobert Moore <robert.moore@intel.com>2005-07-29 18:15:00 -0400
committerLen Brown <len.brown@intel.com>2005-07-30 00:51:39 -0400
commit0c9938cc75057c0fca1af55a55dcfc2842436695 (patch)
treed18e809bf9e3811f20c609b6515d4d1b8520cfbc /drivers/acpi/namespace/nsalloc.c
parentdd8f39bbf5154cdbfd698fc70c66faba33eafa44 (diff)
[ACPI] ACPICA 20050729 from Bob Moore
Implemented support to ignore an attempt to install/load a particular ACPI table more than once. Apparently there exists BIOS code that repeatedly attempts to load the same SSDT upon certain events. Thanks to Venkatesh Pallipadi. Restructured the main interface to the AML parser in order to correctly handle all exceptional conditions. This will prevent leakage of the OwnerId resource and should eliminate the AE_OWNER_ID_LIMIT exceptions seen on some machines. Thanks to Alexey Starikovskiy. Support for "module level code" has been disabled in this version due to a number of issues that have appeared on various machines. The support can be enabled by defining ACPI_ENABLE_MODULE_LEVEL_CODE during subsystem compilation. When the issues are fully resolved, the code will be enabled by default again. Modified the internal functions for debug print support to define the FunctionName parameter as a (const char *) for compatibility with compiler built-in macros such as __FUNCTION__, etc. Linted the entire ACPICA source tree for both 32-bit and 64-bit. Signed-off-by: Robert Moore <robert.moore@intel.com> Signed-off-by: Len Brown <len.brown@intel.com>
Diffstat (limited to 'drivers/acpi/namespace/nsalloc.c')
-rw-r--r--drivers/acpi/namespace/nsalloc.c121
1 files changed, 8 insertions, 113 deletions
diff --git a/drivers/acpi/namespace/nsalloc.c b/drivers/acpi/namespace/nsalloc.c
index edbf1db36b68..21d560decbf9 100644
--- a/drivers/acpi/namespace/nsalloc.c
+++ b/drivers/acpi/namespace/nsalloc.c
@@ -176,10 +176,9 @@ acpi_ns_delete_node (
176 * DESCRIPTION: Initialize a new namespace node and install it amongst 176 * DESCRIPTION: Initialize a new namespace node and install it amongst
177 * its peers. 177 * its peers.
178 * 178 *
179 * Note: Current namespace lookup is linear search. However, the 179 * Note: Current namespace lookup is linear search. This appears
180 * nodes are linked in alphabetical order to 1) put all reserved 180 * to be sufficient as namespace searches consume only a small
181 * names (start with underscore) first, and to 2) make a readable 181 * fraction of the execution time of the ACPI subsystem.
182 * namespace dump.
183 * 182 *
184 ******************************************************************************/ 183 ******************************************************************************/
185 184
@@ -192,10 +191,6 @@ acpi_ns_install_node (
192{ 191{
193 acpi_owner_id owner_id = 0; 192 acpi_owner_id owner_id = 0;
194 struct acpi_namespace_node *child_node; 193 struct acpi_namespace_node *child_node;
195#ifdef ACPI_ALPHABETIC_NAMESPACE
196
197 struct acpi_namespace_node *previous_child_node;
198#endif
199 194
200 195
201 ACPI_FUNCTION_TRACE ("ns_install_node"); 196 ACPI_FUNCTION_TRACE ("ns_install_node");
@@ -219,57 +214,6 @@ acpi_ns_install_node (
219 node->peer = parent_node; 214 node->peer = parent_node;
220 } 215 }
221 else { 216 else {
222#ifdef ACPI_ALPHABETIC_NAMESPACE
223 /*
224 * Walk the list whilst searching for the correct
225 * alphabetic placement.
226 */
227 previous_child_node = NULL;
228 while (acpi_ns_compare_names (acpi_ut_get_node_name (child_node),
229 acpi_ut_get_node_name (node)) < 0) {
230 if (child_node->flags & ANOBJ_END_OF_PEER_LIST) {
231 /* Last peer; Clear end-of-list flag */
232
233 child_node->flags &= ~ANOBJ_END_OF_PEER_LIST;
234
235 /* This node is the new peer to the child node */
236
237 child_node->peer = node;
238
239 /* This node is the new end-of-list */
240
241 node->flags |= ANOBJ_END_OF_PEER_LIST;
242 node->peer = parent_node;
243 break;
244 }
245
246 /* Get next peer */
247
248 previous_child_node = child_node;
249 child_node = child_node->peer;
250 }
251
252 /* Did the node get inserted at the end-of-list? */
253
254 if (!(node->flags & ANOBJ_END_OF_PEER_LIST)) {
255 /*
256 * Loop above terminated without reaching the end-of-list.
257 * Insert the new node at the current location
258 */
259 if (previous_child_node) {
260 /* Insert node alphabetically */
261
262 node->peer = child_node;
263 previous_child_node->peer = node;
264 }
265 else {
266 /* Insert node alphabetically at start of list */
267
268 node->peer = child_node;
269 parent_node->child = node;
270 }
271 }
272#else
273 while (!(child_node->flags & ANOBJ_END_OF_PEER_LIST)) { 217 while (!(child_node->flags & ANOBJ_END_OF_PEER_LIST)) {
274 child_node = child_node->peer; 218 child_node = child_node->peer;
275 } 219 }
@@ -279,9 +223,8 @@ acpi_ns_install_node (
279 /* Clear end-of-list flag */ 223 /* Clear end-of-list flag */
280 224
281 child_node->flags &= ~ANOBJ_END_OF_PEER_LIST; 225 child_node->flags &= ~ANOBJ_END_OF_PEER_LIST;
282 node->flags |= ANOBJ_END_OF_PEER_LIST; 226 node->flags |= ANOBJ_END_OF_PEER_LIST;
283 node->peer = parent_node; 227 node->peer = parent_node;
284#endif
285 } 228 }
286 229
287 /* Init the new entry */ 230 /* Init the new entry */
@@ -570,6 +513,10 @@ acpi_ns_delete_namespace_by_owner (
570 ACPI_FUNCTION_TRACE_U32 ("ns_delete_namespace_by_owner", owner_id); 513 ACPI_FUNCTION_TRACE_U32 ("ns_delete_namespace_by_owner", owner_id);
571 514
572 515
516 if (owner_id == 0) {
517 return_VOID;
518 }
519
573 parent_node = acpi_gbl_root_node; 520 parent_node = acpi_gbl_root_node;
574 child_node = NULL; 521 child_node = NULL;
575 deletion_node = NULL; 522 deletion_node = NULL;
@@ -635,59 +582,7 @@ acpi_ns_delete_namespace_by_owner (
635 } 582 }
636 } 583 }
637 584
638 (void) acpi_ut_release_owner_id (owner_id);
639 return_VOID; 585 return_VOID;
640} 586}
641 587
642 588
643#ifdef ACPI_ALPHABETIC_NAMESPACE
644/*******************************************************************************
645 *
646 * FUNCTION: acpi_ns_compare_names
647 *
648 * PARAMETERS: Name1 - First name to compare
649 * Name2 - Second name to compare
650 *
651 * RETURN: value from strncmp
652 *
653 * DESCRIPTION: Compare two ACPI names. Names that are prefixed with an
654 * underscore are forced to be alphabetically first.
655 *
656 ******************************************************************************/
657
658int
659acpi_ns_compare_names (
660 char *name1,
661 char *name2)
662{
663 char reversed_name1[ACPI_NAME_SIZE];
664 char reversed_name2[ACPI_NAME_SIZE];
665 u32 i;
666 u32 j;
667
668
669 /*
670 * Replace all instances of "underscore" with a value that is smaller so
671 * that all names that are prefixed with underscore(s) are alphabetically
672 * first.
673 *
674 * Reverse the name bytewise so we can just do a 32-bit compare instead
675 * of a strncmp.
676 */
677 for (i = 0, j= (ACPI_NAME_SIZE - 1); i < ACPI_NAME_SIZE; i++, j--) {
678 reversed_name1[j] = name1[i];
679 if (name1[i] == '_') {
680 reversed_name1[j] = '*';
681 }
682
683 reversed_name2[j] = name2[i];
684 if (name2[i] == '_') {
685 reversed_name2[j] = '*';
686 }
687 }
688
689 return (*(int *) reversed_name1 - *(int *) reversed_name2);
690}
691#endif
692
693