aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/acpi/acpica/nswalk.c
diff options
context:
space:
mode:
authorBob Moore <robert.moore@intel.com>2009-05-20 22:27:51 -0400
committerLen Brown <len.brown@intel.com>2009-05-27 00:35:50 -0400
commit8c725bf93706db976e9de495579ca625d493e809 (patch)
tree2299fdabb28ddc5cb81085dcfd13afaffc86febc /drivers/acpi/acpica/nswalk.c
parent474caffdc1ab35e9bcb1f88768442e3a4079a10d (diff)
ACPICA: Simplify and optimize NsGetNextNode function
Reduced parameter count and reduced code for this frequently used function. Signed-off-by: Bob Moore <robert.moore@intel.com> Signed-off-by: Lin Ming <ming.m.lin@intel.com> Signed-off-by: Len Brown <len.brown@intel.com>
Diffstat (limited to 'drivers/acpi/acpica/nswalk.c')
-rw-r--r--drivers/acpi/acpica/nswalk.c69
1 files changed, 53 insertions, 16 deletions
diff --git a/drivers/acpi/acpica/nswalk.c b/drivers/acpi/acpica/nswalk.c
index 83e3aa6d4b9b..35539df5c75d 100644
--- a/drivers/acpi/acpica/nswalk.c
+++ b/drivers/acpi/acpica/nswalk.c
@@ -52,8 +52,7 @@ ACPI_MODULE_NAME("nswalk")
52 * 52 *
53 * FUNCTION: acpi_ns_get_next_node 53 * FUNCTION: acpi_ns_get_next_node
54 * 54 *
55 * PARAMETERS: Type - Type of node to be searched for 55 * PARAMETERS: parent_node - Parent node whose children we are
56 * parent_node - Parent node whose children we are
57 * getting 56 * getting
58 * child_node - Previous child that was found. 57 * child_node - Previous child that was found.
59 * The NEXT child will be returned 58 * The NEXT child will be returned
@@ -66,27 +65,68 @@ ACPI_MODULE_NAME("nswalk")
66 * within Scope is returned. 65 * within Scope is returned.
67 * 66 *
68 ******************************************************************************/ 67 ******************************************************************************/
69struct acpi_namespace_node *acpi_ns_get_next_node(acpi_object_type type, struct acpi_namespace_node 68struct acpi_namespace_node *acpi_ns_get_next_node(struct acpi_namespace_node
70 *parent_node, struct acpi_namespace_node 69 *parent_node,
70 struct acpi_namespace_node
71 *child_node) 71 *child_node)
72{ 72{
73 struct acpi_namespace_node *next_node = NULL;
74
75 ACPI_FUNCTION_ENTRY(); 73 ACPI_FUNCTION_ENTRY();
76 74
77 if (!child_node) { 75 if (!child_node) {
78 76
79 /* It's really the parent's _scope_ that we want */ 77 /* It's really the parent's _scope_ that we want */
80 78
81 next_node = parent_node->child; 79 return parent_node->child;
82 } 80 }
83 81
84 else { 82 /*
85 /* Start search at the NEXT node */ 83 * Get the next node.
86 84 *
87 next_node = acpi_ns_get_next_valid_node(child_node); 85 * If we are at the end of this peer list, return NULL
86 */
87 if (child_node->flags & ANOBJ_END_OF_PEER_LIST) {
88 return NULL;
88 } 89 }
89 90
91 /* Otherwise just return the next peer */
92
93 return child_node->peer;
94}
95
96/*******************************************************************************
97 *
98 * FUNCTION: acpi_ns_get_next_node_typed
99 *
100 * PARAMETERS: Type - Type of node to be searched for
101 * parent_node - Parent node whose children we are
102 * getting
103 * child_node - Previous child that was found.
104 * The NEXT child will be returned
105 *
106 * RETURN: struct acpi_namespace_node - Pointer to the NEXT child or NULL if
107 * none is found.
108 *
109 * DESCRIPTION: Return the next peer node within the namespace. If Handle
110 * is valid, Scope is ignored. Otherwise, the first node
111 * within Scope is returned.
112 *
113 ******************************************************************************/
114
115struct acpi_namespace_node *acpi_ns_get_next_node_typed(acpi_object_type type,
116 struct
117 acpi_namespace_node
118 *parent_node,
119 struct
120 acpi_namespace_node
121 *child_node)
122{
123 struct acpi_namespace_node *next_node = NULL;
124
125 ACPI_FUNCTION_ENTRY();
126
127 next_node = acpi_ns_get_next_node(parent_node, child_node);
128
129
90 /* If any type is OK, we are done */ 130 /* If any type is OK, we are done */
91 131
92 if (type == ACPI_TYPE_ANY) { 132 if (type == ACPI_TYPE_ANY) {
@@ -186,9 +226,7 @@ acpi_ns_walk_namespace(acpi_object_type type,
186 /* Get the next node in this scope. Null if not found */ 226 /* Get the next node in this scope. Null if not found */
187 227
188 status = AE_OK; 228 status = AE_OK;
189 child_node = 229 child_node = acpi_ns_get_next_node(parent_node, child_node);
190 acpi_ns_get_next_node(ACPI_TYPE_ANY, parent_node,
191 child_node);
192 if (child_node) { 230 if (child_node) {
193 231
194 /* Found next child, get the type if we are not searching for ANY */ 232 /* Found next child, get the type if we are not searching for ANY */
@@ -269,8 +307,7 @@ acpi_ns_walk_namespace(acpi_object_type type,
269 * function has specified that the maximum depth has been reached. 307 * function has specified that the maximum depth has been reached.
270 */ 308 */
271 if ((level < max_depth) && (status != AE_CTRL_DEPTH)) { 309 if ((level < max_depth) && (status != AE_CTRL_DEPTH)) {
272 if (acpi_ns_get_next_node 310 if (child_node->child) {
273 (ACPI_TYPE_ANY, child_node, NULL)) {
274 311
275 /* There is at least one child of this node, visit it */ 312 /* There is at least one child of this node, visit it */
276 313