diff options
Diffstat (limited to 'drivers/acpi/namespace/nsalloc.c')
| -rw-r--r-- | drivers/acpi/namespace/nsalloc.c | 121 |
1 files changed, 64 insertions, 57 deletions
diff --git a/drivers/acpi/namespace/nsalloc.c b/drivers/acpi/namespace/nsalloc.c index bfd922c5c7d1..5653a19d7172 100644 --- a/drivers/acpi/namespace/nsalloc.c +++ b/drivers/acpi/namespace/nsalloc.c | |||
| @@ -49,14 +49,20 @@ | |||
| 49 | #define _COMPONENT ACPI_NAMESPACE | 49 | #define _COMPONENT ACPI_NAMESPACE |
| 50 | ACPI_MODULE_NAME ("nsalloc") | 50 | ACPI_MODULE_NAME ("nsalloc") |
| 51 | 51 | ||
| 52 | /* Local prototypes */ | ||
| 53 | |||
| 54 | static void | ||
| 55 | acpi_ns_remove_reference ( | ||
| 56 | struct acpi_namespace_node *node); | ||
| 57 | |||
| 52 | 58 | ||
| 53 | /******************************************************************************* | 59 | /******************************************************************************* |
| 54 | * | 60 | * |
| 55 | * FUNCTION: acpi_ns_create_node | 61 | * FUNCTION: acpi_ns_create_node |
| 56 | * | 62 | * |
| 57 | * PARAMETERS: acpi_name - Name of the new node | 63 | * PARAMETERS: Name - Name of the new node (4 char ACPI name) |
| 58 | * | 64 | * |
| 59 | * RETURN: None | 65 | * RETURN: New namespace node (Null on failure) |
| 60 | * | 66 | * |
| 61 | * DESCRIPTION: Create a namespace node | 67 | * DESCRIPTION: Create a namespace node |
| 62 | * | 68 | * |
| @@ -145,7 +151,6 @@ acpi_ns_delete_node ( | |||
| 145 | } | 151 | } |
| 146 | } | 152 | } |
| 147 | 153 | ||
| 148 | |||
| 149 | ACPI_MEM_TRACKING (acpi_gbl_memory_lists[ACPI_MEM_LIST_NSNODE].total_freed++); | 154 | ACPI_MEM_TRACKING (acpi_gbl_memory_lists[ACPI_MEM_LIST_NSNODE].total_freed++); |
| 150 | 155 | ||
| 151 | /* | 156 | /* |
| @@ -157,57 +162,6 @@ acpi_ns_delete_node ( | |||
| 157 | } | 162 | } |
| 158 | 163 | ||
| 159 | 164 | ||
| 160 | #ifdef ACPI_ALPHABETIC_NAMESPACE | ||
| 161 | /******************************************************************************* | ||
| 162 | * | ||
| 163 | * FUNCTION: acpi_ns_compare_names | ||
| 164 | * | ||
| 165 | * PARAMETERS: Name1 - First name to compare | ||
| 166 | * Name2 - Second name to compare | ||
| 167 | * | ||
| 168 | * RETURN: value from strncmp | ||
| 169 | * | ||
| 170 | * DESCRIPTION: Compare two ACPI names. Names that are prefixed with an | ||
| 171 | * underscore are forced to be alphabetically first. | ||
| 172 | * | ||
| 173 | ******************************************************************************/ | ||
| 174 | |||
| 175 | int | ||
| 176 | acpi_ns_compare_names ( | ||
| 177 | char *name1, | ||
| 178 | char *name2) | ||
| 179 | { | ||
| 180 | char reversed_name1[ACPI_NAME_SIZE]; | ||
| 181 | char reversed_name2[ACPI_NAME_SIZE]; | ||
| 182 | u32 i; | ||
| 183 | u32 j; | ||
| 184 | |||
| 185 | |||
| 186 | /* | ||
| 187 | * Replace all instances of "underscore" with a value that is smaller so | ||
| 188 | * that all names that are prefixed with underscore(s) are alphabetically | ||
| 189 | * first. | ||
| 190 | * | ||
| 191 | * Reverse the name bytewise so we can just do a 32-bit compare instead | ||
| 192 | * of a strncmp. | ||
| 193 | */ | ||
| 194 | for (i = 0, j= (ACPI_NAME_SIZE - 1); i < ACPI_NAME_SIZE; i++, j--) { | ||
| 195 | reversed_name1[j] = name1[i]; | ||
| 196 | if (name1[i] == '_') { | ||
| 197 | reversed_name1[j] = '*'; | ||
| 198 | } | ||
| 199 | |||
| 200 | reversed_name2[j] = name2[i]; | ||
| 201 | if (name2[i] == '_') { | ||
| 202 | reversed_name2[j] = '*'; | ||
| 203 | } | ||
| 204 | } | ||
| 205 | |||
| 206 | return (*(int *) reversed_name1 - *(int *) reversed_name2); | ||
| 207 | } | ||
| 208 | #endif | ||
| 209 | |||
| 210 | |||
| 211 | /******************************************************************************* | 165 | /******************************************************************************* |
| 212 | * | 166 | * |
| 213 | * FUNCTION: acpi_ns_install_node | 167 | * FUNCTION: acpi_ns_install_node |
| @@ -271,7 +225,8 @@ acpi_ns_install_node ( | |||
| 271 | * alphabetic placement. | 225 | * alphabetic placement. |
| 272 | */ | 226 | */ |
| 273 | previous_child_node = NULL; | 227 | previous_child_node = NULL; |
| 274 | while (acpi_ns_compare_names (acpi_ut_get_node_name (child_node), acpi_ut_get_node_name (node)) < 0) { | 228 | while (acpi_ns_compare_names (acpi_ut_get_node_name (child_node), |
| 229 | acpi_ut_get_node_name (node)) < 0) { | ||
| 275 | if (child_node->flags & ANOBJ_END_OF_PEER_LIST) { | 230 | if (child_node->flags & ANOBJ_END_OF_PEER_LIST) { |
| 276 | /* Last peer; Clear end-of-list flag */ | 231 | /* Last peer; Clear end-of-list flag */ |
| 277 | 232 | ||
| @@ -429,7 +384,8 @@ acpi_ns_delete_children ( | |||
| 429 | /* There should be only one reference remaining on this node */ | 384 | /* There should be only one reference remaining on this node */ |
| 430 | 385 | ||
| 431 | if (child_node->reference_count != 1) { | 386 | if (child_node->reference_count != 1) { |
| 432 | ACPI_REPORT_WARNING (("Existing references (%d) on node being deleted (%p)\n", | 387 | ACPI_REPORT_WARNING (( |
| 388 | "Existing references (%d) on node being deleted (%p)\n", | ||
| 433 | child_node->reference_count, child_node)); | 389 | child_node->reference_count, child_node)); |
| 434 | } | 390 | } |
| 435 | 391 | ||
| @@ -548,7 +504,7 @@ acpi_ns_delete_namespace_subtree ( | |||
| 548 | * | 504 | * |
| 549 | ******************************************************************************/ | 505 | ******************************************************************************/ |
| 550 | 506 | ||
| 551 | void | 507 | static void |
| 552 | acpi_ns_remove_reference ( | 508 | acpi_ns_remove_reference ( |
| 553 | struct acpi_namespace_node *node) | 509 | struct acpi_namespace_node *node) |
| 554 | { | 510 | { |
| @@ -683,3 +639,54 @@ acpi_ns_delete_namespace_by_owner ( | |||
| 683 | } | 639 | } |
| 684 | 640 | ||
| 685 | 641 | ||
| 642 | #ifdef ACPI_ALPHABETIC_NAMESPACE | ||
| 643 | /******************************************************************************* | ||
| 644 | * | ||
| 645 | * FUNCTION: acpi_ns_compare_names | ||
| 646 | * | ||
| 647 | * PARAMETERS: Name1 - First name to compare | ||
| 648 | * Name2 - Second name to compare | ||
| 649 | * | ||
| 650 | * RETURN: value from strncmp | ||
| 651 | * | ||
| 652 | * DESCRIPTION: Compare two ACPI names. Names that are prefixed with an | ||
| 653 | * underscore are forced to be alphabetically first. | ||
| 654 | * | ||
| 655 | ******************************************************************************/ | ||
| 656 | |||
| 657 | int | ||
| 658 | acpi_ns_compare_names ( | ||
| 659 | char *name1, | ||
| 660 | char *name2) | ||
| 661 | { | ||
| 662 | char reversed_name1[ACPI_NAME_SIZE]; | ||
| 663 | char reversed_name2[ACPI_NAME_SIZE]; | ||
| 664 | u32 i; | ||
| 665 | u32 j; | ||
| 666 | |||
| 667 | |||
| 668 | /* | ||
| 669 | * Replace all instances of "underscore" with a value that is smaller so | ||
| 670 | * that all names that are prefixed with underscore(s) are alphabetically | ||
| 671 | * first. | ||
| 672 | * | ||
| 673 | * Reverse the name bytewise so we can just do a 32-bit compare instead | ||
| 674 | * of a strncmp. | ||
| 675 | */ | ||
| 676 | for (i = 0, j= (ACPI_NAME_SIZE - 1); i < ACPI_NAME_SIZE; i++, j--) { | ||
| 677 | reversed_name1[j] = name1[i]; | ||
| 678 | if (name1[i] == '_') { | ||
| 679 | reversed_name1[j] = '*'; | ||
| 680 | } | ||
| 681 | |||
| 682 | reversed_name2[j] = name2[i]; | ||
| 683 | if (name2[i] == '_') { | ||
| 684 | reversed_name2[j] = '*'; | ||
| 685 | } | ||
| 686 | } | ||
| 687 | |||
| 688 | return (*(int *) reversed_name1 - *(int *) reversed_name2); | ||
| 689 | } | ||
| 690 | #endif | ||
| 691 | |||
| 692 | |||
