aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/acpi/namespace
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/acpi/namespace')
-rw-r--r--drivers/acpi/namespace/nsaccess.c355
-rw-r--r--drivers/acpi/namespace/nsalloc.c350
-rw-r--r--drivers/acpi/namespace/nsdump.c461
-rw-r--r--drivers/acpi/namespace/nsdumpdv.c74
-rw-r--r--drivers/acpi/namespace/nseval.c274
-rw-r--r--drivers/acpi/namespace/nsinit.c257
-rw-r--r--drivers/acpi/namespace/nsload.c264
-rw-r--r--drivers/acpi/namespace/nsnames.c118
-rw-r--r--drivers/acpi/namespace/nsobject.c209
-rw-r--r--drivers/acpi/namespace/nsparse.c84
-rw-r--r--drivers/acpi/namespace/nssearch.c205
-rw-r--r--drivers/acpi/namespace/nsutils.c502
-rw-r--r--drivers/acpi/namespace/nswalk.c105
-rw-r--r--drivers/acpi/namespace/nsxfeval.c430
-rw-r--r--drivers/acpi/namespace/nsxfname.c173
-rw-r--r--drivers/acpi/namespace/nsxfobj.c91
16 files changed, 1721 insertions, 2231 deletions
diff --git a/drivers/acpi/namespace/nsaccess.c b/drivers/acpi/namespace/nsaccess.c
index ece7a9dedd5c..edfbe34600f5 100644
--- a/drivers/acpi/namespace/nsaccess.c
+++ b/drivers/acpi/namespace/nsaccess.c
@@ -41,16 +41,13 @@
41 * POSSIBILITY OF SUCH DAMAGES. 41 * POSSIBILITY OF SUCH DAMAGES.
42 */ 42 */
43 43
44
45#include <acpi/acpi.h> 44#include <acpi/acpi.h>
46#include <acpi/amlcode.h> 45#include <acpi/amlcode.h>
47#include <acpi/acnamesp.h> 46#include <acpi/acnamesp.h>
48#include <acpi/acdispat.h> 47#include <acpi/acdispat.h>
49 48
50
51#define _COMPONENT ACPI_NAMESPACE 49#define _COMPONENT ACPI_NAMESPACE
52 ACPI_MODULE_NAME ("nsaccess") 50ACPI_MODULE_NAME("nsaccess")
53
54 51
55/******************************************************************************* 52/*******************************************************************************
56 * 53 *
@@ -65,24 +62,19 @@
65 * MUTEX: Locks namespace for entire execution 62 * MUTEX: Locks namespace for entire execution
66 * 63 *
67 ******************************************************************************/ 64 ******************************************************************************/
68 65acpi_status acpi_ns_root_initialize(void)
69acpi_status
70acpi_ns_root_initialize (
71 void)
72{ 66{
73 acpi_status status; 67 acpi_status status;
74 const struct acpi_predefined_names *init_val = NULL; 68 const struct acpi_predefined_names *init_val = NULL;
75 struct acpi_namespace_node *new_node; 69 struct acpi_namespace_node *new_node;
76 union acpi_operand_object *obj_desc; 70 union acpi_operand_object *obj_desc;
77 acpi_string val = NULL; 71 acpi_string val = NULL;
78
79
80 ACPI_FUNCTION_TRACE ("ns_root_initialize");
81 72
73 ACPI_FUNCTION_TRACE("ns_root_initialize");
82 74
83 status = acpi_ut_acquire_mutex (ACPI_MTX_NAMESPACE); 75 status = acpi_ut_acquire_mutex(ACPI_MTX_NAMESPACE);
84 if (ACPI_FAILURE (status)) { 76 if (ACPI_FAILURE(status)) {
85 return_ACPI_STATUS (status); 77 return_ACPI_STATUS(status);
86 } 78 }
87 79
88 /* 80 /*
@@ -102,24 +94,26 @@ acpi_ns_root_initialize (
102 94
103 /* Enter the pre-defined names in the name table */ 95 /* Enter the pre-defined names in the name table */
104 96
105 ACPI_DEBUG_PRINT ((ACPI_DB_INFO, 97 ACPI_DEBUG_PRINT((ACPI_DB_INFO,
106 "Entering predefined entries into namespace\n")); 98 "Entering predefined entries into namespace\n"));
107 99
108 for (init_val = acpi_gbl_pre_defined_names; init_val->name; init_val++) { 100 for (init_val = acpi_gbl_pre_defined_names; init_val->name; init_val++) {
109 /* _OSI is optional for now, will be permanent later */ 101 /* _OSI is optional for now, will be permanent later */
110 102
111 if (!ACPI_STRCMP (init_val->name, "_OSI") && !acpi_gbl_create_osi_method) { 103 if (!ACPI_STRCMP(init_val->name, "_OSI")
104 && !acpi_gbl_create_osi_method) {
112 continue; 105 continue;
113 } 106 }
114 107
115 status = acpi_ns_lookup (NULL, init_val->name, init_val->type, 108 status = acpi_ns_lookup(NULL, init_val->name, init_val->type,
116 ACPI_IMODE_LOAD_PASS2, ACPI_NS_NO_UPSEARCH, 109 ACPI_IMODE_LOAD_PASS2,
117 NULL, &new_node); 110 ACPI_NS_NO_UPSEARCH, NULL, &new_node);
118 111
119 if (ACPI_FAILURE (status) || (!new_node)) /* Must be on same line for code converter */ { 112 if (ACPI_FAILURE(status) || (!new_node)) { /* Must be on same line for code converter */
120 ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, 113 ACPI_DEBUG_PRINT((ACPI_DB_ERROR,
121 "Could not create predefined name %s, %s\n", 114 "Could not create predefined name %s, %s\n",
122 init_val->name, acpi_format_exception (status))); 115 init_val->name,
116 acpi_format_exception(status)));
123 } 117 }
124 118
125 /* 119 /*
@@ -128,11 +122,11 @@ acpi_ns_root_initialize (
128 * initial value, create the initial value. 122 * initial value, create the initial value.
129 */ 123 */
130 if (init_val->val) { 124 if (init_val->val) {
131 status = acpi_os_predefined_override (init_val, &val); 125 status = acpi_os_predefined_override(init_val, &val);
132 if (ACPI_FAILURE (status)) { 126 if (ACPI_FAILURE(status)) {
133 ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, 127 ACPI_DEBUG_PRINT((ACPI_DB_ERROR,
134 "Could not override predefined %s\n", 128 "Could not override predefined %s\n",
135 init_val->name)); 129 init_val->name));
136 } 130 }
137 131
138 if (!val) { 132 if (!val) {
@@ -143,7 +137,8 @@ acpi_ns_root_initialize (
143 * Entry requests an initial value, allocate a 137 * Entry requests an initial value, allocate a
144 * descriptor for it. 138 * descriptor for it.
145 */ 139 */
146 obj_desc = acpi_ut_create_internal_object (init_val->type); 140 obj_desc =
141 acpi_ut_create_internal_object(init_val->type);
147 if (!obj_desc) { 142 if (!obj_desc) {
148 status = AE_NO_MEMORY; 143 status = AE_NO_MEMORY;
149 goto unlock_and_exit; 144 goto unlock_and_exit;
@@ -156,55 +151,62 @@ acpi_ns_root_initialize (
156 */ 151 */
157 switch (init_val->type) { 152 switch (init_val->type) {
158 case ACPI_TYPE_METHOD: 153 case ACPI_TYPE_METHOD:
159 obj_desc->method.param_count = (u8) ACPI_TO_INTEGER (val); 154 obj_desc->method.param_count =
155 (u8) ACPI_TO_INTEGER(val);
160 obj_desc->common.flags |= AOPOBJ_DATA_VALID; 156 obj_desc->common.flags |= AOPOBJ_DATA_VALID;
161 157
162#if defined (_ACPI_ASL_COMPILER) || defined (_ACPI_DUMP_App) 158#if defined (ACPI_ASL_COMPILER)
163 159
164 /* 160 /* save the parameter count for the i_aSL compiler */
165 * i_aSL Compiler cheats by putting parameter count 161
166 * in the owner_iD 162 new_node->value = obj_desc->method.param_count;
167 */
168 new_node->owner_id = obj_desc->method.param_count;
169#else 163#else
170 /* Mark this as a very SPECIAL method */ 164 /* Mark this as a very SPECIAL method */
171 165
172 obj_desc->method.method_flags = AML_METHOD_INTERNAL_ONLY; 166 obj_desc->method.method_flags =
173 obj_desc->method.implementation = acpi_ut_osi_implementation; 167 AML_METHOD_INTERNAL_ONLY;
168
169#ifndef ACPI_DUMP_APP
170 obj_desc->method.implementation =
171 acpi_ut_osi_implementation;
172#endif
174#endif 173#endif
175 break; 174 break;
176 175
177 case ACPI_TYPE_INTEGER: 176 case ACPI_TYPE_INTEGER:
178 177
179 obj_desc->integer.value = ACPI_TO_INTEGER (val); 178 obj_desc->integer.value = ACPI_TO_INTEGER(val);
180 break; 179 break;
181 180
182
183 case ACPI_TYPE_STRING: 181 case ACPI_TYPE_STRING:
184 182
185 /* 183 /*
186 * Build an object around the static string 184 * Build an object around the static string
187 */ 185 */
188 obj_desc->string.length = (u32) ACPI_STRLEN (val); 186 obj_desc->string.length =
187 (u32) ACPI_STRLEN(val);
189 obj_desc->string.pointer = val; 188 obj_desc->string.pointer = val;
190 obj_desc->common.flags |= AOPOBJ_STATIC_POINTER; 189 obj_desc->common.flags |= AOPOBJ_STATIC_POINTER;
191 break; 190 break;
192 191
193
194 case ACPI_TYPE_MUTEX: 192 case ACPI_TYPE_MUTEX:
195 193
196 obj_desc->mutex.node = new_node; 194 obj_desc->mutex.node = new_node;
197 obj_desc->mutex.sync_level = (u8) (ACPI_TO_INTEGER (val) - 1); 195 obj_desc->mutex.sync_level =
196 (u8) (ACPI_TO_INTEGER(val) - 1);
198 197
199 if (ACPI_STRCMP (init_val->name, "_GL_") == 0) { 198 if (ACPI_STRCMP(init_val->name, "_GL_") == 0) {
200 /* 199 /*
201 * Create a counting semaphore for the 200 * Create a counting semaphore for the
202 * global lock 201 * global lock
203 */ 202 */
204 status = acpi_os_create_semaphore (ACPI_NO_UNIT_LIMIT, 203 status =
205 1, &obj_desc->mutex.semaphore); 204 acpi_os_create_semaphore
206 if (ACPI_FAILURE (status)) { 205 (ACPI_NO_UNIT_LIMIT, 1,
207 acpi_ut_remove_reference (obj_desc); 206 &obj_desc->mutex.semaphore);
207 if (ACPI_FAILURE(status)) {
208 acpi_ut_remove_reference
209 (obj_desc);
208 goto unlock_and_exit; 210 goto unlock_and_exit;
209 } 211 }
210 212
@@ -212,56 +214,58 @@ acpi_ns_root_initialize (
212 * We just created the mutex for the 214 * We just created the mutex for the
213 * global lock, save it 215 * global lock, save it
214 */ 216 */
215 acpi_gbl_global_lock_semaphore = obj_desc->mutex.semaphore; 217 acpi_gbl_global_lock_semaphore =
216 } 218 obj_desc->mutex.semaphore;
217 else { 219 } else {
218 /* Create a mutex */ 220 /* Create a mutex */
219 221
220 status = acpi_os_create_semaphore (1, 1, 222 status = acpi_os_create_semaphore(1, 1,
221 &obj_desc->mutex.semaphore); 223 &obj_desc->
222 if (ACPI_FAILURE (status)) { 224 mutex.
223 acpi_ut_remove_reference (obj_desc); 225 semaphore);
226 if (ACPI_FAILURE(status)) {
227 acpi_ut_remove_reference
228 (obj_desc);
224 goto unlock_and_exit; 229 goto unlock_and_exit;
225 } 230 }
226 } 231 }
227 break; 232 break;
228 233
229
230 default: 234 default:
231 235
232 ACPI_REPORT_ERROR (("Unsupported initial type value %X\n", 236 ACPI_REPORT_ERROR(("Unsupported initial type value %X\n", init_val->type));
233 init_val->type)); 237 acpi_ut_remove_reference(obj_desc);
234 acpi_ut_remove_reference (obj_desc);
235 obj_desc = NULL; 238 obj_desc = NULL;
236 continue; 239 continue;
237 } 240 }
238 241
239 /* Store pointer to value descriptor in the Node */ 242 /* Store pointer to value descriptor in the Node */
240 243
241 status = acpi_ns_attach_object (new_node, obj_desc, 244 status = acpi_ns_attach_object(new_node, obj_desc,
242 ACPI_GET_OBJECT_TYPE (obj_desc)); 245 ACPI_GET_OBJECT_TYPE
246 (obj_desc));
243 247
244 /* Remove local reference to the object */ 248 /* Remove local reference to the object */
245 249
246 acpi_ut_remove_reference (obj_desc); 250 acpi_ut_remove_reference(obj_desc);
247 } 251 }
248 } 252 }
249 253
250 254 unlock_and_exit:
251unlock_and_exit: 255 (void)acpi_ut_release_mutex(ACPI_MTX_NAMESPACE);
252 (void) acpi_ut_release_mutex (ACPI_MTX_NAMESPACE);
253 256
254 /* Save a handle to "_GPE", it is always present */ 257 /* Save a handle to "_GPE", it is always present */
255 258
256 if (ACPI_SUCCESS (status)) { 259 if (ACPI_SUCCESS(status)) {
257 status = acpi_ns_get_node_by_path ("\\_GPE", NULL, ACPI_NS_NO_UPSEARCH, 260 status =
258 &acpi_gbl_fadt_gpe_device); 261 acpi_ns_get_node_by_path("\\_GPE", NULL,
262 ACPI_NS_NO_UPSEARCH,
263 &acpi_gbl_fadt_gpe_device);
259 } 264 }
260 265
261 return_ACPI_STATUS (status); 266 return_ACPI_STATUS(status);
262} 267}
263 268
264
265/******************************************************************************* 269/*******************************************************************************
266 * 270 *
267 * FUNCTION: acpi_ns_lookup 271 * FUNCTION: acpi_ns_lookup
@@ -286,62 +290,57 @@ unlock_and_exit:
286 ******************************************************************************/ 290 ******************************************************************************/
287 291
288acpi_status 292acpi_status
289acpi_ns_lookup ( 293acpi_ns_lookup(union acpi_generic_state *scope_info,
290 union acpi_generic_state *scope_info, 294 char *pathname,
291 char *pathname, 295 acpi_object_type type,
292 acpi_object_type type, 296 acpi_interpreter_mode interpreter_mode,
293 acpi_interpreter_mode interpreter_mode, 297 u32 flags,
294 u32 flags, 298 struct acpi_walk_state *walk_state,
295 struct acpi_walk_state *walk_state, 299 struct acpi_namespace_node **return_node)
296 struct acpi_namespace_node **return_node)
297{ 300{
298 acpi_status status; 301 acpi_status status;
299 char *path = pathname; 302 char *path = pathname;
300 struct acpi_namespace_node *prefix_node; 303 struct acpi_namespace_node *prefix_node;
301 struct acpi_namespace_node *current_node = NULL; 304 struct acpi_namespace_node *current_node = NULL;
302 struct acpi_namespace_node *this_node = NULL; 305 struct acpi_namespace_node *this_node = NULL;
303 u32 num_segments; 306 u32 num_segments;
304 u32 num_carats; 307 u32 num_carats;
305 acpi_name simple_name; 308 acpi_name simple_name;
306 acpi_object_type type_to_check_for; 309 acpi_object_type type_to_check_for;
307 acpi_object_type this_search_type; 310 acpi_object_type this_search_type;
308 u32 search_parent_flag = ACPI_NS_SEARCH_PARENT; 311 u32 search_parent_flag = ACPI_NS_SEARCH_PARENT;
309 u32 local_flags = flags & ~(ACPI_NS_ERROR_IF_FOUND | 312 u32 local_flags = flags & ~(ACPI_NS_ERROR_IF_FOUND |
310 ACPI_NS_SEARCH_PARENT); 313 ACPI_NS_SEARCH_PARENT);
311 314
312 315 ACPI_FUNCTION_TRACE("ns_lookup");
313 ACPI_FUNCTION_TRACE ("ns_lookup");
314
315 316
316 if (!return_node) { 317 if (!return_node) {
317 return_ACPI_STATUS (AE_BAD_PARAMETER); 318 return_ACPI_STATUS(AE_BAD_PARAMETER);
318 } 319 }
319 320
320 acpi_gbl_ns_lookup_count++; 321 acpi_gbl_ns_lookup_count++;
321 *return_node = ACPI_ENTRY_NOT_FOUND; 322 *return_node = ACPI_ENTRY_NOT_FOUND;
322 323
323 if (!acpi_gbl_root_node) { 324 if (!acpi_gbl_root_node) {
324 return_ACPI_STATUS (AE_NO_NAMESPACE); 325 return_ACPI_STATUS(AE_NO_NAMESPACE);
325 } 326 }
326 327
327 /* 328 /*
328 * Get the prefix scope. 329 * Get the prefix scope.
329 * A null scope means use the root scope 330 * A null scope means use the root scope
330 */ 331 */
331 if ((!scope_info) || 332 if ((!scope_info) || (!scope_info->scope.node)) {
332 (!scope_info->scope.node)) { 333 ACPI_DEBUG_PRINT((ACPI_DB_NAMES,
333 ACPI_DEBUG_PRINT ((ACPI_DB_NAMES, 334 "Null scope prefix, using root node (%p)\n",
334 "Null scope prefix, using root node (%p)\n", 335 acpi_gbl_root_node));
335 acpi_gbl_root_node));
336 336
337 prefix_node = acpi_gbl_root_node; 337 prefix_node = acpi_gbl_root_node;
338 } 338 } else {
339 else {
340 prefix_node = scope_info->scope.node; 339 prefix_node = scope_info->scope.node;
341 if (ACPI_GET_DESCRIPTOR_TYPE (prefix_node) != ACPI_DESC_TYPE_NAMED) { 340 if (ACPI_GET_DESCRIPTOR_TYPE(prefix_node) !=
342 ACPI_REPORT_ERROR (("ns_lookup: %p is not a namespace node [%s]\n", 341 ACPI_DESC_TYPE_NAMED) {
343 prefix_node, acpi_ut_get_descriptor_name (prefix_node))); 342 ACPI_REPORT_ERROR(("ns_lookup: %p is not a namespace node [%s]\n", prefix_node, acpi_ut_get_descriptor_name(prefix_node)));
344 return_ACPI_STATUS (AE_AML_INTERNAL); 343 return_ACPI_STATUS(AE_AML_INTERNAL);
345 } 344 }
346 345
347 /* 346 /*
@@ -349,9 +348,9 @@ acpi_ns_lookup (
349 * Device/Method, etc.) It could be a Package or other object node. 348 * Device/Method, etc.) It could be a Package or other object node.
350 * Backup up the tree to find the containing scope node. 349 * Backup up the tree to find the containing scope node.
351 */ 350 */
352 while (!acpi_ns_opens_scope (prefix_node->type) && 351 while (!acpi_ns_opens_scope(prefix_node->type) &&
353 prefix_node->type != ACPI_TYPE_ANY) { 352 prefix_node->type != ACPI_TYPE_ANY) {
354 prefix_node = acpi_ns_get_parent_node (prefix_node); 353 prefix_node = acpi_ns_get_parent_node(prefix_node);
355 } 354 }
356 } 355 }
357 356
@@ -366,13 +365,13 @@ acpi_ns_lookup (
366 /* A Null name_path is allowed and refers to the root */ 365 /* A Null name_path is allowed and refers to the root */
367 366
368 num_segments = 0; 367 num_segments = 0;
369 this_node = acpi_gbl_root_node; 368 this_node = acpi_gbl_root_node;
370 path = ""; 369 path = "";
371 370
372 ACPI_DEBUG_PRINT ((ACPI_DB_NAMES, 371 ACPI_DEBUG_PRINT((ACPI_DB_NAMES,
373 "Null Pathname (Zero segments), Flags=%X\n", flags)); 372 "Null Pathname (Zero segments), Flags=%X\n",
374 } 373 flags));
375 else { 374 } else {
376 /* 375 /*
377 * Name pointer is valid (and must be in internal name format) 376 * Name pointer is valid (and must be in internal name format)
378 * 377 *
@@ -396,15 +395,16 @@ acpi_ns_lookup (
396 395
397 path++; 396 path++;
398 397
399 ACPI_DEBUG_PRINT ((ACPI_DB_NAMES, 398 ACPI_DEBUG_PRINT((ACPI_DB_NAMES,
400 "Path is absolute from root [%p]\n", this_node)); 399 "Path is absolute from root [%p]\n",
401 } 400 this_node));
402 else { 401 } else {
403 /* Pathname is relative to current scope, start there */ 402 /* Pathname is relative to current scope, start there */
404 403
405 ACPI_DEBUG_PRINT ((ACPI_DB_NAMES, 404 ACPI_DEBUG_PRINT((ACPI_DB_NAMES,
406 "Searching relative to prefix scope [%4.4s] (%p)\n", 405 "Searching relative to prefix scope [%4.4s] (%p)\n",
407 acpi_ut_get_node_name (prefix_node), prefix_node)); 406 acpi_ut_get_node_name(prefix_node),
407 prefix_node));
408 408
409 /* 409 /*
410 * Handle multiple Parent Prefixes (carat) by just getting 410 * Handle multiple Parent Prefixes (carat) by just getting
@@ -425,20 +425,20 @@ acpi_ns_lookup (
425 /* Backup to the parent node */ 425 /* Backup to the parent node */
426 426
427 num_carats++; 427 num_carats++;
428 this_node = acpi_ns_get_parent_node (this_node); 428 this_node = acpi_ns_get_parent_node(this_node);
429 if (!this_node) { 429 if (!this_node) {
430 /* Current scope has no parent scope */ 430 /* Current scope has no parent scope */
431 431
432 ACPI_REPORT_ERROR ( 432 ACPI_REPORT_ERROR(("ACPI path has too many parent prefixes (^) - reached beyond root node\n"));
433 ("ACPI path has too many parent prefixes (^) - reached beyond root node\n")); 433 return_ACPI_STATUS(AE_NOT_FOUND);
434 return_ACPI_STATUS (AE_NOT_FOUND);
435 } 434 }
436 } 435 }
437 436
438 if (search_parent_flag == ACPI_NS_NO_UPSEARCH) { 437 if (search_parent_flag == ACPI_NS_NO_UPSEARCH) {
439 ACPI_DEBUG_PRINT ((ACPI_DB_NAMES, 438 ACPI_DEBUG_PRINT((ACPI_DB_NAMES,
440 "Search scope is [%4.4s], path has %d carat(s)\n", 439 "Search scope is [%4.4s], path has %d carat(s)\n",
441 acpi_ut_get_node_name (this_node), num_carats)); 440 acpi_ut_get_node_name
441 (this_node), num_carats));
442 } 442 }
443 } 443 }
444 444
@@ -464,9 +464,9 @@ acpi_ns_lookup (
464 num_segments = 0; 464 num_segments = 0;
465 type = this_node->type; 465 type = this_node->type;
466 466
467 ACPI_DEBUG_PRINT ((ACPI_DB_NAMES, 467 ACPI_DEBUG_PRINT((ACPI_DB_NAMES,
468 "Prefix-only Pathname (Zero name segments), Flags=%X\n", 468 "Prefix-only Pathname (Zero name segments), Flags=%X\n",
469 flags)); 469 flags));
470 break; 470 break;
471 471
472 case AML_DUAL_NAME_PREFIX: 472 case AML_DUAL_NAME_PREFIX:
@@ -480,8 +480,9 @@ acpi_ns_lookup (
480 num_segments = 2; 480 num_segments = 2;
481 path++; 481 path++;
482 482
483 ACPI_DEBUG_PRINT ((ACPI_DB_NAMES, 483 ACPI_DEBUG_PRINT((ACPI_DB_NAMES,
484 "Dual Pathname (2 segments, Flags=%X)\n", flags)); 484 "Dual Pathname (2 segments, Flags=%X)\n",
485 flags));
485 break; 486 break;
486 487
487 case AML_MULTI_NAME_PREFIX_OP: 488 case AML_MULTI_NAME_PREFIX_OP:
@@ -493,12 +494,12 @@ acpi_ns_lookup (
493 /* Extract segment count, point to first name segment */ 494 /* Extract segment count, point to first name segment */
494 495
495 path++; 496 path++;
496 num_segments = (u32) (u8) *path; 497 num_segments = (u32) (u8) * path;
497 path++; 498 path++;
498 499
499 ACPI_DEBUG_PRINT ((ACPI_DB_NAMES, 500 ACPI_DEBUG_PRINT((ACPI_DB_NAMES,
500 "Multi Pathname (%d Segments, Flags=%X) \n", 501 "Multi Pathname (%d Segments, Flags=%X) \n",
501 num_segments, flags)); 502 num_segments, flags));
502 break; 503 break;
503 504
504 default: 505 default:
@@ -508,15 +509,15 @@ acpi_ns_lookup (
508 */ 509 */
509 num_segments = 1; 510 num_segments = 1;
510 511
511 ACPI_DEBUG_PRINT ((ACPI_DB_NAMES, 512 ACPI_DEBUG_PRINT((ACPI_DB_NAMES,
512 "Simple Pathname (1 segment, Flags=%X)\n", flags)); 513 "Simple Pathname (1 segment, Flags=%X)\n",
514 flags));
513 break; 515 break;
514 } 516 }
515 517
516 ACPI_DEBUG_EXEC (acpi_ns_print_pathname (num_segments, path)); 518 ACPI_DEBUG_EXEC(acpi_ns_print_pathname(num_segments, path));
517 } 519 }
518 520
519
520 /* 521 /*
521 * Search namespace for each segment of the name. Loop through and 522 * Search namespace for each segment of the name. Loop through and
522 * verify (or add to the namespace) each name segment. 523 * verify (or add to the namespace) each name segment.
@@ -540,7 +541,7 @@ acpi_ns_lookup (
540 * requested it AND we have a single, non-fully-qualified name_seg 541 * requested it AND we have a single, non-fully-qualified name_seg
541 */ 542 */
542 if ((search_parent_flag != ACPI_NS_NO_UPSEARCH) && 543 if ((search_parent_flag != ACPI_NS_NO_UPSEARCH) &&
543 (flags & ACPI_NS_SEARCH_PARENT)) { 544 (flags & ACPI_NS_SEARCH_PARENT)) {
544 local_flags |= ACPI_NS_SEARCH_PARENT; 545 local_flags |= ACPI_NS_SEARCH_PARENT;
545 } 546 }
546 547
@@ -553,24 +554,28 @@ acpi_ns_lookup (
553 554
554 /* Extract one ACPI name from the front of the pathname */ 555 /* Extract one ACPI name from the front of the pathname */
555 556
556 ACPI_MOVE_32_TO_32 (&simple_name, path); 557 ACPI_MOVE_32_TO_32(&simple_name, path);
557 558
558 /* Try to find the single (4 character) ACPI name */ 559 /* Try to find the single (4 character) ACPI name */
559 560
560 status = acpi_ns_search_and_enter (simple_name, walk_state, current_node, 561 status =
561 interpreter_mode, this_search_type, local_flags, &this_node); 562 acpi_ns_search_and_enter(simple_name, walk_state,
562 if (ACPI_FAILURE (status)) { 563 current_node, interpreter_mode,
564 this_search_type, local_flags,
565 &this_node);
566 if (ACPI_FAILURE(status)) {
563 if (status == AE_NOT_FOUND) { 567 if (status == AE_NOT_FOUND) {
564 /* Name not found in ACPI namespace */ 568 /* Name not found in ACPI namespace */
565 569
566 ACPI_DEBUG_PRINT ((ACPI_DB_NAMES, 570 ACPI_DEBUG_PRINT((ACPI_DB_NAMES,
567 "Name [%4.4s] not found in scope [%4.4s] %p\n", 571 "Name [%4.4s] not found in scope [%4.4s] %p\n",
568 (char *) &simple_name, (char *) &current_node->name, 572 (char *)&simple_name,
569 current_node)); 573 (char *)&current_node->name,
574 current_node));
570 } 575 }
571 576
572 *return_node = this_node; 577 *return_node = this_node;
573 return_ACPI_STATUS (status); 578 return_ACPI_STATUS(status);
574 } 579 }
575 580
576 /* 581 /*
@@ -586,19 +591,16 @@ acpi_ns_lookup (
586 * 591 *
587 * Then we have a type mismatch. Just warn and ignore it. 592 * Then we have a type mismatch. Just warn and ignore it.
588 */ 593 */
589 if ((num_segments == 0) && 594 if ((num_segments == 0) &&
590 (type_to_check_for != ACPI_TYPE_ANY) && 595 (type_to_check_for != ACPI_TYPE_ANY) &&
591 (type_to_check_for != ACPI_TYPE_LOCAL_ALIAS) && 596 (type_to_check_for != ACPI_TYPE_LOCAL_ALIAS) &&
592 (type_to_check_for != ACPI_TYPE_LOCAL_METHOD_ALIAS) && 597 (type_to_check_for != ACPI_TYPE_LOCAL_METHOD_ALIAS) &&
593 (type_to_check_for != ACPI_TYPE_LOCAL_SCOPE) && 598 (type_to_check_for != ACPI_TYPE_LOCAL_SCOPE) &&
594 (this_node->type != ACPI_TYPE_ANY) && 599 (this_node->type != ACPI_TYPE_ANY) &&
595 (this_node->type != type_to_check_for)) { 600 (this_node->type != type_to_check_for)) {
596 /* Complain about a type mismatch */ 601 /* Complain about a type mismatch */
597 602
598 ACPI_REPORT_WARNING ( 603 ACPI_REPORT_WARNING(("ns_lookup: Type mismatch on %4.4s (%s), searching for (%s)\n", (char *)&simple_name, acpi_ut_get_type_name(this_node->type), acpi_ut_get_type_name(type_to_check_for)));
599 ("ns_lookup: Type mismatch on %4.4s (%s), searching for (%s)\n",
600 (char *) &simple_name, acpi_ut_get_type_name (this_node->type),
601 acpi_ut_get_type_name (type_to_check_for)));
602 } 604 }
603 605
604 /* 606 /*
@@ -624,15 +626,16 @@ acpi_ns_lookup (
624 * If entry is a type which opens a scope, push the new scope on the 626 * If entry is a type which opens a scope, push the new scope on the
625 * scope stack. 627 * scope stack.
626 */ 628 */
627 if (acpi_ns_opens_scope (type)) { 629 if (acpi_ns_opens_scope(type)) {
628 status = acpi_ds_scope_stack_push (this_node, type, walk_state); 630 status =
629 if (ACPI_FAILURE (status)) { 631 acpi_ds_scope_stack_push(this_node, type,
630 return_ACPI_STATUS (status); 632 walk_state);
633 if (ACPI_FAILURE(status)) {
634 return_ACPI_STATUS(status);
631 } 635 }
632 } 636 }
633 } 637 }
634 638
635 *return_node = this_node; 639 *return_node = this_node;
636 return_ACPI_STATUS (AE_OK); 640 return_ACPI_STATUS(AE_OK);
637} 641}
638
diff --git a/drivers/acpi/namespace/nsalloc.c b/drivers/acpi/namespace/nsalloc.c
index 5653a19d7172..cc7a85f8cfe6 100644
--- a/drivers/acpi/namespace/nsalloc.c
+++ b/drivers/acpi/namespace/nsalloc.c
@@ -41,20 +41,14 @@
41 * POSSIBILITY OF SUCH DAMAGES. 41 * POSSIBILITY OF SUCH DAMAGES.
42 */ 42 */
43 43
44
45#include <acpi/acpi.h> 44#include <acpi/acpi.h>
46#include <acpi/acnamesp.h> 45#include <acpi/acnamesp.h>
47 46
48
49#define _COMPONENT ACPI_NAMESPACE 47#define _COMPONENT ACPI_NAMESPACE
50 ACPI_MODULE_NAME ("nsalloc") 48ACPI_MODULE_NAME("nsalloc")
51 49
52/* Local prototypes */ 50/* Local prototypes */
53 51static void acpi_ns_remove_reference(struct acpi_namespace_node *node);
54static void
55acpi_ns_remove_reference (
56 struct acpi_namespace_node *node);
57
58 52
59/******************************************************************************* 53/*******************************************************************************
60 * 54 *
@@ -68,31 +62,26 @@ acpi_ns_remove_reference (
68 * 62 *
69 ******************************************************************************/ 63 ******************************************************************************/
70 64
71struct acpi_namespace_node * 65struct acpi_namespace_node *acpi_ns_create_node(u32 name)
72acpi_ns_create_node (
73 u32 name)
74{ 66{
75 struct acpi_namespace_node *node; 67 struct acpi_namespace_node *node;
76
77 68
78 ACPI_FUNCTION_TRACE ("ns_create_node"); 69 ACPI_FUNCTION_TRACE("ns_create_node");
79 70
80 71 node = ACPI_MEM_CALLOCATE(sizeof(struct acpi_namespace_node));
81 node = ACPI_MEM_CALLOCATE (sizeof (struct acpi_namespace_node));
82 if (!node) { 72 if (!node) {
83 return_PTR (NULL); 73 return_PTR(NULL);
84 } 74 }
85 75
86 ACPI_MEM_TRACKING (acpi_gbl_memory_lists[ACPI_MEM_LIST_NSNODE].total_allocated++); 76 ACPI_MEM_TRACKING(acpi_gbl_ns_node_list->total_allocated++);
87 77
88 node->name.integer = name; 78 node->name.integer = name;
89 node->reference_count = 1; 79 node->reference_count = 1;
90 ACPI_SET_DESCRIPTOR_TYPE (node, ACPI_DESC_TYPE_NAMED); 80 ACPI_SET_DESCRIPTOR_TYPE(node, ACPI_DESC_TYPE_NAMED);
91 81
92 return_PTR (node); 82 return_PTR(node);
93} 83}
94 84
95
96/******************************************************************************* 85/*******************************************************************************
97 * 86 *
98 * FUNCTION: acpi_ns_delete_node 87 * FUNCTION: acpi_ns_delete_node
@@ -105,19 +94,15 @@ acpi_ns_create_node (
105 * 94 *
106 ******************************************************************************/ 95 ******************************************************************************/
107 96
108void 97void acpi_ns_delete_node(struct acpi_namespace_node *node)
109acpi_ns_delete_node (
110 struct acpi_namespace_node *node)
111{ 98{
112 struct acpi_namespace_node *parent_node; 99 struct acpi_namespace_node *parent_node;
113 struct acpi_namespace_node *prev_node; 100 struct acpi_namespace_node *prev_node;
114 struct acpi_namespace_node *next_node; 101 struct acpi_namespace_node *next_node;
115
116 102
117 ACPI_FUNCTION_TRACE_PTR ("ns_delete_node", node); 103 ACPI_FUNCTION_TRACE_PTR("ns_delete_node", node);
118 104
119 105 parent_node = acpi_ns_get_parent_node(node);
120 parent_node = acpi_ns_get_parent_node (node);
121 106
122 prev_node = NULL; 107 prev_node = NULL;
123 next_node = parent_node->child; 108 next_node = parent_node->child;
@@ -136,32 +121,29 @@ acpi_ns_delete_node (
136 if (next_node->flags & ANOBJ_END_OF_PEER_LIST) { 121 if (next_node->flags & ANOBJ_END_OF_PEER_LIST) {
137 prev_node->flags |= ANOBJ_END_OF_PEER_LIST; 122 prev_node->flags |= ANOBJ_END_OF_PEER_LIST;
138 } 123 }
139 } 124 } else {
140 else {
141 /* Node is first child (has no previous peer) */ 125 /* Node is first child (has no previous peer) */
142 126
143 if (next_node->flags & ANOBJ_END_OF_PEER_LIST) { 127 if (next_node->flags & ANOBJ_END_OF_PEER_LIST) {
144 /* No peers at all */ 128 /* No peers at all */
145 129
146 parent_node->child = NULL; 130 parent_node->child = NULL;
147 } 131 } else { /* Link peer list to parent */
148 else { /* Link peer list to parent */
149 132
150 parent_node->child = next_node->peer; 133 parent_node->child = next_node->peer;
151 } 134 }
152 } 135 }
153 136
154 ACPI_MEM_TRACKING (acpi_gbl_memory_lists[ACPI_MEM_LIST_NSNODE].total_freed++); 137 ACPI_MEM_TRACKING(acpi_gbl_ns_node_list->total_freed++);
155 138
156 /* 139 /*
157 * Detach an object if there is one then delete the node 140 * Detach an object if there is one then delete the node
158 */ 141 */
159 acpi_ns_detach_object (node); 142 acpi_ns_detach_object(node);
160 ACPI_MEM_FREE (node); 143 ACPI_MEM_FREE(node);
161 return_VOID; 144 return_VOID;
162} 145}
163 146
164
165/******************************************************************************* 147/*******************************************************************************
166 * 148 *
167 * FUNCTION: acpi_ns_install_node 149 * FUNCTION: acpi_ns_install_node
@@ -176,30 +158,20 @@ acpi_ns_delete_node (
176 * DESCRIPTION: Initialize a new namespace node and install it amongst 158 * DESCRIPTION: Initialize a new namespace node and install it amongst
177 * its peers. 159 * its peers.
178 * 160 *
179 * Note: Current namespace lookup is linear search. However, the 161 * Note: Current namespace lookup is linear search. This appears
180 * nodes are linked in alphabetical order to 1) put all reserved 162 * to be sufficient as namespace searches consume only a small
181 * names (start with underscore) first, and to 2) make a readable 163 * fraction of the execution time of the ACPI subsystem.
182 * namespace dump.
183 * 164 *
184 ******************************************************************************/ 165 ******************************************************************************/
185 166
186void 167void acpi_ns_install_node(struct acpi_walk_state *walk_state, struct acpi_namespace_node *parent_node, /* Parent */
187acpi_ns_install_node ( 168 struct acpi_namespace_node *node, /* New Child */
188 struct acpi_walk_state *walk_state, 169 acpi_object_type type)
189 struct acpi_namespace_node *parent_node, /* Parent */
190 struct acpi_namespace_node *node, /* New Child*/
191 acpi_object_type type)
192{ 170{
193 u16 owner_id = 0; 171 acpi_owner_id owner_id = 0;
194 struct acpi_namespace_node *child_node; 172 struct acpi_namespace_node *child_node;
195#ifdef ACPI_ALPHABETIC_NAMESPACE
196
197 struct acpi_namespace_node *previous_child_node;
198#endif
199
200
201 ACPI_FUNCTION_TRACE ("ns_install_node");
202 173
174 ACPI_FUNCTION_TRACE("ns_install_node");
203 175
204 /* 176 /*
205 * Get the owner ID from the Walk state 177 * Get the owner ID from the Walk state
@@ -217,59 +189,7 @@ acpi_ns_install_node (
217 parent_node->child = node; 189 parent_node->child = node;
218 node->flags |= ANOBJ_END_OF_PEER_LIST; 190 node->flags |= ANOBJ_END_OF_PEER_LIST;
219 node->peer = parent_node; 191 node->peer = parent_node;
220 } 192 } else {
221 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)) { 193 while (!(child_node->flags & ANOBJ_END_OF_PEER_LIST)) {
274 child_node = child_node->peer; 194 child_node = child_node->peer;
275 } 195 }
@@ -279,9 +199,8 @@ acpi_ns_install_node (
279 /* Clear end-of-list flag */ 199 /* Clear end-of-list flag */
280 200
281 child_node->flags &= ~ANOBJ_END_OF_PEER_LIST; 201 child_node->flags &= ~ANOBJ_END_OF_PEER_LIST;
282 node->flags |= ANOBJ_END_OF_PEER_LIST; 202 node->flags |= ANOBJ_END_OF_PEER_LIST;
283 node->peer = parent_node; 203 node->peer = parent_node;
284#endif
285 } 204 }
286 205
287 /* Init the new entry */ 206 /* Init the new entry */
@@ -289,24 +208,25 @@ acpi_ns_install_node (
289 node->owner_id = owner_id; 208 node->owner_id = owner_id;
290 node->type = (u8) type; 209 node->type = (u8) type;
291 210
292 ACPI_DEBUG_PRINT ((ACPI_DB_NAMES, 211 ACPI_DEBUG_PRINT((ACPI_DB_NAMES,
293 "%4.4s (%s) [Node %p Owner %X] added to %4.4s (%s) [Node %p]\n", 212 "%4.4s (%s) [Node %p Owner %X] added to %4.4s (%s) [Node %p]\n",
294 acpi_ut_get_node_name (node), acpi_ut_get_type_name (node->type), node, owner_id, 213 acpi_ut_get_node_name(node),
295 acpi_ut_get_node_name (parent_node), acpi_ut_get_type_name (parent_node->type), 214 acpi_ut_get_type_name(node->type), node, owner_id,
296 parent_node)); 215 acpi_ut_get_node_name(parent_node),
216 acpi_ut_get_type_name(parent_node->type),
217 parent_node));
297 218
298 /* 219 /*
299 * Increment the reference count(s) of all parents up to 220 * Increment the reference count(s) of all parents up to
300 * the root! 221 * the root!
301 */ 222 */
302 while ((node = acpi_ns_get_parent_node (node)) != NULL) { 223 while ((node = acpi_ns_get_parent_node(node)) != NULL) {
303 node->reference_count++; 224 node->reference_count++;
304 } 225 }
305 226
306 return_VOID; 227 return_VOID;
307} 228}
308 229
309
310/******************************************************************************* 230/*******************************************************************************
311 * 231 *
312 * FUNCTION: acpi_ns_delete_children 232 * FUNCTION: acpi_ns_delete_children
@@ -320,18 +240,14 @@ acpi_ns_install_node (
320 * 240 *
321 ******************************************************************************/ 241 ******************************************************************************/
322 242
323void 243void acpi_ns_delete_children(struct acpi_namespace_node *parent_node)
324acpi_ns_delete_children (
325 struct acpi_namespace_node *parent_node)
326{ 244{
327 struct acpi_namespace_node *child_node; 245 struct acpi_namespace_node *child_node;
328 struct acpi_namespace_node *next_node; 246 struct acpi_namespace_node *next_node;
329 struct acpi_namespace_node *node; 247 struct acpi_namespace_node *node;
330 u8 flags; 248 u8 flags;
331
332
333 ACPI_FUNCTION_TRACE_PTR ("ns_delete_children", parent_node);
334 249
250 ACPI_FUNCTION_TRACE_PTR("ns_delete_children", parent_node);
335 251
336 if (!parent_node) { 252 if (!parent_node) {
337 return_VOID; 253 return_VOID;
@@ -350,48 +266,48 @@ acpi_ns_delete_children (
350 do { 266 do {
351 /* Get the things we need */ 267 /* Get the things we need */
352 268
353 next_node = child_node->peer; 269 next_node = child_node->peer;
354 flags = child_node->flags; 270 flags = child_node->flags;
355 271
356 /* Grandchildren should have all been deleted already */ 272 /* Grandchildren should have all been deleted already */
357 273
358 if (child_node->child) { 274 if (child_node->child) {
359 ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "Found a grandchild! P=%p C=%p\n", 275 ACPI_DEBUG_PRINT((ACPI_DB_ERROR,
360 parent_node, child_node)); 276 "Found a grandchild! P=%p C=%p\n",
277 parent_node, child_node));
361 } 278 }
362 279
363 /* Now we can free this child object */ 280 /* Now we can free this child object */
364 281
365 ACPI_MEM_TRACKING (acpi_gbl_memory_lists[ACPI_MEM_LIST_NSNODE].total_freed++); 282 ACPI_MEM_TRACKING(acpi_gbl_ns_node_list->total_freed++);
366 283
367 ACPI_DEBUG_PRINT ((ACPI_DB_ALLOCATIONS, "Object %p, Remaining %X\n", 284 ACPI_DEBUG_PRINT((ACPI_DB_ALLOCATIONS,
368 child_node, acpi_gbl_current_node_count)); 285 "Object %p, Remaining %X\n", child_node,
286 acpi_gbl_current_node_count));
369 287
370 /* 288 /*
371 * Detach an object if there is one, then free the child node 289 * Detach an object if there is one, then free the child node
372 */ 290 */
373 acpi_ns_detach_object (child_node); 291 acpi_ns_detach_object(child_node);
374 292
375 /* 293 /*
376 * Decrement the reference count(s) of all parents up to 294 * Decrement the reference count(s) of all parents up to
377 * the root! (counts were incremented when the node was created) 295 * the root! (counts were incremented when the node was created)
378 */ 296 */
379 node = child_node; 297 node = child_node;
380 while ((node = acpi_ns_get_parent_node (node)) != NULL) { 298 while ((node = acpi_ns_get_parent_node(node)) != NULL) {
381 node->reference_count--; 299 node->reference_count--;
382 } 300 }
383 301
384 /* There should be only one reference remaining on this node */ 302 /* There should be only one reference remaining on this node */
385 303
386 if (child_node->reference_count != 1) { 304 if (child_node->reference_count != 1) {
387 ACPI_REPORT_WARNING (( 305 ACPI_REPORT_WARNING(("Existing references (%d) on node being deleted (%p)\n", child_node->reference_count, child_node));
388 "Existing references (%d) on node being deleted (%p)\n",
389 child_node->reference_count, child_node));
390 } 306 }
391 307
392 /* Now we can delete the node */ 308 /* Now we can delete the node */
393 309
394 ACPI_MEM_FREE (child_node); 310 ACPI_MEM_FREE(child_node);
395 311
396 /* And move on to the next child in the list */ 312 /* And move on to the next child in the list */
397 313
@@ -399,7 +315,6 @@ acpi_ns_delete_children (
399 315
400 } while (!(flags & ANOBJ_END_OF_PEER_LIST)); 316 } while (!(flags & ANOBJ_END_OF_PEER_LIST));
401 317
402
403 /* Clear the parent's child pointer */ 318 /* Clear the parent's child pointer */
404 319
405 parent_node->child = NULL; 320 parent_node->child = NULL;
@@ -407,7 +322,6 @@ acpi_ns_delete_children (
407 return_VOID; 322 return_VOID;
408} 323}
409 324
410
411/******************************************************************************* 325/*******************************************************************************
412 * 326 *
413 * FUNCTION: acpi_ns_delete_namespace_subtree 327 * FUNCTION: acpi_ns_delete_namespace_subtree
@@ -421,16 +335,12 @@ acpi_ns_delete_children (
421 * 335 *
422 ******************************************************************************/ 336 ******************************************************************************/
423 337
424void 338void acpi_ns_delete_namespace_subtree(struct acpi_namespace_node *parent_node)
425acpi_ns_delete_namespace_subtree (
426 struct acpi_namespace_node *parent_node)
427{ 339{
428 struct acpi_namespace_node *child_node = NULL; 340 struct acpi_namespace_node *child_node = NULL;
429 u32 level = 1; 341 u32 level = 1;
430
431
432 ACPI_FUNCTION_TRACE ("ns_delete_namespace_subtree");
433 342
343 ACPI_FUNCTION_TRACE("ns_delete_namespace_subtree");
434 344
435 if (!parent_node) { 345 if (!parent_node) {
436 return_VOID; 346 return_VOID;
@@ -443,16 +353,17 @@ acpi_ns_delete_namespace_subtree (
443 while (level > 0) { 353 while (level > 0) {
444 /* Get the next node in this scope (NULL if none) */ 354 /* Get the next node in this scope (NULL if none) */
445 355
446 child_node = acpi_ns_get_next_node (ACPI_TYPE_ANY, parent_node, 356 child_node = acpi_ns_get_next_node(ACPI_TYPE_ANY, parent_node,
447 child_node); 357 child_node);
448 if (child_node) { 358 if (child_node) {
449 /* Found a child node - detach any attached object */ 359 /* Found a child node - detach any attached object */
450 360
451 acpi_ns_detach_object (child_node); 361 acpi_ns_detach_object(child_node);
452 362
453 /* Check if this node has any children */ 363 /* Check if this node has any children */
454 364
455 if (acpi_ns_get_next_node (ACPI_TYPE_ANY, child_node, NULL)) { 365 if (acpi_ns_get_next_node
366 (ACPI_TYPE_ANY, child_node, NULL)) {
456 /* 367 /*
457 * There is at least one child of this node, 368 * There is at least one child of this node,
458 * visit the node 369 * visit the node
@@ -461,8 +372,7 @@ acpi_ns_delete_namespace_subtree (
461 parent_node = child_node; 372 parent_node = child_node;
462 child_node = NULL; 373 child_node = NULL;
463 } 374 }
464 } 375 } else {
465 else {
466 /* 376 /*
467 * No more children of this parent node. 377 * No more children of this parent node.
468 * Move up to the grandparent. 378 * Move up to the grandparent.
@@ -473,7 +383,7 @@ acpi_ns_delete_namespace_subtree (
473 * Now delete all of the children of this parent 383 * Now delete all of the children of this parent
474 * all at the same time. 384 * all at the same time.
475 */ 385 */
476 acpi_ns_delete_children (parent_node); 386 acpi_ns_delete_children(parent_node);
477 387
478 /* New "last child" is this parent node */ 388 /* New "last child" is this parent node */
479 389
@@ -481,14 +391,13 @@ acpi_ns_delete_namespace_subtree (
481 391
482 /* Move up the tree to the grandparent */ 392 /* Move up the tree to the grandparent */
483 393
484 parent_node = acpi_ns_get_parent_node (parent_node); 394 parent_node = acpi_ns_get_parent_node(parent_node);
485 } 395 }
486 } 396 }
487 397
488 return_VOID; 398 return_VOID;
489} 399}
490 400
491
492/******************************************************************************* 401/*******************************************************************************
493 * 402 *
494 * FUNCTION: acpi_ns_remove_reference 403 * FUNCTION: acpi_ns_remove_reference
@@ -504,16 +413,12 @@ acpi_ns_delete_namespace_subtree (
504 * 413 *
505 ******************************************************************************/ 414 ******************************************************************************/
506 415
507static void 416static void acpi_ns_remove_reference(struct acpi_namespace_node *node)
508acpi_ns_remove_reference (
509 struct acpi_namespace_node *node)
510{ 417{
511 struct acpi_namespace_node *parent_node; 418 struct acpi_namespace_node *parent_node;
512 struct acpi_namespace_node *this_node; 419 struct acpi_namespace_node *this_node;
513
514
515 ACPI_FUNCTION_ENTRY ();
516 420
421 ACPI_FUNCTION_ENTRY();
517 422
518 /* 423 /*
519 * Decrement the reference count(s) of this node and all 424 * Decrement the reference count(s) of this node and all
@@ -523,7 +428,7 @@ acpi_ns_remove_reference (
523 while (this_node) { 428 while (this_node) {
524 /* Prepare to move up to parent */ 429 /* Prepare to move up to parent */
525 430
526 parent_node = acpi_ns_get_parent_node (this_node); 431 parent_node = acpi_ns_get_parent_node(this_node);
527 432
528 /* Decrement the reference count on this node */ 433 /* Decrement the reference count on this node */
529 434
@@ -534,15 +439,14 @@ acpi_ns_remove_reference (
534 if (!this_node->reference_count) { 439 if (!this_node->reference_count) {
535 /* Delete all children and delete the node */ 440 /* Delete all children and delete the node */
536 441
537 acpi_ns_delete_children (this_node); 442 acpi_ns_delete_children(this_node);
538 acpi_ns_delete_node (this_node); 443 acpi_ns_delete_node(this_node);
539 } 444 }
540 445
541 this_node = parent_node; 446 this_node = parent_node;
542 } 447 }
543} 448}
544 449
545
546/******************************************************************************* 450/*******************************************************************************
547 * 451 *
548 * FUNCTION: acpi_ns_delete_namespace_by_owner 452 * FUNCTION: acpi_ns_delete_namespace_by_owner
@@ -557,23 +461,23 @@ acpi_ns_remove_reference (
557 * 461 *
558 ******************************************************************************/ 462 ******************************************************************************/
559 463
560void 464void acpi_ns_delete_namespace_by_owner(acpi_owner_id owner_id)
561acpi_ns_delete_namespace_by_owner (
562 u16 owner_id)
563{ 465{
564 struct acpi_namespace_node *child_node; 466 struct acpi_namespace_node *child_node;
565 struct acpi_namespace_node *deletion_node; 467 struct acpi_namespace_node *deletion_node;
566 u32 level; 468 u32 level;
567 struct acpi_namespace_node *parent_node; 469 struct acpi_namespace_node *parent_node;
568
569 470
570 ACPI_FUNCTION_TRACE_U32 ("ns_delete_namespace_by_owner", owner_id); 471 ACPI_FUNCTION_TRACE_U32("ns_delete_namespace_by_owner", owner_id);
571 472
473 if (owner_id == 0) {
474 return_VOID;
475 }
572 476
573 parent_node = acpi_gbl_root_node; 477 parent_node = acpi_gbl_root_node;
574 child_node = NULL; 478 child_node = NULL;
575 deletion_node = NULL; 479 deletion_node = NULL;
576 level = 1; 480 level = 1;
577 481
578 /* 482 /*
579 * Traverse the tree of nodes until we bubble back up 483 * Traverse the tree of nodes until we bubble back up
@@ -584,10 +488,12 @@ acpi_ns_delete_namespace_by_owner (
584 * Get the next child of this parent node. When child_node is NULL, 488 * Get the next child of this parent node. When child_node is NULL,
585 * the first child of the parent is returned 489 * the first child of the parent is returned
586 */ 490 */
587 child_node = acpi_ns_get_next_node (ACPI_TYPE_ANY, parent_node, child_node); 491 child_node =
492 acpi_ns_get_next_node(ACPI_TYPE_ANY, parent_node,
493 child_node);
588 494
589 if (deletion_node) { 495 if (deletion_node) {
590 acpi_ns_remove_reference (deletion_node); 496 acpi_ns_remove_reference(deletion_node);
591 deletion_node = NULL; 497 deletion_node = NULL;
592 } 498 }
593 499
@@ -595,12 +501,13 @@ acpi_ns_delete_namespace_by_owner (
595 if (child_node->owner_id == owner_id) { 501 if (child_node->owner_id == owner_id) {
596 /* Found a matching child node - detach any attached object */ 502 /* Found a matching child node - detach any attached object */
597 503
598 acpi_ns_detach_object (child_node); 504 acpi_ns_detach_object(child_node);
599 } 505 }
600 506
601 /* Check if this node has any children */ 507 /* Check if this node has any children */
602 508
603 if (acpi_ns_get_next_node (ACPI_TYPE_ANY, child_node, NULL)) { 509 if (acpi_ns_get_next_node
510 (ACPI_TYPE_ANY, child_node, NULL)) {
604 /* 511 /*
605 * There is at least one child of this node, 512 * There is at least one child of this node,
606 * visit the node 513 * visit the node
@@ -608,12 +515,10 @@ acpi_ns_delete_namespace_by_owner (
608 level++; 515 level++;
609 parent_node = child_node; 516 parent_node = child_node;
610 child_node = NULL; 517 child_node = NULL;
611 } 518 } else if (child_node->owner_id == owner_id) {
612 else if (child_node->owner_id == owner_id) {
613 deletion_node = child_node; 519 deletion_node = child_node;
614 } 520 }
615 } 521 } else {
616 else {
617 /* 522 /*
618 * No more children of this parent node. 523 * No more children of this parent node.
619 * Move up to the grandparent. 524 * Move up to the grandparent.
@@ -631,62 +536,9 @@ acpi_ns_delete_namespace_by_owner (
631 536
632 /* Move up the tree to the grandparent */ 537 /* Move up the tree to the grandparent */
633 538
634 parent_node = acpi_ns_get_parent_node (parent_node); 539 parent_node = acpi_ns_get_parent_node(parent_node);
635 } 540 }
636 } 541 }
637 542
638 return_VOID; 543 return_VOID;
639} 544}
640
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
657int
658acpi_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
diff --git a/drivers/acpi/namespace/nsdump.c b/drivers/acpi/namespace/nsdump.c
index 6c2aef0e0dd4..9faf1d5c86ed 100644
--- a/drivers/acpi/namespace/nsdump.c
+++ b/drivers/acpi/namespace/nsdump.c
@@ -41,31 +41,22 @@
41 * POSSIBILITY OF SUCH DAMAGES. 41 * POSSIBILITY OF SUCH DAMAGES.
42 */ 42 */
43 43
44
45#include <acpi/acpi.h> 44#include <acpi/acpi.h>
46#include <acpi/acnamesp.h> 45#include <acpi/acnamesp.h>
47#include <acpi/acparser.h> 46#include <acpi/acparser.h>
48 47
49
50#define _COMPONENT ACPI_NAMESPACE 48#define _COMPONENT ACPI_NAMESPACE
51 ACPI_MODULE_NAME ("nsdump") 49ACPI_MODULE_NAME("nsdump")
52 50
53/* Local prototypes */ 51/* Local prototypes */
54
55#ifdef ACPI_OBSOLETE_FUNCTIONS 52#ifdef ACPI_OBSOLETE_FUNCTIONS
56void 53void acpi_ns_dump_root_devices(void);
57acpi_ns_dump_root_devices (
58 void);
59 54
60static acpi_status 55static acpi_status
61acpi_ns_dump_one_device ( 56acpi_ns_dump_one_device(acpi_handle obj_handle,
62 acpi_handle obj_handle, 57 u32 level, void *context, void **return_value);
63 u32 level,
64 void *context,
65 void **return_value);
66#endif 58#endif
67 59
68
69#if defined(ACPI_DEBUG_OUTPUT) || defined(ACPI_DEBUGGER) 60#if defined(ACPI_DEBUG_OUTPUT) || defined(ACPI_DEBUGGER)
70/******************************************************************************* 61/*******************************************************************************
71 * 62 *
@@ -80,36 +71,38 @@ acpi_ns_dump_one_device (
80 * 71 *
81 ******************************************************************************/ 72 ******************************************************************************/
82 73
83void 74void acpi_ns_print_pathname(u32 num_segments, char *pathname)
84acpi_ns_print_pathname (
85 u32 num_segments,
86 char *pathname)
87{ 75{
88 ACPI_FUNCTION_NAME ("ns_print_pathname"); 76 acpi_native_uint i;
89 77
78 ACPI_FUNCTION_NAME("ns_print_pathname");
90 79
91 if (!(acpi_dbg_level & ACPI_LV_NAMES) || !(acpi_dbg_layer & ACPI_NAMESPACE)) { 80 if (!(acpi_dbg_level & ACPI_LV_NAMES)
81 || !(acpi_dbg_layer & ACPI_NAMESPACE)) {
92 return; 82 return;
93 } 83 }
94 84
95 /* Print the entire name */ 85 /* Print the entire name */
96 86
97 ACPI_DEBUG_PRINT ((ACPI_DB_NAMES, "[")); 87 ACPI_DEBUG_PRINT((ACPI_DB_NAMES, "["));
98 88
99 while (num_segments) { 89 while (num_segments) {
100 acpi_os_printf ("%4.4s", pathname); 90 for (i = 0; i < 4; i++) {
101 pathname += ACPI_NAME_SIZE; 91 ACPI_IS_PRINT(pathname[i]) ?
92 acpi_os_printf("%c", pathname[i]) :
93 acpi_os_printf("?");
94 }
102 95
96 pathname += ACPI_NAME_SIZE;
103 num_segments--; 97 num_segments--;
104 if (num_segments) { 98 if (num_segments) {
105 acpi_os_printf ("."); 99 acpi_os_printf(".");
106 } 100 }
107 } 101 }
108 102
109 acpi_os_printf ("]\n"); 103 acpi_os_printf("]\n");
110} 104}
111 105
112
113/******************************************************************************* 106/*******************************************************************************
114 * 107 *
115 * FUNCTION: acpi_ns_dump_pathname 108 * FUNCTION: acpi_ns_dump_pathname
@@ -127,15 +120,10 @@ acpi_ns_print_pathname (
127 ******************************************************************************/ 120 ******************************************************************************/
128 121
129void 122void
130acpi_ns_dump_pathname ( 123acpi_ns_dump_pathname(acpi_handle handle, char *msg, u32 level, u32 component)
131 acpi_handle handle,
132 char *msg,
133 u32 level,
134 u32 component)
135{ 124{
136 125
137 ACPI_FUNCTION_TRACE ("ns_dump_pathname"); 126 ACPI_FUNCTION_TRACE("ns_dump_pathname");
138
139 127
140 /* Do this only if the requested debug level and component are enabled */ 128 /* Do this only if the requested debug level and component are enabled */
141 129
@@ -145,12 +133,11 @@ acpi_ns_dump_pathname (
145 133
146 /* Convert handle to a full pathname and print it (with supplied message) */ 134 /* Convert handle to a full pathname and print it (with supplied message) */
147 135
148 acpi_ns_print_node_pathname (handle, msg); 136 acpi_ns_print_node_pathname(handle, msg);
149 acpi_os_printf ("\n"); 137 acpi_os_printf("\n");
150 return_VOID; 138 return_VOID;
151} 139}
152 140
153
154/******************************************************************************* 141/*******************************************************************************
155 * 142 *
156 * FUNCTION: acpi_ns_dump_one_object 143 * FUNCTION: acpi_ns_dump_one_object
@@ -168,24 +155,19 @@ acpi_ns_dump_pathname (
168 ******************************************************************************/ 155 ******************************************************************************/
169 156
170acpi_status 157acpi_status
171acpi_ns_dump_one_object ( 158acpi_ns_dump_one_object(acpi_handle obj_handle,
172 acpi_handle obj_handle, 159 u32 level, void *context, void **return_value)
173 u32 level,
174 void *context,
175 void **return_value)
176{ 160{
177 struct acpi_walk_info *info = (struct acpi_walk_info *) context; 161 struct acpi_walk_info *info = (struct acpi_walk_info *)context;
178 struct acpi_namespace_node *this_node; 162 struct acpi_namespace_node *this_node;
179 union acpi_operand_object *obj_desc = NULL; 163 union acpi_operand_object *obj_desc = NULL;
180 acpi_object_type obj_type; 164 acpi_object_type obj_type;
181 acpi_object_type type; 165 acpi_object_type type;
182 u32 bytes_to_dump; 166 u32 bytes_to_dump;
183 u32 dbg_level; 167 u32 dbg_level;
184 u32 i; 168 u32 i;
185
186
187 ACPI_FUNCTION_NAME ("ns_dump_one_object");
188 169
170 ACPI_FUNCTION_NAME("ns_dump_one_object");
189 171
190 /* Is output enabled? */ 172 /* Is output enabled? */
191 173
@@ -194,193 +176,215 @@ acpi_ns_dump_one_object (
194 } 176 }
195 177
196 if (!obj_handle) { 178 if (!obj_handle) {
197 ACPI_DEBUG_PRINT ((ACPI_DB_INFO, "Null object handle\n")); 179 ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Null object handle\n"));
198 return (AE_OK); 180 return (AE_OK);
199 } 181 }
200 182
201 this_node = acpi_ns_map_handle_to_node (obj_handle); 183 this_node = acpi_ns_map_handle_to_node(obj_handle);
202 type = this_node->type; 184 type = this_node->type;
203 185
204 /* Check if the owner matches */ 186 /* Check if the owner matches */
205 187
206 if ((info->owner_id != ACPI_UINT32_MAX) && 188 if ((info->owner_id != ACPI_OWNER_ID_MAX) &&
207 (info->owner_id != this_node->owner_id)) { 189 (info->owner_id != this_node->owner_id)) {
208 return (AE_OK); 190 return (AE_OK);
209 } 191 }
210 192
211 /* Indent the object according to the level */ 193 if (!(info->display_type & ACPI_DISPLAY_SHORT)) {
194 /* Indent the object according to the level */
212 195
213 acpi_os_printf ("%2d%*s", (u32) level - 1, (int) level * 2, " "); 196 acpi_os_printf("%2d%*s", (u32) level - 1, (int)level * 2, " ");
214 197
215 /* Check the node type and name */ 198 /* Check the node type and name */
216 199
217 if (type > ACPI_TYPE_LOCAL_MAX) { 200 if (type > ACPI_TYPE_LOCAL_MAX) {
218 ACPI_REPORT_WARNING (("Invalid ACPI Type %08X\n", type)); 201 ACPI_REPORT_WARNING(("Invalid ACPI Type %08X\n", type));
219 } 202 }
203
204 if (!acpi_ut_valid_acpi_name(this_node->name.integer)) {
205 ACPI_REPORT_WARNING(("Invalid ACPI Name %08X\n",
206 this_node->name.integer));
207 }
220 208
221 if (!acpi_ut_valid_acpi_name (this_node->name.integer)) { 209 acpi_os_printf("%4.4s", acpi_ut_get_node_name(this_node));
222 ACPI_REPORT_WARNING (("Invalid ACPI Name %08X\n",
223 this_node->name.integer));
224 } 210 }
225 211
226 /* 212 /*
227 * Now we can print out the pertinent information 213 * Now we can print out the pertinent information
228 */ 214 */
229 acpi_os_printf ("%4.4s %-12s %p ", 215 acpi_os_printf(" %-12s %p ", acpi_ut_get_type_name(type), this_node);
230 acpi_ut_get_node_name (this_node), acpi_ut_get_type_name (type), this_node);
231 216
232 dbg_level = acpi_dbg_level; 217 dbg_level = acpi_dbg_level;
233 acpi_dbg_level = 0; 218 acpi_dbg_level = 0;
234 obj_desc = acpi_ns_get_attached_object (this_node); 219 obj_desc = acpi_ns_get_attached_object(this_node);
235 acpi_dbg_level = dbg_level; 220 acpi_dbg_level = dbg_level;
236 221
237 switch (info->display_type) { 222 switch (info->display_type & ACPI_DISPLAY_MASK) {
238 case ACPI_DISPLAY_SUMMARY: 223 case ACPI_DISPLAY_SUMMARY:
239 224
240 if (!obj_desc) { 225 if (!obj_desc) {
241 /* No attached object, we are done */ 226 /* No attached object, we are done */
242 227
243 acpi_os_printf ("\n"); 228 acpi_os_printf("\n");
244 return (AE_OK); 229 return (AE_OK);
245 } 230 }
246 231
247 switch (type) { 232 switch (type) {
248 case ACPI_TYPE_PROCESSOR: 233 case ACPI_TYPE_PROCESSOR:
249 234
250 acpi_os_printf ("ID %X Len %.4X Addr %p\n", 235 acpi_os_printf("ID %X Len %.4X Addr %p\n",
251 obj_desc->processor.proc_id, obj_desc->processor.length, 236 obj_desc->processor.proc_id,
252 (char *) obj_desc->processor.address); 237 obj_desc->processor.length,
238 (char *)obj_desc->processor.address);
253 break; 239 break;
254 240
255
256 case ACPI_TYPE_DEVICE: 241 case ACPI_TYPE_DEVICE:
257 242
258 acpi_os_printf ("Notify Object: %p\n", obj_desc); 243 acpi_os_printf("Notify Object: %p\n", obj_desc);
259 break; 244 break;
260 245
261
262 case ACPI_TYPE_METHOD: 246 case ACPI_TYPE_METHOD:
263 247
264 acpi_os_printf ("Args %X Len %.4X Aml %p\n", 248 acpi_os_printf("Args %X Len %.4X Aml %p\n",
265 (u32) obj_desc->method.param_count, 249 (u32) obj_desc->method.param_count,
266 obj_desc->method.aml_length, obj_desc->method.aml_start); 250 obj_desc->method.aml_length,
251 obj_desc->method.aml_start);
267 break; 252 break;
268 253
269
270 case ACPI_TYPE_INTEGER: 254 case ACPI_TYPE_INTEGER:
271 255
272 acpi_os_printf ("= %8.8X%8.8X\n", 256 acpi_os_printf("= %8.8X%8.8X\n",
273 ACPI_FORMAT_UINT64 (obj_desc->integer.value)); 257 ACPI_FORMAT_UINT64(obj_desc->integer.
258 value));
274 break; 259 break;
275 260
276
277 case ACPI_TYPE_PACKAGE: 261 case ACPI_TYPE_PACKAGE:
278 262
279 if (obj_desc->common.flags & AOPOBJ_DATA_VALID) { 263 if (obj_desc->common.flags & AOPOBJ_DATA_VALID) {
280 acpi_os_printf ("Elements %.2X\n", 264 acpi_os_printf("Elements %.2X\n",
281 obj_desc->package.count); 265 obj_desc->package.count);
282 } 266 } else {
283 else { 267 acpi_os_printf("[Length not yet evaluated]\n");
284 acpi_os_printf ("[Length not yet evaluated]\n");
285 } 268 }
286 break; 269 break;
287 270
288
289 case ACPI_TYPE_BUFFER: 271 case ACPI_TYPE_BUFFER:
290 272
291 if (obj_desc->common.flags & AOPOBJ_DATA_VALID) { 273 if (obj_desc->common.flags & AOPOBJ_DATA_VALID) {
292 acpi_os_printf ("Len %.2X", 274 acpi_os_printf("Len %.2X",
293 obj_desc->buffer.length); 275 obj_desc->buffer.length);
294 276
295 /* Dump some of the buffer */ 277 /* Dump some of the buffer */
296 278
297 if (obj_desc->buffer.length > 0) { 279 if (obj_desc->buffer.length > 0) {
298 acpi_os_printf (" ="); 280 acpi_os_printf(" =");
299 for (i = 0; (i < obj_desc->buffer.length && i < 12); i++) { 281 for (i = 0;
300 acpi_os_printf (" %.2hX", obj_desc->buffer.pointer[i]); 282 (i < obj_desc->buffer.length
283 && i < 12); i++) {
284 acpi_os_printf(" %.2hX",
285 obj_desc->buffer.
286 pointer[i]);
301 } 287 }
302 } 288 }
303 acpi_os_printf ("\n"); 289 acpi_os_printf("\n");
304 } 290 } else {
305 else { 291 acpi_os_printf("[Length not yet evaluated]\n");
306 acpi_os_printf ("[Length not yet evaluated]\n");
307 } 292 }
308 break; 293 break;
309 294
310
311 case ACPI_TYPE_STRING: 295 case ACPI_TYPE_STRING:
312 296
313 acpi_os_printf ("Len %.2X ", obj_desc->string.length); 297 acpi_os_printf("Len %.2X ", obj_desc->string.length);
314 acpi_ut_print_string (obj_desc->string.pointer, 32); 298 acpi_ut_print_string(obj_desc->string.pointer, 32);
315 acpi_os_printf ("\n"); 299 acpi_os_printf("\n");
316 break; 300 break;
317 301
318
319 case ACPI_TYPE_REGION: 302 case ACPI_TYPE_REGION:
320 303
321 acpi_os_printf ("[%s]", 304 acpi_os_printf("[%s]",
322 acpi_ut_get_region_name (obj_desc->region.space_id)); 305 acpi_ut_get_region_name(obj_desc->region.
306 space_id));
323 if (obj_desc->region.flags & AOPOBJ_DATA_VALID) { 307 if (obj_desc->region.flags & AOPOBJ_DATA_VALID) {
324 acpi_os_printf (" Addr %8.8X%8.8X Len %.4X\n", 308 acpi_os_printf(" Addr %8.8X%8.8X Len %.4X\n",
325 ACPI_FORMAT_UINT64 (obj_desc->region.address), 309 ACPI_FORMAT_UINT64(obj_desc->
326 obj_desc->region.length); 310 region.
327 } 311 address),
328 else { 312 obj_desc->region.length);
329 acpi_os_printf (" [Address/Length not yet evaluated]\n"); 313 } else {
314 acpi_os_printf
315 (" [Address/Length not yet evaluated]\n");
330 } 316 }
331 break; 317 break;
332 318
333
334 case ACPI_TYPE_LOCAL_REFERENCE: 319 case ACPI_TYPE_LOCAL_REFERENCE:
335 320
336 acpi_os_printf ("[%s]\n", 321 acpi_os_printf("[%s]\n",
337 acpi_ps_get_opcode_name (obj_desc->reference.opcode)); 322 acpi_ps_get_opcode_name(obj_desc->
323 reference.
324 opcode));
338 break; 325 break;
339 326
340
341 case ACPI_TYPE_BUFFER_FIELD: 327 case ACPI_TYPE_BUFFER_FIELD:
342 328
343 if (obj_desc->buffer_field.buffer_obj && 329 if (obj_desc->buffer_field.buffer_obj &&
344 obj_desc->buffer_field.buffer_obj->buffer.node) { 330 obj_desc->buffer_field.buffer_obj->buffer.node) {
345 acpi_os_printf ("Buf [%4.4s]", 331 acpi_os_printf("Buf [%4.4s]",
346 acpi_ut_get_node_name (obj_desc->buffer_field.buffer_obj->buffer.node)); 332 acpi_ut_get_node_name(obj_desc->
333 buffer_field.
334 buffer_obj->
335 buffer.
336 node));
347 } 337 }
348 break; 338 break;
349 339
350
351 case ACPI_TYPE_LOCAL_REGION_FIELD: 340 case ACPI_TYPE_LOCAL_REGION_FIELD:
352 341
353 acpi_os_printf ("Rgn [%4.4s]", 342 acpi_os_printf("Rgn [%4.4s]",
354 acpi_ut_get_node_name (obj_desc->common_field.region_obj->region.node)); 343 acpi_ut_get_node_name(obj_desc->
344 common_field.
345 region_obj->region.
346 node));
355 break; 347 break;
356 348
357
358 case ACPI_TYPE_LOCAL_BANK_FIELD: 349 case ACPI_TYPE_LOCAL_BANK_FIELD:
359 350
360 acpi_os_printf ("Rgn [%4.4s] Bnk [%4.4s]", 351 acpi_os_printf("Rgn [%4.4s] Bnk [%4.4s]",
361 acpi_ut_get_node_name (obj_desc->common_field.region_obj->region.node), 352 acpi_ut_get_node_name(obj_desc->
362 acpi_ut_get_node_name (obj_desc->bank_field.bank_obj->common_field.node)); 353 common_field.
354 region_obj->region.
355 node),
356 acpi_ut_get_node_name(obj_desc->
357 bank_field.
358 bank_obj->
359 common_field.
360 node));
363 break; 361 break;
364 362
365
366 case ACPI_TYPE_LOCAL_INDEX_FIELD: 363 case ACPI_TYPE_LOCAL_INDEX_FIELD:
367 364
368 acpi_os_printf ("Idx [%4.4s] Dat [%4.4s]", 365 acpi_os_printf("Idx [%4.4s] Dat [%4.4s]",
369 acpi_ut_get_node_name (obj_desc->index_field.index_obj->common_field.node), 366 acpi_ut_get_node_name(obj_desc->
370 acpi_ut_get_node_name (obj_desc->index_field.data_obj->common_field.node)); 367 index_field.
368 index_obj->
369 common_field.node),
370 acpi_ut_get_node_name(obj_desc->
371 index_field.
372 data_obj->
373 common_field.
374 node));
371 break; 375 break;
372 376
373
374 case ACPI_TYPE_LOCAL_ALIAS: 377 case ACPI_TYPE_LOCAL_ALIAS:
375 case ACPI_TYPE_LOCAL_METHOD_ALIAS: 378 case ACPI_TYPE_LOCAL_METHOD_ALIAS:
376 379
377 acpi_os_printf ("Target %4.4s (%p)\n", 380 acpi_os_printf("Target %4.4s (%p)\n",
378 acpi_ut_get_node_name (obj_desc), obj_desc); 381 acpi_ut_get_node_name(obj_desc),
382 obj_desc);
379 break; 383 break;
380 384
381 default: 385 default:
382 386
383 acpi_os_printf ("Object %p\n", obj_desc); 387 acpi_os_printf("Object %p\n", obj_desc);
384 break; 388 break;
385 } 389 }
386 390
@@ -392,11 +396,15 @@ acpi_ns_dump_one_object (
392 case ACPI_TYPE_LOCAL_BANK_FIELD: 396 case ACPI_TYPE_LOCAL_BANK_FIELD:
393 case ACPI_TYPE_LOCAL_INDEX_FIELD: 397 case ACPI_TYPE_LOCAL_INDEX_FIELD:
394 398
395 acpi_os_printf (" Off %.3X Len %.2X Acc %.2hd\n", 399 acpi_os_printf(" Off %.3X Len %.2X Acc %.2hd\n",
396 (obj_desc->common_field.base_byte_offset * 8) 400 (obj_desc->common_field.
397 + obj_desc->common_field.start_field_bit_offset, 401 base_byte_offset * 8)
398 obj_desc->common_field.bit_length, 402 +
399 obj_desc->common_field.access_byte_width); 403 obj_desc->common_field.
404 start_field_bit_offset,
405 obj_desc->common_field.bit_length,
406 obj_desc->common_field.
407 access_byte_width);
400 break; 408 break;
401 409
402 default: 410 default:
@@ -404,56 +412,55 @@ acpi_ns_dump_one_object (
404 } 412 }
405 break; 413 break;
406 414
407
408 case ACPI_DISPLAY_OBJECTS: 415 case ACPI_DISPLAY_OBJECTS:
409 416
410 acpi_os_printf ("O:%p", obj_desc); 417 acpi_os_printf("O:%p", obj_desc);
411 if (!obj_desc) { 418 if (!obj_desc) {
412 /* No attached object, we are done */ 419 /* No attached object, we are done */
413 420
414 acpi_os_printf ("\n"); 421 acpi_os_printf("\n");
415 return (AE_OK); 422 return (AE_OK);
416 } 423 }
417 424
418 acpi_os_printf ("(R%d)", obj_desc->common.reference_count); 425 acpi_os_printf("(R%d)", obj_desc->common.reference_count);
419 426
420 switch (type) { 427 switch (type) {
421 case ACPI_TYPE_METHOD: 428 case ACPI_TYPE_METHOD:
422 429
423 /* Name is a Method and its AML offset/length are set */ 430 /* Name is a Method and its AML offset/length are set */
424 431
425 acpi_os_printf (" M:%p-%X\n", obj_desc->method.aml_start, 432 acpi_os_printf(" M:%p-%X\n", obj_desc->method.aml_start,
426 obj_desc->method.aml_length); 433 obj_desc->method.aml_length);
427 break; 434 break;
428 435
429 case ACPI_TYPE_INTEGER: 436 case ACPI_TYPE_INTEGER:
430 437
431 acpi_os_printf (" I:%8.8X8.8%X\n", 438 acpi_os_printf(" I:%8.8X8.8%X\n",
432 ACPI_FORMAT_UINT64 (obj_desc->integer.value)); 439 ACPI_FORMAT_UINT64(obj_desc->integer.
440 value));
433 break; 441 break;
434 442
435 case ACPI_TYPE_STRING: 443 case ACPI_TYPE_STRING:
436 444
437 acpi_os_printf (" S:%p-%X\n", obj_desc->string.pointer, 445 acpi_os_printf(" S:%p-%X\n", obj_desc->string.pointer,
438 obj_desc->string.length); 446 obj_desc->string.length);
439 break; 447 break;
440 448
441 case ACPI_TYPE_BUFFER: 449 case ACPI_TYPE_BUFFER:
442 450
443 acpi_os_printf (" B:%p-%X\n", obj_desc->buffer.pointer, 451 acpi_os_printf(" B:%p-%X\n", obj_desc->buffer.pointer,
444 obj_desc->buffer.length); 452 obj_desc->buffer.length);
445 break; 453 break;
446 454
447 default: 455 default:
448 456
449 acpi_os_printf ("\n"); 457 acpi_os_printf("\n");
450 break; 458 break;
451 } 459 }
452 break; 460 break;
453 461
454
455 default: 462 default:
456 acpi_os_printf ("\n"); 463 acpi_os_printf("\n");
457 break; 464 break;
458 } 465 }
459 466
@@ -463,61 +470,58 @@ acpi_ns_dump_one_object (
463 return (AE_OK); 470 return (AE_OK);
464 } 471 }
465 472
466
467 /* If there is an attached object, display it */ 473 /* If there is an attached object, display it */
468 474
469 dbg_level = acpi_dbg_level; 475 dbg_level = acpi_dbg_level;
470 acpi_dbg_level = 0; 476 acpi_dbg_level = 0;
471 obj_desc = acpi_ns_get_attached_object (this_node); 477 obj_desc = acpi_ns_get_attached_object(this_node);
472 acpi_dbg_level = dbg_level; 478 acpi_dbg_level = dbg_level;
473 479
474 /* Dump attached objects */ 480 /* Dump attached objects */
475 481
476 while (obj_desc) { 482 while (obj_desc) {
477 obj_type = ACPI_TYPE_INVALID; 483 obj_type = ACPI_TYPE_INVALID;
478 acpi_os_printf (" Attached Object %p: ", obj_desc); 484 acpi_os_printf("Attached Object %p: ", obj_desc);
479 485
480 /* Decode the type of attached object and dump the contents */ 486 /* Decode the type of attached object and dump the contents */
481 487
482 switch (ACPI_GET_DESCRIPTOR_TYPE (obj_desc)) { 488 switch (ACPI_GET_DESCRIPTOR_TYPE(obj_desc)) {
483 case ACPI_DESC_TYPE_NAMED: 489 case ACPI_DESC_TYPE_NAMED:
484 490
485 acpi_os_printf ("(Ptr to Node)\n"); 491 acpi_os_printf("(Ptr to Node)\n");
486 bytes_to_dump = sizeof (struct acpi_namespace_node); 492 bytes_to_dump = sizeof(struct acpi_namespace_node);
493 ACPI_DUMP_BUFFER(obj_desc, bytes_to_dump);
487 break; 494 break;
488 495
489
490 case ACPI_DESC_TYPE_OPERAND: 496 case ACPI_DESC_TYPE_OPERAND:
491 497
492 obj_type = ACPI_GET_OBJECT_TYPE (obj_desc); 498 obj_type = ACPI_GET_OBJECT_TYPE(obj_desc);
493 499
494 if (obj_type > ACPI_TYPE_LOCAL_MAX) { 500 if (obj_type > ACPI_TYPE_LOCAL_MAX) {
495 acpi_os_printf ("(Ptr to ACPI Object type %X [UNKNOWN])\n", 501 acpi_os_printf
496 obj_type); 502 ("(Ptr to ACPI Object type %X [UNKNOWN])\n",
503 obj_type);
497 bytes_to_dump = 32; 504 bytes_to_dump = 32;
505 } else {
506 acpi_os_printf
507 ("(Ptr to ACPI Object type %X [%s])\n",
508 obj_type, acpi_ut_get_type_name(obj_type));
509 bytes_to_dump =
510 sizeof(union acpi_operand_object);
498 } 511 }
499 else {
500 acpi_os_printf ("(Ptr to ACPI Object type %s, %X)\n",
501 acpi_ut_get_type_name (obj_type), obj_type);
502 bytes_to_dump = sizeof (union acpi_operand_object);
503 }
504 break;
505 512
513 ACPI_DUMP_BUFFER(obj_desc, bytes_to_dump);
514 break;
506 515
507 default: 516 default:
508 517
509 acpi_os_printf (
510 "(String or Buffer ptr - not an object descriptor) [%s]\n",
511 acpi_ut_get_descriptor_name (obj_desc));
512 bytes_to_dump = 16;
513 break; 518 break;
514 } 519 }
515 520
516 ACPI_DUMP_BUFFER (obj_desc, bytes_to_dump);
517
518 /* If value is NOT an internal object, we are done */ 521 /* If value is NOT an internal object, we are done */
519 522
520 if (ACPI_GET_DESCRIPTOR_TYPE (obj_desc) != ACPI_DESC_TYPE_OPERAND) { 523 if (ACPI_GET_DESCRIPTOR_TYPE(obj_desc) !=
524 ACPI_DESC_TYPE_OPERAND) {
521 goto cleanup; 525 goto cleanup;
522 } 526 }
523 527
@@ -525,51 +529,56 @@ acpi_ns_dump_one_object (
525 * Valid object, get the pointer to next level, if any 529 * Valid object, get the pointer to next level, if any
526 */ 530 */
527 switch (obj_type) { 531 switch (obj_type) {
528 case ACPI_TYPE_STRING:
529 obj_desc = (void *) obj_desc->string.pointer;
530 break;
531
532 case ACPI_TYPE_BUFFER: 532 case ACPI_TYPE_BUFFER:
533 obj_desc = (void *) obj_desc->buffer.pointer; 533 case ACPI_TYPE_STRING:
534 break; 534 /*
535 * NOTE: takes advantage of common fields between string/buffer
536 */
537 bytes_to_dump = obj_desc->string.length;
538 obj_desc = (void *)obj_desc->string.pointer;
539 acpi_os_printf("(Buffer/String pointer %p length %X)\n",
540 obj_desc, bytes_to_dump);
541 ACPI_DUMP_BUFFER(obj_desc, bytes_to_dump);
542 goto cleanup;
535 543
536 case ACPI_TYPE_BUFFER_FIELD: 544 case ACPI_TYPE_BUFFER_FIELD:
537 obj_desc = (union acpi_operand_object *) obj_desc->buffer_field.buffer_obj; 545 obj_desc =
546 (union acpi_operand_object *)obj_desc->buffer_field.
547 buffer_obj;
538 break; 548 break;
539 549
540 case ACPI_TYPE_PACKAGE: 550 case ACPI_TYPE_PACKAGE:
541 obj_desc = (void *) obj_desc->package.elements; 551 obj_desc = (void *)obj_desc->package.elements;
542 break; 552 break;
543 553
544 case ACPI_TYPE_METHOD: 554 case ACPI_TYPE_METHOD:
545 obj_desc = (void *) obj_desc->method.aml_start; 555 obj_desc = (void *)obj_desc->method.aml_start;
546 break; 556 break;
547 557
548 case ACPI_TYPE_LOCAL_REGION_FIELD: 558 case ACPI_TYPE_LOCAL_REGION_FIELD:
549 obj_desc = (void *) obj_desc->field.region_obj; 559 obj_desc = (void *)obj_desc->field.region_obj;
550 break; 560 break;
551 561
552 case ACPI_TYPE_LOCAL_BANK_FIELD: 562 case ACPI_TYPE_LOCAL_BANK_FIELD:
553 obj_desc = (void *) obj_desc->bank_field.region_obj; 563 obj_desc = (void *)obj_desc->bank_field.region_obj;
554 break; 564 break;
555 565
556 case ACPI_TYPE_LOCAL_INDEX_FIELD: 566 case ACPI_TYPE_LOCAL_INDEX_FIELD:
557 obj_desc = (void *) obj_desc->index_field.index_obj; 567 obj_desc = (void *)obj_desc->index_field.index_obj;
558 break; 568 break;
559 569
560 default: 570 default:
561 goto cleanup; 571 goto cleanup;
562 } 572 }
563 573
564 obj_type = ACPI_TYPE_INVALID; /* Terminate loop after next pass */ 574 obj_type = ACPI_TYPE_INVALID; /* Terminate loop after next pass */
565 } 575 }
566 576
567cleanup: 577 cleanup:
568 acpi_os_printf ("\n"); 578 acpi_os_printf("\n");
569 return (AE_OK); 579 return (AE_OK);
570} 580}
571 581
572
573#ifdef ACPI_FUTURE_USAGE 582#ifdef ACPI_FUTURE_USAGE
574/******************************************************************************* 583/*******************************************************************************
575 * 584 *
@@ -591,29 +600,25 @@ cleanup:
591 ******************************************************************************/ 600 ******************************************************************************/
592 601
593void 602void
594acpi_ns_dump_objects ( 603acpi_ns_dump_objects(acpi_object_type type,
595 acpi_object_type type, 604 u8 display_type,
596 u8 display_type, 605 u32 max_depth,
597 u32 max_depth, 606 acpi_owner_id owner_id, acpi_handle start_handle)
598 u32 owner_id,
599 acpi_handle start_handle)
600{ 607{
601 struct acpi_walk_info info; 608 struct acpi_walk_info info;
602
603
604 ACPI_FUNCTION_ENTRY ();
605 609
610 ACPI_FUNCTION_ENTRY();
606 611
607 info.debug_level = ACPI_LV_TABLES; 612 info.debug_level = ACPI_LV_TABLES;
608 info.owner_id = owner_id; 613 info.owner_id = owner_id;
609 info.display_type = display_type; 614 info.display_type = display_type;
610 615
611 (void) acpi_ns_walk_namespace (type, start_handle, max_depth, 616 (void)acpi_ns_walk_namespace(type, start_handle, max_depth,
612 ACPI_NS_WALK_NO_UNLOCK, acpi_ns_dump_one_object, 617 ACPI_NS_WALK_NO_UNLOCK,
613 (void *) &info, NULL); 618 acpi_ns_dump_one_object, (void *)&info,
619 NULL);
614} 620}
615#endif /* ACPI_FUTURE_USAGE */ 621#endif /* ACPI_FUTURE_USAGE */
616
617 622
618/******************************************************************************* 623/*******************************************************************************
619 * 624 *
@@ -628,26 +633,20 @@ acpi_ns_dump_objects (
628 * 633 *
629 ******************************************************************************/ 634 ******************************************************************************/
630 635
631void 636void acpi_ns_dump_entry(acpi_handle handle, u32 debug_level)
632acpi_ns_dump_entry (
633 acpi_handle handle,
634 u32 debug_level)
635{ 637{
636 struct acpi_walk_info info; 638 struct acpi_walk_info info;
637
638
639 ACPI_FUNCTION_ENTRY ();
640 639
640 ACPI_FUNCTION_ENTRY();
641 641
642 info.debug_level = debug_level; 642 info.debug_level = debug_level;
643 info.owner_id = ACPI_UINT32_MAX; 643 info.owner_id = ACPI_OWNER_ID_MAX;
644 info.display_type = ACPI_DISPLAY_SUMMARY; 644 info.display_type = ACPI_DISPLAY_SUMMARY;
645 645
646 (void) acpi_ns_dump_one_object (handle, 1, &info, NULL); 646 (void)acpi_ns_dump_one_object(handle, 1, &info, NULL);
647} 647}
648 648
649 649#ifdef ACPI_ASL_COMPILER
650#ifdef _ACPI_ASL_COMPILER
651/******************************************************************************* 650/*******************************************************************************
652 * 651 *
653 * FUNCTION: acpi_ns_dump_tables 652 * FUNCTION: acpi_ns_dump_tables
@@ -663,23 +662,19 @@ acpi_ns_dump_entry (
663 * 662 *
664 ******************************************************************************/ 663 ******************************************************************************/
665 664
666void 665void acpi_ns_dump_tables(acpi_handle search_base, u32 max_depth)
667acpi_ns_dump_tables (
668 acpi_handle search_base,
669 u32 max_depth)
670{ 666{
671 acpi_handle search_handle = search_base; 667 acpi_handle search_handle = search_base;
672
673
674 ACPI_FUNCTION_TRACE ("ns_dump_tables");
675 668
669 ACPI_FUNCTION_TRACE("ns_dump_tables");
676 670
677 if (!acpi_gbl_root_node) { 671 if (!acpi_gbl_root_node) {
678 /* 672 /*
679 * If the name space has not been initialized, 673 * If the name space has not been initialized,
680 * there is nothing to dump. 674 * there is nothing to dump.
681 */ 675 */
682 ACPI_DEBUG_PRINT ((ACPI_DB_TABLES, "namespace not initialized!\n")); 676 ACPI_DEBUG_PRINT((ACPI_DB_TABLES,
677 "namespace not initialized!\n"));
683 return_VOID; 678 return_VOID;
684 } 679 }
685 680
@@ -687,12 +682,12 @@ acpi_ns_dump_tables (
687 /* Entire namespace */ 682 /* Entire namespace */
688 683
689 search_handle = acpi_gbl_root_node; 684 search_handle = acpi_gbl_root_node;
690 ACPI_DEBUG_PRINT ((ACPI_DB_TABLES, "\\\n")); 685 ACPI_DEBUG_PRINT((ACPI_DB_TABLES, "\\\n"));
691 } 686 }
692 687
693 acpi_ns_dump_objects (ACPI_TYPE_ANY, ACPI_DISPLAY_OBJECTS, max_depth, 688 acpi_ns_dump_objects(ACPI_TYPE_ANY, ACPI_DISPLAY_OBJECTS, max_depth,
694 ACPI_UINT32_MAX, search_handle); 689 ACPI_OWNER_ID_MAX, search_handle);
695 return_VOID; 690 return_VOID;
696} 691}
697#endif /* _ACPI_ASL_COMPILER */ 692#endif /* _ACPI_ASL_COMPILER */
698#endif /* defined(ACPI_DEBUG_OUTPUT) || defined(ACPI_DEBUGGER) */ 693#endif /* defined(ACPI_DEBUG_OUTPUT) || defined(ACPI_DEBUGGER) */
diff --git a/drivers/acpi/namespace/nsdumpdv.c b/drivers/acpi/namespace/nsdumpdv.c
index 27c4f7cd2a43..55de883943d6 100644
--- a/drivers/acpi/namespace/nsdumpdv.c
+++ b/drivers/acpi/namespace/nsdumpdv.c
@@ -41,20 +41,15 @@
41 * POSSIBILITY OF SUCH DAMAGES. 41 * POSSIBILITY OF SUCH DAMAGES.
42 */ 42 */
43 43
44
45#include <acpi/acpi.h> 44#include <acpi/acpi.h>
46 45
47
48/* TBD: This entire module is apparently obsolete and should be removed */ 46/* TBD: This entire module is apparently obsolete and should be removed */
49 47
50#define _COMPONENT ACPI_NAMESPACE 48#define _COMPONENT ACPI_NAMESPACE
51 ACPI_MODULE_NAME ("nsdumpdv") 49ACPI_MODULE_NAME("nsdumpdv")
52
53#ifdef ACPI_OBSOLETE_FUNCTIONS 50#ifdef ACPI_OBSOLETE_FUNCTIONS
54#if defined(ACPI_DEBUG_OUTPUT) || defined(ACPI_DEBUGGER) 51#if defined(ACPI_DEBUG_OUTPUT) || defined(ACPI_DEBUGGER)
55
56#include <acpi/acnamesp.h> 52#include <acpi/acnamesp.h>
57
58/******************************************************************************* 53/*******************************************************************************
59 * 54 *
60 * FUNCTION: acpi_ns_dump_one_device 55 * FUNCTION: acpi_ns_dump_one_device
@@ -70,44 +65,39 @@
70 * This procedure is a user_function called by acpi_ns_walk_namespace. 65 * This procedure is a user_function called by acpi_ns_walk_namespace.
71 * 66 *
72 ******************************************************************************/ 67 ******************************************************************************/
73
74static acpi_status 68static acpi_status
75acpi_ns_dump_one_device ( 69acpi_ns_dump_one_device(acpi_handle obj_handle,
76 acpi_handle obj_handle, 70 u32 level, void *context, void **return_value)
77 u32 level,
78 void *context,
79 void **return_value)
80{ 71{
81 struct acpi_buffer buffer; 72 struct acpi_buffer buffer;
82 struct acpi_device_info *info; 73 struct acpi_device_info *info;
83 acpi_status status; 74 acpi_status status;
84 u32 i; 75 u32 i;
85
86 76
87 ACPI_FUNCTION_NAME ("ns_dump_one_device"); 77 ACPI_FUNCTION_NAME("ns_dump_one_device");
88 78
89 79 status =
90 status = acpi_ns_dump_one_object (obj_handle, level, context, return_value); 80 acpi_ns_dump_one_object(obj_handle, level, context, return_value);
91 81
92 buffer.length = ACPI_ALLOCATE_LOCAL_BUFFER; 82 buffer.length = ACPI_ALLOCATE_LOCAL_BUFFER;
93 status = acpi_get_object_info (obj_handle, &buffer); 83 status = acpi_get_object_info(obj_handle, &buffer);
94 if (ACPI_SUCCESS (status)) { 84 if (ACPI_SUCCESS(status)) {
95 info = buffer.pointer; 85 info = buffer.pointer;
96 for (i = 0; i < level; i++) { 86 for (i = 0; i < level; i++) {
97 ACPI_DEBUG_PRINT_RAW ((ACPI_DB_TABLES, " ")); 87 ACPI_DEBUG_PRINT_RAW((ACPI_DB_TABLES, " "));
98 } 88 }
99 89
100 ACPI_DEBUG_PRINT_RAW ((ACPI_DB_TABLES, 90 ACPI_DEBUG_PRINT_RAW((ACPI_DB_TABLES,
101 " HID: %s, ADR: %8.8X%8.8X, Status: %X\n", 91 " HID: %s, ADR: %8.8X%8.8X, Status: %X\n",
102 info->hardware_id.value, ACPI_FORMAT_UINT64 (info->address), 92 info->hardware_id.value,
103 info->current_status)); 93 ACPI_FORMAT_UINT64(info->address),
104 ACPI_MEM_FREE (info); 94 info->current_status));
95 ACPI_MEM_FREE(info);
105 } 96 }
106 97
107 return (status); 98 return (status);
108} 99}
109 100
110
111/******************************************************************************* 101/*******************************************************************************
112 * 102 *
113 * FUNCTION: acpi_ns_dump_root_devices 103 * FUNCTION: acpi_ns_dump_root_devices
@@ -120,16 +110,12 @@ acpi_ns_dump_one_device (
120 * 110 *
121 ******************************************************************************/ 111 ******************************************************************************/
122 112
123void 113void acpi_ns_dump_root_devices(void)
124acpi_ns_dump_root_devices (
125 void)
126{ 114{
127 acpi_handle sys_bus_handle; 115 acpi_handle sys_bus_handle;
128 acpi_status status; 116 acpi_status status;
129
130
131 ACPI_FUNCTION_NAME ("ns_dump_root_devices");
132 117
118 ACPI_FUNCTION_NAME("ns_dump_root_devices");
133 119
134 /* Only dump the table if tracing is enabled */ 120 /* Only dump the table if tracing is enabled */
135 121
@@ -138,19 +124,17 @@ acpi_ns_dump_root_devices (
138 } 124 }
139 125
140 status = acpi_get_handle(NULL, ACPI_NS_SYSTEM_BUS, &sys_bus_handle); 126 status = acpi_get_handle(NULL, ACPI_NS_SYSTEM_BUS, &sys_bus_handle);
141 if (ACPI_FAILURE (status)) { 127 if (ACPI_FAILURE(status)) {
142 return; 128 return;
143 } 129 }
144 130
145 ACPI_DEBUG_PRINT ((ACPI_DB_TABLES, 131 ACPI_DEBUG_PRINT((ACPI_DB_TABLES,
146 "Display of all devices in the namespace:\n")); 132 "Display of all devices in the namespace:\n"));
147 133
148 status = acpi_ns_walk_namespace (ACPI_TYPE_DEVICE, sys_bus_handle, 134 status = acpi_ns_walk_namespace(ACPI_TYPE_DEVICE, sys_bus_handle,
149 ACPI_UINT32_MAX, ACPI_NS_WALK_NO_UNLOCK, 135 ACPI_UINT32_MAX, ACPI_NS_WALK_NO_UNLOCK,
150 acpi_ns_dump_one_device, NULL, NULL); 136 acpi_ns_dump_one_device, NULL, NULL);
151} 137}
152 138
153#endif 139#endif
154#endif 140#endif
155
156
diff --git a/drivers/acpi/namespace/nseval.c b/drivers/acpi/namespace/nseval.c
index 1ae89a1c8826..0191c7d92824 100644
--- a/drivers/acpi/namespace/nseval.c
+++ b/drivers/acpi/namespace/nseval.c
@@ -42,26 +42,19 @@
42 * POSSIBILITY OF SUCH DAMAGES. 42 * POSSIBILITY OF SUCH DAMAGES.
43 */ 43 */
44 44
45
46#include <acpi/acpi.h> 45#include <acpi/acpi.h>
47#include <acpi/acparser.h> 46#include <acpi/acparser.h>
48#include <acpi/acinterp.h> 47#include <acpi/acinterp.h>
49#include <acpi/acnamesp.h> 48#include <acpi/acnamesp.h>
50 49
51
52#define _COMPONENT ACPI_NAMESPACE 50#define _COMPONENT ACPI_NAMESPACE
53 ACPI_MODULE_NAME ("nseval") 51ACPI_MODULE_NAME("nseval")
54 52
55/* Local prototypes */ 53/* Local prototypes */
56
57static acpi_status 54static acpi_status
58acpi_ns_execute_control_method ( 55acpi_ns_execute_control_method(struct acpi_parameter_info *info);
59 struct acpi_parameter_info *info);
60
61static acpi_status
62acpi_ns_get_object_value (
63 struct acpi_parameter_info *info);
64 56
57static acpi_status acpi_ns_get_object_value(struct acpi_parameter_info *info);
65 58
66/******************************************************************************* 59/*******************************************************************************
67 * 60 *
@@ -85,48 +78,44 @@ acpi_ns_get_object_value (
85 ******************************************************************************/ 78 ******************************************************************************/
86 79
87acpi_status 80acpi_status
88acpi_ns_evaluate_relative ( 81acpi_ns_evaluate_relative(char *pathname, struct acpi_parameter_info *info)
89 char *pathname,
90 struct acpi_parameter_info *info)
91{ 82{
92 acpi_status status; 83 acpi_status status;
93 struct acpi_namespace_node *node = NULL; 84 struct acpi_namespace_node *node = NULL;
94 union acpi_generic_state *scope_info; 85 union acpi_generic_state *scope_info;
95 char *internal_path = NULL; 86 char *internal_path = NULL;
96
97
98 ACPI_FUNCTION_TRACE ("ns_evaluate_relative");
99 87
88 ACPI_FUNCTION_TRACE("ns_evaluate_relative");
100 89
101 /* 90 /*
102 * Must have a valid object handle 91 * Must have a valid object handle
103 */ 92 */
104 if (!info || !info->node) { 93 if (!info || !info->node) {
105 return_ACPI_STATUS (AE_BAD_PARAMETER); 94 return_ACPI_STATUS(AE_BAD_PARAMETER);
106 } 95 }
107 96
108 /* Build an internal name string for the method */ 97 /* Build an internal name string for the method */
109 98
110 status = acpi_ns_internalize_name (pathname, &internal_path); 99 status = acpi_ns_internalize_name(pathname, &internal_path);
111 if (ACPI_FAILURE (status)) { 100 if (ACPI_FAILURE(status)) {
112 return_ACPI_STATUS (status); 101 return_ACPI_STATUS(status);
113 } 102 }
114 103
115 scope_info = acpi_ut_create_generic_state (); 104 scope_info = acpi_ut_create_generic_state();
116 if (!scope_info) { 105 if (!scope_info) {
117 goto cleanup1; 106 goto cleanup1;
118 } 107 }
119 108
120 /* Get the prefix handle and Node */ 109 /* Get the prefix handle and Node */
121 110
122 status = acpi_ut_acquire_mutex (ACPI_MTX_NAMESPACE); 111 status = acpi_ut_acquire_mutex(ACPI_MTX_NAMESPACE);
123 if (ACPI_FAILURE (status)) { 112 if (ACPI_FAILURE(status)) {
124 goto cleanup; 113 goto cleanup;
125 } 114 }
126 115
127 info->node = acpi_ns_map_handle_to_node (info->node); 116 info->node = acpi_ns_map_handle_to_node(info->node);
128 if (!info->node) { 117 if (!info->node) {
129 (void) acpi_ut_release_mutex (ACPI_MTX_NAMESPACE); 118 (void)acpi_ut_release_mutex(ACPI_MTX_NAMESPACE);
130 status = AE_BAD_PARAMETER; 119 status = AE_BAD_PARAMETER;
131 goto cleanup; 120 goto cleanup;
132 } 121 }
@@ -134,39 +123,38 @@ acpi_ns_evaluate_relative (
134 /* Lookup the name in the namespace */ 123 /* Lookup the name in the namespace */
135 124
136 scope_info->scope.node = info->node; 125 scope_info->scope.node = info->node;
137 status = acpi_ns_lookup (scope_info, internal_path, ACPI_TYPE_ANY, 126 status = acpi_ns_lookup(scope_info, internal_path, ACPI_TYPE_ANY,
138 ACPI_IMODE_EXECUTE, ACPI_NS_NO_UPSEARCH, NULL, 127 ACPI_IMODE_EXECUTE, ACPI_NS_NO_UPSEARCH, NULL,
139 &node); 128 &node);
140 129
141 (void) acpi_ut_release_mutex (ACPI_MTX_NAMESPACE); 130 (void)acpi_ut_release_mutex(ACPI_MTX_NAMESPACE);
142 131
143 if (ACPI_FAILURE (status)) { 132 if (ACPI_FAILURE(status)) {
144 ACPI_DEBUG_PRINT ((ACPI_DB_NAMES, "Object [%s] not found [%s]\n", 133 ACPI_DEBUG_PRINT((ACPI_DB_NAMES, "Object [%s] not found [%s]\n",
145 pathname, acpi_format_exception (status))); 134 pathname, acpi_format_exception(status)));
146 goto cleanup; 135 goto cleanup;
147 } 136 }
148 137
149 /* 138 /*
150 * Now that we have a handle to the object, we can attempt to evaluate it. 139 * Now that we have a handle to the object, we can attempt to evaluate it.
151 */ 140 */
152 ACPI_DEBUG_PRINT ((ACPI_DB_NAMES, "%s [%p] Value %p\n", 141 ACPI_DEBUG_PRINT((ACPI_DB_NAMES, "%s [%p] Value %p\n",
153 pathname, node, acpi_ns_get_attached_object (node))); 142 pathname, node, acpi_ns_get_attached_object(node)));
154 143
155 info->node = node; 144 info->node = node;
156 status = acpi_ns_evaluate_by_handle (info); 145 status = acpi_ns_evaluate_by_handle(info);
157 146
158 ACPI_DEBUG_PRINT ((ACPI_DB_NAMES, "*** Completed eval of object %s ***\n", 147 ACPI_DEBUG_PRINT((ACPI_DB_NAMES,
159 pathname)); 148 "*** Completed eval of object %s ***\n", pathname));
160 149
161cleanup: 150 cleanup:
162 acpi_ut_delete_generic_state (scope_info); 151 acpi_ut_delete_generic_state(scope_info);
163 152
164cleanup1: 153 cleanup1:
165 ACPI_MEM_FREE (internal_path); 154 ACPI_MEM_FREE(internal_path);
166 return_ACPI_STATUS (status); 155 return_ACPI_STATUS(status);
167} 156}
168 157
169
170/******************************************************************************* 158/*******************************************************************************
171 * 159 *
172 * FUNCTION: acpi_ns_evaluate_by_name 160 * FUNCTION: acpi_ns_evaluate_by_name
@@ -189,68 +177,63 @@ cleanup1:
189 ******************************************************************************/ 177 ******************************************************************************/
190 178
191acpi_status 179acpi_status
192acpi_ns_evaluate_by_name ( 180acpi_ns_evaluate_by_name(char *pathname, struct acpi_parameter_info *info)
193 char *pathname,
194 struct acpi_parameter_info *info)
195{ 181{
196 acpi_status status; 182 acpi_status status;
197 char *internal_path = NULL; 183 char *internal_path = NULL;
198
199
200 ACPI_FUNCTION_TRACE ("ns_evaluate_by_name");
201 184
185 ACPI_FUNCTION_TRACE("ns_evaluate_by_name");
202 186
203 /* Build an internal name string for the method */ 187 /* Build an internal name string for the method */
204 188
205 status = acpi_ns_internalize_name (pathname, &internal_path); 189 status = acpi_ns_internalize_name(pathname, &internal_path);
206 if (ACPI_FAILURE (status)) { 190 if (ACPI_FAILURE(status)) {
207 return_ACPI_STATUS (status); 191 return_ACPI_STATUS(status);
208 } 192 }
209 193
210 status = acpi_ut_acquire_mutex (ACPI_MTX_NAMESPACE); 194 status = acpi_ut_acquire_mutex(ACPI_MTX_NAMESPACE);
211 if (ACPI_FAILURE (status)) { 195 if (ACPI_FAILURE(status)) {
212 goto cleanup; 196 goto cleanup;
213 } 197 }
214 198
215 /* Lookup the name in the namespace */ 199 /* Lookup the name in the namespace */
216 200
217 status = acpi_ns_lookup (NULL, internal_path, ACPI_TYPE_ANY, 201 status = acpi_ns_lookup(NULL, internal_path, ACPI_TYPE_ANY,
218 ACPI_IMODE_EXECUTE, ACPI_NS_NO_UPSEARCH, NULL, 202 ACPI_IMODE_EXECUTE, ACPI_NS_NO_UPSEARCH, NULL,
219 &info->node); 203 &info->node);
220 204
221 (void) acpi_ut_release_mutex (ACPI_MTX_NAMESPACE); 205 (void)acpi_ut_release_mutex(ACPI_MTX_NAMESPACE);
222 206
223 if (ACPI_FAILURE (status)) { 207 if (ACPI_FAILURE(status)) {
224 ACPI_DEBUG_PRINT ((ACPI_DB_NAMES, 208 ACPI_DEBUG_PRINT((ACPI_DB_NAMES,
225 "Object at [%s] was not found, status=%.4X\n", 209 "Object at [%s] was not found, status=%.4X\n",
226 pathname, status)); 210 pathname, status));
227 goto cleanup; 211 goto cleanup;
228 } 212 }
229 213
230 /* 214 /*
231 * Now that we have a handle to the object, we can attempt to evaluate it. 215 * Now that we have a handle to the object, we can attempt to evaluate it.
232 */ 216 */
233 ACPI_DEBUG_PRINT ((ACPI_DB_NAMES, "%s [%p] Value %p\n", 217 ACPI_DEBUG_PRINT((ACPI_DB_NAMES, "%s [%p] Value %p\n",
234 pathname, info->node, acpi_ns_get_attached_object (info->node))); 218 pathname, info->node,
235 219 acpi_ns_get_attached_object(info->node)));
236 status = acpi_ns_evaluate_by_handle (info);
237 220
238 ACPI_DEBUG_PRINT ((ACPI_DB_NAMES, "*** Completed eval of object %s ***\n", 221 status = acpi_ns_evaluate_by_handle(info);
239 pathname));
240 222
223 ACPI_DEBUG_PRINT((ACPI_DB_NAMES,
224 "*** Completed eval of object %s ***\n", pathname));
241 225
242cleanup: 226 cleanup:
243 227
244 /* Cleanup */ 228 /* Cleanup */
245 229
246 if (internal_path) { 230 if (internal_path) {
247 ACPI_MEM_FREE (internal_path); 231 ACPI_MEM_FREE(internal_path);
248 } 232 }
249 233
250 return_ACPI_STATUS (status); 234 return_ACPI_STATUS(status);
251} 235}
252 236
253
254/******************************************************************************* 237/*******************************************************************************
255 * 238 *
256 * FUNCTION: acpi_ns_evaluate_by_handle 239 * FUNCTION: acpi_ns_evaluate_by_handle
@@ -275,26 +258,22 @@ cleanup:
275 * 258 *
276 ******************************************************************************/ 259 ******************************************************************************/
277 260
278acpi_status 261acpi_status acpi_ns_evaluate_by_handle(struct acpi_parameter_info *info)
279acpi_ns_evaluate_by_handle (
280 struct acpi_parameter_info *info)
281{ 262{
282 acpi_status status; 263 acpi_status status;
283
284
285 ACPI_FUNCTION_TRACE ("ns_evaluate_by_handle");
286 264
265 ACPI_FUNCTION_TRACE("ns_evaluate_by_handle");
287 266
288 /* Check if namespace has been initialized */ 267 /* Check if namespace has been initialized */
289 268
290 if (!acpi_gbl_root_node) { 269 if (!acpi_gbl_root_node) {
291 return_ACPI_STATUS (AE_NO_NAMESPACE); 270 return_ACPI_STATUS(AE_NO_NAMESPACE);
292 } 271 }
293 272
294 /* Parameter Validation */ 273 /* Parameter Validation */
295 274
296 if (!info) { 275 if (!info) {
297 return_ACPI_STATUS (AE_BAD_PARAMETER); 276 return_ACPI_STATUS(AE_BAD_PARAMETER);
298 } 277 }
299 278
300 /* Initialize the return value to an invalid object */ 279 /* Initialize the return value to an invalid object */
@@ -303,23 +282,25 @@ acpi_ns_evaluate_by_handle (
303 282
304 /* Get the prefix handle and Node */ 283 /* Get the prefix handle and Node */
305 284
306 status = acpi_ut_acquire_mutex (ACPI_MTX_NAMESPACE); 285 status = acpi_ut_acquire_mutex(ACPI_MTX_NAMESPACE);
307 if (ACPI_FAILURE (status)) { 286 if (ACPI_FAILURE(status)) {
308 return_ACPI_STATUS (status); 287 return_ACPI_STATUS(status);
309 } 288 }
310 289
311 info->node = acpi_ns_map_handle_to_node (info->node); 290 info->node = acpi_ns_map_handle_to_node(info->node);
312 if (!info->node) { 291 if (!info->node) {
313 (void) acpi_ut_release_mutex (ACPI_MTX_NAMESPACE); 292 (void)acpi_ut_release_mutex(ACPI_MTX_NAMESPACE);
314 return_ACPI_STATUS (AE_BAD_PARAMETER); 293 return_ACPI_STATUS(AE_BAD_PARAMETER);
315 } 294 }
316 295
317 /* 296 /*
318 * For a method alias, we must grab the actual method node so that proper 297 * For a method alias, we must grab the actual method node so that proper
319 * scoping context will be established before execution. 298 * scoping context will be established before execution.
320 */ 299 */
321 if (acpi_ns_get_type (info->node) == ACPI_TYPE_LOCAL_METHOD_ALIAS) { 300 if (acpi_ns_get_type(info->node) == ACPI_TYPE_LOCAL_METHOD_ALIAS) {
322 info->node = ACPI_CAST_PTR (struct acpi_namespace_node, info->node->object); 301 info->node =
302 ACPI_CAST_PTR(struct acpi_namespace_node,
303 info->node->object);
323 } 304 }
324 305
325 /* 306 /*
@@ -329,17 +310,16 @@ acpi_ns_evaluate_by_handle (
329 * 310 *
330 * In both cases, the namespace is unlocked by the acpi_ns* procedure 311 * In both cases, the namespace is unlocked by the acpi_ns* procedure
331 */ 312 */
332 if (acpi_ns_get_type (info->node) == ACPI_TYPE_METHOD) { 313 if (acpi_ns_get_type(info->node) == ACPI_TYPE_METHOD) {
333 /* 314 /*
334 * Case 1) We have an actual control method to execute 315 * Case 1) We have an actual control method to execute
335 */ 316 */
336 status = acpi_ns_execute_control_method (info); 317 status = acpi_ns_execute_control_method(info);
337 } 318 } else {
338 else {
339 /* 319 /*
340 * Case 2) Object is NOT a method, just return its current value 320 * Case 2) Object is NOT a method, just return its current value
341 */ 321 */
342 status = acpi_ns_get_object_value (info); 322 status = acpi_ns_get_object_value(info);
343 } 323 }
344 324
345 /* 325 /*
@@ -355,16 +335,16 @@ acpi_ns_evaluate_by_handle (
355 * Namespace was unlocked by the handling acpi_ns* function, so we 335 * Namespace was unlocked by the handling acpi_ns* function, so we
356 * just return 336 * just return
357 */ 337 */
358 return_ACPI_STATUS (status); 338 return_ACPI_STATUS(status);
359} 339}
360 340
361
362/******************************************************************************* 341/*******************************************************************************
363 * 342 *
364 * FUNCTION: acpi_ns_execute_control_method 343 * FUNCTION: acpi_ns_execute_control_method
365 * 344 *
366 * PARAMETERS: Info - Method info block, contains: 345 * PARAMETERS: Info - Method info block, contains:
367 * Node - Method Node to execute 346 * Node - Method Node to execute
347 * obj_desc - Method object
368 * Parameters - List of parameters to pass to the method, 348 * Parameters - List of parameters to pass to the method,
369 * terminated by NULL. Params itself may be 349 * terminated by NULL. Params itself may be
370 * NULL if no parameters are being passed. 350 * NULL if no parameters are being passed.
@@ -383,31 +363,29 @@ acpi_ns_evaluate_by_handle (
383 ******************************************************************************/ 363 ******************************************************************************/
384 364
385static acpi_status 365static acpi_status
386acpi_ns_execute_control_method ( 366acpi_ns_execute_control_method(struct acpi_parameter_info *info)
387 struct acpi_parameter_info *info)
388{ 367{
389 acpi_status status; 368 acpi_status status;
390 union acpi_operand_object *obj_desc;
391
392
393 ACPI_FUNCTION_TRACE ("ns_execute_control_method");
394 369
370 ACPI_FUNCTION_TRACE("ns_execute_control_method");
395 371
396 /* Verify that there is a method associated with this object */ 372 /* Verify that there is a method associated with this object */
397 373
398 obj_desc = acpi_ns_get_attached_object (info->node); 374 info->obj_desc = acpi_ns_get_attached_object(info->node);
399 if (!obj_desc) { 375 if (!info->obj_desc) {
400 ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "No attached method object\n")); 376 ACPI_DEBUG_PRINT((ACPI_DB_ERROR,
377 "No attached method object\n"));
401 378
402 (void) acpi_ut_release_mutex (ACPI_MTX_NAMESPACE); 379 (void)acpi_ut_release_mutex(ACPI_MTX_NAMESPACE);
403 return_ACPI_STATUS (AE_NULL_OBJECT); 380 return_ACPI_STATUS(AE_NULL_OBJECT);
404 } 381 }
405 382
406 ACPI_DUMP_PATHNAME (info->node, "Execute Method:", 383 ACPI_DUMP_PATHNAME(info->node, "Execute Method:",
407 ACPI_LV_INFO, _COMPONENT); 384 ACPI_LV_INFO, _COMPONENT);
408 385
409 ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "Method at AML address %p Length %X\n", 386 ACPI_DEBUG_PRINT((ACPI_DB_EXEC, "Method at AML address %p Length %X\n",
410 obj_desc->method.aml_start + 1, obj_desc->method.aml_length - 1)); 387 info->obj_desc->method.aml_start + 1,
388 info->obj_desc->method.aml_length - 1));
411 389
412 /* 390 /*
413 * Unlock the namespace before execution. This allows namespace access 391 * Unlock the namespace before execution. This allows namespace access
@@ -416,27 +394,26 @@ acpi_ns_execute_control_method (
416 * interpreter locks to ensure that no thread is using the portion of the 394 * interpreter locks to ensure that no thread is using the portion of the
417 * namespace that is being deleted. 395 * namespace that is being deleted.
418 */ 396 */
419 status = acpi_ut_release_mutex (ACPI_MTX_NAMESPACE); 397 status = acpi_ut_release_mutex(ACPI_MTX_NAMESPACE);
420 if (ACPI_FAILURE (status)) { 398 if (ACPI_FAILURE(status)) {
421 return_ACPI_STATUS (status); 399 return_ACPI_STATUS(status);
422 } 400 }
423 401
424 /* 402 /*
425 * Execute the method via the interpreter. The interpreter is locked 403 * Execute the method via the interpreter. The interpreter is locked
426 * here before calling into the AML parser 404 * here before calling into the AML parser
427 */ 405 */
428 status = acpi_ex_enter_interpreter (); 406 status = acpi_ex_enter_interpreter();
429 if (ACPI_FAILURE (status)) { 407 if (ACPI_FAILURE(status)) {
430 return_ACPI_STATUS (status); 408 return_ACPI_STATUS(status);
431 } 409 }
432 410
433 status = acpi_psx_execute (info); 411 status = acpi_ps_execute_method(info);
434 acpi_ex_exit_interpreter (); 412 acpi_ex_exit_interpreter();
435 413
436 return_ACPI_STATUS (status); 414 return_ACPI_STATUS(status);
437} 415}
438 416
439
440/******************************************************************************* 417/*******************************************************************************
441 * 418 *
442 * FUNCTION: acpi_ns_get_object_value 419 * FUNCTION: acpi_ns_get_object_value
@@ -454,16 +431,12 @@ acpi_ns_execute_control_method (
454 * 431 *
455 ******************************************************************************/ 432 ******************************************************************************/
456 433
457static acpi_status 434static acpi_status acpi_ns_get_object_value(struct acpi_parameter_info *info)
458acpi_ns_get_object_value (
459 struct acpi_parameter_info *info)
460{ 435{
461 acpi_status status = AE_OK; 436 acpi_status status = AE_OK;
462 struct acpi_namespace_node *resolved_node = info->node; 437 struct acpi_namespace_node *resolved_node = info->node;
463
464
465 ACPI_FUNCTION_TRACE ("ns_get_object_value");
466 438
439 ACPI_FUNCTION_TRACE("ns_get_object_value");
467 440
468 /* 441 /*
469 * Objects require additional resolution steps (e.g., the Node may be a 442 * Objects require additional resolution steps (e.g., the Node may be a
@@ -486,32 +459,33 @@ acpi_ns_get_object_value (
486 * 459 *
487 * We must release the namespace lock before entering the intepreter. 460 * We must release the namespace lock before entering the intepreter.
488 */ 461 */
489 status = acpi_ut_release_mutex (ACPI_MTX_NAMESPACE); 462 status = acpi_ut_release_mutex(ACPI_MTX_NAMESPACE);
490 if (ACPI_FAILURE (status)) { 463 if (ACPI_FAILURE(status)) {
491 return_ACPI_STATUS (status); 464 return_ACPI_STATUS(status);
492 } 465 }
493 466
494 status = acpi_ex_enter_interpreter (); 467 status = acpi_ex_enter_interpreter();
495 if (ACPI_SUCCESS (status)) { 468 if (ACPI_SUCCESS(status)) {
496 status = acpi_ex_resolve_node_to_value (&resolved_node, NULL); 469 status = acpi_ex_resolve_node_to_value(&resolved_node, NULL);
497 /* 470 /*
498 * If acpi_ex_resolve_node_to_value() succeeded, the return value was placed 471 * If acpi_ex_resolve_node_to_value() succeeded, the return value was placed
499 * in resolved_node. 472 * in resolved_node.
500 */ 473 */
501 acpi_ex_exit_interpreter (); 474 acpi_ex_exit_interpreter();
502 475
503 if (ACPI_SUCCESS (status)) { 476 if (ACPI_SUCCESS(status)) {
504 status = AE_CTRL_RETURN_VALUE; 477 status = AE_CTRL_RETURN_VALUE;
505 info->return_object = ACPI_CAST_PTR 478 info->return_object = ACPI_CAST_PTR
506 (union acpi_operand_object, resolved_node); 479 (union acpi_operand_object, resolved_node);
507 ACPI_DEBUG_PRINT ((ACPI_DB_NAMES, "Returning object %p [%s]\n", 480 ACPI_DEBUG_PRINT((ACPI_DB_NAMES,
508 info->return_object, 481 "Returning object %p [%s]\n",
509 acpi_ut_get_object_type_name (info->return_object))); 482 info->return_object,
483 acpi_ut_get_object_type_name(info->
484 return_object)));
510 } 485 }
511 } 486 }
512 487
513 /* Namespace is unlocked */ 488 /* Namespace is unlocked */
514 489
515 return_ACPI_STATUS (status); 490 return_ACPI_STATUS(status);
516} 491}
517
diff --git a/drivers/acpi/namespace/nsinit.c b/drivers/acpi/namespace/nsinit.c
index 362802ae29a2..0a08d2f04a06 100644
--- a/drivers/acpi/namespace/nsinit.c
+++ b/drivers/acpi/namespace/nsinit.c
@@ -41,31 +41,22 @@
41 * POSSIBILITY OF SUCH DAMAGES. 41 * POSSIBILITY OF SUCH DAMAGES.
42 */ 42 */
43 43
44
45#include <acpi/acpi.h> 44#include <acpi/acpi.h>
46#include <acpi/acnamesp.h> 45#include <acpi/acnamesp.h>
47#include <acpi/acdispat.h> 46#include <acpi/acdispat.h>
48#include <acpi/acinterp.h> 47#include <acpi/acinterp.h>
49 48
50#define _COMPONENT ACPI_NAMESPACE 49#define _COMPONENT ACPI_NAMESPACE
51 ACPI_MODULE_NAME ("nsinit") 50ACPI_MODULE_NAME("nsinit")
52 51
53/* Local prototypes */ 52/* Local prototypes */
54
55static acpi_status 53static acpi_status
56acpi_ns_init_one_object ( 54acpi_ns_init_one_object(acpi_handle obj_handle,
57 acpi_handle obj_handle, 55 u32 level, void *context, void **return_value);
58 u32 level,
59 void *context,
60 void **return_value);
61 56
62static acpi_status 57static acpi_status
63acpi_ns_init_one_device ( 58acpi_ns_init_one_device(acpi_handle obj_handle,
64 acpi_handle obj_handle, 59 u32 nesting_level, void *context, void **return_value);
65 u32 nesting_level,
66 void *context,
67 void **return_value);
68
69 60
70/******************************************************************************* 61/*******************************************************************************
71 * 62 *
@@ -80,52 +71,48 @@ acpi_ns_init_one_device (
80 * 71 *
81 ******************************************************************************/ 72 ******************************************************************************/
82 73
83acpi_status 74acpi_status acpi_ns_initialize_objects(void)
84acpi_ns_initialize_objects (
85 void)
86{ 75{
87 acpi_status status; 76 acpi_status status;
88 struct acpi_init_walk_info info; 77 struct acpi_init_walk_info info;
89
90 78
91 ACPI_FUNCTION_TRACE ("ns_initialize_objects"); 79 ACPI_FUNCTION_TRACE("ns_initialize_objects");
92 80
93 81 ACPI_DEBUG_PRINT((ACPI_DB_DISPATCH,
94 ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH, 82 "**** Starting initialization of namespace objects ****\n"));
95 "**** Starting initialization of namespace objects ****\n")); 83 ACPI_DEBUG_PRINT_RAW((ACPI_DB_INIT,
96 ACPI_DEBUG_PRINT_RAW ((ACPI_DB_INIT, 84 "Completing Region/Field/Buffer/Package initialization:"));
97 "Completing Region/Field/Buffer/Package initialization:"));
98 85
99 /* Set all init info to zero */ 86 /* Set all init info to zero */
100 87
101 ACPI_MEMSET (&info, 0, sizeof (struct acpi_init_walk_info)); 88 ACPI_MEMSET(&info, 0, sizeof(struct acpi_init_walk_info));
102 89
103 /* Walk entire namespace from the supplied root */ 90 /* Walk entire namespace from the supplied root */
104 91
105 status = acpi_walk_namespace (ACPI_TYPE_ANY, ACPI_ROOT_OBJECT, 92 status = acpi_walk_namespace(ACPI_TYPE_ANY, ACPI_ROOT_OBJECT,
106 ACPI_UINT32_MAX, acpi_ns_init_one_object, 93 ACPI_UINT32_MAX, acpi_ns_init_one_object,
107 &info, NULL); 94 &info, NULL);
108 if (ACPI_FAILURE (status)) { 95 if (ACPI_FAILURE(status)) {
109 ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "walk_namespace failed! %s\n", 96 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, "walk_namespace failed! %s\n",
110 acpi_format_exception (status))); 97 acpi_format_exception(status)));
111 } 98 }
112 99
113 ACPI_DEBUG_PRINT_RAW ((ACPI_DB_INIT, 100 ACPI_DEBUG_PRINT_RAW((ACPI_DB_INIT,
114 "\nInitialized %hd/%hd Regions %hd/%hd Fields %hd/%hd Buffers %hd/%hd Packages (%hd nodes)\n", 101 "\nInitialized %hd/%hd Regions %hd/%hd Fields %hd/%hd Buffers %hd/%hd Packages (%hd nodes)\n",
115 info.op_region_init, info.op_region_count, 102 info.op_region_init, info.op_region_count,
116 info.field_init, info.field_count, 103 info.field_init, info.field_count,
117 info.buffer_init, info.buffer_count, 104 info.buffer_init, info.buffer_count,
118 info.package_init, info.package_count, info.object_count)); 105 info.package_init, info.package_count,
106 info.object_count));
119 107
120 ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH, 108 ACPI_DEBUG_PRINT((ACPI_DB_DISPATCH,
121 "%hd Control Methods found\n", info.method_count)); 109 "%hd Control Methods found\n", info.method_count));
122 ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH, 110 ACPI_DEBUG_PRINT((ACPI_DB_DISPATCH,
123 "%hd Op Regions found\n", info.op_region_count)); 111 "%hd Op Regions found\n", info.op_region_count));
124 112
125 return_ACPI_STATUS (AE_OK); 113 return_ACPI_STATUS(AE_OK);
126} 114}
127 115
128
129/******************************************************************************* 116/*******************************************************************************
130 * 117 *
131 * FUNCTION: acpi_ns_initialize_devices 118 * FUNCTION: acpi_ns_initialize_devices
@@ -142,16 +129,12 @@ acpi_ns_initialize_objects (
142 * 129 *
143 ******************************************************************************/ 130 ******************************************************************************/
144 131
145acpi_status 132acpi_status acpi_ns_initialize_devices(void)
146acpi_ns_initialize_devices (
147 void)
148{ 133{
149 acpi_status status; 134 acpi_status status;
150 struct acpi_device_walk_info info; 135 struct acpi_device_walk_info info;
151
152
153 ACPI_FUNCTION_TRACE ("ns_initialize_devices");
154 136
137 ACPI_FUNCTION_TRACE("ns_initialize_devices");
155 138
156 /* Init counters */ 139 /* Init counters */
157 140
@@ -159,34 +142,34 @@ acpi_ns_initialize_devices (
159 info.num_STA = 0; 142 info.num_STA = 0;
160 info.num_INI = 0; 143 info.num_INI = 0;
161 144
162 ACPI_DEBUG_PRINT_RAW ((ACPI_DB_INIT, 145 ACPI_DEBUG_PRINT_RAW((ACPI_DB_INIT,
163 "Executing all Device _STA and_INI methods:")); 146 "Executing all Device _STA and_INI methods:"));
164 147
165 status = acpi_ut_acquire_mutex (ACPI_MTX_NAMESPACE); 148 status = acpi_ut_acquire_mutex(ACPI_MTX_NAMESPACE);
166 if (ACPI_FAILURE (status)) { 149 if (ACPI_FAILURE(status)) {
167 return_ACPI_STATUS (status); 150 return_ACPI_STATUS(status);
168 } 151 }
169 152
170 /* Walk namespace for all objects */ 153 /* Walk namespace for all objects */
171 154
172 status = acpi_ns_walk_namespace (ACPI_TYPE_ANY, ACPI_ROOT_OBJECT, 155 status = acpi_ns_walk_namespace(ACPI_TYPE_ANY, ACPI_ROOT_OBJECT,
173 ACPI_UINT32_MAX, TRUE, acpi_ns_init_one_device, &info, NULL); 156 ACPI_UINT32_MAX, TRUE,
157 acpi_ns_init_one_device, &info, NULL);
174 158
175 (void) acpi_ut_release_mutex (ACPI_MTX_NAMESPACE); 159 (void)acpi_ut_release_mutex(ACPI_MTX_NAMESPACE);
176 160
177 if (ACPI_FAILURE (status)) { 161 if (ACPI_FAILURE(status)) {
178 ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "walk_namespace failed! %s\n", 162 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, "walk_namespace failed! %s\n",
179 acpi_format_exception (status))); 163 acpi_format_exception(status)));
180 } 164 }
181 165
182 ACPI_DEBUG_PRINT_RAW ((ACPI_DB_INIT, 166 ACPI_DEBUG_PRINT_RAW((ACPI_DB_INIT,
183 "\n%hd Devices found containing: %hd _STA, %hd _INI methods\n", 167 "\n%hd Devices found containing: %hd _STA, %hd _INI methods\n",
184 info.device_count, info.num_STA, info.num_INI)); 168 info.device_count, info.num_STA, info.num_INI));
185 169
186 return_ACPI_STATUS (status); 170 return_ACPI_STATUS(status);
187} 171}
188 172
189
190/******************************************************************************* 173/*******************************************************************************
191 * 174 *
192 * FUNCTION: acpi_ns_init_one_object 175 * FUNCTION: acpi_ns_init_one_object
@@ -208,28 +191,25 @@ acpi_ns_initialize_devices (
208 ******************************************************************************/ 191 ******************************************************************************/
209 192
210static acpi_status 193static acpi_status
211acpi_ns_init_one_object ( 194acpi_ns_init_one_object(acpi_handle obj_handle,
212 acpi_handle obj_handle, 195 u32 level, void *context, void **return_value)
213 u32 level,
214 void *context,
215 void **return_value)
216{ 196{
217 acpi_object_type type; 197 acpi_object_type type;
218 acpi_status status; 198 acpi_status status;
219 struct acpi_init_walk_info *info = (struct acpi_init_walk_info *) context; 199 struct acpi_init_walk_info *info =
220 struct acpi_namespace_node *node = (struct acpi_namespace_node *) obj_handle; 200 (struct acpi_init_walk_info *)context;
221 union acpi_operand_object *obj_desc; 201 struct acpi_namespace_node *node =
222 202 (struct acpi_namespace_node *)obj_handle;
223 203 union acpi_operand_object *obj_desc;
224 ACPI_FUNCTION_NAME ("ns_init_one_object");
225 204
205 ACPI_FUNCTION_NAME("ns_init_one_object");
226 206
227 info->object_count++; 207 info->object_count++;
228 208
229 /* And even then, we are only interested in a few object types */ 209 /* And even then, we are only interested in a few object types */
230 210
231 type = acpi_ns_get_type (obj_handle); 211 type = acpi_ns_get_type(obj_handle);
232 obj_desc = acpi_ns_get_attached_object (node); 212 obj_desc = acpi_ns_get_attached_object(node);
233 if (!obj_desc) { 213 if (!obj_desc) {
234 return (AE_OK); 214 return (AE_OK);
235 } 215 }
@@ -269,8 +249,8 @@ acpi_ns_init_one_object (
269 /* 249 /*
270 * Must lock the interpreter before executing AML code 250 * Must lock the interpreter before executing AML code
271 */ 251 */
272 status = acpi_ex_enter_interpreter (); 252 status = acpi_ex_enter_interpreter();
273 if (ACPI_FAILURE (status)) { 253 if (ACPI_FAILURE(status)) {
274 return (status); 254 return (status);
275 } 255 }
276 256
@@ -282,25 +262,25 @@ acpi_ns_init_one_object (
282 case ACPI_TYPE_REGION: 262 case ACPI_TYPE_REGION:
283 263
284 info->op_region_init++; 264 info->op_region_init++;
285 status = acpi_ds_get_region_arguments (obj_desc); 265 status = acpi_ds_get_region_arguments(obj_desc);
286 break; 266 break;
287 267
288 case ACPI_TYPE_BUFFER_FIELD: 268 case ACPI_TYPE_BUFFER_FIELD:
289 269
290 info->field_init++; 270 info->field_init++;
291 status = acpi_ds_get_buffer_field_arguments (obj_desc); 271 status = acpi_ds_get_buffer_field_arguments(obj_desc);
292 break; 272 break;
293 273
294 case ACPI_TYPE_BUFFER: 274 case ACPI_TYPE_BUFFER:
295 275
296 info->buffer_init++; 276 info->buffer_init++;
297 status = acpi_ds_get_buffer_arguments (obj_desc); 277 status = acpi_ds_get_buffer_arguments(obj_desc);
298 break; 278 break;
299 279
300 case ACPI_TYPE_PACKAGE: 280 case ACPI_TYPE_PACKAGE:
301 281
302 info->package_init++; 282 info->package_init++;
303 status = acpi_ds_get_package_arguments (obj_desc); 283 status = acpi_ds_get_package_arguments(obj_desc);
304 break; 284 break;
305 285
306 default: 286 default:
@@ -308,12 +288,13 @@ acpi_ns_init_one_object (
308 break; 288 break;
309 } 289 }
310 290
311 if (ACPI_FAILURE (status)) { 291 if (ACPI_FAILURE(status)) {
312 ACPI_DEBUG_PRINT_RAW ((ACPI_DB_ERROR, "\n")); 292 ACPI_DEBUG_PRINT_RAW((ACPI_DB_ERROR, "\n"));
313 ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, 293 ACPI_DEBUG_PRINT((ACPI_DB_ERROR,
314 "Could not execute arguments for [%4.4s] (%s), %s\n", 294 "Could not execute arguments for [%4.4s] (%s), %s\n",
315 acpi_ut_get_node_name (node), acpi_ut_get_type_name (type), 295 acpi_ut_get_node_name(node),
316 acpi_format_exception (status))); 296 acpi_ut_get_type_name(type),
297 acpi_format_exception(status)));
317 } 298 }
318 299
319 /* 300 /*
@@ -321,18 +302,17 @@ acpi_ns_init_one_object (
321 * pathname 302 * pathname
322 */ 303 */
323 if (!(acpi_dbg_level & ACPI_LV_INIT_NAMES)) { 304 if (!(acpi_dbg_level & ACPI_LV_INIT_NAMES)) {
324 ACPI_DEBUG_PRINT_RAW ((ACPI_DB_INIT, ".")); 305 ACPI_DEBUG_PRINT_RAW((ACPI_DB_INIT, "."));
325 } 306 }
326 307
327 /* 308 /*
328 * We ignore errors from above, and always return OK, since we don't want 309 * We ignore errors from above, and always return OK, since we don't want
329 * to abort the walk on any single error. 310 * to abort the walk on any single error.
330 */ 311 */
331 acpi_ex_exit_interpreter (); 312 acpi_ex_exit_interpreter();
332 return (AE_OK); 313 return (AE_OK);
333} 314}
334 315
335
336/******************************************************************************* 316/*******************************************************************************
337 * 317 *
338 * FUNCTION: acpi_ns_init_one_device 318 * FUNCTION: acpi_ns_init_one_device
@@ -348,41 +328,37 @@ acpi_ns_init_one_object (
348 ******************************************************************************/ 328 ******************************************************************************/
349 329
350static acpi_status 330static acpi_status
351acpi_ns_init_one_device ( 331acpi_ns_init_one_device(acpi_handle obj_handle,
352 acpi_handle obj_handle, 332 u32 nesting_level, void *context, void **return_value)
353 u32 nesting_level,
354 void *context,
355 void **return_value)
356{ 333{
357 struct acpi_device_walk_info *info = (struct acpi_device_walk_info *) context; 334 struct acpi_device_walk_info *info =
358 struct acpi_parameter_info pinfo; 335 (struct acpi_device_walk_info *)context;
359 u32 flags; 336 struct acpi_parameter_info pinfo;
360 acpi_status status; 337 u32 flags;
361 338 acpi_status status;
362
363 ACPI_FUNCTION_TRACE ("ns_init_one_device");
364 339
340 ACPI_FUNCTION_TRACE("ns_init_one_device");
365 341
366 pinfo.parameters = NULL; 342 pinfo.parameters = NULL;
367 pinfo.parameter_type = ACPI_PARAM_ARGS; 343 pinfo.parameter_type = ACPI_PARAM_ARGS;
368 344
369 pinfo.node = acpi_ns_map_handle_to_node (obj_handle); 345 pinfo.node = acpi_ns_map_handle_to_node(obj_handle);
370 if (!pinfo.node) { 346 if (!pinfo.node) {
371 return_ACPI_STATUS (AE_BAD_PARAMETER); 347 return_ACPI_STATUS(AE_BAD_PARAMETER);
372 } 348 }
373 349
374 /* 350 /*
375 * We will run _STA/_INI on Devices, Processors and thermal_zones only 351 * We will run _STA/_INI on Devices, Processors and thermal_zones only
376 */ 352 */
377 if ((pinfo.node->type != ACPI_TYPE_DEVICE) && 353 if ((pinfo.node->type != ACPI_TYPE_DEVICE) &&
378 (pinfo.node->type != ACPI_TYPE_PROCESSOR) && 354 (pinfo.node->type != ACPI_TYPE_PROCESSOR) &&
379 (pinfo.node->type != ACPI_TYPE_THERMAL)) { 355 (pinfo.node->type != ACPI_TYPE_THERMAL)) {
380 return_ACPI_STATUS (AE_OK); 356 return_ACPI_STATUS(AE_OK);
381 } 357 }
382 358
383 if ((acpi_dbg_level <= ACPI_LV_ALL_EXCEPTIONS) && 359 if ((acpi_dbg_level <= ACPI_LV_ALL_EXCEPTIONS) &&
384 (!(acpi_dbg_level & ACPI_LV_INFO))) { 360 (!(acpi_dbg_level & ACPI_LV_INFO))) {
385 ACPI_DEBUG_PRINT_RAW ((ACPI_DB_INIT, ".")); 361 ACPI_DEBUG_PRINT_RAW((ACPI_DB_INIT, "."));
386 } 362 }
387 363
388 info->device_count++; 364 info->device_count++;
@@ -390,20 +366,20 @@ acpi_ns_init_one_device (
390 /* 366 /*
391 * Run _STA to determine if we can run _INI on the device. 367 * Run _STA to determine if we can run _INI on the device.
392 */ 368 */
393 ACPI_DEBUG_EXEC (acpi_ut_display_init_pathname (ACPI_TYPE_METHOD, 369 ACPI_DEBUG_EXEC(acpi_ut_display_init_pathname(ACPI_TYPE_METHOD,
394 pinfo.node, METHOD_NAME__STA)); 370 pinfo.node,
395 status = acpi_ut_execute_STA (pinfo.node, &flags); 371 METHOD_NAME__STA));
372 status = acpi_ut_execute_STA(pinfo.node, &flags);
396 373
397 if (ACPI_FAILURE (status)) { 374 if (ACPI_FAILURE(status)) {
398 if (pinfo.node->type == ACPI_TYPE_DEVICE) { 375 if (pinfo.node->type == ACPI_TYPE_DEVICE) {
399 /* Ignore error and move on to next device */ 376 /* Ignore error and move on to next device */
400 377
401 return_ACPI_STATUS (AE_OK); 378 return_ACPI_STATUS(AE_OK);
402 } 379 }
403 380
404 /* _STA is not required for Processor or thermal_zone objects */ 381 /* _STA is not required for Processor or thermal_zone objects */
405 } 382 } else {
406 else {
407 info->num_STA++; 383 info->num_STA++;
408 384
409 if (!(flags & 0x01)) { 385 if (!(flags & 0x01)) {
@@ -416,32 +392,34 @@ acpi_ns_init_one_device (
416 /* 392 /*
417 * The device is present. Run _INI. 393 * The device is present. Run _INI.
418 */ 394 */
419 ACPI_DEBUG_EXEC (acpi_ut_display_init_pathname (ACPI_TYPE_METHOD, 395 ACPI_DEBUG_EXEC(acpi_ut_display_init_pathname(ACPI_TYPE_METHOD,
420 pinfo.node, METHOD_NAME__INI)); 396 pinfo.node,
421 status = acpi_ns_evaluate_relative (METHOD_NAME__INI, &pinfo); 397 METHOD_NAME__INI));
422 if (ACPI_FAILURE (status)) { 398 status = acpi_ns_evaluate_relative(METHOD_NAME__INI, &pinfo);
399 if (ACPI_FAILURE(status)) {
423 /* No _INI (AE_NOT_FOUND) means device requires no initialization */ 400 /* No _INI (AE_NOT_FOUND) means device requires no initialization */
424 401
425 if (status != AE_NOT_FOUND) { 402 if (status != AE_NOT_FOUND) {
426 /* Ignore error and move on to next device */ 403 /* Ignore error and move on to next device */
427 404
428#ifdef ACPI_DEBUG_OUTPUT 405#ifdef ACPI_DEBUG_OUTPUT
429 char *scope_name = acpi_ns_get_external_pathname (pinfo.node); 406 char *scope_name =
407 acpi_ns_get_external_pathname(pinfo.node);
430 408
431 ACPI_DEBUG_PRINT ((ACPI_DB_WARN, "%s._INI failed: %s\n", 409 ACPI_DEBUG_PRINT((ACPI_DB_WARN, "%s._INI failed: %s\n",
432 scope_name, acpi_format_exception (status))); 410 scope_name,
411 acpi_format_exception(status)));
433 412
434 ACPI_MEM_FREE (scope_name); 413 ACPI_MEM_FREE(scope_name);
435#endif 414#endif
436 } 415 }
437 416
438 status = AE_OK; 417 status = AE_OK;
439 } 418 } else {
440 else {
441 /* Delete any return object (especially if implicit_return is enabled) */ 419 /* Delete any return object (especially if implicit_return is enabled) */
442 420
443 if (pinfo.return_object) { 421 if (pinfo.return_object) {
444 acpi_ut_remove_reference (pinfo.return_object); 422 acpi_ut_remove_reference(pinfo.return_object);
445 } 423 }
446 424
447 /* Count of successful INIs */ 425 /* Count of successful INIs */
@@ -452,8 +430,9 @@ acpi_ns_init_one_device (
452 if (acpi_gbl_init_handler) { 430 if (acpi_gbl_init_handler) {
453 /* External initialization handler is present, call it */ 431 /* External initialization handler is present, call it */
454 432
455 status = acpi_gbl_init_handler (pinfo.node, ACPI_INIT_DEVICE_INI); 433 status =
434 acpi_gbl_init_handler(pinfo.node, ACPI_INIT_DEVICE_INI);
456 } 435 }
457 436
458 return_ACPI_STATUS (status); 437 return_ACPI_STATUS(status);
459} 438}
diff --git a/drivers/acpi/namespace/nsload.c b/drivers/acpi/namespace/nsload.c
index 34e497016601..c28849de465a 100644
--- a/drivers/acpi/namespace/nsload.c
+++ b/drivers/acpi/namespace/nsload.c
@@ -41,32 +41,22 @@
41 * POSSIBILITY OF SUCH DAMAGES. 41 * POSSIBILITY OF SUCH DAMAGES.
42 */ 42 */
43 43
44
45#include <acpi/acpi.h> 44#include <acpi/acpi.h>
46#include <acpi/acnamesp.h> 45#include <acpi/acnamesp.h>
47#include <acpi/acdispat.h> 46#include <acpi/acdispat.h>
48 47
49
50#define _COMPONENT ACPI_NAMESPACE 48#define _COMPONENT ACPI_NAMESPACE
51 ACPI_MODULE_NAME ("nsload") 49ACPI_MODULE_NAME("nsload")
52 50
53/* Local prototypes */ 51/* Local prototypes */
54 52static acpi_status acpi_ns_load_table_by_type(acpi_table_type table_type);
55static acpi_status
56acpi_ns_load_table_by_type (
57 acpi_table_type table_type);
58 53
59#ifdef ACPI_FUTURE_IMPLEMENTATION 54#ifdef ACPI_FUTURE_IMPLEMENTATION
60acpi_status 55acpi_status acpi_ns_unload_namespace(acpi_handle handle);
61acpi_ns_unload_namespace (
62 acpi_handle handle);
63 56
64static acpi_status 57static acpi_status acpi_ns_delete_subtree(acpi_handle start_handle);
65acpi_ns_delete_subtree (
66 acpi_handle start_handle);
67#endif 58#endif
68 59
69
70#ifndef ACPI_NO_METHOD_EXECUTION 60#ifndef ACPI_NO_METHOD_EXECUTION
71/******************************************************************************* 61/*******************************************************************************
72 * 62 *
@@ -82,40 +72,39 @@ acpi_ns_delete_subtree (
82 ******************************************************************************/ 72 ******************************************************************************/
83 73
84acpi_status 74acpi_status
85acpi_ns_load_table ( 75acpi_ns_load_table(struct acpi_table_desc *table_desc,
86 struct acpi_table_desc *table_desc, 76 struct acpi_namespace_node *node)
87 struct acpi_namespace_node *node)
88{ 77{
89 acpi_status status; 78 acpi_status status;
90
91
92 ACPI_FUNCTION_TRACE ("ns_load_table");
93 79
80 ACPI_FUNCTION_TRACE("ns_load_table");
94 81
95 /* Check if table contains valid AML (must be DSDT, PSDT, SSDT, etc.) */ 82 /* Check if table contains valid AML (must be DSDT, PSDT, SSDT, etc.) */
96 83
97 if (!(acpi_gbl_table_data[table_desc->type].flags & ACPI_TABLE_EXECUTABLE)) { 84 if (!
85 (acpi_gbl_table_data[table_desc->type].
86 flags & ACPI_TABLE_EXECUTABLE)) {
98 /* Just ignore this table */ 87 /* Just ignore this table */
99 88
100 return_ACPI_STATUS (AE_OK); 89 return_ACPI_STATUS(AE_OK);
101 } 90 }
102 91
103 /* Check validity of the AML start and length */ 92 /* Check validity of the AML start and length */
104 93
105 if (!table_desc->aml_start) { 94 if (!table_desc->aml_start) {
106 ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "Null AML pointer\n")); 95 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, "Null AML pointer\n"));
107 return_ACPI_STATUS (AE_BAD_PARAMETER); 96 return_ACPI_STATUS(AE_BAD_PARAMETER);
108 } 97 }
109 98
110 ACPI_DEBUG_PRINT ((ACPI_DB_INFO, "AML block at %p\n", 99 ACPI_DEBUG_PRINT((ACPI_DB_INFO, "AML block at %p\n",
111 table_desc->aml_start)); 100 table_desc->aml_start));
112 101
113 /* Ignore table if there is no AML contained within */ 102 /* Ignore table if there is no AML contained within */
114 103
115 if (!table_desc->aml_length) { 104 if (!table_desc->aml_length) {
116 ACPI_REPORT_WARNING (("Zero-length AML block in table [%4.4s]\n", 105 ACPI_REPORT_WARNING(("Zero-length AML block in table [%4.4s]\n",
117 table_desc->pointer->signature)); 106 table_desc->pointer->signature));
118 return_ACPI_STATUS (AE_OK); 107 return_ACPI_STATUS(AE_OK);
119 } 108 }
120 109
121 /* 110 /*
@@ -127,19 +116,19 @@ acpi_ns_load_table (
127 * to another control method, we can't continue parsing 116 * to another control method, we can't continue parsing
128 * because we don't know how many arguments to parse next! 117 * because we don't know how many arguments to parse next!
129 */ 118 */
130 ACPI_DEBUG_PRINT ((ACPI_DB_INFO, 119 ACPI_DEBUG_PRINT((ACPI_DB_INFO,
131 "**** Loading table into namespace ****\n")); 120 "**** Loading table into namespace ****\n"));
132 121
133 status = acpi_ut_acquire_mutex (ACPI_MTX_NAMESPACE); 122 status = acpi_ut_acquire_mutex(ACPI_MTX_NAMESPACE);
134 if (ACPI_FAILURE (status)) { 123 if (ACPI_FAILURE(status)) {
135 return_ACPI_STATUS (status); 124 return_ACPI_STATUS(status);
136 } 125 }
137 126
138 status = acpi_ns_parse_table (table_desc, node->child); 127 status = acpi_ns_parse_table(table_desc, node->child);
139 (void) acpi_ut_release_mutex (ACPI_MTX_NAMESPACE); 128 (void)acpi_ut_release_mutex(ACPI_MTX_NAMESPACE);
140 129
141 if (ACPI_FAILURE (status)) { 130 if (ACPI_FAILURE(status)) {
142 return_ACPI_STATUS (status); 131 return_ACPI_STATUS(status);
143 } 132 }
144 133
145 /* 134 /*
@@ -148,18 +137,17 @@ acpi_ns_load_table (
148 * just-in-time parsing, we delete the control method 137 * just-in-time parsing, we delete the control method
149 * parse trees. 138 * parse trees.
150 */ 139 */
151 ACPI_DEBUG_PRINT ((ACPI_DB_INFO, 140 ACPI_DEBUG_PRINT((ACPI_DB_INFO,
152 "**** Begin Table Method Parsing and Object Initialization ****\n")); 141 "**** Begin Table Method Parsing and Object Initialization ****\n"));
153 142
154 status = acpi_ds_initialize_objects (table_desc, node); 143 status = acpi_ds_initialize_objects(table_desc, node);
155 144
156 ACPI_DEBUG_PRINT ((ACPI_DB_INFO, 145 ACPI_DEBUG_PRINT((ACPI_DB_INFO,
157 "**** Completed Table Method Parsing and Object Initialization ****\n")); 146 "**** Completed Table Method Parsing and Object Initialization ****\n"));
158 147
159 return_ACPI_STATUS (status); 148 return_ACPI_STATUS(status);
160} 149}
161 150
162
163/******************************************************************************* 151/*******************************************************************************
164 * 152 *
165 * FUNCTION: acpi_ns_load_table_by_type 153 * FUNCTION: acpi_ns_load_table_by_type
@@ -174,21 +162,17 @@ acpi_ns_load_table (
174 * 162 *
175 ******************************************************************************/ 163 ******************************************************************************/
176 164
177static acpi_status 165static acpi_status acpi_ns_load_table_by_type(acpi_table_type table_type)
178acpi_ns_load_table_by_type (
179 acpi_table_type table_type)
180{ 166{
181 u32 i; 167 u32 i;
182 acpi_status status; 168 acpi_status status;
183 struct acpi_table_desc *table_desc; 169 struct acpi_table_desc *table_desc;
184
185 170
186 ACPI_FUNCTION_TRACE ("ns_load_table_by_type"); 171 ACPI_FUNCTION_TRACE("ns_load_table_by_type");
187 172
188 173 status = acpi_ut_acquire_mutex(ACPI_MTX_TABLES);
189 status = acpi_ut_acquire_mutex (ACPI_MTX_TABLES); 174 if (ACPI_FAILURE(status)) {
190 if (ACPI_FAILURE (status)) { 175 return_ACPI_STATUS(status);
191 return_ACPI_STATUS (status);
192 } 176 }
193 177
194 /* 178 /*
@@ -198,7 +182,7 @@ acpi_ns_load_table_by_type (
198 switch (table_type) { 182 switch (table_type) {
199 case ACPI_TABLE_DSDT: 183 case ACPI_TABLE_DSDT:
200 184
201 ACPI_DEBUG_PRINT ((ACPI_DB_INFO, "Loading DSDT\n")); 185 ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Namespace load: DSDT\n"));
202 186
203 table_desc = acpi_gbl_table_lists[ACPI_TABLE_DSDT].next; 187 table_desc = acpi_gbl_table_lists[ACPI_TABLE_DSDT].next;
204 188
@@ -210,57 +194,33 @@ acpi_ns_load_table_by_type (
210 194
211 /* Now load the single DSDT */ 195 /* Now load the single DSDT */
212 196
213 status = acpi_ns_load_table (table_desc, acpi_gbl_root_node); 197 status = acpi_ns_load_table(table_desc, acpi_gbl_root_node);
214 if (ACPI_SUCCESS (status)) { 198 if (ACPI_SUCCESS(status)) {
215 table_desc->loaded_into_namespace = TRUE; 199 table_desc->loaded_into_namespace = TRUE;
216 } 200 }
217 break; 201 break;
218 202
219
220 case ACPI_TABLE_SSDT: 203 case ACPI_TABLE_SSDT:
204 case ACPI_TABLE_PSDT:
221 205
222 ACPI_DEBUG_PRINT ((ACPI_DB_INFO, "Loading %d SSDTs\n", 206 ACPI_DEBUG_PRINT((ACPI_DB_INFO,
223 acpi_gbl_table_lists[ACPI_TABLE_SSDT].count)); 207 "Namespace load: %d SSDT or PSDTs\n",
208 acpi_gbl_table_lists[table_type].count));
224 209
225 /* 210 /*
226 * Traverse list of SSDT tables 211 * Traverse list of SSDT or PSDT tables
227 */ 212 */
228 table_desc = acpi_gbl_table_lists[ACPI_TABLE_SSDT].next; 213 table_desc = acpi_gbl_table_lists[table_type].next;
229 for (i = 0; i < acpi_gbl_table_lists[ACPI_TABLE_SSDT].count; i++) { 214 for (i = 0; i < acpi_gbl_table_lists[table_type].count; i++) {
230 /* 215 /*
231 * Only attempt to load table if it is not 216 * Only attempt to load table into namespace if it is not
232 * already loaded! 217 * already loaded!
233 */ 218 */
234 if (!table_desc->loaded_into_namespace) { 219 if (!table_desc->loaded_into_namespace) {
235 status = acpi_ns_load_table (table_desc, acpi_gbl_root_node); 220 status =
236 if (ACPI_FAILURE (status)) { 221 acpi_ns_load_table(table_desc,
237 break; 222 acpi_gbl_root_node);
238 } 223 if (ACPI_FAILURE(status)) {
239
240 table_desc->loaded_into_namespace = TRUE;
241 }
242
243 table_desc = table_desc->next;
244 }
245 break;
246
247
248 case ACPI_TABLE_PSDT:
249
250 ACPI_DEBUG_PRINT ((ACPI_DB_INFO, "Loading %d PSDTs\n",
251 acpi_gbl_table_lists[ACPI_TABLE_PSDT].count));
252
253 /*
254 * Traverse list of PSDT tables
255 */
256 table_desc = acpi_gbl_table_lists[ACPI_TABLE_PSDT].next;
257
258 for (i = 0; i < acpi_gbl_table_lists[ACPI_TABLE_PSDT].count; i++) {
259 /* Only attempt to load table if it is not already loaded! */
260
261 if (!table_desc->loaded_into_namespace) {
262 status = acpi_ns_load_table (table_desc, acpi_gbl_root_node);
263 if (ACPI_FAILURE (status)) {
264 break; 224 break;
265 } 225 }
266 226
@@ -271,19 +231,16 @@ acpi_ns_load_table_by_type (
271 } 231 }
272 break; 232 break;
273 233
274
275 default: 234 default:
276 status = AE_SUPPORT; 235 status = AE_SUPPORT;
277 break; 236 break;
278 } 237 }
279 238
280 239 unlock_and_exit:
281unlock_and_exit: 240 (void)acpi_ut_release_mutex(ACPI_MTX_TABLES);
282 (void) acpi_ut_release_mutex (ACPI_MTX_TABLES); 241 return_ACPI_STATUS(status);
283 return_ACPI_STATUS (status);
284} 242}
285 243
286
287/******************************************************************************* 244/*******************************************************************************
288 * 245 *
289 * FUNCTION: acpi_load_namespace 246 * FUNCTION: acpi_load_namespace
@@ -297,45 +254,40 @@ unlock_and_exit:
297 * 254 *
298 ******************************************************************************/ 255 ******************************************************************************/
299 256
300acpi_status 257acpi_status acpi_ns_load_namespace(void)
301acpi_ns_load_namespace (
302 void)
303{ 258{
304 acpi_status status; 259 acpi_status status;
305
306
307 ACPI_FUNCTION_TRACE ("acpi_load_name_space");
308 260
261 ACPI_FUNCTION_TRACE("acpi_load_name_space");
309 262
310 /* There must be at least a DSDT installed */ 263 /* There must be at least a DSDT installed */
311 264
312 if (acpi_gbl_DSDT == NULL) { 265 if (acpi_gbl_DSDT == NULL) {
313 ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "DSDT is not in memory\n")); 266 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, "DSDT is not in memory\n"));
314 return_ACPI_STATUS (AE_NO_ACPI_TABLES); 267 return_ACPI_STATUS(AE_NO_ACPI_TABLES);
315 } 268 }
316 269
317 /* 270 /*
318 * Load the namespace. The DSDT is required, 271 * Load the namespace. The DSDT is required,
319 * but the SSDT and PSDT tables are optional. 272 * but the SSDT and PSDT tables are optional.
320 */ 273 */
321 status = acpi_ns_load_table_by_type (ACPI_TABLE_DSDT); 274 status = acpi_ns_load_table_by_type(ACPI_TABLE_DSDT);
322 if (ACPI_FAILURE (status)) { 275 if (ACPI_FAILURE(status)) {
323 return_ACPI_STATUS (status); 276 return_ACPI_STATUS(status);
324 } 277 }
325 278
326 /* Ignore exceptions from these */ 279 /* Ignore exceptions from these */
327 280
328 (void) acpi_ns_load_table_by_type (ACPI_TABLE_SSDT); 281 (void)acpi_ns_load_table_by_type(ACPI_TABLE_SSDT);
329 (void) acpi_ns_load_table_by_type (ACPI_TABLE_PSDT); 282 (void)acpi_ns_load_table_by_type(ACPI_TABLE_PSDT);
330 283
331 ACPI_DEBUG_PRINT_RAW ((ACPI_DB_INIT, 284 ACPI_DEBUG_PRINT_RAW((ACPI_DB_INIT,
332 "ACPI Namespace successfully loaded at root %p\n", 285 "ACPI Namespace successfully loaded at root %p\n",
333 acpi_gbl_root_node)); 286 acpi_gbl_root_node));
334 287
335 return_ACPI_STATUS (status); 288 return_ACPI_STATUS(status);
336} 289}
337 290
338
339#ifdef ACPI_FUTURE_IMPLEMENTATION 291#ifdef ACPI_FUTURE_IMPLEMENTATION
340/******************************************************************************* 292/*******************************************************************************
341 * 293 *
@@ -353,24 +305,20 @@ acpi_ns_load_namespace (
353 * 305 *
354 ******************************************************************************/ 306 ******************************************************************************/
355 307
356static acpi_status 308static acpi_status acpi_ns_delete_subtree(acpi_handle start_handle)
357acpi_ns_delete_subtree (
358 acpi_handle start_handle)
359{ 309{
360 acpi_status status; 310 acpi_status status;
361 acpi_handle child_handle; 311 acpi_handle child_handle;
362 acpi_handle parent_handle; 312 acpi_handle parent_handle;
363 acpi_handle next_child_handle; 313 acpi_handle next_child_handle;
364 acpi_handle dummy; 314 acpi_handle dummy;
365 u32 level; 315 u32 level;
366
367
368 ACPI_FUNCTION_TRACE ("ns_delete_subtree");
369 316
317 ACPI_FUNCTION_TRACE("ns_delete_subtree");
370 318
371 parent_handle = start_handle; 319 parent_handle = start_handle;
372 child_handle = NULL; 320 child_handle = NULL;
373 level = 1; 321 level = 1;
374 322
375 /* 323 /*
376 * Traverse the tree of objects until we bubble back up 324 * Traverse the tree of objects until we bubble back up
@@ -379,18 +327,19 @@ acpi_ns_delete_subtree (
379 while (level > 0) { 327 while (level > 0) {
380 /* Attempt to get the next object in this scope */ 328 /* Attempt to get the next object in this scope */
381 329
382 status = acpi_get_next_object (ACPI_TYPE_ANY, parent_handle, 330 status = acpi_get_next_object(ACPI_TYPE_ANY, parent_handle,
383 child_handle, &next_child_handle); 331 child_handle, &next_child_handle);
384 332
385 child_handle = next_child_handle; 333 child_handle = next_child_handle;
386 334
387 /* Did we get a new object? */ 335 /* Did we get a new object? */
388 336
389 if (ACPI_SUCCESS (status)) { 337 if (ACPI_SUCCESS(status)) {
390 /* Check if this object has any children */ 338 /* Check if this object has any children */
391 339
392 if (ACPI_SUCCESS (acpi_get_next_object (ACPI_TYPE_ANY, child_handle, 340 if (ACPI_SUCCESS
393 NULL, &dummy))) { 341 (acpi_get_next_object
342 (ACPI_TYPE_ANY, child_handle, NULL, &dummy))) {
394 /* 343 /*
395 * There is at least one child of this object, 344 * There is at least one child of this object,
396 * visit the object 345 * visit the object
@@ -399,8 +348,7 @@ acpi_ns_delete_subtree (
399 parent_handle = child_handle; 348 parent_handle = child_handle;
400 child_handle = NULL; 349 child_handle = NULL;
401 } 350 }
402 } 351 } else {
403 else {
404 /* 352 /*
405 * No more children in this object, go back up to 353 * No more children in this object, go back up to
406 * the object's parent 354 * the object's parent
@@ -409,24 +357,23 @@ acpi_ns_delete_subtree (
409 357
410 /* Delete all children now */ 358 /* Delete all children now */
411 359
412 acpi_ns_delete_children (child_handle); 360 acpi_ns_delete_children(child_handle);
413 361
414 child_handle = parent_handle; 362 child_handle = parent_handle;
415 status = acpi_get_parent (parent_handle, &parent_handle); 363 status = acpi_get_parent(parent_handle, &parent_handle);
416 if (ACPI_FAILURE (status)) { 364 if (ACPI_FAILURE(status)) {
417 return_ACPI_STATUS (status); 365 return_ACPI_STATUS(status);
418 } 366 }
419 } 367 }
420 } 368 }
421 369
422 /* Now delete the starting object, and we are done */ 370 /* Now delete the starting object, and we are done */
423 371
424 acpi_ns_delete_node (child_handle); 372 acpi_ns_delete_node(child_handle);
425 373
426 return_ACPI_STATUS (AE_OK); 374 return_ACPI_STATUS(AE_OK);
427} 375}
428 376
429
430/******************************************************************************* 377/*******************************************************************************
431 * 378 *
432 * FUNCTION: acpi_ns_unload_name_space 379 * FUNCTION: acpi_ns_unload_name_space
@@ -441,32 +388,27 @@ acpi_ns_delete_subtree (
441 * 388 *
442 ******************************************************************************/ 389 ******************************************************************************/
443 390
444acpi_status 391acpi_status acpi_ns_unload_namespace(acpi_handle handle)
445acpi_ns_unload_namespace (
446 acpi_handle handle)
447{ 392{
448 acpi_status status; 393 acpi_status status;
449
450
451 ACPI_FUNCTION_TRACE ("ns_unload_name_space");
452 394
395 ACPI_FUNCTION_TRACE("ns_unload_name_space");
453 396
454 /* Parameter validation */ 397 /* Parameter validation */
455 398
456 if (!acpi_gbl_root_node) { 399 if (!acpi_gbl_root_node) {
457 return_ACPI_STATUS (AE_NO_NAMESPACE); 400 return_ACPI_STATUS(AE_NO_NAMESPACE);
458 } 401 }
459 402
460 if (!handle) { 403 if (!handle) {
461 return_ACPI_STATUS (AE_BAD_PARAMETER); 404 return_ACPI_STATUS(AE_BAD_PARAMETER);
462 } 405 }
463 406
464 /* This function does the real work */ 407 /* This function does the real work */
465 408
466 status = acpi_ns_delete_subtree (handle); 409 status = acpi_ns_delete_subtree(handle);
467 410
468 return_ACPI_STATUS (status); 411 return_ACPI_STATUS(status);
469} 412}
470#endif 413#endif
471#endif 414#endif
472
diff --git a/drivers/acpi/namespace/nsnames.c b/drivers/acpi/namespace/nsnames.c
index d8ce7e39795f..d5e8dea61c27 100644
--- a/drivers/acpi/namespace/nsnames.c
+++ b/drivers/acpi/namespace/nsnames.c
@@ -41,23 +41,17 @@
41 * POSSIBILITY OF SUCH DAMAGES. 41 * POSSIBILITY OF SUCH DAMAGES.
42 */ 42 */
43 43
44
45#include <acpi/acpi.h> 44#include <acpi/acpi.h>
46#include <acpi/amlcode.h> 45#include <acpi/amlcode.h>
47#include <acpi/acnamesp.h> 46#include <acpi/acnamesp.h>
48 47
49
50#define _COMPONENT ACPI_NAMESPACE 48#define _COMPONENT ACPI_NAMESPACE
51 ACPI_MODULE_NAME ("nsnames") 49ACPI_MODULE_NAME("nsnames")
52 50
53/* Local prototypes */ 51/* Local prototypes */
54
55static void 52static void
56acpi_ns_build_external_path ( 53acpi_ns_build_external_path(struct acpi_namespace_node *node,
57 struct acpi_namespace_node *node, 54 acpi_size size, char *name_buffer);
58 acpi_size size,
59 char *name_buffer);
60
61 55
62/******************************************************************************* 56/*******************************************************************************
63 * 57 *
@@ -75,17 +69,13 @@ acpi_ns_build_external_path (
75 ******************************************************************************/ 69 ******************************************************************************/
76 70
77static void 71static void
78acpi_ns_build_external_path ( 72acpi_ns_build_external_path(struct acpi_namespace_node *node,
79 struct acpi_namespace_node *node, 73 acpi_size size, char *name_buffer)
80 acpi_size size,
81 char *name_buffer)
82{ 74{
83 acpi_size index; 75 acpi_size index;
84 struct acpi_namespace_node *parent_node; 76 struct acpi_namespace_node *parent_node;
85
86
87 ACPI_FUNCTION_NAME ("ns_build_external_path");
88 77
78 ACPI_FUNCTION_NAME("ns_build_external_path");
89 79
90 /* Special case for root */ 80 /* Special case for root */
91 81
@@ -106,8 +96,8 @@ acpi_ns_build_external_path (
106 96
107 /* Put the name into the buffer */ 97 /* Put the name into the buffer */
108 98
109 ACPI_MOVE_32_TO_32 ((name_buffer + index), &parent_node->name); 99 ACPI_MOVE_32_TO_32((name_buffer + index), &parent_node->name);
110 parent_node = acpi_ns_get_parent_node (parent_node); 100 parent_node = acpi_ns_get_parent_node(parent_node);
111 101
112 /* Prefix name with the path separator */ 102 /* Prefix name with the path separator */
113 103
@@ -120,15 +110,14 @@ acpi_ns_build_external_path (
120 name_buffer[index] = AML_ROOT_PREFIX; 110 name_buffer[index] = AML_ROOT_PREFIX;
121 111
122 if (index != 0) { 112 if (index != 0) {
123 ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, 113 ACPI_DEBUG_PRINT((ACPI_DB_ERROR,
124 "Could not construct pathname; index=%X, size=%X, Path=%s\n", 114 "Could not construct pathname; index=%X, size=%X, Path=%s\n",
125 (u32) index, (u32) size, &name_buffer[size])); 115 (u32) index, (u32) size, &name_buffer[size]));
126 } 116 }
127 117
128 return; 118 return;
129} 119}
130 120
131
132#ifdef ACPI_DEBUG_OUTPUT 121#ifdef ACPI_DEBUG_OUTPUT
133/******************************************************************************* 122/*******************************************************************************
134 * 123 *
@@ -144,37 +133,32 @@ acpi_ns_build_external_path (
144 * 133 *
145 ******************************************************************************/ 134 ******************************************************************************/
146 135
147char * 136char *acpi_ns_get_external_pathname(struct acpi_namespace_node *node)
148acpi_ns_get_external_pathname (
149 struct acpi_namespace_node *node)
150{ 137{
151 char *name_buffer; 138 char *name_buffer;
152 acpi_size size; 139 acpi_size size;
153
154
155 ACPI_FUNCTION_TRACE_PTR ("ns_get_external_pathname", node);
156 140
141 ACPI_FUNCTION_TRACE_PTR("ns_get_external_pathname", node);
157 142
158 /* Calculate required buffer size based on depth below root */ 143 /* Calculate required buffer size based on depth below root */
159 144
160 size = acpi_ns_get_pathname_length (node); 145 size = acpi_ns_get_pathname_length(node);
161 146
162 /* Allocate a buffer to be returned to caller */ 147 /* Allocate a buffer to be returned to caller */
163 148
164 name_buffer = ACPI_MEM_CALLOCATE (size); 149 name_buffer = ACPI_MEM_CALLOCATE(size);
165 if (!name_buffer) { 150 if (!name_buffer) {
166 ACPI_REPORT_ERROR (("ns_get_table_pathname: allocation failure\n")); 151 ACPI_REPORT_ERROR(("ns_get_table_pathname: allocation failure\n"));
167 return_PTR (NULL); 152 return_PTR(NULL);
168 } 153 }
169 154
170 /* Build the path in the allocated buffer */ 155 /* Build the path in the allocated buffer */
171 156
172 acpi_ns_build_external_path (node, size, name_buffer); 157 acpi_ns_build_external_path(node, size, name_buffer);
173 return_PTR (name_buffer); 158 return_PTR(name_buffer);
174} 159}
175#endif 160#endif
176 161
177
178/******************************************************************************* 162/*******************************************************************************
179 * 163 *
180 * FUNCTION: acpi_ns_get_pathname_length 164 * FUNCTION: acpi_ns_get_pathname_length
@@ -187,16 +171,12 @@ acpi_ns_get_external_pathname (
187 * 171 *
188 ******************************************************************************/ 172 ******************************************************************************/
189 173
190acpi_size 174acpi_size acpi_ns_get_pathname_length(struct acpi_namespace_node *node)
191acpi_ns_get_pathname_length (
192 struct acpi_namespace_node *node)
193{ 175{
194 acpi_size size; 176 acpi_size size;
195 struct acpi_namespace_node *next_node; 177 struct acpi_namespace_node *next_node;
196
197
198 ACPI_FUNCTION_ENTRY ();
199 178
179 ACPI_FUNCTION_ENTRY();
200 180
201 /* 181 /*
202 * Compute length of pathname as 5 * number of name segments. 182 * Compute length of pathname as 5 * number of name segments.
@@ -207,17 +187,16 @@ acpi_ns_get_pathname_length (
207 187
208 while (next_node && (next_node != acpi_gbl_root_node)) { 188 while (next_node && (next_node != acpi_gbl_root_node)) {
209 size += ACPI_PATH_SEGMENT_LENGTH; 189 size += ACPI_PATH_SEGMENT_LENGTH;
210 next_node = acpi_ns_get_parent_node (next_node); 190 next_node = acpi_ns_get_parent_node(next_node);
211 } 191 }
212 192
213 if (!size) { 193 if (!size) {
214 size = 1; /* Root node case */ 194 size = 1; /* Root node case */
215 } 195 }
216 196
217 return (size + 1); /* +1 for null string terminator */ 197 return (size + 1); /* +1 for null string terminator */
218} 198}
219 199
220
221/******************************************************************************* 200/*******************************************************************************
222 * 201 *
223 * FUNCTION: acpi_ns_handle_to_pathname 202 * FUNCTION: acpi_ns_handle_to_pathname
@@ -233,41 +212,36 @@ acpi_ns_get_pathname_length (
233 ******************************************************************************/ 212 ******************************************************************************/
234 213
235acpi_status 214acpi_status
236acpi_ns_handle_to_pathname ( 215acpi_ns_handle_to_pathname(acpi_handle target_handle,
237 acpi_handle target_handle, 216 struct acpi_buffer * buffer)
238 struct acpi_buffer *buffer)
239{ 217{
240 acpi_status status; 218 acpi_status status;
241 struct acpi_namespace_node *node; 219 struct acpi_namespace_node *node;
242 acpi_size required_size; 220 acpi_size required_size;
243 221
222 ACPI_FUNCTION_TRACE_PTR("ns_handle_to_pathname", target_handle);
244 223
245 ACPI_FUNCTION_TRACE_PTR ("ns_handle_to_pathname", target_handle); 224 node = acpi_ns_map_handle_to_node(target_handle);
246
247
248 node = acpi_ns_map_handle_to_node (target_handle);
249 if (!node) { 225 if (!node) {
250 return_ACPI_STATUS (AE_BAD_PARAMETER); 226 return_ACPI_STATUS(AE_BAD_PARAMETER);
251 } 227 }
252 228
253 /* Determine size required for the caller buffer */ 229 /* Determine size required for the caller buffer */
254 230
255 required_size = acpi_ns_get_pathname_length (node); 231 required_size = acpi_ns_get_pathname_length(node);
256 232
257 /* Validate/Allocate/Clear caller buffer */ 233 /* Validate/Allocate/Clear caller buffer */
258 234
259 status = acpi_ut_initialize_buffer (buffer, required_size); 235 status = acpi_ut_initialize_buffer(buffer, required_size);
260 if (ACPI_FAILURE (status)) { 236 if (ACPI_FAILURE(status)) {
261 return_ACPI_STATUS (status); 237 return_ACPI_STATUS(status);
262 } 238 }
263 239
264 /* Build the path in the caller buffer */ 240 /* Build the path in the caller buffer */
265 241
266 acpi_ns_build_external_path (node, required_size, buffer->pointer); 242 acpi_ns_build_external_path(node, required_size, buffer->pointer);
267 243
268 ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "%s [%X] \n", 244 ACPI_DEBUG_PRINT((ACPI_DB_EXEC, "%s [%X] \n",
269 (char *) buffer->pointer, (u32) required_size)); 245 (char *)buffer->pointer, (u32) required_size));
270 return_ACPI_STATUS (AE_OK); 246 return_ACPI_STATUS(AE_OK);
271} 247}
272
273
diff --git a/drivers/acpi/namespace/nsobject.c b/drivers/acpi/namespace/nsobject.c
index 27258c1ca4f1..fc9be946ebed 100644
--- a/drivers/acpi/namespace/nsobject.c
+++ b/drivers/acpi/namespace/nsobject.c
@@ -42,14 +42,11 @@
42 * POSSIBILITY OF SUCH DAMAGES. 42 * POSSIBILITY OF SUCH DAMAGES.
43 */ 43 */
44 44
45
46#include <acpi/acpi.h> 45#include <acpi/acpi.h>
47#include <acpi/acnamesp.h> 46#include <acpi/acnamesp.h>
48 47
49
50#define _COMPONENT ACPI_NAMESPACE 48#define _COMPONENT ACPI_NAMESPACE
51 ACPI_MODULE_NAME ("nsobject") 49ACPI_MODULE_NAME("nsobject")
52
53 50
54/******************************************************************************* 51/*******************************************************************************
55 * 52 *
@@ -71,20 +68,15 @@
71 * MUTEX: Assumes namespace is locked 68 * MUTEX: Assumes namespace is locked
72 * 69 *
73 ******************************************************************************/ 70 ******************************************************************************/
74
75acpi_status 71acpi_status
76acpi_ns_attach_object ( 72acpi_ns_attach_object(struct acpi_namespace_node *node,
77 struct acpi_namespace_node *node, 73 union acpi_operand_object *object, acpi_object_type type)
78 union acpi_operand_object *object,
79 acpi_object_type type)
80{ 74{
81 union acpi_operand_object *obj_desc; 75 union acpi_operand_object *obj_desc;
82 union acpi_operand_object *last_obj_desc; 76 union acpi_operand_object *last_obj_desc;
83 acpi_object_type object_type = ACPI_TYPE_ANY; 77 acpi_object_type object_type = ACPI_TYPE_ANY;
84
85
86 ACPI_FUNCTION_TRACE ("ns_attach_object");
87 78
79 ACPI_FUNCTION_TRACE("ns_attach_object");
88 80
89 /* 81 /*
90 * Parameter validation 82 * Parameter validation
@@ -92,40 +84,39 @@ acpi_ns_attach_object (
92 if (!node) { 84 if (!node) {
93 /* Invalid handle */ 85 /* Invalid handle */
94 86
95 ACPI_REPORT_ERROR (("ns_attach_object: Null named_obj handle\n")); 87 ACPI_REPORT_ERROR(("ns_attach_object: Null named_obj handle\n"));
96 return_ACPI_STATUS (AE_BAD_PARAMETER); 88 return_ACPI_STATUS(AE_BAD_PARAMETER);
97 } 89 }
98 90
99 if (!object && (ACPI_TYPE_ANY != type)) { 91 if (!object && (ACPI_TYPE_ANY != type)) {
100 /* Null object */ 92 /* Null object */
101 93
102 ACPI_REPORT_ERROR (( 94 ACPI_REPORT_ERROR(("ns_attach_object: Null object, but type not ACPI_TYPE_ANY\n"));
103 "ns_attach_object: Null object, but type not ACPI_TYPE_ANY\n")); 95 return_ACPI_STATUS(AE_BAD_PARAMETER);
104 return_ACPI_STATUS (AE_BAD_PARAMETER);
105 } 96 }
106 97
107 if (ACPI_GET_DESCRIPTOR_TYPE (node) != ACPI_DESC_TYPE_NAMED) { 98 if (ACPI_GET_DESCRIPTOR_TYPE(node) != ACPI_DESC_TYPE_NAMED) {
108 /* Not a name handle */ 99 /* Not a name handle */
109 100
110 ACPI_REPORT_ERROR (("ns_attach_object: Invalid handle %p [%s]\n", 101 ACPI_REPORT_ERROR(("ns_attach_object: Invalid handle %p [%s]\n",
111 node, acpi_ut_get_descriptor_name (node))); 102 node, acpi_ut_get_descriptor_name(node)));
112 return_ACPI_STATUS (AE_BAD_PARAMETER); 103 return_ACPI_STATUS(AE_BAD_PARAMETER);
113 } 104 }
114 105
115 /* Check if this object is already attached */ 106 /* Check if this object is already attached */
116 107
117 if (node->object == object) { 108 if (node->object == object) {
118 ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, 109 ACPI_DEBUG_PRINT((ACPI_DB_EXEC,
119 "Obj %p already installed in name_obj %p\n", 110 "Obj %p already installed in name_obj %p\n",
120 object, node)); 111 object, node));
121 112
122 return_ACPI_STATUS (AE_OK); 113 return_ACPI_STATUS(AE_OK);
123 } 114 }
124 115
125 /* If null object, we will just install it */ 116 /* If null object, we will just install it */
126 117
127 if (!object) { 118 if (!object) {
128 obj_desc = NULL; 119 obj_desc = NULL;
129 object_type = ACPI_TYPE_ANY; 120 object_type = ACPI_TYPE_ANY;
130 } 121 }
131 122
@@ -133,14 +124,14 @@ acpi_ns_attach_object (
133 * If the source object is a namespace Node with an attached object, 124 * If the source object is a namespace Node with an attached object,
134 * we will use that (attached) object 125 * we will use that (attached) object
135 */ 126 */
136 else if ((ACPI_GET_DESCRIPTOR_TYPE (object) == ACPI_DESC_TYPE_NAMED) && 127 else if ((ACPI_GET_DESCRIPTOR_TYPE(object) == ACPI_DESC_TYPE_NAMED) &&
137 ((struct acpi_namespace_node *) object)->object) { 128 ((struct acpi_namespace_node *)object)->object) {
138 /* 129 /*
139 * Value passed is a name handle and that name has a 130 * Value passed is a name handle and that name has a
140 * non-null value. Use that name's value and type. 131 * non-null value. Use that name's value and type.
141 */ 132 */
142 obj_desc = ((struct acpi_namespace_node *) object)->object; 133 obj_desc = ((struct acpi_namespace_node *)object)->object;
143 object_type = ((struct acpi_namespace_node *) object)->type; 134 object_type = ((struct acpi_namespace_node *)object)->type;
144 } 135 }
145 136
146 /* 137 /*
@@ -148,20 +139,20 @@ acpi_ns_attach_object (
148 * it first 139 * it first
149 */ 140 */
150 else { 141 else {
151 obj_desc = (union acpi_operand_object *) object; 142 obj_desc = (union acpi_operand_object *)object;
152 143
153 /* Use the given type */ 144 /* Use the given type */
154 145
155 object_type = type; 146 object_type = type;
156 } 147 }
157 148
158 ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "Installing %p into Node %p [%4.4s]\n", 149 ACPI_DEBUG_PRINT((ACPI_DB_EXEC, "Installing %p into Node %p [%4.4s]\n",
159 obj_desc, node, acpi_ut_get_node_name (node))); 150 obj_desc, node, acpi_ut_get_node_name(node)));
160 151
161 /* Detach an existing attached object if present */ 152 /* Detach an existing attached object if present */
162 153
163 if (node->object) { 154 if (node->object) {
164 acpi_ns_detach_object (node); 155 acpi_ns_detach_object(node);
165 } 156 }
166 157
167 if (obj_desc) { 158 if (obj_desc) {
@@ -169,7 +160,7 @@ acpi_ns_attach_object (
169 * Must increment the new value's reference count 160 * Must increment the new value's reference count
170 * (if it is an internal object) 161 * (if it is an internal object)
171 */ 162 */
172 acpi_ut_add_reference (obj_desc); 163 acpi_ut_add_reference(obj_desc);
173 164
174 /* 165 /*
175 * Handle objects with multiple descriptors - walk 166 * Handle objects with multiple descriptors - walk
@@ -185,13 +176,12 @@ acpi_ns_attach_object (
185 last_obj_desc->common.next_object = node->object; 176 last_obj_desc->common.next_object = node->object;
186 } 177 }
187 178
188 node->type = (u8) object_type; 179 node->type = (u8) object_type;
189 node->object = obj_desc; 180 node->object = obj_desc;
190 181
191 return_ACPI_STATUS (AE_OK); 182 return_ACPI_STATUS(AE_OK);
192} 183}
193 184
194
195/******************************************************************************* 185/*******************************************************************************
196 * 186 *
197 * FUNCTION: acpi_ns_detach_object 187 * FUNCTION: acpi_ns_detach_object
@@ -206,30 +196,27 @@ acpi_ns_attach_object (
206 * 196 *
207 ******************************************************************************/ 197 ******************************************************************************/
208 198
209void 199void acpi_ns_detach_object(struct acpi_namespace_node *node)
210acpi_ns_detach_object (
211 struct acpi_namespace_node *node)
212{ 200{
213 union acpi_operand_object *obj_desc; 201 union acpi_operand_object *obj_desc;
214
215
216 ACPI_FUNCTION_TRACE ("ns_detach_object");
217 202
203 ACPI_FUNCTION_TRACE("ns_detach_object");
218 204
219 obj_desc = node->object; 205 obj_desc = node->object;
220 206
221 if (!obj_desc || 207 if (!obj_desc ||
222 (ACPI_GET_OBJECT_TYPE (obj_desc) == ACPI_TYPE_LOCAL_DATA)) { 208 (ACPI_GET_OBJECT_TYPE(obj_desc) == ACPI_TYPE_LOCAL_DATA)) {
223 return_VOID; 209 return_VOID;
224 } 210 }
225 211
226 /* Clear the entry in all cases */ 212 /* Clear the entry in all cases */
227 213
228 node->object = NULL; 214 node->object = NULL;
229 if (ACPI_GET_DESCRIPTOR_TYPE (obj_desc) == ACPI_DESC_TYPE_OPERAND) { 215 if (ACPI_GET_DESCRIPTOR_TYPE(obj_desc) == ACPI_DESC_TYPE_OPERAND) {
230 node->object = obj_desc->common.next_object; 216 node->object = obj_desc->common.next_object;
231 if (node->object && 217 if (node->object &&
232 (ACPI_GET_OBJECT_TYPE (node->object) != ACPI_TYPE_LOCAL_DATA)) { 218 (ACPI_GET_OBJECT_TYPE(node->object) !=
219 ACPI_TYPE_LOCAL_DATA)) {
233 node->object = node->object->common.next_object; 220 node->object = node->object->common.next_object;
234 } 221 }
235 } 222 }
@@ -238,16 +225,15 @@ acpi_ns_detach_object (
238 225
239 node->type = ACPI_TYPE_ANY; 226 node->type = ACPI_TYPE_ANY;
240 227
241 ACPI_DEBUG_PRINT ((ACPI_DB_NAMES, "Node %p [%4.4s] Object %p\n", 228 ACPI_DEBUG_PRINT((ACPI_DB_NAMES, "Node %p [%4.4s] Object %p\n",
242 node, acpi_ut_get_node_name (node), obj_desc)); 229 node, acpi_ut_get_node_name(node), obj_desc));
243 230
244 /* Remove one reference on the object (and all subobjects) */ 231 /* Remove one reference on the object (and all subobjects) */
245 232
246 acpi_ut_remove_reference (obj_desc); 233 acpi_ut_remove_reference(obj_desc);
247 return_VOID; 234 return_VOID;
248} 235}
249 236
250
251/******************************************************************************* 237/*******************************************************************************
252 * 238 *
253 * FUNCTION: acpi_ns_get_attached_object 239 * FUNCTION: acpi_ns_get_attached_object
@@ -261,29 +247,28 @@ acpi_ns_detach_object (
261 * 247 *
262 ******************************************************************************/ 248 ******************************************************************************/
263 249
264union acpi_operand_object * 250union acpi_operand_object *acpi_ns_get_attached_object(struct
265acpi_ns_get_attached_object ( 251 acpi_namespace_node
266 struct acpi_namespace_node *node) 252 *node)
267{ 253{
268 ACPI_FUNCTION_TRACE_PTR ("ns_get_attached_object", node); 254 ACPI_FUNCTION_TRACE_PTR("ns_get_attached_object", node);
269
270 255
271 if (!node) { 256 if (!node) {
272 ACPI_DEBUG_PRINT ((ACPI_DB_WARN, "Null Node ptr\n")); 257 ACPI_DEBUG_PRINT((ACPI_DB_WARN, "Null Node ptr\n"));
273 return_PTR (NULL); 258 return_PTR(NULL);
274 } 259 }
275 260
276 if (!node->object || 261 if (!node->object ||
277 ((ACPI_GET_DESCRIPTOR_TYPE (node->object) != ACPI_DESC_TYPE_OPERAND) && 262 ((ACPI_GET_DESCRIPTOR_TYPE(node->object) != ACPI_DESC_TYPE_OPERAND)
278 (ACPI_GET_DESCRIPTOR_TYPE (node->object) != ACPI_DESC_TYPE_NAMED)) || 263 && (ACPI_GET_DESCRIPTOR_TYPE(node->object) !=
279 (ACPI_GET_OBJECT_TYPE (node->object) == ACPI_TYPE_LOCAL_DATA)) { 264 ACPI_DESC_TYPE_NAMED))
280 return_PTR (NULL); 265 || (ACPI_GET_OBJECT_TYPE(node->object) == ACPI_TYPE_LOCAL_DATA)) {
266 return_PTR(NULL);
281 } 267 }
282 268
283 return_PTR (node->object); 269 return_PTR(node->object);
284} 270}
285 271
286
287/******************************************************************************* 272/*******************************************************************************
288 * 273 *
289 * FUNCTION: acpi_ns_get_secondary_object 274 * FUNCTION: acpi_ns_get_secondary_object
@@ -297,24 +282,23 @@ acpi_ns_get_attached_object (
297 * 282 *
298 ******************************************************************************/ 283 ******************************************************************************/
299 284
300union acpi_operand_object * 285union acpi_operand_object *acpi_ns_get_secondary_object(union
301acpi_ns_get_secondary_object ( 286 acpi_operand_object
302 union acpi_operand_object *obj_desc) 287 *obj_desc)
303{ 288{
304 ACPI_FUNCTION_TRACE_PTR ("ns_get_secondary_object", obj_desc); 289 ACPI_FUNCTION_TRACE_PTR("ns_get_secondary_object", obj_desc);
305 290
306 291 if ((!obj_desc) ||
307 if ((!obj_desc) || 292 (ACPI_GET_OBJECT_TYPE(obj_desc) == ACPI_TYPE_LOCAL_DATA) ||
308 (ACPI_GET_OBJECT_TYPE (obj_desc) == ACPI_TYPE_LOCAL_DATA) || 293 (!obj_desc->common.next_object) ||
309 (!obj_desc->common.next_object) || 294 (ACPI_GET_OBJECT_TYPE(obj_desc->common.next_object) ==
310 (ACPI_GET_OBJECT_TYPE (obj_desc->common.next_object) == ACPI_TYPE_LOCAL_DATA)) { 295 ACPI_TYPE_LOCAL_DATA)) {
311 return_PTR (NULL); 296 return_PTR(NULL);
312 } 297 }
313 298
314 return_PTR (obj_desc->common.next_object); 299 return_PTR(obj_desc->common.next_object);
315} 300}
316 301
317
318/******************************************************************************* 302/*******************************************************************************
319 * 303 *
320 * FUNCTION: acpi_ns_attach_data 304 * FUNCTION: acpi_ns_attach_data
@@ -330,23 +314,20 @@ acpi_ns_get_secondary_object (
330 ******************************************************************************/ 314 ******************************************************************************/
331 315
332acpi_status 316acpi_status
333acpi_ns_attach_data ( 317acpi_ns_attach_data(struct acpi_namespace_node *node,
334 struct acpi_namespace_node *node, 318 acpi_object_handler handler, void *data)
335 acpi_object_handler handler,
336 void *data)
337{ 319{
338 union acpi_operand_object *prev_obj_desc; 320 union acpi_operand_object *prev_obj_desc;
339 union acpi_operand_object *obj_desc; 321 union acpi_operand_object *obj_desc;
340 union acpi_operand_object *data_desc; 322 union acpi_operand_object *data_desc;
341
342 323
343 /* We only allow one attachment per handler */ 324 /* We only allow one attachment per handler */
344 325
345 prev_obj_desc = NULL; 326 prev_obj_desc = NULL;
346 obj_desc = node->object; 327 obj_desc = node->object;
347 while (obj_desc) { 328 while (obj_desc) {
348 if ((ACPI_GET_OBJECT_TYPE (obj_desc) == ACPI_TYPE_LOCAL_DATA) && 329 if ((ACPI_GET_OBJECT_TYPE(obj_desc) == ACPI_TYPE_LOCAL_DATA) &&
349 (obj_desc->data.handler == handler)) { 330 (obj_desc->data.handler == handler)) {
350 return (AE_ALREADY_EXISTS); 331 return (AE_ALREADY_EXISTS);
351 } 332 }
352 333
@@ -356,7 +337,7 @@ acpi_ns_attach_data (
356 337
357 /* Create an internal object for the data */ 338 /* Create an internal object for the data */
358 339
359 data_desc = acpi_ut_create_internal_object (ACPI_TYPE_LOCAL_DATA); 340 data_desc = acpi_ut_create_internal_object(ACPI_TYPE_LOCAL_DATA);
360 if (!data_desc) { 341 if (!data_desc) {
361 return (AE_NO_MEMORY); 342 return (AE_NO_MEMORY);
362 } 343 }
@@ -368,15 +349,13 @@ acpi_ns_attach_data (
368 349
369 if (prev_obj_desc) { 350 if (prev_obj_desc) {
370 prev_obj_desc->common.next_object = data_desc; 351 prev_obj_desc->common.next_object = data_desc;
371 } 352 } else {
372 else {
373 node->object = data_desc; 353 node->object = data_desc;
374 } 354 }
375 355
376 return (AE_OK); 356 return (AE_OK);
377} 357}
378 358
379
380/******************************************************************************* 359/*******************************************************************************
381 * 360 *
382 * FUNCTION: acpi_ns_detach_data 361 * FUNCTION: acpi_ns_detach_data
@@ -392,27 +371,25 @@ acpi_ns_attach_data (
392 ******************************************************************************/ 371 ******************************************************************************/
393 372
394acpi_status 373acpi_status
395acpi_ns_detach_data ( 374acpi_ns_detach_data(struct acpi_namespace_node * node,
396 struct acpi_namespace_node *node, 375 acpi_object_handler handler)
397 acpi_object_handler handler)
398{ 376{
399 union acpi_operand_object *obj_desc; 377 union acpi_operand_object *obj_desc;
400 union acpi_operand_object *prev_obj_desc; 378 union acpi_operand_object *prev_obj_desc;
401
402 379
403 prev_obj_desc = NULL; 380 prev_obj_desc = NULL;
404 obj_desc = node->object; 381 obj_desc = node->object;
405 while (obj_desc) { 382 while (obj_desc) {
406 if ((ACPI_GET_OBJECT_TYPE (obj_desc) == ACPI_TYPE_LOCAL_DATA) && 383 if ((ACPI_GET_OBJECT_TYPE(obj_desc) == ACPI_TYPE_LOCAL_DATA) &&
407 (obj_desc->data.handler == handler)) { 384 (obj_desc->data.handler == handler)) {
408 if (prev_obj_desc) { 385 if (prev_obj_desc) {
409 prev_obj_desc->common.next_object = obj_desc->common.next_object; 386 prev_obj_desc->common.next_object =
410 } 387 obj_desc->common.next_object;
411 else { 388 } else {
412 node->object = obj_desc->common.next_object; 389 node->object = obj_desc->common.next_object;
413 } 390 }
414 391
415 acpi_ut_remove_reference (obj_desc); 392 acpi_ut_remove_reference(obj_desc);
416 return (AE_OK); 393 return (AE_OK);
417 } 394 }
418 395
@@ -423,7 +400,6 @@ acpi_ns_detach_data (
423 return (AE_NOT_FOUND); 400 return (AE_NOT_FOUND);
424} 401}
425 402
426
427/******************************************************************************* 403/*******************************************************************************
428 * 404 *
429 * FUNCTION: acpi_ns_get_attached_data 405 * FUNCTION: acpi_ns_get_attached_data
@@ -440,18 +416,15 @@ acpi_ns_detach_data (
440 ******************************************************************************/ 416 ******************************************************************************/
441 417
442acpi_status 418acpi_status
443acpi_ns_get_attached_data ( 419acpi_ns_get_attached_data(struct acpi_namespace_node * node,
444 struct acpi_namespace_node *node, 420 acpi_object_handler handler, void **data)
445 acpi_object_handler handler,
446 void **data)
447{ 421{
448 union acpi_operand_object *obj_desc; 422 union acpi_operand_object *obj_desc;
449
450 423
451 obj_desc = node->object; 424 obj_desc = node->object;
452 while (obj_desc) { 425 while (obj_desc) {
453 if ((ACPI_GET_OBJECT_TYPE (obj_desc) == ACPI_TYPE_LOCAL_DATA) && 426 if ((ACPI_GET_OBJECT_TYPE(obj_desc) == ACPI_TYPE_LOCAL_DATA) &&
454 (obj_desc->data.handler == handler)) { 427 (obj_desc->data.handler == handler)) {
455 *data = obj_desc->data.pointer; 428 *data = obj_desc->data.pointer;
456 return (AE_OK); 429 return (AE_OK);
457 } 430 }
@@ -461,5 +434,3 @@ acpi_ns_get_attached_data (
461 434
462 return (AE_NOT_FOUND); 435 return (AE_NOT_FOUND);
463} 436}
464
465
diff --git a/drivers/acpi/namespace/nsparse.c b/drivers/acpi/namespace/nsparse.c
index a0e13e8d3764..433442a9ec74 100644
--- a/drivers/acpi/namespace/nsparse.c
+++ b/drivers/acpi/namespace/nsparse.c
@@ -41,16 +41,13 @@
41 * POSSIBILITY OF SUCH DAMAGES. 41 * POSSIBILITY OF SUCH DAMAGES.
42 */ 42 */
43 43
44
45#include <acpi/acpi.h> 44#include <acpi/acpi.h>
46#include <acpi/acnamesp.h> 45#include <acpi/acnamesp.h>
47#include <acpi/acparser.h> 46#include <acpi/acparser.h>
48#include <acpi/acdispat.h> 47#include <acpi/acdispat.h>
49 48
50
51#define _COMPONENT ACPI_NAMESPACE 49#define _COMPONENT ACPI_NAMESPACE
52 ACPI_MODULE_NAME ("nsparse") 50ACPI_MODULE_NAME("nsparse")
53
54 51
55/******************************************************************************* 52/*******************************************************************************
56 * 53 *
@@ -64,54 +61,50 @@
64 * DESCRIPTION: Perform one complete parse of an ACPI/AML table. 61 * DESCRIPTION: Perform one complete parse of an ACPI/AML table.
65 * 62 *
66 ******************************************************************************/ 63 ******************************************************************************/
67
68acpi_status 64acpi_status
69acpi_ns_one_complete_parse ( 65acpi_ns_one_complete_parse(u8 pass_number, struct acpi_table_desc * table_desc)
70 u32 pass_number,
71 struct acpi_table_desc *table_desc)
72{ 66{
73 union acpi_parse_object *parse_root; 67 union acpi_parse_object *parse_root;
74 acpi_status status; 68 acpi_status status;
75 struct acpi_walk_state *walk_state; 69 struct acpi_walk_state *walk_state;
76
77
78 ACPI_FUNCTION_TRACE ("ns_one_complete_parse");
79 70
71 ACPI_FUNCTION_TRACE("ns_one_complete_parse");
80 72
81 /* Create and init a Root Node */ 73 /* Create and init a Root Node */
82 74
83 parse_root = acpi_ps_create_scope_op (); 75 parse_root = acpi_ps_create_scope_op();
84 if (!parse_root) { 76 if (!parse_root) {
85 return_ACPI_STATUS (AE_NO_MEMORY); 77 return_ACPI_STATUS(AE_NO_MEMORY);
86 } 78 }
87 79
88 /* Create and initialize a new walk state */ 80 /* Create and initialize a new walk state */
89 81
90 walk_state = acpi_ds_create_walk_state (table_desc->table_id, 82 walk_state = acpi_ds_create_walk_state(table_desc->owner_id,
91 NULL, NULL, NULL); 83 NULL, NULL, NULL);
92 if (!walk_state) { 84 if (!walk_state) {
93 acpi_ps_free_op (parse_root); 85 acpi_ps_free_op(parse_root);
94 return_ACPI_STATUS (AE_NO_MEMORY); 86 return_ACPI_STATUS(AE_NO_MEMORY);
95 } 87 }
96 88
97 status = acpi_ds_init_aml_walk (walk_state, parse_root, NULL, 89 status = acpi_ds_init_aml_walk(walk_state, parse_root, NULL,
98 table_desc->aml_start, table_desc->aml_length, 90 table_desc->aml_start,
99 NULL, pass_number); 91 table_desc->aml_length, NULL,
100 if (ACPI_FAILURE (status)) { 92 pass_number);
101 acpi_ds_delete_walk_state (walk_state); 93 if (ACPI_FAILURE(status)) {
102 return_ACPI_STATUS (status); 94 acpi_ds_delete_walk_state(walk_state);
95 return_ACPI_STATUS(status);
103 } 96 }
104 97
105 /* Parse the AML */ 98 /* Parse the AML */
106 99
107 ACPI_DEBUG_PRINT ((ACPI_DB_PARSE, "*PARSE* pass %d parse\n", pass_number)); 100 ACPI_DEBUG_PRINT((ACPI_DB_PARSE, "*PARSE* pass %d parse\n",
108 status = acpi_ps_parse_aml (walk_state); 101 pass_number));
102 status = acpi_ps_parse_aml(walk_state);
109 103
110 acpi_ps_delete_parse_tree (parse_root); 104 acpi_ps_delete_parse_tree(parse_root);
111 return_ACPI_STATUS (status); 105 return_ACPI_STATUS(status);
112} 106}
113 107
114
115/******************************************************************************* 108/*******************************************************************************
116 * 109 *
117 * FUNCTION: acpi_ns_parse_table 110 * FUNCTION: acpi_ns_parse_table
@@ -126,15 +119,12 @@ acpi_ns_one_complete_parse (
126 ******************************************************************************/ 119 ******************************************************************************/
127 120
128acpi_status 121acpi_status
129acpi_ns_parse_table ( 122acpi_ns_parse_table(struct acpi_table_desc *table_desc,
130 struct acpi_table_desc *table_desc, 123 struct acpi_namespace_node *start_node)
131 struct acpi_namespace_node *start_node)
132{ 124{
133 acpi_status status; 125 acpi_status status;
134
135
136 ACPI_FUNCTION_TRACE ("ns_parse_table");
137 126
127 ACPI_FUNCTION_TRACE("ns_parse_table");
138 128
139 /* 129 /*
140 * AML Parse, pass 1 130 * AML Parse, pass 1
@@ -146,9 +136,10 @@ acpi_ns_parse_table (
146 * to service the entire parse. The second pass of the parse then 136 * to service the entire parse. The second pass of the parse then
147 * performs another complete parse of the AML.. 137 * performs another complete parse of the AML..
148 */ 138 */
149 status = acpi_ns_one_complete_parse (1, table_desc); 139 ACPI_DEBUG_PRINT((ACPI_DB_PARSE, "**** Start pass 1\n"));
150 if (ACPI_FAILURE (status)) { 140 status = acpi_ns_one_complete_parse(1, table_desc);
151 return_ACPI_STATUS (status); 141 if (ACPI_FAILURE(status)) {
142 return_ACPI_STATUS(status);
152 } 143 }
153 144
154 /* 145 /*
@@ -160,12 +151,11 @@ acpi_ns_parse_table (
160 * overhead of this is compensated for by the fact that the 151 * overhead of this is compensated for by the fact that the
161 * parse objects are all cached. 152 * parse objects are all cached.
162 */ 153 */
163 status = acpi_ns_one_complete_parse (2, table_desc); 154 ACPI_DEBUG_PRINT((ACPI_DB_PARSE, "**** Start pass 2\n"));
164 if (ACPI_FAILURE (status)) { 155 status = acpi_ns_one_complete_parse(2, table_desc);
165 return_ACPI_STATUS (status); 156 if (ACPI_FAILURE(status)) {
157 return_ACPI_STATUS(status);
166 } 158 }
167 159
168 return_ACPI_STATUS (status); 160 return_ACPI_STATUS(status);
169} 161}
170
171
diff --git a/drivers/acpi/namespace/nssearch.c b/drivers/acpi/namespace/nssearch.c
index af8aaa9cc4f3..50a3ca5470ed 100644
--- a/drivers/acpi/namespace/nssearch.c
+++ b/drivers/acpi/namespace/nssearch.c
@@ -41,23 +41,18 @@
41 * POSSIBILITY OF SUCH DAMAGES. 41 * POSSIBILITY OF SUCH DAMAGES.
42 */ 42 */
43 43
44
45#include <acpi/acpi.h> 44#include <acpi/acpi.h>
46#include <acpi/acnamesp.h> 45#include <acpi/acnamesp.h>
47 46
48
49#define _COMPONENT ACPI_NAMESPACE 47#define _COMPONENT ACPI_NAMESPACE
50 ACPI_MODULE_NAME ("nssearch") 48ACPI_MODULE_NAME("nssearch")
51 49
52/* Local prototypes */ 50/* Local prototypes */
53
54static acpi_status 51static acpi_status
55acpi_ns_search_parent_tree ( 52acpi_ns_search_parent_tree(u32 target_name,
56 u32 target_name, 53 struct acpi_namespace_node *node,
57 struct acpi_namespace_node *node, 54 acpi_object_type type,
58 acpi_object_type type, 55 struct acpi_namespace_node **return_node);
59 struct acpi_namespace_node **return_node);
60
61 56
62/******************************************************************************* 57/*******************************************************************************
63 * 58 *
@@ -87,30 +82,28 @@ acpi_ns_search_parent_tree (
87 ******************************************************************************/ 82 ******************************************************************************/
88 83
89acpi_status 84acpi_status
90acpi_ns_search_node ( 85acpi_ns_search_node(u32 target_name,
91 u32 target_name, 86 struct acpi_namespace_node *node,
92 struct acpi_namespace_node *node, 87 acpi_object_type type,
93 acpi_object_type type, 88 struct acpi_namespace_node **return_node)
94 struct acpi_namespace_node **return_node)
95{ 89{
96 struct acpi_namespace_node *next_node; 90 struct acpi_namespace_node *next_node;
97
98
99 ACPI_FUNCTION_TRACE ("ns_search_node");
100 91
92 ACPI_FUNCTION_TRACE("ns_search_node");
101 93
102#ifdef ACPI_DEBUG_OUTPUT 94#ifdef ACPI_DEBUG_OUTPUT
103 if (ACPI_LV_NAMES & acpi_dbg_level) { 95 if (ACPI_LV_NAMES & acpi_dbg_level) {
104 char *scope_name; 96 char *scope_name;
105 97
106 scope_name = acpi_ns_get_external_pathname (node); 98 scope_name = acpi_ns_get_external_pathname(node);
107 if (scope_name) { 99 if (scope_name) {
108 ACPI_DEBUG_PRINT ((ACPI_DB_NAMES, 100 ACPI_DEBUG_PRINT((ACPI_DB_NAMES,
109 "Searching %s (%p) For [%4.4s] (%s)\n", 101 "Searching %s (%p) For [%4.4s] (%s)\n",
110 scope_name, node, (char *) &target_name, 102 scope_name, node,
111 acpi_ut_get_type_name (type))); 103 (char *)&target_name,
104 acpi_ut_get_type_name(type)));
112 105
113 ACPI_MEM_FREE (scope_name); 106 ACPI_MEM_FREE(scope_name);
114 } 107 }
115 } 108 }
116#endif 109#endif
@@ -126,20 +119,26 @@ acpi_ns_search_node (
126 if (next_node->name.integer == target_name) { 119 if (next_node->name.integer == target_name) {
127 /* Resolve a control method alias if any */ 120 /* Resolve a control method alias if any */
128 121
129 if (acpi_ns_get_type (next_node) == ACPI_TYPE_LOCAL_METHOD_ALIAS) { 122 if (acpi_ns_get_type(next_node) ==
130 next_node = ACPI_CAST_PTR (struct acpi_namespace_node, next_node->object); 123 ACPI_TYPE_LOCAL_METHOD_ALIAS) {
124 next_node =
125 ACPI_CAST_PTR(struct acpi_namespace_node,
126 next_node->object);
131 } 127 }
132 128
133 /* 129 /*
134 * Found matching entry. 130 * Found matching entry.
135 */ 131 */
136 ACPI_DEBUG_PRINT ((ACPI_DB_NAMES, 132 ACPI_DEBUG_PRINT((ACPI_DB_NAMES,
137 "Name [%4.4s] (%s) %p found in scope [%4.4s] %p\n", 133 "Name [%4.4s] (%s) %p found in scope [%4.4s] %p\n",
138 (char *) &target_name, acpi_ut_get_type_name (next_node->type), 134 (char *)&target_name,
139 next_node, acpi_ut_get_node_name (node), node)); 135 acpi_ut_get_type_name(next_node->
136 type),
137 next_node,
138 acpi_ut_get_node_name(node), node));
140 139
141 *return_node = next_node; 140 *return_node = next_node;
142 return_ACPI_STATUS (AE_OK); 141 return_ACPI_STATUS(AE_OK);
143 } 142 }
144 143
145 /* 144 /*
@@ -159,15 +158,14 @@ acpi_ns_search_node (
159 158
160 /* Searched entire namespace level, not found */ 159 /* Searched entire namespace level, not found */
161 160
162 ACPI_DEBUG_PRINT ((ACPI_DB_NAMES, 161 ACPI_DEBUG_PRINT((ACPI_DB_NAMES,
163 "Name [%4.4s] (%s) not found in search in scope [%4.4s] %p first child %p\n", 162 "Name [%4.4s] (%s) not found in search in scope [%4.4s] %p first child %p\n",
164 (char *) &target_name, acpi_ut_get_type_name (type), 163 (char *)&target_name, acpi_ut_get_type_name(type),
165 acpi_ut_get_node_name (node), node, node->child)); 164 acpi_ut_get_node_name(node), node, node->child));
166 165
167 return_ACPI_STATUS (AE_NOT_FOUND); 166 return_ACPI_STATUS(AE_NOT_FOUND);
168} 167}
169 168
170
171/******************************************************************************* 169/*******************************************************************************
172 * 170 *
173 * FUNCTION: acpi_ns_search_parent_tree 171 * FUNCTION: acpi_ns_search_parent_tree
@@ -194,43 +192,42 @@ acpi_ns_search_node (
194 ******************************************************************************/ 192 ******************************************************************************/
195 193
196static acpi_status 194static acpi_status
197acpi_ns_search_parent_tree ( 195acpi_ns_search_parent_tree(u32 target_name,
198 u32 target_name, 196 struct acpi_namespace_node *node,
199 struct acpi_namespace_node *node, 197 acpi_object_type type,
200 acpi_object_type type, 198 struct acpi_namespace_node **return_node)
201 struct acpi_namespace_node **return_node)
202{ 199{
203 acpi_status status; 200 acpi_status status;
204 struct acpi_namespace_node *parent_node; 201 struct acpi_namespace_node *parent_node;
205 202
203 ACPI_FUNCTION_TRACE("ns_search_parent_tree");
206 204
207 ACPI_FUNCTION_TRACE ("ns_search_parent_tree"); 205 parent_node = acpi_ns_get_parent_node(node);
208
209
210 parent_node = acpi_ns_get_parent_node (node);
211 206
212 /* 207 /*
213 * If there is no parent (i.e., we are at the root) or type is "local", 208 * If there is no parent (i.e., we are at the root) or type is "local",
214 * we won't be searching the parent tree. 209 * we won't be searching the parent tree.
215 */ 210 */
216 if (!parent_node) { 211 if (!parent_node) {
217 ACPI_DEBUG_PRINT ((ACPI_DB_NAMES, "[%4.4s] has no parent\n", 212 ACPI_DEBUG_PRINT((ACPI_DB_NAMES, "[%4.4s] has no parent\n",
218 (char *) &target_name)); 213 (char *)&target_name));
219 return_ACPI_STATUS (AE_NOT_FOUND); 214 return_ACPI_STATUS(AE_NOT_FOUND);
220 } 215 }
221 216
222 if (acpi_ns_local (type)) { 217 if (acpi_ns_local(type)) {
223 ACPI_DEBUG_PRINT ((ACPI_DB_NAMES, 218 ACPI_DEBUG_PRINT((ACPI_DB_NAMES,
224 "[%4.4s] type [%s] must be local to this scope (no parent search)\n", 219 "[%4.4s] type [%s] must be local to this scope (no parent search)\n",
225 (char *) &target_name, acpi_ut_get_type_name (type))); 220 (char *)&target_name,
226 return_ACPI_STATUS (AE_NOT_FOUND); 221 acpi_ut_get_type_name(type)));
222 return_ACPI_STATUS(AE_NOT_FOUND);
227 } 223 }
228 224
229 /* Search the parent tree */ 225 /* Search the parent tree */
230 226
231 ACPI_DEBUG_PRINT ((ACPI_DB_NAMES, 227 ACPI_DEBUG_PRINT((ACPI_DB_NAMES,
232 "Searching parent [%4.4s] for [%4.4s]\n", 228 "Searching parent [%4.4s] for [%4.4s]\n",
233 acpi_ut_get_node_name (parent_node), (char *) &target_name)); 229 acpi_ut_get_node_name(parent_node),
230 (char *)&target_name));
234 231
235 /* 232 /*
236 * Search parents until target is found or we have backed up to the root 233 * Search parents until target is found or we have backed up to the root
@@ -241,25 +238,24 @@ acpi_ns_search_parent_tree (
241 * object type at this point, we only care about the existence of 238 * object type at this point, we only care about the existence of
242 * the actual name we are searching for. Typechecking comes later. 239 * the actual name we are searching for. Typechecking comes later.
243 */ 240 */
244 status = acpi_ns_search_node (target_name, parent_node, 241 status = acpi_ns_search_node(target_name, parent_node,
245 ACPI_TYPE_ANY, return_node); 242 ACPI_TYPE_ANY, return_node);
246 if (ACPI_SUCCESS (status)) { 243 if (ACPI_SUCCESS(status)) {
247 return_ACPI_STATUS (status); 244 return_ACPI_STATUS(status);
248 } 245 }
249 246
250 /* 247 /*
251 * Not found here, go up another level 248 * Not found here, go up another level
252 * (until we reach the root) 249 * (until we reach the root)
253 */ 250 */
254 parent_node = acpi_ns_get_parent_node (parent_node); 251 parent_node = acpi_ns_get_parent_node(parent_node);
255 } 252 }
256 253
257 /* Not found in parent tree */ 254 /* Not found in parent tree */
258 255
259 return_ACPI_STATUS (AE_NOT_FOUND); 256 return_ACPI_STATUS(AE_NOT_FOUND);
260} 257}
261 258
262
263/******************************************************************************* 259/*******************************************************************************
264 * 260 *
265 * FUNCTION: acpi_ns_search_and_enter 261 * FUNCTION: acpi_ns_search_and_enter
@@ -286,52 +282,46 @@ acpi_ns_search_parent_tree (
286 ******************************************************************************/ 282 ******************************************************************************/
287 283
288acpi_status 284acpi_status
289acpi_ns_search_and_enter ( 285acpi_ns_search_and_enter(u32 target_name,
290 u32 target_name, 286 struct acpi_walk_state *walk_state,
291 struct acpi_walk_state *walk_state, 287 struct acpi_namespace_node *node,
292 struct acpi_namespace_node *node, 288 acpi_interpreter_mode interpreter_mode,
293 acpi_interpreter_mode interpreter_mode, 289 acpi_object_type type,
294 acpi_object_type type, 290 u32 flags, struct acpi_namespace_node **return_node)
295 u32 flags,
296 struct acpi_namespace_node **return_node)
297{ 291{
298 acpi_status status; 292 acpi_status status;
299 struct acpi_namespace_node *new_node; 293 struct acpi_namespace_node *new_node;
300
301
302 ACPI_FUNCTION_TRACE ("ns_search_and_enter");
303 294
295 ACPI_FUNCTION_TRACE("ns_search_and_enter");
304 296
305 /* Parameter validation */ 297 /* Parameter validation */
306 298
307 if (!node || !target_name || !return_node) { 299 if (!node || !target_name || !return_node) {
308 ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, 300 ACPI_DEBUG_PRINT((ACPI_DB_ERROR,
309 "Null param: Node %p Name %X return_node %p\n", 301 "Null param: Node %p Name %X return_node %p\n",
310 node, target_name, return_node)); 302 node, target_name, return_node));
311 303
312 ACPI_REPORT_ERROR (("ns_search_and_enter: Null parameter\n")); 304 ACPI_REPORT_ERROR(("ns_search_and_enter: Null parameter\n"));
313 return_ACPI_STATUS (AE_BAD_PARAMETER); 305 return_ACPI_STATUS(AE_BAD_PARAMETER);
314 } 306 }
315 307
316 /* Name must consist of printable characters */ 308 /* Name must consist of printable characters */
317 309
318 if (!acpi_ut_valid_acpi_name (target_name)) { 310 if (!acpi_ut_valid_acpi_name(target_name)) {
319 ACPI_REPORT_ERROR (("ns_search_and_enter: Bad character in ACPI Name: %X\n", 311 ACPI_REPORT_ERROR(("ns_search_and_enter: Bad character in ACPI Name: %X\n", target_name));
320 target_name)); 312 return_ACPI_STATUS(AE_BAD_CHARACTER);
321 return_ACPI_STATUS (AE_BAD_CHARACTER);
322 } 313 }
323 314
324 /* Try to find the name in the namespace level specified by the caller */ 315 /* Try to find the name in the namespace level specified by the caller */
325 316
326 *return_node = ACPI_ENTRY_NOT_FOUND; 317 *return_node = ACPI_ENTRY_NOT_FOUND;
327 status = acpi_ns_search_node (target_name, node, type, return_node); 318 status = acpi_ns_search_node(target_name, node, type, return_node);
328 if (status != AE_NOT_FOUND) { 319 if (status != AE_NOT_FOUND) {
329 /* 320 /*
330 * If we found it AND the request specifies that a find is an error, 321 * If we found it AND the request specifies that a find is an error,
331 * return the error 322 * return the error
332 */ 323 */
333 if ((status == AE_OK) && 324 if ((status == AE_OK) && (flags & ACPI_NS_ERROR_IF_FOUND)) {
334 (flags & ACPI_NS_ERROR_IF_FOUND)) {
335 status = AE_ALREADY_EXISTS; 325 status = AE_ALREADY_EXISTS;
336 } 326 }
337 327
@@ -339,7 +329,7 @@ acpi_ns_search_and_enter (
339 * Either found it or there was an error 329 * Either found it or there was an error
340 * -- finished either way 330 * -- finished either way
341 */ 331 */
342 return_ACPI_STATUS (status); 332 return_ACPI_STATUS(status);
343 } 333 }
344 334
345 /* 335 /*
@@ -351,14 +341,16 @@ acpi_ns_search_and_enter (
351 * and during the execution phase. 341 * and during the execution phase.
352 */ 342 */
353 if ((interpreter_mode != ACPI_IMODE_LOAD_PASS1) && 343 if ((interpreter_mode != ACPI_IMODE_LOAD_PASS1) &&
354 (flags & ACPI_NS_SEARCH_PARENT)) { 344 (flags & ACPI_NS_SEARCH_PARENT)) {
355 /* 345 /*
356 * Not found at this level - search parent tree according to the 346 * Not found at this level - search parent tree according to the
357 * ACPI specification 347 * ACPI specification
358 */ 348 */
359 status = acpi_ns_search_parent_tree (target_name, node, type, return_node); 349 status =
360 if (ACPI_SUCCESS (status)) { 350 acpi_ns_search_parent_tree(target_name, node, type,
361 return_ACPI_STATUS (status); 351 return_node);
352 if (ACPI_SUCCESS(status)) {
353 return_ACPI_STATUS(status);
362 } 354 }
363 } 355 }
364 356
@@ -366,25 +358,24 @@ acpi_ns_search_and_enter (
366 * In execute mode, just search, never add names. Exit now. 358 * In execute mode, just search, never add names. Exit now.
367 */ 359 */
368 if (interpreter_mode == ACPI_IMODE_EXECUTE) { 360 if (interpreter_mode == ACPI_IMODE_EXECUTE) {
369 ACPI_DEBUG_PRINT ((ACPI_DB_NAMES, 361 ACPI_DEBUG_PRINT((ACPI_DB_NAMES,
370 "%4.4s Not found in %p [Not adding]\n", 362 "%4.4s Not found in %p [Not adding]\n",
371 (char *) &target_name, node)); 363 (char *)&target_name, node));
372 364
373 return_ACPI_STATUS (AE_NOT_FOUND); 365 return_ACPI_STATUS(AE_NOT_FOUND);
374 } 366 }
375 367
376 /* Create the new named object */ 368 /* Create the new named object */
377 369
378 new_node = acpi_ns_create_node (target_name); 370 new_node = acpi_ns_create_node(target_name);
379 if (!new_node) { 371 if (!new_node) {
380 return_ACPI_STATUS (AE_NO_MEMORY); 372 return_ACPI_STATUS(AE_NO_MEMORY);
381 } 373 }
382 374
383 /* Install the new object into the parent's list of children */ 375 /* Install the new object into the parent's list of children */
384 376
385 acpi_ns_install_node (walk_state, node, new_node, type); 377 acpi_ns_install_node(walk_state, node, new_node, type);
386 *return_node = new_node; 378 *return_node = new_node;
387 379
388 return_ACPI_STATUS (AE_OK); 380 return_ACPI_STATUS(AE_OK);
389} 381}
390
diff --git a/drivers/acpi/namespace/nsutils.c b/drivers/acpi/namespace/nsutils.c
index c53b82e94ce3..ebec036423c9 100644
--- a/drivers/acpi/namespace/nsutils.c
+++ b/drivers/acpi/namespace/nsutils.c
@@ -42,28 +42,21 @@
42 * POSSIBILITY OF SUCH DAMAGES. 42 * POSSIBILITY OF SUCH DAMAGES.
43 */ 43 */
44 44
45
46#include <acpi/acpi.h> 45#include <acpi/acpi.h>
47#include <acpi/acnamesp.h> 46#include <acpi/acnamesp.h>
48#include <acpi/amlcode.h> 47#include <acpi/amlcode.h>
49#include <acpi/actables.h> 48#include <acpi/actables.h>
50 49
51#define _COMPONENT ACPI_NAMESPACE 50#define _COMPONENT ACPI_NAMESPACE
52 ACPI_MODULE_NAME ("nsutils") 51ACPI_MODULE_NAME("nsutils")
53 52
54/* Local prototypes */ 53/* Local prototypes */
55 54static u8 acpi_ns_valid_path_separator(char sep);
56static u8
57acpi_ns_valid_path_separator (
58 char sep);
59 55
60#ifdef ACPI_OBSOLETE_FUNCTIONS 56#ifdef ACPI_OBSOLETE_FUNCTIONS
61acpi_name 57acpi_name acpi_ns_find_parent_name(struct acpi_namespace_node *node_to_search);
62acpi_ns_find_parent_name (
63 struct acpi_namespace_node *node_to_search);
64#endif 58#endif
65 59
66
67/******************************************************************************* 60/*******************************************************************************
68 * 61 *
69 * FUNCTION: acpi_ns_report_error 62 * FUNCTION: acpi_ns_report_error
@@ -81,51 +74,45 @@ acpi_ns_find_parent_name (
81 ******************************************************************************/ 74 ******************************************************************************/
82 75
83void 76void
84acpi_ns_report_error ( 77acpi_ns_report_error(char *module_name,
85 char *module_name, 78 u32 line_number,
86 u32 line_number, 79 u32 component_id,
87 u32 component_id, 80 char *internal_name, acpi_status lookup_status)
88 char *internal_name,
89 acpi_status lookup_status)
90{ 81{
91 acpi_status status; 82 acpi_status status;
92 char *name = NULL; 83 char *name = NULL;
93
94 84
95 acpi_os_printf ("%8s-%04d: *** Error: Looking up ", 85 acpi_os_printf("%8s-%04d: *** Error: Looking up ",
96 module_name, line_number); 86 module_name, line_number);
97 87
98 if (lookup_status == AE_BAD_CHARACTER) { 88 if (lookup_status == AE_BAD_CHARACTER) {
99 /* There is a non-ascii character in the name */ 89 /* There is a non-ascii character in the name */
100 90
101 acpi_os_printf ("[0x%4.4X] (NON-ASCII)\n", 91 acpi_os_printf("[0x%4.4X] (NON-ASCII)\n",
102 *(ACPI_CAST_PTR (u32, internal_name))); 92 *(ACPI_CAST_PTR(u32, internal_name)));
103 } 93 } else {
104 else {
105 /* Convert path to external format */ 94 /* Convert path to external format */
106 95
107 status = acpi_ns_externalize_name (ACPI_UINT32_MAX, 96 status = acpi_ns_externalize_name(ACPI_UINT32_MAX,
108 internal_name, NULL, &name); 97 internal_name, NULL, &name);
109 98
110 /* Print target name */ 99 /* Print target name */
111 100
112 if (ACPI_SUCCESS (status)) { 101 if (ACPI_SUCCESS(status)) {
113 acpi_os_printf ("[%s]", name); 102 acpi_os_printf("[%s]", name);
114 } 103 } else {
115 else { 104 acpi_os_printf("[COULD NOT EXTERNALIZE NAME]");
116 acpi_os_printf ("[COULD NOT EXTERNALIZE NAME]");
117 } 105 }
118 106
119 if (name) { 107 if (name) {
120 ACPI_MEM_FREE (name); 108 ACPI_MEM_FREE(name);
121 } 109 }
122 } 110 }
123 111
124 acpi_os_printf (" in namespace, %s\n", 112 acpi_os_printf(" in namespace, %s\n",
125 acpi_format_exception (lookup_status)); 113 acpi_format_exception(lookup_status));
126} 114}
127 115
128
129/******************************************************************************* 116/*******************************************************************************
130 * 117 *
131 * FUNCTION: acpi_ns_report_method_error 118 * FUNCTION: acpi_ns_report_method_error
@@ -145,34 +132,31 @@ acpi_ns_report_error (
145 ******************************************************************************/ 132 ******************************************************************************/
146 133
147void 134void
148acpi_ns_report_method_error ( 135acpi_ns_report_method_error(char *module_name,
149 char *module_name, 136 u32 line_number,
150 u32 line_number, 137 u32 component_id,
151 u32 component_id, 138 char *message,
152 char *message, 139 struct acpi_namespace_node *prefix_node,
153 struct acpi_namespace_node *prefix_node, 140 char *path, acpi_status method_status)
154 char *path,
155 acpi_status method_status)
156{ 141{
157 acpi_status status; 142 acpi_status status;
158 struct acpi_namespace_node *node = prefix_node; 143 struct acpi_namespace_node *node = prefix_node;
159
160 144
161 if (path) { 145 if (path) {
162 status = acpi_ns_get_node_by_path (path, prefix_node, 146 status = acpi_ns_get_node_by_path(path, prefix_node,
163 ACPI_NS_NO_UPSEARCH, &node); 147 ACPI_NS_NO_UPSEARCH, &node);
164 if (ACPI_FAILURE (status)) { 148 if (ACPI_FAILURE(status)) {
165 acpi_os_printf ("report_method_error: Could not get node\n"); 149 acpi_os_printf
150 ("report_method_error: Could not get node\n");
166 return; 151 return;
167 } 152 }
168 } 153 }
169 154
170 acpi_os_printf ("%8s-%04d: *** Error: ", module_name, line_number); 155 acpi_os_printf("%8s-%04d: *** Error: ", module_name, line_number);
171 acpi_ns_print_node_pathname (node, message); 156 acpi_ns_print_node_pathname(node, message);
172 acpi_os_printf (", %s\n", acpi_format_exception (method_status)); 157 acpi_os_printf(", %s\n", acpi_format_exception(method_status));
173} 158}
174 159
175
176/******************************************************************************* 160/*******************************************************************************
177 * 161 *
178 * FUNCTION: acpi_ns_print_node_pathname 162 * FUNCTION: acpi_ns_print_node_pathname
@@ -186,16 +170,13 @@ acpi_ns_report_method_error (
186 ******************************************************************************/ 170 ******************************************************************************/
187 171
188void 172void
189acpi_ns_print_node_pathname ( 173acpi_ns_print_node_pathname(struct acpi_namespace_node *node, char *message)
190 struct acpi_namespace_node *node,
191 char *message)
192{ 174{
193 struct acpi_buffer buffer; 175 struct acpi_buffer buffer;
194 acpi_status status; 176 acpi_status status;
195
196 177
197 if (!node) { 178 if (!node) {
198 acpi_os_printf ("[NULL NAME]"); 179 acpi_os_printf("[NULL NAME]");
199 return; 180 return;
200 } 181 }
201 182
@@ -203,18 +184,17 @@ acpi_ns_print_node_pathname (
203 184
204 buffer.length = ACPI_ALLOCATE_LOCAL_BUFFER; 185 buffer.length = ACPI_ALLOCATE_LOCAL_BUFFER;
205 186
206 status = acpi_ns_handle_to_pathname (node, &buffer); 187 status = acpi_ns_handle_to_pathname(node, &buffer);
207 if (ACPI_SUCCESS (status)) { 188 if (ACPI_SUCCESS(status)) {
208 if (message) { 189 if (message) {
209 acpi_os_printf ("%s ", message); 190 acpi_os_printf("%s ", message);
210 } 191 }
211 192
212 acpi_os_printf ("[%s] (Node %p)", (char *) buffer.pointer, node); 193 acpi_os_printf("[%s] (Node %p)", (char *)buffer.pointer, node);
213 ACPI_MEM_FREE (buffer.pointer); 194 ACPI_MEM_FREE(buffer.pointer);
214 } 195 }
215} 196}
216 197
217
218/******************************************************************************* 198/*******************************************************************************
219 * 199 *
220 * FUNCTION: acpi_ns_valid_root_prefix 200 * FUNCTION: acpi_ns_valid_root_prefix
@@ -227,15 +207,12 @@ acpi_ns_print_node_pathname (
227 * 207 *
228 ******************************************************************************/ 208 ******************************************************************************/
229 209
230u8 210u8 acpi_ns_valid_root_prefix(char prefix)
231acpi_ns_valid_root_prefix (
232 char prefix)
233{ 211{
234 212
235 return ((u8) (prefix == '\\')); 213 return ((u8) (prefix == '\\'));
236} 214}
237 215
238
239/******************************************************************************* 216/*******************************************************************************
240 * 217 *
241 * FUNCTION: acpi_ns_valid_path_separator 218 * FUNCTION: acpi_ns_valid_path_separator
@@ -248,15 +225,12 @@ acpi_ns_valid_root_prefix (
248 * 225 *
249 ******************************************************************************/ 226 ******************************************************************************/
250 227
251static u8 228static u8 acpi_ns_valid_path_separator(char sep)
252acpi_ns_valid_path_separator (
253 char sep)
254{ 229{
255 230
256 return ((u8) (sep == '.')); 231 return ((u8) (sep == '.'));
257} 232}
258 233
259
260/******************************************************************************* 234/*******************************************************************************
261 * 235 *
262 * FUNCTION: acpi_ns_get_type 236 * FUNCTION: acpi_ns_get_type
@@ -269,22 +243,18 @@ acpi_ns_valid_path_separator (
269 * 243 *
270 ******************************************************************************/ 244 ******************************************************************************/
271 245
272acpi_object_type 246acpi_object_type acpi_ns_get_type(struct acpi_namespace_node * node)
273acpi_ns_get_type (
274 struct acpi_namespace_node *node)
275{ 247{
276 ACPI_FUNCTION_TRACE ("ns_get_type"); 248 ACPI_FUNCTION_TRACE("ns_get_type");
277
278 249
279 if (!node) { 250 if (!node) {
280 ACPI_REPORT_WARNING (("ns_get_type: Null Node input pointer\n")); 251 ACPI_REPORT_WARNING(("ns_get_type: Null Node input pointer\n"));
281 return_VALUE (ACPI_TYPE_ANY); 252 return_VALUE(ACPI_TYPE_ANY);
282 } 253 }
283 254
284 return_VALUE ((acpi_object_type) node->type); 255 return_VALUE((acpi_object_type) node->type);
285} 256}
286 257
287
288/******************************************************************************* 258/*******************************************************************************
289 * 259 *
290 * FUNCTION: acpi_ns_local 260 * FUNCTION: acpi_ns_local
@@ -298,24 +268,20 @@ acpi_ns_get_type (
298 * 268 *
299 ******************************************************************************/ 269 ******************************************************************************/
300 270
301u32 271u32 acpi_ns_local(acpi_object_type type)
302acpi_ns_local (
303 acpi_object_type type)
304{ 272{
305 ACPI_FUNCTION_TRACE ("ns_local"); 273 ACPI_FUNCTION_TRACE("ns_local");
306
307 274
308 if (!acpi_ut_valid_object_type (type)) { 275 if (!acpi_ut_valid_object_type(type)) {
309 /* Type code out of range */ 276 /* Type code out of range */
310 277
311 ACPI_REPORT_WARNING (("ns_local: Invalid Object Type\n")); 278 ACPI_REPORT_WARNING(("ns_local: Invalid Object Type\n"));
312 return_VALUE (ACPI_NS_NORMAL); 279 return_VALUE(ACPI_NS_NORMAL);
313 } 280 }
314 281
315 return_VALUE ((u32) acpi_gbl_ns_properties[type] & ACPI_NS_LOCAL); 282 return_VALUE((u32) acpi_gbl_ns_properties[type] & ACPI_NS_LOCAL);
316} 283}
317 284
318
319/******************************************************************************* 285/*******************************************************************************
320 * 286 *
321 * FUNCTION: acpi_ns_get_internal_name_length 287 * FUNCTION: acpi_ns_get_internal_name_length
@@ -330,16 +296,12 @@ acpi_ns_local (
330 * 296 *
331 ******************************************************************************/ 297 ******************************************************************************/
332 298
333void 299void acpi_ns_get_internal_name_length(struct acpi_namestring_info *info)
334acpi_ns_get_internal_name_length (
335 struct acpi_namestring_info *info)
336{ 300{
337 char *next_external_char; 301 char *next_external_char;
338 u32 i; 302 u32 i;
339
340
341 ACPI_FUNCTION_ENTRY ();
342 303
304 ACPI_FUNCTION_ENTRY();
343 305
344 next_external_char = info->external_name; 306 next_external_char = info->external_name;
345 info->num_carats = 0; 307 info->num_carats = 0;
@@ -353,11 +315,10 @@ acpi_ns_get_internal_name_length (
353 * 315 *
354 * strlen() + 1 covers the first name_seg, which has no path separator 316 * strlen() + 1 covers the first name_seg, which has no path separator
355 */ 317 */
356 if (acpi_ns_valid_root_prefix (next_external_char[0])) { 318 if (acpi_ns_valid_root_prefix(next_external_char[0])) {
357 info->fully_qualified = TRUE; 319 info->fully_qualified = TRUE;
358 next_external_char++; 320 next_external_char++;
359 } 321 } else {
360 else {
361 /* 322 /*
362 * Handle Carat prefixes 323 * Handle Carat prefixes
363 */ 324 */
@@ -375,19 +336,18 @@ acpi_ns_get_internal_name_length (
375 if (*next_external_char) { 336 if (*next_external_char) {
376 info->num_segments = 1; 337 info->num_segments = 1;
377 for (i = 0; next_external_char[i]; i++) { 338 for (i = 0; next_external_char[i]; i++) {
378 if (acpi_ns_valid_path_separator (next_external_char[i])) { 339 if (acpi_ns_valid_path_separator(next_external_char[i])) {
379 info->num_segments++; 340 info->num_segments++;
380 } 341 }
381 } 342 }
382 } 343 }
383 344
384 info->length = (ACPI_NAME_SIZE * info->num_segments) + 345 info->length = (ACPI_NAME_SIZE * info->num_segments) +
385 4 + info->num_carats; 346 4 + info->num_carats;
386 347
387 info->next_external_char = next_external_char; 348 info->next_external_char = next_external_char;
388} 349}
389 350
390
391/******************************************************************************* 351/*******************************************************************************
392 * 352 *
393 * FUNCTION: acpi_ns_build_internal_name 353 * FUNCTION: acpi_ns_build_internal_name
@@ -401,19 +361,15 @@ acpi_ns_get_internal_name_length (
401 * 361 *
402 ******************************************************************************/ 362 ******************************************************************************/
403 363
404acpi_status 364acpi_status acpi_ns_build_internal_name(struct acpi_namestring_info *info)
405acpi_ns_build_internal_name (
406 struct acpi_namestring_info *info)
407{ 365{
408 u32 num_segments = info->num_segments; 366 u32 num_segments = info->num_segments;
409 char *internal_name = info->internal_name; 367 char *internal_name = info->internal_name;
410 char *external_name = info->next_external_char; 368 char *external_name = info->next_external_char;
411 char *result = NULL; 369 char *result = NULL;
412 acpi_native_uint i; 370 acpi_native_uint i;
413
414
415 ACPI_FUNCTION_TRACE ("ns_build_internal_name");
416 371
372 ACPI_FUNCTION_TRACE("ns_build_internal_name");
417 373
418 /* Setup the correct prefixes, counts, and pointers */ 374 /* Setup the correct prefixes, counts, and pointers */
419 375
@@ -422,18 +378,15 @@ acpi_ns_build_internal_name (
422 378
423 if (num_segments <= 1) { 379 if (num_segments <= 1) {
424 result = &internal_name[1]; 380 result = &internal_name[1];
425 } 381 } else if (num_segments == 2) {
426 else if (num_segments == 2) {
427 internal_name[1] = AML_DUAL_NAME_PREFIX; 382 internal_name[1] = AML_DUAL_NAME_PREFIX;
428 result = &internal_name[2]; 383 result = &internal_name[2];
429 } 384 } else {
430 else {
431 internal_name[1] = AML_MULTI_NAME_PREFIX_OP; 385 internal_name[1] = AML_MULTI_NAME_PREFIX_OP;
432 internal_name[2] = (char) num_segments; 386 internal_name[2] = (char)num_segments;
433 result = &internal_name[3]; 387 result = &internal_name[3];
434 } 388 }
435 } 389 } else {
436 else {
437 /* 390 /*
438 * Not fully qualified. 391 * Not fully qualified.
439 * Handle Carats first, then append the name segments 392 * Handle Carats first, then append the name segments
@@ -447,15 +400,14 @@ acpi_ns_build_internal_name (
447 400
448 if (num_segments <= 1) { 401 if (num_segments <= 1) {
449 result = &internal_name[i]; 402 result = &internal_name[i];
450 } 403 } else if (num_segments == 2) {
451 else if (num_segments == 2) {
452 internal_name[i] = AML_DUAL_NAME_PREFIX; 404 internal_name[i] = AML_DUAL_NAME_PREFIX;
453 result = &internal_name[(acpi_native_uint) (i+1)]; 405 result = &internal_name[(acpi_native_uint) (i + 1)];
454 } 406 } else {
455 else {
456 internal_name[i] = AML_MULTI_NAME_PREFIX_OP; 407 internal_name[i] = AML_MULTI_NAME_PREFIX_OP;
457 internal_name[(acpi_native_uint) (i+1)] = (char) num_segments; 408 internal_name[(acpi_native_uint) (i + 1)] =
458 result = &internal_name[(acpi_native_uint) (i+2)]; 409 (char)num_segments;
410 result = &internal_name[(acpi_native_uint) (i + 2)];
459 } 411 }
460 } 412 }
461 413
@@ -463,25 +415,25 @@ acpi_ns_build_internal_name (
463 415
464 for (; num_segments; num_segments--) { 416 for (; num_segments; num_segments--) {
465 for (i = 0; i < ACPI_NAME_SIZE; i++) { 417 for (i = 0; i < ACPI_NAME_SIZE; i++) {
466 if (acpi_ns_valid_path_separator (*external_name) || 418 if (acpi_ns_valid_path_separator(*external_name) ||
467 (*external_name == 0)) { 419 (*external_name == 0)) {
468 /* Pad the segment with underscore(s) if segment is short */ 420 /* Pad the segment with underscore(s) if segment is short */
469 421
470 result[i] = '_'; 422 result[i] = '_';
471 } 423 } else {
472 else {
473 /* Convert the character to uppercase and save it */ 424 /* Convert the character to uppercase and save it */
474 425
475 result[i] = (char) ACPI_TOUPPER ((int) *external_name); 426 result[i] =
427 (char)ACPI_TOUPPER((int)*external_name);
476 external_name++; 428 external_name++;
477 } 429 }
478 } 430 }
479 431
480 /* Now we must have a path separator, or the pathname is bad */ 432 /* Now we must have a path separator, or the pathname is bad */
481 433
482 if (!acpi_ns_valid_path_separator (*external_name) && 434 if (!acpi_ns_valid_path_separator(*external_name) &&
483 (*external_name != 0)) { 435 (*external_name != 0)) {
484 return_ACPI_STATUS (AE_BAD_PARAMETER); 436 return_ACPI_STATUS(AE_BAD_PARAMETER);
485 } 437 }
486 438
487 /* Move on the next segment */ 439 /* Move on the next segment */
@@ -495,18 +447,17 @@ acpi_ns_build_internal_name (
495 *result = 0; 447 *result = 0;
496 448
497 if (info->fully_qualified) { 449 if (info->fully_qualified) {
498 ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "Returning [%p] (abs) \"\\%s\"\n", 450 ACPI_DEBUG_PRINT((ACPI_DB_EXEC,
499 internal_name, internal_name)); 451 "Returning [%p] (abs) \"\\%s\"\n",
500 } 452 internal_name, internal_name));
501 else { 453 } else {
502 ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "Returning [%p] (rel) \"%s\"\n", 454 ACPI_DEBUG_PRINT((ACPI_DB_EXEC, "Returning [%p] (rel) \"%s\"\n",
503 internal_name, internal_name)); 455 internal_name, internal_name));
504 } 456 }
505 457
506 return_ACPI_STATUS (AE_OK); 458 return_ACPI_STATUS(AE_OK);
507} 459}
508 460
509
510/******************************************************************************* 461/*******************************************************************************
511 * 462 *
512 * FUNCTION: acpi_ns_internalize_name 463 * FUNCTION: acpi_ns_internalize_name
@@ -522,51 +473,43 @@ acpi_ns_build_internal_name (
522 * 473 *
523 *******************************************************************************/ 474 *******************************************************************************/
524 475
525acpi_status 476acpi_status acpi_ns_internalize_name(char *external_name, char **converted_name)
526acpi_ns_internalize_name (
527 char *external_name,
528 char **converted_name)
529{ 477{
530 char *internal_name; 478 char *internal_name;
531 struct acpi_namestring_info info; 479 struct acpi_namestring_info info;
532 acpi_status status; 480 acpi_status status;
533
534
535 ACPI_FUNCTION_TRACE ("ns_internalize_name");
536 481
482 ACPI_FUNCTION_TRACE("ns_internalize_name");
537 483
538 if ((!external_name) || 484 if ((!external_name) || (*external_name == 0) || (!converted_name)) {
539 (*external_name == 0) || 485 return_ACPI_STATUS(AE_BAD_PARAMETER);
540 (!converted_name)) {
541 return_ACPI_STATUS (AE_BAD_PARAMETER);
542 } 486 }
543 487
544 /* Get the length of the new internal name */ 488 /* Get the length of the new internal name */
545 489
546 info.external_name = external_name; 490 info.external_name = external_name;
547 acpi_ns_get_internal_name_length (&info); 491 acpi_ns_get_internal_name_length(&info);
548 492
549 /* We need a segment to store the internal name */ 493 /* We need a segment to store the internal name */
550 494
551 internal_name = ACPI_MEM_CALLOCATE (info.length); 495 internal_name = ACPI_MEM_CALLOCATE(info.length);
552 if (!internal_name) { 496 if (!internal_name) {
553 return_ACPI_STATUS (AE_NO_MEMORY); 497 return_ACPI_STATUS(AE_NO_MEMORY);
554 } 498 }
555 499
556 /* Build the name */ 500 /* Build the name */
557 501
558 info.internal_name = internal_name; 502 info.internal_name = internal_name;
559 status = acpi_ns_build_internal_name (&info); 503 status = acpi_ns_build_internal_name(&info);
560 if (ACPI_FAILURE (status)) { 504 if (ACPI_FAILURE(status)) {
561 ACPI_MEM_FREE (internal_name); 505 ACPI_MEM_FREE(internal_name);
562 return_ACPI_STATUS (status); 506 return_ACPI_STATUS(status);
563 } 507 }
564 508
565 *converted_name = internal_name; 509 *converted_name = internal_name;
566 return_ACPI_STATUS (AE_OK); 510 return_ACPI_STATUS(AE_OK);
567} 511}
568 512
569
570/******************************************************************************* 513/*******************************************************************************
571 * 514 *
572 * FUNCTION: acpi_ns_externalize_name 515 * FUNCTION: acpi_ns_externalize_name
@@ -585,27 +528,21 @@ acpi_ns_internalize_name (
585 ******************************************************************************/ 528 ******************************************************************************/
586 529
587acpi_status 530acpi_status
588acpi_ns_externalize_name ( 531acpi_ns_externalize_name(u32 internal_name_length,
589 u32 internal_name_length, 532 char *internal_name,
590 char *internal_name, 533 u32 * converted_name_length, char **converted_name)
591 u32 *converted_name_length,
592 char **converted_name)
593{ 534{
594 acpi_native_uint names_index = 0; 535 acpi_native_uint names_index = 0;
595 acpi_native_uint num_segments = 0; 536 acpi_native_uint num_segments = 0;
596 acpi_native_uint required_length; 537 acpi_native_uint required_length;
597 acpi_native_uint prefix_length = 0; 538 acpi_native_uint prefix_length = 0;
598 acpi_native_uint i = 0; 539 acpi_native_uint i = 0;
599 acpi_native_uint j = 0; 540 acpi_native_uint j = 0;
600
601 541
602 ACPI_FUNCTION_TRACE ("ns_externalize_name"); 542 ACPI_FUNCTION_TRACE("ns_externalize_name");
603 543
604 544 if (!internal_name_length || !internal_name || !converted_name) {
605 if (!internal_name_length || 545 return_ACPI_STATUS(AE_BAD_PARAMETER);
606 !internal_name ||
607 !converted_name) {
608 return_ACPI_STATUS (AE_BAD_PARAMETER);
609 } 546 }
610 547
611 /* 548 /*
@@ -620,8 +557,7 @@ acpi_ns_externalize_name (
620 for (i = 0; i < internal_name_length; i++) { 557 for (i = 0; i < internal_name_length; i++) {
621 if (internal_name[i] == '^') { 558 if (internal_name[i] == '^') {
622 prefix_length = i + 1; 559 prefix_length = i + 1;
623 } 560 } else {
624 else {
625 break; 561 break;
626 } 562 }
627 } 563 }
@@ -648,7 +584,8 @@ acpi_ns_externalize_name (
648 584
649 names_index = prefix_length + 2; 585 names_index = prefix_length + 2;
650 num_segments = (acpi_native_uint) (u8) 586 num_segments = (acpi_native_uint) (u8)
651 internal_name[(acpi_native_uint) (prefix_length + 1)]; 587 internal_name[(acpi_native_uint)
588 (prefix_length + 1)];
652 break; 589 break;
653 590
654 case AML_DUAL_NAME_PREFIX: 591 case AML_DUAL_NAME_PREFIX:
@@ -683,23 +620,23 @@ acpi_ns_externalize_name (
683 * punctuation ('.') between object names, plus the NULL terminator. 620 * punctuation ('.') between object names, plus the NULL terminator.
684 */ 621 */
685 required_length = prefix_length + (4 * num_segments) + 622 required_length = prefix_length + (4 * num_segments) +
686 ((num_segments > 0) ? (num_segments - 1) : 0) + 1; 623 ((num_segments > 0) ? (num_segments - 1) : 0) + 1;
687 624
688 /* 625 /*
689 * Check to see if we're still in bounds. If not, there's a problem 626 * Check to see if we're still in bounds. If not, there's a problem
690 * with internal_name (invalid format). 627 * with internal_name (invalid format).
691 */ 628 */
692 if (required_length > internal_name_length) { 629 if (required_length > internal_name_length) {
693 ACPI_REPORT_ERROR (("ns_externalize_name: Invalid internal name\n")); 630 ACPI_REPORT_ERROR(("ns_externalize_name: Invalid internal name\n"));
694 return_ACPI_STATUS (AE_BAD_PATHNAME); 631 return_ACPI_STATUS(AE_BAD_PATHNAME);
695 } 632 }
696 633
697 /* 634 /*
698 * Build converted_name 635 * Build converted_name
699 */ 636 */
700 *converted_name = ACPI_MEM_CALLOCATE (required_length); 637 *converted_name = ACPI_MEM_CALLOCATE(required_length);
701 if (!(*converted_name)) { 638 if (!(*converted_name)) {
702 return_ACPI_STATUS (AE_NO_MEMORY); 639 return_ACPI_STATUS(AE_NO_MEMORY);
703 } 640 }
704 641
705 j = 0; 642 j = 0;
@@ -725,10 +662,9 @@ acpi_ns_externalize_name (
725 *converted_name_length = (u32) required_length; 662 *converted_name_length = (u32) required_length;
726 } 663 }
727 664
728 return_ACPI_STATUS (AE_OK); 665 return_ACPI_STATUS(AE_OK);
729} 666}
730 667
731
732/******************************************************************************* 668/*******************************************************************************
733 * 669 *
734 * FUNCTION: acpi_ns_map_handle_to_node 670 * FUNCTION: acpi_ns_map_handle_to_node
@@ -745,13 +681,10 @@ acpi_ns_externalize_name (
745 * 681 *
746 ******************************************************************************/ 682 ******************************************************************************/
747 683
748struct acpi_namespace_node * 684struct acpi_namespace_node *acpi_ns_map_handle_to_node(acpi_handle handle)
749acpi_ns_map_handle_to_node (
750 acpi_handle handle)
751{ 685{
752 686
753 ACPI_FUNCTION_ENTRY (); 687 ACPI_FUNCTION_ENTRY();
754
755 688
756 /* 689 /*
757 * Simple implementation. 690 * Simple implementation.
@@ -766,14 +699,13 @@ acpi_ns_map_handle_to_node (
766 699
767 /* We can at least attempt to verify the handle */ 700 /* We can at least attempt to verify the handle */
768 701
769 if (ACPI_GET_DESCRIPTOR_TYPE (handle) != ACPI_DESC_TYPE_NAMED) { 702 if (ACPI_GET_DESCRIPTOR_TYPE(handle) != ACPI_DESC_TYPE_NAMED) {
770 return (NULL); 703 return (NULL);
771 } 704 }
772 705
773 return ((struct acpi_namespace_node *) handle); 706 return ((struct acpi_namespace_node *)handle);
774} 707}
775 708
776
777/******************************************************************************* 709/*******************************************************************************
778 * 710 *
779 * FUNCTION: acpi_ns_convert_entry_to_handle 711 * FUNCTION: acpi_ns_convert_entry_to_handle
@@ -786,18 +718,14 @@ acpi_ns_map_handle_to_node (
786 * 718 *
787 ******************************************************************************/ 719 ******************************************************************************/
788 720
789acpi_handle 721acpi_handle acpi_ns_convert_entry_to_handle(struct acpi_namespace_node *node)
790acpi_ns_convert_entry_to_handle (
791 struct acpi_namespace_node *node)
792{ 722{
793 723
794
795 /* 724 /*
796 * Simple implementation for now; 725 * Simple implementation for now;
797 */ 726 */
798 return ((acpi_handle) node); 727 return ((acpi_handle) node);
799 728
800
801/* Example future implementation --------------------- 729/* Example future implementation ---------------------
802 730
803 if (!Node) 731 if (!Node)
@@ -810,12 +738,10 @@ acpi_ns_convert_entry_to_handle (
810 return (ACPI_ROOT_OBJECT); 738 return (ACPI_ROOT_OBJECT);
811 } 739 }
812 740
813
814 return ((acpi_handle) Node); 741 return ((acpi_handle) Node);
815------------------------------------------------------*/ 742------------------------------------------------------*/
816} 743}
817 744
818
819/******************************************************************************* 745/*******************************************************************************
820 * 746 *
821 * FUNCTION: acpi_ns_terminate 747 * FUNCTION: acpi_ns_terminate
@@ -828,42 +754,37 @@ acpi_ns_convert_entry_to_handle (
828 * 754 *
829 ******************************************************************************/ 755 ******************************************************************************/
830 756
831void 757void acpi_ns_terminate(void)
832acpi_ns_terminate (
833 void)
834{ 758{
835 union acpi_operand_object *obj_desc; 759 union acpi_operand_object *obj_desc;
836
837
838 ACPI_FUNCTION_TRACE ("ns_terminate");
839 760
761 ACPI_FUNCTION_TRACE("ns_terminate");
840 762
841 /* 763 /*
842 * 1) Free the entire namespace -- all nodes and objects 764 * 1) Free the entire namespace -- all nodes and objects
843 * 765 *
844 * Delete all object descriptors attached to namepsace nodes 766 * Delete all object descriptors attached to namepsace nodes
845 */ 767 */
846 acpi_ns_delete_namespace_subtree (acpi_gbl_root_node); 768 acpi_ns_delete_namespace_subtree(acpi_gbl_root_node);
847 769
848 /* Detach any objects attached to the root */ 770 /* Detach any objects attached to the root */
849 771
850 obj_desc = acpi_ns_get_attached_object (acpi_gbl_root_node); 772 obj_desc = acpi_ns_get_attached_object(acpi_gbl_root_node);
851 if (obj_desc) { 773 if (obj_desc) {
852 acpi_ns_detach_object (acpi_gbl_root_node); 774 acpi_ns_detach_object(acpi_gbl_root_node);
853 } 775 }
854 776
855 ACPI_DEBUG_PRINT ((ACPI_DB_INFO, "Namespace freed\n")); 777 ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Namespace freed\n"));
856 778
857 /* 779 /*
858 * 2) Now we can delete the ACPI tables 780 * 2) Now we can delete the ACPI tables
859 */ 781 */
860 acpi_tb_delete_all_tables (); 782 acpi_tb_delete_all_tables();
861 ACPI_DEBUG_PRINT ((ACPI_DB_INFO, "ACPI Tables freed\n")); 783 ACPI_DEBUG_PRINT((ACPI_DB_INFO, "ACPI Tables freed\n"));
862 784
863 return_VOID; 785 return_VOID;
864} 786}
865 787
866
867/******************************************************************************* 788/*******************************************************************************
868 * 789 *
869 * FUNCTION: acpi_ns_opens_scope 790 * FUNCTION: acpi_ns_opens_scope
@@ -875,24 +796,21 @@ acpi_ns_terminate (
875 * 796 *
876 ******************************************************************************/ 797 ******************************************************************************/
877 798
878u32 799u32 acpi_ns_opens_scope(acpi_object_type type)
879acpi_ns_opens_scope (
880 acpi_object_type type)
881{ 800{
882 ACPI_FUNCTION_TRACE_STR ("ns_opens_scope", acpi_ut_get_type_name (type)); 801 ACPI_FUNCTION_TRACE_STR("ns_opens_scope", acpi_ut_get_type_name(type));
883
884 802
885 if (!acpi_ut_valid_object_type (type)) { 803 if (!acpi_ut_valid_object_type(type)) {
886 /* type code out of range */ 804 /* type code out of range */
887 805
888 ACPI_REPORT_WARNING (("ns_opens_scope: Invalid Object Type %X\n", type)); 806 ACPI_REPORT_WARNING(("ns_opens_scope: Invalid Object Type %X\n",
889 return_VALUE (ACPI_NS_NORMAL); 807 type));
808 return_VALUE(ACPI_NS_NORMAL);
890 } 809 }
891 810
892 return_VALUE (((u32) acpi_gbl_ns_properties[type]) & ACPI_NS_NEWSCOPE); 811 return_VALUE(((u32) acpi_gbl_ns_properties[type]) & ACPI_NS_NEWSCOPE);
893} 812}
894 813
895
896/******************************************************************************* 814/*******************************************************************************
897 * 815 *
898 * FUNCTION: acpi_ns_get_node_by_path 816 * FUNCTION: acpi_ns_get_node_by_path
@@ -916,33 +834,29 @@ acpi_ns_opens_scope (
916 ******************************************************************************/ 834 ******************************************************************************/
917 835
918acpi_status 836acpi_status
919acpi_ns_get_node_by_path ( 837acpi_ns_get_node_by_path(char *pathname,
920 char *pathname, 838 struct acpi_namespace_node *start_node,
921 struct acpi_namespace_node *start_node, 839 u32 flags, struct acpi_namespace_node **return_node)
922 u32 flags,
923 struct acpi_namespace_node **return_node)
924{ 840{
925 union acpi_generic_state scope_info; 841 union acpi_generic_state scope_info;
926 acpi_status status; 842 acpi_status status;
927 char *internal_path = NULL; 843 char *internal_path = NULL;
928
929
930 ACPI_FUNCTION_TRACE_PTR ("ns_get_node_by_path", pathname);
931 844
845 ACPI_FUNCTION_TRACE_PTR("ns_get_node_by_path", pathname);
932 846
933 if (pathname) { 847 if (pathname) {
934 /* Convert path to internal representation */ 848 /* Convert path to internal representation */
935 849
936 status = acpi_ns_internalize_name (pathname, &internal_path); 850 status = acpi_ns_internalize_name(pathname, &internal_path);
937 if (ACPI_FAILURE (status)) { 851 if (ACPI_FAILURE(status)) {
938 return_ACPI_STATUS (status); 852 return_ACPI_STATUS(status);
939 } 853 }
940 } 854 }
941 855
942 /* Must lock namespace during lookup */ 856 /* Must lock namespace during lookup */
943 857
944 status = acpi_ut_acquire_mutex (ACPI_MTX_NAMESPACE); 858 status = acpi_ut_acquire_mutex(ACPI_MTX_NAMESPACE);
945 if (ACPI_FAILURE (status)) { 859 if (ACPI_FAILURE(status)) {
946 goto cleanup; 860 goto cleanup;
947 } 861 }
948 862
@@ -952,25 +866,25 @@ acpi_ns_get_node_by_path (
952 866
953 /* Lookup the name in the namespace */ 867 /* Lookup the name in the namespace */
954 868
955 status = acpi_ns_lookup (&scope_info, internal_path, 869 status = acpi_ns_lookup(&scope_info, internal_path,
956 ACPI_TYPE_ANY, ACPI_IMODE_EXECUTE, 870 ACPI_TYPE_ANY, ACPI_IMODE_EXECUTE,
957 (flags | ACPI_NS_DONT_OPEN_SCOPE), 871 (flags | ACPI_NS_DONT_OPEN_SCOPE),
958 NULL, return_node); 872 NULL, return_node);
959 if (ACPI_FAILURE (status)) { 873 if (ACPI_FAILURE(status)) {
960 ACPI_DEBUG_PRINT ((ACPI_DB_INFO, "%s, %s\n", 874 ACPI_DEBUG_PRINT((ACPI_DB_INFO, "%s, %s\n",
961 internal_path, acpi_format_exception (status))); 875 internal_path,
876 acpi_format_exception(status)));
962 } 877 }
963 878
964 (void) acpi_ut_release_mutex (ACPI_MTX_NAMESPACE); 879 (void)acpi_ut_release_mutex(ACPI_MTX_NAMESPACE);
965 880
966cleanup: 881 cleanup:
967 if (internal_path) { 882 if (internal_path) {
968 ACPI_MEM_FREE (internal_path); 883 ACPI_MEM_FREE(internal_path);
969 } 884 }
970 return_ACPI_STATUS (status); 885 return_ACPI_STATUS(status);
971} 886}
972 887
973
974/******************************************************************************* 888/*******************************************************************************
975 * 889 *
976 * FUNCTION: acpi_ns_get_parent_node 890 * FUNCTION: acpi_ns_get_parent_node
@@ -983,12 +897,10 @@ cleanup:
983 * 897 *
984 ******************************************************************************/ 898 ******************************************************************************/
985 899
986struct acpi_namespace_node * 900struct acpi_namespace_node *acpi_ns_get_parent_node(struct acpi_namespace_node
987acpi_ns_get_parent_node ( 901 *node)
988 struct acpi_namespace_node *node)
989{ 902{
990 ACPI_FUNCTION_ENTRY (); 903 ACPI_FUNCTION_ENTRY();
991
992 904
993 if (!node) { 905 if (!node) {
994 return (NULL); 906 return (NULL);
@@ -1006,7 +918,6 @@ acpi_ns_get_parent_node (
1006 return (node->peer); 918 return (node->peer);
1007} 919}
1008 920
1009
1010/******************************************************************************* 921/*******************************************************************************
1011 * 922 *
1012 * FUNCTION: acpi_ns_get_next_valid_node 923 * FUNCTION: acpi_ns_get_next_valid_node
@@ -1021,9 +932,9 @@ acpi_ns_get_parent_node (
1021 * 932 *
1022 ******************************************************************************/ 933 ******************************************************************************/
1023 934
1024struct acpi_namespace_node * 935struct acpi_namespace_node *acpi_ns_get_next_valid_node(struct
1025acpi_ns_get_next_valid_node ( 936 acpi_namespace_node
1026 struct acpi_namespace_node *node) 937 *node)
1027{ 938{
1028 939
1029 /* If we are at the end of this peer list, return NULL */ 940 /* If we are at the end of this peer list, return NULL */
@@ -1037,7 +948,6 @@ acpi_ns_get_next_valid_node (
1037 return (node->peer); 948 return (node->peer);
1038} 949}
1039 950
1040
1041#ifdef ACPI_OBSOLETE_FUNCTIONS 951#ifdef ACPI_OBSOLETE_FUNCTIONS
1042/******************************************************************************* 952/*******************************************************************************
1043 * 953 *
@@ -1053,38 +963,36 @@ acpi_ns_get_next_valid_node (
1053 * 963 *
1054 ******************************************************************************/ 964 ******************************************************************************/
1055 965
1056acpi_name 966acpi_name acpi_ns_find_parent_name(struct acpi_namespace_node * child_node)
1057acpi_ns_find_parent_name (
1058 struct acpi_namespace_node *child_node)
1059{ 967{
1060 struct acpi_namespace_node *parent_node; 968 struct acpi_namespace_node *parent_node;
1061
1062
1063 ACPI_FUNCTION_TRACE ("ns_find_parent_name");
1064 969
970 ACPI_FUNCTION_TRACE("ns_find_parent_name");
1065 971
1066 if (child_node) { 972 if (child_node) {
1067 /* Valid entry. Get the parent Node */ 973 /* Valid entry. Get the parent Node */
1068 974
1069 parent_node = acpi_ns_get_parent_node (child_node); 975 parent_node = acpi_ns_get_parent_node(child_node);
1070 if (parent_node) { 976 if (parent_node) {
1071 ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, 977 ACPI_DEBUG_PRINT((ACPI_DB_EXEC,
1072 "Parent of %p [%4.4s] is %p [%4.4s]\n", 978 "Parent of %p [%4.4s] is %p [%4.4s]\n",
1073 child_node, acpi_ut_get_node_name (child_node), 979 child_node,
1074 parent_node, acpi_ut_get_node_name (parent_node))); 980 acpi_ut_get_node_name(child_node),
981 parent_node,
982 acpi_ut_get_node_name(parent_node)));
1075 983
1076 if (parent_node->name.integer) { 984 if (parent_node->name.integer) {
1077 return_VALUE ((acpi_name) parent_node->name.integer); 985 return_VALUE((acpi_name) parent_node->name.
986 integer);
1078 } 987 }
1079 } 988 }
1080 989
1081 ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, 990 ACPI_DEBUG_PRINT((ACPI_DB_EXEC,
1082 "Unable to find parent of %p (%4.4s)\n", 991 "Unable to find parent of %p (%4.4s)\n",
1083 child_node, acpi_ut_get_node_name (child_node))); 992 child_node,
993 acpi_ut_get_node_name(child_node)));
1084 } 994 }
1085 995
1086 return_VALUE (ACPI_UNKNOWN_NAME); 996 return_VALUE(ACPI_UNKNOWN_NAME);
1087} 997}
1088#endif 998#endif
1089
1090
diff --git a/drivers/acpi/namespace/nswalk.c b/drivers/acpi/namespace/nswalk.c
index f9a7277dca6e..5f164c0df33b 100644
--- a/drivers/acpi/namespace/nswalk.c
+++ b/drivers/acpi/namespace/nswalk.c
@@ -41,14 +41,11 @@
41 * POSSIBILITY OF SUCH DAMAGES. 41 * POSSIBILITY OF SUCH DAMAGES.
42 */ 42 */
43 43
44
45#include <acpi/acpi.h> 44#include <acpi/acpi.h>
46#include <acpi/acnamesp.h> 45#include <acpi/acnamesp.h>
47 46
48
49#define _COMPONENT ACPI_NAMESPACE 47#define _COMPONENT ACPI_NAMESPACE
50 ACPI_MODULE_NAME ("nswalk") 48ACPI_MODULE_NAME("nswalk")
51
52 49
53/******************************************************************************* 50/*******************************************************************************
54 * 51 *
@@ -68,18 +65,15 @@
68 * within Scope is returned. 65 * within Scope is returned.
69 * 66 *
70 ******************************************************************************/ 67 ******************************************************************************/
71 68struct acpi_namespace_node *acpi_ns_get_next_node(acpi_object_type type,
72struct acpi_namespace_node * 69 struct acpi_namespace_node
73acpi_ns_get_next_node ( 70 *parent_node,
74 acpi_object_type type, 71 struct acpi_namespace_node
75 struct acpi_namespace_node *parent_node, 72 *child_node)
76 struct acpi_namespace_node *child_node)
77{ 73{
78 struct acpi_namespace_node *next_node = NULL; 74 struct acpi_namespace_node *next_node = NULL;
79
80
81 ACPI_FUNCTION_ENTRY ();
82 75
76 ACPI_FUNCTION_ENTRY();
83 77
84 if (!child_node) { 78 if (!child_node) {
85 /* It's really the parent's _scope_ that we want */ 79 /* It's really the parent's _scope_ that we want */
@@ -92,7 +86,7 @@ acpi_ns_get_next_node (
92 else { 86 else {
93 /* Start search at the NEXT node */ 87 /* Start search at the NEXT node */
94 88
95 next_node = acpi_ns_get_next_valid_node (child_node); 89 next_node = acpi_ns_get_next_valid_node(child_node);
96 } 90 }
97 91
98 /* If any type is OK, we are done */ 92 /* If any type is OK, we are done */
@@ -114,7 +108,7 @@ acpi_ns_get_next_node (
114 108
115 /* Otherwise, move on to the next node */ 109 /* Otherwise, move on to the next node */
116 110
117 next_node = acpi_ns_get_next_valid_node (next_node); 111 next_node = acpi_ns_get_next_valid_node(next_node);
118 } 112 }
119 113
120 /* Not found */ 114 /* Not found */
@@ -122,7 +116,6 @@ acpi_ns_get_next_node (
122 return (NULL); 116 return (NULL);
123} 117}
124 118
125
126/******************************************************************************* 119/*******************************************************************************
127 * 120 *
128 * FUNCTION: acpi_ns_walk_namespace 121 * FUNCTION: acpi_ns_walk_namespace
@@ -154,25 +147,21 @@ acpi_ns_get_next_node (
154 ******************************************************************************/ 147 ******************************************************************************/
155 148
156acpi_status 149acpi_status
157acpi_ns_walk_namespace ( 150acpi_ns_walk_namespace(acpi_object_type type,
158 acpi_object_type type, 151 acpi_handle start_node,
159 acpi_handle start_node, 152 u32 max_depth,
160 u32 max_depth, 153 u8 unlock_before_callback,
161 u8 unlock_before_callback, 154 acpi_walk_callback user_function,
162 acpi_walk_callback user_function, 155 void *context, void **return_value)
163 void *context,
164 void **return_value)
165{ 156{
166 acpi_status status; 157 acpi_status status;
167 acpi_status mutex_status; 158 acpi_status mutex_status;
168 struct acpi_namespace_node *child_node; 159 struct acpi_namespace_node *child_node;
169 struct acpi_namespace_node *parent_node; 160 struct acpi_namespace_node *parent_node;
170 acpi_object_type child_type; 161 acpi_object_type child_type;
171 u32 level; 162 u32 level;
172
173
174 ACPI_FUNCTION_TRACE ("ns_walk_namespace");
175 163
164 ACPI_FUNCTION_TRACE("ns_walk_namespace");
176 165
177 /* Special case for the namespace Root Node */ 166 /* Special case for the namespace Root Node */
178 167
@@ -183,9 +172,9 @@ acpi_ns_walk_namespace (
183 /* Null child means "get first node" */ 172 /* Null child means "get first node" */
184 173
185 parent_node = start_node; 174 parent_node = start_node;
186 child_node = NULL; 175 child_node = NULL;
187 child_type = ACPI_TYPE_ANY; 176 child_type = ACPI_TYPE_ANY;
188 level = 1; 177 level = 1;
189 178
190 /* 179 /*
191 * Traverse the tree of nodes until we bubble back up to where we 180 * Traverse the tree of nodes until we bubble back up to where we
@@ -196,7 +185,9 @@ acpi_ns_walk_namespace (
196 /* Get the next node in this scope. Null if not found */ 185 /* Get the next node in this scope. Null if not found */
197 186
198 status = AE_OK; 187 status = AE_OK;
199 child_node = acpi_ns_get_next_node (ACPI_TYPE_ANY, parent_node, child_node); 188 child_node =
189 acpi_ns_get_next_node(ACPI_TYPE_ANY, parent_node,
190 child_node);
200 if (child_node) { 191 if (child_node) {
201 /* 192 /*
202 * Found node, Get the type if we are not 193 * Found node, Get the type if we are not
@@ -212,19 +203,25 @@ acpi_ns_walk_namespace (
212 * callback function 203 * callback function
213 */ 204 */
214 if (unlock_before_callback) { 205 if (unlock_before_callback) {
215 mutex_status = acpi_ut_release_mutex (ACPI_MTX_NAMESPACE); 206 mutex_status =
216 if (ACPI_FAILURE (mutex_status)) { 207 acpi_ut_release_mutex
217 return_ACPI_STATUS (mutex_status); 208 (ACPI_MTX_NAMESPACE);
209 if (ACPI_FAILURE(mutex_status)) {
210 return_ACPI_STATUS
211 (mutex_status);
218 } 212 }
219 } 213 }
220 214
221 status = user_function (child_node, level, 215 status = user_function(child_node, level,
222 context, return_value); 216 context, return_value);
223 217
224 if (unlock_before_callback) { 218 if (unlock_before_callback) {
225 mutex_status = acpi_ut_acquire_mutex (ACPI_MTX_NAMESPACE); 219 mutex_status =
226 if (ACPI_FAILURE (mutex_status)) { 220 acpi_ut_acquire_mutex
227 return_ACPI_STATUS (mutex_status); 221 (ACPI_MTX_NAMESPACE);
222 if (ACPI_FAILURE(mutex_status)) {
223 return_ACPI_STATUS
224 (mutex_status);
228 } 225 }
229 } 226 }
230 227
@@ -239,13 +236,13 @@ acpi_ns_walk_namespace (
239 236
240 /* Exit now, with OK status */ 237 /* Exit now, with OK status */
241 238
242 return_ACPI_STATUS (AE_OK); 239 return_ACPI_STATUS(AE_OK);
243 240
244 default: 241 default:
245 242
246 /* All others are valid exceptions */ 243 /* All others are valid exceptions */
247 244
248 return_ACPI_STATUS (status); 245 return_ACPI_STATUS(status);
249 } 246 }
250 } 247 }
251 248
@@ -258,7 +255,8 @@ acpi_ns_walk_namespace (
258 * maximum depth has been reached. 255 * maximum depth has been reached.
259 */ 256 */
260 if ((level < max_depth) && (status != AE_CTRL_DEPTH)) { 257 if ((level < max_depth) && (status != AE_CTRL_DEPTH)) {
261 if (acpi_ns_get_next_node (ACPI_TYPE_ANY, child_node, NULL)) { 258 if (acpi_ns_get_next_node
259 (ACPI_TYPE_ANY, child_node, NULL)) {
262 /* 260 /*
263 * There is at least one child of this 261 * There is at least one child of this
264 * node, visit the onde 262 * node, visit the onde
@@ -268,8 +266,7 @@ acpi_ns_walk_namespace (
268 child_node = NULL; 266 child_node = NULL;
269 } 267 }
270 } 268 }
271 } 269 } else {
272 else {
273 /* 270 /*
274 * No more children of this node (acpi_ns_get_next_node 271 * No more children of this node (acpi_ns_get_next_node
275 * failed), go back upwards in the namespace tree to 272 * failed), go back upwards in the namespace tree to
@@ -277,13 +274,11 @@ acpi_ns_walk_namespace (
277 */ 274 */
278 level--; 275 level--;
279 child_node = parent_node; 276 child_node = parent_node;
280 parent_node = acpi_ns_get_parent_node (parent_node); 277 parent_node = acpi_ns_get_parent_node(parent_node);
281 } 278 }
282 } 279 }
283 280
284 /* Complete walk, not terminated by user function */ 281 /* Complete walk, not terminated by user function */
285 282
286 return_ACPI_STATUS (AE_OK); 283 return_ACPI_STATUS(AE_OK);
287} 284}
288
289
diff --git a/drivers/acpi/namespace/nsxfeval.c b/drivers/acpi/namespace/nsxfeval.c
index 12ea202257fa..c07b046659ff 100644
--- a/drivers/acpi/namespace/nsxfeval.c
+++ b/drivers/acpi/namespace/nsxfeval.c
@@ -48,10 +48,8 @@
48#include <acpi/acnamesp.h> 48#include <acpi/acnamesp.h>
49#include <acpi/acinterp.h> 49#include <acpi/acinterp.h>
50 50
51
52#define _COMPONENT ACPI_NAMESPACE 51#define _COMPONENT ACPI_NAMESPACE
53 ACPI_MODULE_NAME ("nsxfeval") 52ACPI_MODULE_NAME("nsxfeval")
54
55 53
56/******************************************************************************* 54/*******************************************************************************
57 * 55 *
@@ -73,27 +71,23 @@
73 * be valid (non-null) 71 * be valid (non-null)
74 * 72 *
75 ******************************************************************************/ 73 ******************************************************************************/
76
77#ifdef ACPI_FUTURE_USAGE 74#ifdef ACPI_FUTURE_USAGE
78acpi_status 75acpi_status
79acpi_evaluate_object_typed ( 76acpi_evaluate_object_typed(acpi_handle handle,
80 acpi_handle handle, 77 acpi_string pathname,
81 acpi_string pathname, 78 struct acpi_object_list *external_params,
82 struct acpi_object_list *external_params, 79 struct acpi_buffer *return_buffer,
83 struct acpi_buffer *return_buffer, 80 acpi_object_type return_type)
84 acpi_object_type return_type)
85{ 81{
86 acpi_status status; 82 acpi_status status;
87 u8 must_free = FALSE; 83 u8 must_free = FALSE;
88
89
90 ACPI_FUNCTION_TRACE ("acpi_evaluate_object_typed");
91 84
85 ACPI_FUNCTION_TRACE("acpi_evaluate_object_typed");
92 86
93 /* Return buffer must be valid */ 87 /* Return buffer must be valid */
94 88
95 if (!return_buffer) { 89 if (!return_buffer) {
96 return_ACPI_STATUS (AE_BAD_PARAMETER); 90 return_ACPI_STATUS(AE_BAD_PARAMETER);
97 } 91 }
98 92
99 if (return_buffer->length == ACPI_ALLOCATE_BUFFER) { 93 if (return_buffer->length == ACPI_ALLOCATE_BUFFER) {
@@ -102,51 +96,52 @@ acpi_evaluate_object_typed (
102 96
103 /* Evaluate the object */ 97 /* Evaluate the object */
104 98
105 status = acpi_evaluate_object (handle, pathname, external_params, return_buffer); 99 status =
106 if (ACPI_FAILURE (status)) { 100 acpi_evaluate_object(handle, pathname, external_params,
107 return_ACPI_STATUS (status); 101 return_buffer);
102 if (ACPI_FAILURE(status)) {
103 return_ACPI_STATUS(status);
108 } 104 }
109 105
110 /* Type ANY means "don't care" */ 106 /* Type ANY means "don't care" */
111 107
112 if (return_type == ACPI_TYPE_ANY) { 108 if (return_type == ACPI_TYPE_ANY) {
113 return_ACPI_STATUS (AE_OK); 109 return_ACPI_STATUS(AE_OK);
114 } 110 }
115 111
116 if (return_buffer->length == 0) { 112 if (return_buffer->length == 0) {
117 /* Error because caller specifically asked for a return value */ 113 /* Error because caller specifically asked for a return value */
118 114
119 ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, 115 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, "No return value\n"));
120 "No return value\n"));
121 116
122 return_ACPI_STATUS (AE_NULL_OBJECT); 117 return_ACPI_STATUS(AE_NULL_OBJECT);
123 } 118 }
124 119
125 /* Examine the object type returned from evaluate_object */ 120 /* Examine the object type returned from evaluate_object */
126 121
127 if (((union acpi_object *) return_buffer->pointer)->type == return_type) { 122 if (((union acpi_object *)return_buffer->pointer)->type == return_type) {
128 return_ACPI_STATUS (AE_OK); 123 return_ACPI_STATUS(AE_OK);
129 } 124 }
130 125
131 /* Return object type does not match requested type */ 126 /* Return object type does not match requested type */
132 127
133 ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, 128 ACPI_DEBUG_PRINT((ACPI_DB_ERROR,
134 "Incorrect return type [%s] requested [%s]\n", 129 "Incorrect return type [%s] requested [%s]\n",
135 acpi_ut_get_type_name (((union acpi_object *) return_buffer->pointer)->type), 130 acpi_ut_get_type_name(((union acpi_object *)
136 acpi_ut_get_type_name (return_type))); 131 return_buffer->pointer)->type),
132 acpi_ut_get_type_name(return_type)));
137 133
138 if (must_free) { 134 if (must_free) {
139 /* Caller used ACPI_ALLOCATE_BUFFER, free the return buffer */ 135 /* Caller used ACPI_ALLOCATE_BUFFER, free the return buffer */
140 136
141 acpi_os_free (return_buffer->pointer); 137 acpi_os_free(return_buffer->pointer);
142 return_buffer->pointer = NULL; 138 return_buffer->pointer = NULL;
143 } 139 }
144 140
145 return_buffer->length = 0; 141 return_buffer->length = 0;
146 return_ACPI_STATUS (AE_TYPE); 142 return_ACPI_STATUS(AE_TYPE);
147} 143}
148#endif /* ACPI_FUTURE_USAGE */ 144#endif /* ACPI_FUTURE_USAGE */
149
150 145
151/******************************************************************************* 146/*******************************************************************************
152 * 147 *
@@ -169,21 +164,18 @@ acpi_evaluate_object_typed (
169 ******************************************************************************/ 164 ******************************************************************************/
170 165
171acpi_status 166acpi_status
172acpi_evaluate_object ( 167acpi_evaluate_object(acpi_handle handle,
173 acpi_handle handle, 168 acpi_string pathname,
174 acpi_string pathname, 169 struct acpi_object_list *external_params,
175 struct acpi_object_list *external_params, 170 struct acpi_buffer *return_buffer)
176 struct acpi_buffer *return_buffer)
177{ 171{
178 acpi_status status; 172 acpi_status status;
179 acpi_status status2; 173 acpi_status status2;
180 struct acpi_parameter_info info; 174 struct acpi_parameter_info info;
181 acpi_size buffer_space_needed; 175 acpi_size buffer_space_needed;
182 u32 i; 176 u32 i;
183
184
185 ACPI_FUNCTION_TRACE ("acpi_evaluate_object");
186 177
178 ACPI_FUNCTION_TRACE("acpi_evaluate_object");
187 179
188 info.node = handle; 180 info.node = handle;
189 info.parameters = NULL; 181 info.parameters = NULL;
@@ -200,11 +192,11 @@ acpi_evaluate_object (
200 * Allocate a new parameter block for the internal objects 192 * Allocate a new parameter block for the internal objects
201 * Add 1 to count to allow for null terminated internal list 193 * Add 1 to count to allow for null terminated internal list
202 */ 194 */
203 info.parameters = ACPI_MEM_CALLOCATE ( 195 info.parameters = ACPI_MEM_CALLOCATE(((acpi_size)
204 ((acpi_size) external_params->count + 1) * 196 external_params->count +
205 sizeof (void *)); 197 1) * sizeof(void *));
206 if (!info.parameters) { 198 if (!info.parameters) {
207 return_ACPI_STATUS (AE_NO_MEMORY); 199 return_ACPI_STATUS(AE_NO_MEMORY);
208 } 200 }
209 201
210 /* 202 /*
@@ -212,48 +204,47 @@ acpi_evaluate_object (
212 * internal object 204 * internal object
213 */ 205 */
214 for (i = 0; i < external_params->count; i++) { 206 for (i = 0; i < external_params->count; i++) {
215 status = acpi_ut_copy_eobject_to_iobject (&external_params->pointer[i], 207 status =
216 &info.parameters[i]); 208 acpi_ut_copy_eobject_to_iobject(&external_params->
217 if (ACPI_FAILURE (status)) { 209 pointer[i],
218 acpi_ut_delete_internal_object_list (info.parameters); 210 &info.
219 return_ACPI_STATUS (status); 211 parameters[i]);
212 if (ACPI_FAILURE(status)) {
213 acpi_ut_delete_internal_object_list(info.
214 parameters);
215 return_ACPI_STATUS(status);
220 } 216 }
221 } 217 }
222 info.parameters[external_params->count] = NULL; 218 info.parameters[external_params->count] = NULL;
223 } 219 }
224 220
225
226 /* 221 /*
227 * Three major cases: 222 * Three major cases:
228 * 1) Fully qualified pathname 223 * 1) Fully qualified pathname
229 * 2) No handle, not fully qualified pathname (error) 224 * 2) No handle, not fully qualified pathname (error)
230 * 3) Valid handle 225 * 3) Valid handle
231 */ 226 */
232 if ((pathname) && 227 if ((pathname) && (acpi_ns_valid_root_prefix(pathname[0]))) {
233 (acpi_ns_valid_root_prefix (pathname[0]))) {
234 /* 228 /*
235 * The path is fully qualified, just evaluate by name 229 * The path is fully qualified, just evaluate by name
236 */ 230 */
237 status = acpi_ns_evaluate_by_name (pathname, &info); 231 status = acpi_ns_evaluate_by_name(pathname, &info);
238 } 232 } else if (!handle) {
239 else if (!handle) {
240 /* 233 /*
241 * A handle is optional iff a fully qualified pathname 234 * A handle is optional iff a fully qualified pathname
242 * is specified. Since we've already handled fully 235 * is specified. Since we've already handled fully
243 * qualified names above, this is an error 236 * qualified names above, this is an error
244 */ 237 */
245 if (!pathname) { 238 if (!pathname) {
246 ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, 239 ACPI_DEBUG_PRINT((ACPI_DB_ERROR,
247 "Both Handle and Pathname are NULL\n")); 240 "Both Handle and Pathname are NULL\n"));
248 } 241 } else {
249 else { 242 ACPI_DEBUG_PRINT((ACPI_DB_ERROR,
250 ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, 243 "Handle is NULL and Pathname is relative\n"));
251 "Handle is NULL and Pathname is relative\n"));
252 } 244 }
253 245
254 status = AE_BAD_PARAMETER; 246 status = AE_BAD_PARAMETER;
255 } 247 } else {
256 else {
257 /* 248 /*
258 * We get here if we have a handle -- and if we have a 249 * We get here if we have a handle -- and if we have a
259 * pathname it is relative. The handle will be validated 250 * pathname it is relative. The handle will be validated
@@ -264,17 +255,15 @@ acpi_evaluate_object (
264 * The null pathname case means the handle is for 255 * The null pathname case means the handle is for
265 * the actual object to be evaluated 256 * the actual object to be evaluated
266 */ 257 */
267 status = acpi_ns_evaluate_by_handle (&info); 258 status = acpi_ns_evaluate_by_handle(&info);
268 } 259 } else {
269 else { 260 /*
270 /* 261 * Both a Handle and a relative Pathname
271 * Both a Handle and a relative Pathname 262 */
272 */ 263 status = acpi_ns_evaluate_relative(pathname, &info);
273 status = acpi_ns_evaluate_relative (pathname, &info);
274 } 264 }
275 } 265 }
276 266
277
278 /* 267 /*
279 * If we are expecting a return value, and all went well above, 268 * If we are expecting a return value, and all went well above,
280 * copy the return value to an external object. 269 * copy the return value to an external object.
@@ -282,9 +271,9 @@ acpi_evaluate_object (
282 if (return_buffer) { 271 if (return_buffer) {
283 if (!info.return_object) { 272 if (!info.return_object) {
284 return_buffer->length = 0; 273 return_buffer->length = 0;
285 } 274 } else {
286 else { 275 if (ACPI_GET_DESCRIPTOR_TYPE(info.return_object) ==
287 if (ACPI_GET_DESCRIPTOR_TYPE (info.return_object) == ACPI_DESC_TYPE_NAMED) { 276 ACPI_DESC_TYPE_NAMED) {
288 /* 277 /*
289 * If we received a NS Node as a return object, this means that 278 * If we received a NS Node as a return object, this means that
290 * the object we are evaluating has nothing interesting to 279 * the object we are evaluating has nothing interesting to
@@ -294,37 +283,43 @@ acpi_evaluate_object (
294 * support for various types at a later date if necessary. 283 * support for various types at a later date if necessary.
295 */ 284 */
296 status = AE_TYPE; 285 status = AE_TYPE;
297 info.return_object = NULL; /* No need to delete a NS Node */ 286 info.return_object = NULL; /* No need to delete a NS Node */
298 return_buffer->length = 0; 287 return_buffer->length = 0;
299 } 288 }
300 289
301 if (ACPI_SUCCESS (status)) { 290 if (ACPI_SUCCESS(status)) {
302 /* 291 /*
303 * Find out how large a buffer is needed 292 * Find out how large a buffer is needed
304 * to contain the returned object 293 * to contain the returned object
305 */ 294 */
306 status = acpi_ut_get_object_size (info.return_object, 295 status =
307 &buffer_space_needed); 296 acpi_ut_get_object_size(info.return_object,
308 if (ACPI_SUCCESS (status)) { 297 &buffer_space_needed);
298 if (ACPI_SUCCESS(status)) {
309 /* Validate/Allocate/Clear caller buffer */ 299 /* Validate/Allocate/Clear caller buffer */
310 300
311 status = acpi_ut_initialize_buffer (return_buffer, 301 status =
312 buffer_space_needed); 302 acpi_ut_initialize_buffer
313 if (ACPI_FAILURE (status)) { 303 (return_buffer,
304 buffer_space_needed);
305 if (ACPI_FAILURE(status)) {
314 /* 306 /*
315 * Caller's buffer is too small or a new one can't be allocated 307 * Caller's buffer is too small or a new one can't be allocated
316 */ 308 */
317 ACPI_DEBUG_PRINT ((ACPI_DB_INFO, 309 ACPI_DEBUG_PRINT((ACPI_DB_INFO,
318 "Needed buffer size %X, %s\n", 310 "Needed buffer size %X, %s\n",
319 (u32) buffer_space_needed, 311 (u32)
320 acpi_format_exception (status))); 312 buffer_space_needed,
321 } 313 acpi_format_exception
322 else { 314 (status)));
315 } else {
323 /* 316 /*
324 * We have enough space for the object, build it 317 * We have enough space for the object, build it
325 */ 318 */
326 status = acpi_ut_copy_iobject_to_eobject (info.return_object, 319 status =
327 return_buffer); 320 acpi_ut_copy_iobject_to_eobject
321 (info.return_object,
322 return_buffer);
328 } 323 }
329 } 324 }
330 } 325 }
@@ -336,14 +331,14 @@ acpi_evaluate_object (
336 * Delete the internal return object. NOTE: Interpreter 331 * Delete the internal return object. NOTE: Interpreter
337 * must be locked to avoid race condition. 332 * must be locked to avoid race condition.
338 */ 333 */
339 status2 = acpi_ex_enter_interpreter (); 334 status2 = acpi_ex_enter_interpreter();
340 if (ACPI_SUCCESS (status2)) { 335 if (ACPI_SUCCESS(status2)) {
341 /* 336 /*
342 * Delete the internal return object. (Or at least 337 * Delete the internal return object. (Or at least
343 * decrement the reference count by one) 338 * decrement the reference count by one)
344 */ 339 */
345 acpi_ut_remove_reference (info.return_object); 340 acpi_ut_remove_reference(info.return_object);
346 acpi_ex_exit_interpreter (); 341 acpi_ex_exit_interpreter();
347 } 342 }
348 } 343 }
349 344
@@ -353,13 +348,13 @@ acpi_evaluate_object (
353 if (info.parameters) { 348 if (info.parameters) {
354 /* Free the allocated parameter block */ 349 /* Free the allocated parameter block */
355 350
356 acpi_ut_delete_internal_object_list (info.parameters); 351 acpi_ut_delete_internal_object_list(info.parameters);
357 } 352 }
358 353
359 return_ACPI_STATUS (status); 354 return_ACPI_STATUS(status);
360} 355}
361EXPORT_SYMBOL(acpi_evaluate_object);
362 356
357EXPORT_SYMBOL(acpi_evaluate_object);
363 358
364/******************************************************************************* 359/*******************************************************************************
365 * 360 *
@@ -392,26 +387,20 @@ EXPORT_SYMBOL(acpi_evaluate_object);
392 ******************************************************************************/ 387 ******************************************************************************/
393 388
394acpi_status 389acpi_status
395acpi_walk_namespace ( 390acpi_walk_namespace(acpi_object_type type,
396 acpi_object_type type, 391 acpi_handle start_object,
397 acpi_handle start_object, 392 u32 max_depth,
398 u32 max_depth, 393 acpi_walk_callback user_function,
399 acpi_walk_callback user_function, 394 void *context, void **return_value)
400 void *context,
401 void **return_value)
402{ 395{
403 acpi_status status; 396 acpi_status status;
404
405
406 ACPI_FUNCTION_TRACE ("acpi_walk_namespace");
407 397
398 ACPI_FUNCTION_TRACE("acpi_walk_namespace");
408 399
409 /* Parameter validation */ 400 /* Parameter validation */
410 401
411 if ((type > ACPI_TYPE_EXTERNAL_MAX) || 402 if ((type > ACPI_TYPE_EXTERNAL_MAX) || (!max_depth) || (!user_function)) {
412 (!max_depth) || 403 return_ACPI_STATUS(AE_BAD_PARAMETER);
413 (!user_function)) {
414 return_ACPI_STATUS (AE_BAD_PARAMETER);
415 } 404 }
416 405
417 /* 406 /*
@@ -420,20 +409,20 @@ acpi_walk_namespace (
420 * to the user function - since this function 409 * to the user function - since this function
421 * must be allowed to make Acpi calls itself. 410 * must be allowed to make Acpi calls itself.
422 */ 411 */
423 status = acpi_ut_acquire_mutex (ACPI_MTX_NAMESPACE); 412 status = acpi_ut_acquire_mutex(ACPI_MTX_NAMESPACE);
424 if (ACPI_FAILURE (status)) { 413 if (ACPI_FAILURE(status)) {
425 return_ACPI_STATUS (status); 414 return_ACPI_STATUS(status);
426 } 415 }
427 416
428 status = acpi_ns_walk_namespace (type, start_object, max_depth, 417 status = acpi_ns_walk_namespace(type, start_object, max_depth,
429 ACPI_NS_WALK_UNLOCK, 418 ACPI_NS_WALK_UNLOCK,
430 user_function, context, return_value); 419 user_function, context, return_value);
431 420
432 (void) acpi_ut_release_mutex (ACPI_MTX_NAMESPACE); 421 (void)acpi_ut_release_mutex(ACPI_MTX_NAMESPACE);
433 return_ACPI_STATUS (status); 422 return_ACPI_STATUS(status);
434} 423}
435EXPORT_SYMBOL(acpi_walk_namespace);
436 424
425EXPORT_SYMBOL(acpi_walk_namespace);
437 426
438/******************************************************************************* 427/*******************************************************************************
439 * 428 *
@@ -450,29 +439,26 @@ EXPORT_SYMBOL(acpi_walk_namespace);
450 ******************************************************************************/ 439 ******************************************************************************/
451 440
452static acpi_status 441static acpi_status
453acpi_ns_get_device_callback ( 442acpi_ns_get_device_callback(acpi_handle obj_handle,
454 acpi_handle obj_handle, 443 u32 nesting_level,
455 u32 nesting_level, 444 void *context, void **return_value)
456 void *context,
457 void **return_value)
458{ 445{
459 struct acpi_get_devices_info *info = context; 446 struct acpi_get_devices_info *info = context;
460 acpi_status status; 447 acpi_status status;
461 struct acpi_namespace_node *node; 448 struct acpi_namespace_node *node;
462 u32 flags; 449 u32 flags;
463 struct acpi_device_id hid; 450 struct acpi_device_id hid;
464 struct acpi_compatible_id_list *cid; 451 struct acpi_compatible_id_list *cid;
465 acpi_native_uint i; 452 acpi_native_uint i;
466
467 453
468 status = acpi_ut_acquire_mutex (ACPI_MTX_NAMESPACE); 454 status = acpi_ut_acquire_mutex(ACPI_MTX_NAMESPACE);
469 if (ACPI_FAILURE (status)) { 455 if (ACPI_FAILURE(status)) {
470 return (status); 456 return (status);
471 } 457 }
472 458
473 node = acpi_ns_map_handle_to_node (obj_handle); 459 node = acpi_ns_map_handle_to_node(obj_handle);
474 status = acpi_ut_release_mutex (ACPI_MTX_NAMESPACE); 460 status = acpi_ut_release_mutex(ACPI_MTX_NAMESPACE);
475 if (ACPI_FAILURE (status)) { 461 if (ACPI_FAILURE(status)) {
476 return (status); 462 return (status);
477 } 463 }
478 464
@@ -482,8 +468,8 @@ acpi_ns_get_device_callback (
482 468
483 /* Run _STA to determine if device is present */ 469 /* Run _STA to determine if device is present */
484 470
485 status = acpi_ut_execute_STA (node, &flags); 471 status = acpi_ut_execute_STA(node, &flags);
486 if (ACPI_FAILURE (status)) { 472 if (ACPI_FAILURE(status)) {
487 return (AE_CTRL_DEPTH); 473 return (AE_CTRL_DEPTH);
488 } 474 }
489 475
@@ -496,44 +482,43 @@ acpi_ns_get_device_callback (
496 /* Filter based on device HID & CID */ 482 /* Filter based on device HID & CID */
497 483
498 if (info->hid != NULL) { 484 if (info->hid != NULL) {
499 status = acpi_ut_execute_HID (node, &hid); 485 status = acpi_ut_execute_HID(node, &hid);
500 if (status == AE_NOT_FOUND) { 486 if (status == AE_NOT_FOUND) {
501 return (AE_OK); 487 return (AE_OK);
502 } 488 } else if (ACPI_FAILURE(status)) {
503 else if (ACPI_FAILURE (status)) {
504 return (AE_CTRL_DEPTH); 489 return (AE_CTRL_DEPTH);
505 } 490 }
506 491
507 if (ACPI_STRNCMP (hid.value, info->hid, sizeof (hid.value)) != 0) { 492 if (ACPI_STRNCMP(hid.value, info->hid, sizeof(hid.value)) != 0) {
508 /* Get the list of Compatible IDs */ 493 /* Get the list of Compatible IDs */
509 494
510 status = acpi_ut_execute_CID (node, &cid); 495 status = acpi_ut_execute_CID(node, &cid);
511 if (status == AE_NOT_FOUND) { 496 if (status == AE_NOT_FOUND) {
512 return (AE_OK); 497 return (AE_OK);
513 } 498 } else if (ACPI_FAILURE(status)) {
514 else if (ACPI_FAILURE (status)) {
515 return (AE_CTRL_DEPTH); 499 return (AE_CTRL_DEPTH);
516 } 500 }
517 501
518 /* Walk the CID list */ 502 /* Walk the CID list */
519 503
520 for (i = 0; i < cid->count; i++) { 504 for (i = 0; i < cid->count; i++) {
521 if (ACPI_STRNCMP (cid->id[i].value, info->hid, 505 if (ACPI_STRNCMP(cid->id[i].value, info->hid,
522 sizeof (struct acpi_compatible_id)) != 0) { 506 sizeof(struct
523 ACPI_MEM_FREE (cid); 507 acpi_compatible_id)) !=
508 0) {
509 ACPI_MEM_FREE(cid);
524 return (AE_OK); 510 return (AE_OK);
525 } 511 }
526 } 512 }
527 ACPI_MEM_FREE (cid); 513 ACPI_MEM_FREE(cid);
528 } 514 }
529 } 515 }
530 516
531 status = info->user_function (obj_handle, nesting_level, info->context, 517 status = info->user_function(obj_handle, nesting_level, info->context,
532 return_value); 518 return_value);
533 return (status); 519 return (status);
534} 520}
535 521
536
537/******************************************************************************* 522/*******************************************************************************
538 * 523 *
539 * FUNCTION: acpi_get_devices 524 * FUNCTION: acpi_get_devices
@@ -560,32 +545,28 @@ acpi_ns_get_device_callback (
560 ******************************************************************************/ 545 ******************************************************************************/
561 546
562acpi_status 547acpi_status
563acpi_get_devices ( 548acpi_get_devices(char *HID,
564 char *HID, 549 acpi_walk_callback user_function,
565 acpi_walk_callback user_function, 550 void *context, void **return_value)
566 void *context,
567 void **return_value)
568{ 551{
569 acpi_status status; 552 acpi_status status;
570 struct acpi_get_devices_info info; 553 struct acpi_get_devices_info info;
571
572
573 ACPI_FUNCTION_TRACE ("acpi_get_devices");
574 554
555 ACPI_FUNCTION_TRACE("acpi_get_devices");
575 556
576 /* Parameter validation */ 557 /* Parameter validation */
577 558
578 if (!user_function) { 559 if (!user_function) {
579 return_ACPI_STATUS (AE_BAD_PARAMETER); 560 return_ACPI_STATUS(AE_BAD_PARAMETER);
580 } 561 }
581 562
582 /* 563 /*
583 * We're going to call their callback from OUR callback, so we need 564 * We're going to call their callback from OUR callback, so we need
584 * to know what it is, and their context parameter. 565 * to know what it is, and their context parameter.
585 */ 566 */
586 info.context = context; 567 info.context = context;
587 info.user_function = user_function; 568 info.user_function = user_function;
588 info.hid = HID; 569 info.hid = HID;
589 570
590 /* 571 /*
591 * Lock the namespace around the walk. 572 * Lock the namespace around the walk.
@@ -593,22 +574,22 @@ acpi_get_devices (
593 * to the user function - since this function 574 * to the user function - since this function
594 * must be allowed to make Acpi calls itself. 575 * must be allowed to make Acpi calls itself.
595 */ 576 */
596 status = acpi_ut_acquire_mutex (ACPI_MTX_NAMESPACE); 577 status = acpi_ut_acquire_mutex(ACPI_MTX_NAMESPACE);
597 if (ACPI_FAILURE (status)) { 578 if (ACPI_FAILURE(status)) {
598 return_ACPI_STATUS (status); 579 return_ACPI_STATUS(status);
599 } 580 }
600 581
601 status = acpi_ns_walk_namespace (ACPI_TYPE_DEVICE, 582 status = acpi_ns_walk_namespace(ACPI_TYPE_DEVICE,
602 ACPI_ROOT_OBJECT, ACPI_UINT32_MAX, 583 ACPI_ROOT_OBJECT, ACPI_UINT32_MAX,
603 ACPI_NS_WALK_UNLOCK, 584 ACPI_NS_WALK_UNLOCK,
604 acpi_ns_get_device_callback, &info, 585 acpi_ns_get_device_callback, &info,
605 return_value); 586 return_value);
606 587
607 (void) acpi_ut_release_mutex (ACPI_MTX_NAMESPACE); 588 (void)acpi_ut_release_mutex(ACPI_MTX_NAMESPACE);
608 return_ACPI_STATUS (status); 589 return_ACPI_STATUS(status);
609} 590}
610EXPORT_SYMBOL(acpi_get_devices);
611 591
592EXPORT_SYMBOL(acpi_get_devices);
612 593
613/******************************************************************************* 594/*******************************************************************************
614 * 595 *
@@ -625,44 +606,38 @@ EXPORT_SYMBOL(acpi_get_devices);
625 ******************************************************************************/ 606 ******************************************************************************/
626 607
627acpi_status 608acpi_status
628acpi_attach_data ( 609acpi_attach_data(acpi_handle obj_handle,
629 acpi_handle obj_handle, 610 acpi_object_handler handler, void *data)
630 acpi_object_handler handler,
631 void *data)
632{ 611{
633 struct acpi_namespace_node *node; 612 struct acpi_namespace_node *node;
634 acpi_status status; 613 acpi_status status;
635
636 614
637 /* Parameter validation */ 615 /* Parameter validation */
638 616
639 if (!obj_handle || 617 if (!obj_handle || !handler || !data) {
640 !handler ||
641 !data) {
642 return (AE_BAD_PARAMETER); 618 return (AE_BAD_PARAMETER);
643 } 619 }
644 620
645 status = acpi_ut_acquire_mutex (ACPI_MTX_NAMESPACE); 621 status = acpi_ut_acquire_mutex(ACPI_MTX_NAMESPACE);
646 if (ACPI_FAILURE (status)) { 622 if (ACPI_FAILURE(status)) {
647 return (status); 623 return (status);
648 } 624 }
649 625
650 /* Convert and validate the handle */ 626 /* Convert and validate the handle */
651 627
652 node = acpi_ns_map_handle_to_node (obj_handle); 628 node = acpi_ns_map_handle_to_node(obj_handle);
653 if (!node) { 629 if (!node) {
654 status = AE_BAD_PARAMETER; 630 status = AE_BAD_PARAMETER;
655 goto unlock_and_exit; 631 goto unlock_and_exit;
656 } 632 }
657 633
658 status = acpi_ns_attach_data (node, handler, data); 634 status = acpi_ns_attach_data(node, handler, data);
659 635
660unlock_and_exit: 636 unlock_and_exit:
661 (void) acpi_ut_release_mutex (ACPI_MTX_NAMESPACE); 637 (void)acpi_ut_release_mutex(ACPI_MTX_NAMESPACE);
662 return (status); 638 return (status);
663} 639}
664 640
665
666/******************************************************************************* 641/*******************************************************************************
667 * 642 *
668 * FUNCTION: acpi_detach_data 643 * FUNCTION: acpi_detach_data
@@ -677,42 +652,37 @@ unlock_and_exit:
677 ******************************************************************************/ 652 ******************************************************************************/
678 653
679acpi_status 654acpi_status
680acpi_detach_data ( 655acpi_detach_data(acpi_handle obj_handle, acpi_object_handler handler)
681 acpi_handle obj_handle,
682 acpi_object_handler handler)
683{ 656{
684 struct acpi_namespace_node *node; 657 struct acpi_namespace_node *node;
685 acpi_status status; 658 acpi_status status;
686
687 659
688 /* Parameter validation */ 660 /* Parameter validation */
689 661
690 if (!obj_handle || 662 if (!obj_handle || !handler) {
691 !handler) {
692 return (AE_BAD_PARAMETER); 663 return (AE_BAD_PARAMETER);
693 } 664 }
694 665
695 status = acpi_ut_acquire_mutex (ACPI_MTX_NAMESPACE); 666 status = acpi_ut_acquire_mutex(ACPI_MTX_NAMESPACE);
696 if (ACPI_FAILURE (status)) { 667 if (ACPI_FAILURE(status)) {
697 return (status); 668 return (status);
698 } 669 }
699 670
700 /* Convert and validate the handle */ 671 /* Convert and validate the handle */
701 672
702 node = acpi_ns_map_handle_to_node (obj_handle); 673 node = acpi_ns_map_handle_to_node(obj_handle);
703 if (!node) { 674 if (!node) {
704 status = AE_BAD_PARAMETER; 675 status = AE_BAD_PARAMETER;
705 goto unlock_and_exit; 676 goto unlock_and_exit;
706 } 677 }
707 678
708 status = acpi_ns_detach_data (node, handler); 679 status = acpi_ns_detach_data(node, handler);
709 680
710unlock_and_exit: 681 unlock_and_exit:
711 (void) acpi_ut_release_mutex (ACPI_MTX_NAMESPACE); 682 (void)acpi_ut_release_mutex(ACPI_MTX_NAMESPACE);
712 return (status); 683 return (status);
713} 684}
714 685
715
716/******************************************************************************* 686/*******************************************************************************
717 * 687 *
718 * FUNCTION: acpi_get_data 688 * FUNCTION: acpi_get_data
@@ -728,41 +698,33 @@ unlock_and_exit:
728 ******************************************************************************/ 698 ******************************************************************************/
729 699
730acpi_status 700acpi_status
731acpi_get_data ( 701acpi_get_data(acpi_handle obj_handle, acpi_object_handler handler, void **data)
732 acpi_handle obj_handle,
733 acpi_object_handler handler,
734 void **data)
735{ 702{
736 struct acpi_namespace_node *node; 703 struct acpi_namespace_node *node;
737 acpi_status status; 704 acpi_status status;
738
739 705
740 /* Parameter validation */ 706 /* Parameter validation */
741 707
742 if (!obj_handle || 708 if (!obj_handle || !handler || !data) {
743 !handler ||
744 !data) {
745 return (AE_BAD_PARAMETER); 709 return (AE_BAD_PARAMETER);
746 } 710 }
747 711
748 status = acpi_ut_acquire_mutex (ACPI_MTX_NAMESPACE); 712 status = acpi_ut_acquire_mutex(ACPI_MTX_NAMESPACE);
749 if (ACPI_FAILURE (status)) { 713 if (ACPI_FAILURE(status)) {
750 return (status); 714 return (status);
751 } 715 }
752 716
753 /* Convert and validate the handle */ 717 /* Convert and validate the handle */
754 718
755 node = acpi_ns_map_handle_to_node (obj_handle); 719 node = acpi_ns_map_handle_to_node(obj_handle);
756 if (!node) { 720 if (!node) {
757 status = AE_BAD_PARAMETER; 721 status = AE_BAD_PARAMETER;
758 goto unlock_and_exit; 722 goto unlock_and_exit;
759 } 723 }
760 724
761 status = acpi_ns_get_attached_data (node, handler, data); 725 status = acpi_ns_get_attached_data(node, handler, data);
762 726
763unlock_and_exit: 727 unlock_and_exit:
764 (void) acpi_ut_release_mutex (ACPI_MTX_NAMESPACE); 728 (void)acpi_ut_release_mutex(ACPI_MTX_NAMESPACE);
765 return (status); 729 return (status);
766} 730}
767
768
diff --git a/drivers/acpi/namespace/nsxfname.c b/drivers/acpi/namespace/nsxfname.c
index 8d097914c49a..6b5f8d4481d1 100644
--- a/drivers/acpi/namespace/nsxfname.c
+++ b/drivers/acpi/namespace/nsxfname.c
@@ -47,10 +47,8 @@
47#include <acpi/acpi.h> 47#include <acpi/acpi.h>
48#include <acpi/acnamesp.h> 48#include <acpi/acnamesp.h>
49 49
50
51#define _COMPONENT ACPI_NAMESPACE 50#define _COMPONENT ACPI_NAMESPACE
52 ACPI_MODULE_NAME ("nsxfname") 51ACPI_MODULE_NAME("nsxfname")
53
54 52
55/****************************************************************************** 53/******************************************************************************
56 * 54 *
@@ -69,20 +67,15 @@
69 * namespace handle. 67 * namespace handle.
70 * 68 *
71 ******************************************************************************/ 69 ******************************************************************************/
72
73acpi_status 70acpi_status
74acpi_get_handle ( 71acpi_get_handle(acpi_handle parent,
75 acpi_handle parent, 72 acpi_string pathname, acpi_handle * ret_handle)
76 acpi_string pathname,
77 acpi_handle *ret_handle)
78{ 73{
79 acpi_status status; 74 acpi_status status;
80 struct acpi_namespace_node *node = NULL; 75 struct acpi_namespace_node *node = NULL;
81 struct acpi_namespace_node *prefix_node = NULL; 76 struct acpi_namespace_node *prefix_node = NULL;
82
83
84 ACPI_FUNCTION_ENTRY ();
85 77
78 ACPI_FUNCTION_ENTRY();
86 79
87 /* Parameter Validation */ 80 /* Parameter Validation */
88 81
@@ -93,45 +86,47 @@ acpi_get_handle (
93 /* Convert a parent handle to a prefix node */ 86 /* Convert a parent handle to a prefix node */
94 87
95 if (parent) { 88 if (parent) {
96 status = acpi_ut_acquire_mutex (ACPI_MTX_NAMESPACE); 89 status = acpi_ut_acquire_mutex(ACPI_MTX_NAMESPACE);
97 if (ACPI_FAILURE (status)) { 90 if (ACPI_FAILURE(status)) {
98 return (status); 91 return (status);
99 } 92 }
100 93
101 prefix_node = acpi_ns_map_handle_to_node (parent); 94 prefix_node = acpi_ns_map_handle_to_node(parent);
102 if (!prefix_node) { 95 if (!prefix_node) {
103 (void) acpi_ut_release_mutex (ACPI_MTX_NAMESPACE); 96 (void)acpi_ut_release_mutex(ACPI_MTX_NAMESPACE);
104 return (AE_BAD_PARAMETER); 97 return (AE_BAD_PARAMETER);
105 } 98 }
106 99
107 status = acpi_ut_release_mutex (ACPI_MTX_NAMESPACE); 100 status = acpi_ut_release_mutex(ACPI_MTX_NAMESPACE);
108 if (ACPI_FAILURE (status)) { 101 if (ACPI_FAILURE(status)) {
109 return (status); 102 return (status);
110 } 103 }
111 } 104 }
112 105
113 /* Special case for root, since we can't search for it */ 106 /* Special case for root, since we can't search for it */
114 107
115 if (ACPI_STRCMP (pathname, ACPI_NS_ROOT_PATH) == 0) { 108 if (ACPI_STRCMP(pathname, ACPI_NS_ROOT_PATH) == 0) {
116 *ret_handle = acpi_ns_convert_entry_to_handle (acpi_gbl_root_node); 109 *ret_handle =
110 acpi_ns_convert_entry_to_handle(acpi_gbl_root_node);
117 return (AE_OK); 111 return (AE_OK);
118 } 112 }
119 113
120 /* 114 /*
121 * Find the Node and convert to a handle 115 * Find the Node and convert to a handle
122 */ 116 */
123 status = acpi_ns_get_node_by_path (pathname, prefix_node, ACPI_NS_NO_UPSEARCH, 117 status =
124 &node); 118 acpi_ns_get_node_by_path(pathname, prefix_node, ACPI_NS_NO_UPSEARCH,
119 &node);
125 120
126 *ret_handle = NULL; 121 *ret_handle = NULL;
127 if (ACPI_SUCCESS (status)) { 122 if (ACPI_SUCCESS(status)) {
128 *ret_handle = acpi_ns_convert_entry_to_handle (node); 123 *ret_handle = acpi_ns_convert_entry_to_handle(node);
129 } 124 }
130 125
131 return (status); 126 return (status);
132} 127}
133EXPORT_SYMBOL(acpi_get_handle);
134 128
129EXPORT_SYMBOL(acpi_get_handle);
135 130
136/****************************************************************************** 131/******************************************************************************
137 * 132 *
@@ -150,14 +145,10 @@ EXPORT_SYMBOL(acpi_get_handle);
150 ******************************************************************************/ 145 ******************************************************************************/
151 146
152acpi_status 147acpi_status
153acpi_get_name ( 148acpi_get_name(acpi_handle handle, u32 name_type, struct acpi_buffer * buffer)
154 acpi_handle handle,
155 u32 name_type,
156 struct acpi_buffer *buffer)
157{ 149{
158 acpi_status status; 150 acpi_status status;
159 struct acpi_namespace_node *node; 151 struct acpi_namespace_node *node;
160
161 152
162 /* Parameter validation */ 153 /* Parameter validation */
163 154
@@ -165,15 +156,15 @@ acpi_get_name (
165 return (AE_BAD_PARAMETER); 156 return (AE_BAD_PARAMETER);
166 } 157 }
167 158
168 status = acpi_ut_validate_buffer (buffer); 159 status = acpi_ut_validate_buffer(buffer);
169 if (ACPI_FAILURE (status)) { 160 if (ACPI_FAILURE(status)) {
170 return (status); 161 return (status);
171 } 162 }
172 163
173 if (name_type == ACPI_FULL_PATHNAME) { 164 if (name_type == ACPI_FULL_PATHNAME) {
174 /* Get the full pathname (From the namespace root) */ 165 /* Get the full pathname (From the namespace root) */
175 166
176 status = acpi_ns_handle_to_pathname (handle, buffer); 167 status = acpi_ns_handle_to_pathname(handle, buffer);
177 return (status); 168 return (status);
178 } 169 }
179 170
@@ -181,12 +172,12 @@ acpi_get_name (
181 * Wants the single segment ACPI name. 172 * Wants the single segment ACPI name.
182 * Validate handle and convert to a namespace Node 173 * Validate handle and convert to a namespace Node
183 */ 174 */
184 status = acpi_ut_acquire_mutex (ACPI_MTX_NAMESPACE); 175 status = acpi_ut_acquire_mutex(ACPI_MTX_NAMESPACE);
185 if (ACPI_FAILURE (status)) { 176 if (ACPI_FAILURE(status)) {
186 return (status); 177 return (status);
187 } 178 }
188 179
189 node = acpi_ns_map_handle_to_node (handle); 180 node = acpi_ns_map_handle_to_node(handle);
190 if (!node) { 181 if (!node) {
191 status = AE_BAD_PARAMETER; 182 status = AE_BAD_PARAMETER;
192 goto unlock_and_exit; 183 goto unlock_and_exit;
@@ -194,26 +185,25 @@ acpi_get_name (
194 185
195 /* Validate/Allocate/Clear caller buffer */ 186 /* Validate/Allocate/Clear caller buffer */
196 187
197 status = acpi_ut_initialize_buffer (buffer, ACPI_PATH_SEGMENT_LENGTH); 188 status = acpi_ut_initialize_buffer(buffer, ACPI_PATH_SEGMENT_LENGTH);
198 if (ACPI_FAILURE (status)) { 189 if (ACPI_FAILURE(status)) {
199 goto unlock_and_exit; 190 goto unlock_and_exit;
200 } 191 }
201 192
202 /* Just copy the ACPI name from the Node and zero terminate it */ 193 /* Just copy the ACPI name from the Node and zero terminate it */
203 194
204 ACPI_STRNCPY (buffer->pointer, acpi_ut_get_node_name (node), 195 ACPI_STRNCPY(buffer->pointer, acpi_ut_get_node_name(node),
205 ACPI_NAME_SIZE); 196 ACPI_NAME_SIZE);
206 ((char *) buffer->pointer) [ACPI_NAME_SIZE] = 0; 197 ((char *)buffer->pointer)[ACPI_NAME_SIZE] = 0;
207 status = AE_OK; 198 status = AE_OK;
208 199
200 unlock_and_exit:
209 201
210unlock_and_exit: 202 (void)acpi_ut_release_mutex(ACPI_MTX_NAMESPACE);
211
212 (void) acpi_ut_release_mutex (ACPI_MTX_NAMESPACE);
213 return (status); 203 return (status);
214} 204}
215EXPORT_SYMBOL(acpi_get_name);
216 205
206EXPORT_SYMBOL(acpi_get_name);
217 207
218/****************************************************************************** 208/******************************************************************************
219 * 209 *
@@ -231,17 +221,14 @@ EXPORT_SYMBOL(acpi_get_name);
231 ******************************************************************************/ 221 ******************************************************************************/
232 222
233acpi_status 223acpi_status
234acpi_get_object_info ( 224acpi_get_object_info(acpi_handle handle, struct acpi_buffer * buffer)
235 acpi_handle handle,
236 struct acpi_buffer *buffer)
237{ 225{
238 acpi_status status; 226 acpi_status status;
239 struct acpi_namespace_node *node; 227 struct acpi_namespace_node *node;
240 struct acpi_device_info *info; 228 struct acpi_device_info *info;
241 struct acpi_device_info *return_info; 229 struct acpi_device_info *return_info;
242 struct acpi_compatible_id_list *cid_list = NULL; 230 struct acpi_compatible_id_list *cid_list = NULL;
243 acpi_size size; 231 acpi_size size;
244
245 232
246 /* Parameter validation */ 233 /* Parameter validation */
247 234
@@ -249,37 +236,37 @@ acpi_get_object_info (
249 return (AE_BAD_PARAMETER); 236 return (AE_BAD_PARAMETER);
250 } 237 }
251 238
252 status = acpi_ut_validate_buffer (buffer); 239 status = acpi_ut_validate_buffer(buffer);
253 if (ACPI_FAILURE (status)) { 240 if (ACPI_FAILURE(status)) {
254 return (status); 241 return (status);
255 } 242 }
256 243
257 info = ACPI_MEM_CALLOCATE (sizeof (struct acpi_device_info)); 244 info = ACPI_MEM_CALLOCATE(sizeof(struct acpi_device_info));
258 if (!info) { 245 if (!info) {
259 return (AE_NO_MEMORY); 246 return (AE_NO_MEMORY);
260 } 247 }
261 248
262 status = acpi_ut_acquire_mutex (ACPI_MTX_NAMESPACE); 249 status = acpi_ut_acquire_mutex(ACPI_MTX_NAMESPACE);
263 if (ACPI_FAILURE (status)) { 250 if (ACPI_FAILURE(status)) {
264 goto cleanup; 251 goto cleanup;
265 } 252 }
266 253
267 node = acpi_ns_map_handle_to_node (handle); 254 node = acpi_ns_map_handle_to_node(handle);
268 if (!node) { 255 if (!node) {
269 (void) acpi_ut_release_mutex (ACPI_MTX_NAMESPACE); 256 (void)acpi_ut_release_mutex(ACPI_MTX_NAMESPACE);
270 goto cleanup; 257 goto cleanup;
271 } 258 }
272 259
273 /* Init return structure */ 260 /* Init return structure */
274 261
275 size = sizeof (struct acpi_device_info); 262 size = sizeof(struct acpi_device_info);
276 263
277 info->type = node->type; 264 info->type = node->type;
278 info->name = node->name.integer; 265 info->name = node->name.integer;
279 info->valid = 0; 266 info->valid = 0;
280 267
281 status = acpi_ut_release_mutex (ACPI_MTX_NAMESPACE); 268 status = acpi_ut_release_mutex(ACPI_MTX_NAMESPACE);
282 if (ACPI_FAILURE (status)) { 269 if (ACPI_FAILURE(status)) {
283 goto cleanup; 270 goto cleanup;
284 } 271 }
285 272
@@ -297,73 +284,73 @@ acpi_get_object_info (
297 284
298 /* Execute the Device._HID method */ 285 /* Execute the Device._HID method */
299 286
300 status = acpi_ut_execute_HID (node, &info->hardware_id); 287 status = acpi_ut_execute_HID(node, &info->hardware_id);
301 if (ACPI_SUCCESS (status)) { 288 if (ACPI_SUCCESS(status)) {
302 info->valid |= ACPI_VALID_HID; 289 info->valid |= ACPI_VALID_HID;
303 } 290 }
304 291
305 /* Execute the Device._UID method */ 292 /* Execute the Device._UID method */
306 293
307 status = acpi_ut_execute_UID (node, &info->unique_id); 294 status = acpi_ut_execute_UID(node, &info->unique_id);
308 if (ACPI_SUCCESS (status)) { 295 if (ACPI_SUCCESS(status)) {
309 info->valid |= ACPI_VALID_UID; 296 info->valid |= ACPI_VALID_UID;
310 } 297 }
311 298
312 /* Execute the Device._CID method */ 299 /* Execute the Device._CID method */
313 300
314 status = acpi_ut_execute_CID (node, &cid_list); 301 status = acpi_ut_execute_CID(node, &cid_list);
315 if (ACPI_SUCCESS (status)) { 302 if (ACPI_SUCCESS(status)) {
316 size += ((acpi_size) cid_list->count - 1) * 303 size += ((acpi_size) cid_list->count - 1) *
317 sizeof (struct acpi_compatible_id); 304 sizeof(struct acpi_compatible_id);
318 info->valid |= ACPI_VALID_CID; 305 info->valid |= ACPI_VALID_CID;
319 } 306 }
320 307
321 /* Execute the Device._STA method */ 308 /* Execute the Device._STA method */
322 309
323 status = acpi_ut_execute_STA (node, &info->current_status); 310 status = acpi_ut_execute_STA(node, &info->current_status);
324 if (ACPI_SUCCESS (status)) { 311 if (ACPI_SUCCESS(status)) {
325 info->valid |= ACPI_VALID_STA; 312 info->valid |= ACPI_VALID_STA;
326 } 313 }
327 314
328 /* Execute the Device._ADR method */ 315 /* Execute the Device._ADR method */
329 316
330 status = acpi_ut_evaluate_numeric_object (METHOD_NAME__ADR, node, 317 status = acpi_ut_evaluate_numeric_object(METHOD_NAME__ADR, node,
331 &info->address); 318 &info->address);
332 if (ACPI_SUCCESS (status)) { 319 if (ACPI_SUCCESS(status)) {
333 info->valid |= ACPI_VALID_ADR; 320 info->valid |= ACPI_VALID_ADR;
334 } 321 }
335 322
336 /* Execute the Device._sx_d methods */ 323 /* Execute the Device._sx_d methods */
337 324
338 status = acpi_ut_execute_sxds (node, info->highest_dstates); 325 status = acpi_ut_execute_sxds(node, info->highest_dstates);
339 if (ACPI_SUCCESS (status)) { 326 if (ACPI_SUCCESS(status)) {
340 info->valid |= ACPI_VALID_SXDS; 327 info->valid |= ACPI_VALID_SXDS;
341 } 328 }
342 } 329 }
343 330
344 /* Validate/Allocate/Clear caller buffer */ 331 /* Validate/Allocate/Clear caller buffer */
345 332
346 status = acpi_ut_initialize_buffer (buffer, size); 333 status = acpi_ut_initialize_buffer(buffer, size);
347 if (ACPI_FAILURE (status)) { 334 if (ACPI_FAILURE(status)) {
348 goto cleanup; 335 goto cleanup;
349 } 336 }
350 337
351 /* Populate the return buffer */ 338 /* Populate the return buffer */
352 339
353 return_info = buffer->pointer; 340 return_info = buffer->pointer;
354 ACPI_MEMCPY (return_info, info, sizeof (struct acpi_device_info)); 341 ACPI_MEMCPY(return_info, info, sizeof(struct acpi_device_info));
355 342
356 if (cid_list) { 343 if (cid_list) {
357 ACPI_MEMCPY (&return_info->compatibility_id, cid_list, cid_list->size); 344 ACPI_MEMCPY(&return_info->compatibility_id, cid_list,
345 cid_list->size);
358 } 346 }
359 347
360 348 cleanup:
361cleanup: 349 ACPI_MEM_FREE(info);
362 ACPI_MEM_FREE (info);
363 if (cid_list) { 350 if (cid_list) {
364 ACPI_MEM_FREE (cid_list); 351 ACPI_MEM_FREE(cid_list);
365 } 352 }
366 return (status); 353 return (status);
367} 354}
368EXPORT_SYMBOL(acpi_get_object_info);
369 355
356EXPORT_SYMBOL(acpi_get_object_info);
diff --git a/drivers/acpi/namespace/nsxfobj.c b/drivers/acpi/namespace/nsxfobj.c
index 363e1f6cfb18..0856d42e6909 100644
--- a/drivers/acpi/namespace/nsxfobj.c
+++ b/drivers/acpi/namespace/nsxfobj.c
@@ -47,9 +47,8 @@
47#include <acpi/acpi.h> 47#include <acpi/acpi.h>
48#include <acpi/acnamesp.h> 48#include <acpi/acnamesp.h>
49 49
50
51#define _COMPONENT ACPI_NAMESPACE 50#define _COMPONENT ACPI_NAMESPACE
52 ACPI_MODULE_NAME ("nsxfobj") 51ACPI_MODULE_NAME("nsxfobj")
53 52
54/******************************************************************************* 53/*******************************************************************************
55 * 54 *
@@ -63,15 +62,10 @@
63 * DESCRIPTION: This routine returns the type associatd with a particular handle 62 * DESCRIPTION: This routine returns the type associatd with a particular handle
64 * 63 *
65 ******************************************************************************/ 64 ******************************************************************************/
66 65acpi_status acpi_get_type(acpi_handle handle, acpi_object_type * ret_type)
67acpi_status
68acpi_get_type (
69 acpi_handle handle,
70 acpi_object_type *ret_type)
71{ 66{
72 struct acpi_namespace_node *node; 67 struct acpi_namespace_node *node;
73 acpi_status status; 68 acpi_status status;
74
75 69
76 /* Parameter Validation */ 70 /* Parameter Validation */
77 71
@@ -88,27 +82,26 @@ acpi_get_type (
88 return (AE_OK); 82 return (AE_OK);
89 } 83 }
90 84
91 status = acpi_ut_acquire_mutex (ACPI_MTX_NAMESPACE); 85 status = acpi_ut_acquire_mutex(ACPI_MTX_NAMESPACE);
92 if (ACPI_FAILURE (status)) { 86 if (ACPI_FAILURE(status)) {
93 return (status); 87 return (status);
94 } 88 }
95 89
96 /* Convert and validate the handle */ 90 /* Convert and validate the handle */
97 91
98 node = acpi_ns_map_handle_to_node (handle); 92 node = acpi_ns_map_handle_to_node(handle);
99 if (!node) { 93 if (!node) {
100 (void) acpi_ut_release_mutex (ACPI_MTX_NAMESPACE); 94 (void)acpi_ut_release_mutex(ACPI_MTX_NAMESPACE);
101 return (AE_BAD_PARAMETER); 95 return (AE_BAD_PARAMETER);
102 } 96 }
103 97
104 *ret_type = node->type; 98 *ret_type = node->type;
105 99
106 100 status = acpi_ut_release_mutex(ACPI_MTX_NAMESPACE);
107 status = acpi_ut_release_mutex (ACPI_MTX_NAMESPACE);
108 return (status); 101 return (status);
109} 102}
110EXPORT_SYMBOL(acpi_get_type);
111 103
104EXPORT_SYMBOL(acpi_get_type);
112 105
113/******************************************************************************* 106/*******************************************************************************
114 * 107 *
@@ -124,14 +117,10 @@ EXPORT_SYMBOL(acpi_get_type);
124 * 117 *
125 ******************************************************************************/ 118 ******************************************************************************/
126 119
127acpi_status 120acpi_status acpi_get_parent(acpi_handle handle, acpi_handle * ret_handle)
128acpi_get_parent (
129 acpi_handle handle,
130 acpi_handle *ret_handle)
131{ 121{
132 struct acpi_namespace_node *node; 122 struct acpi_namespace_node *node;
133 acpi_status status; 123 acpi_status status;
134
135 124
136 if (!ret_handle) { 125 if (!ret_handle) {
137 return (AE_BAD_PARAMETER); 126 return (AE_BAD_PARAMETER);
@@ -143,14 +132,14 @@ acpi_get_parent (
143 return (AE_NULL_ENTRY); 132 return (AE_NULL_ENTRY);
144 } 133 }
145 134
146 status = acpi_ut_acquire_mutex (ACPI_MTX_NAMESPACE); 135 status = acpi_ut_acquire_mutex(ACPI_MTX_NAMESPACE);
147 if (ACPI_FAILURE (status)) { 136 if (ACPI_FAILURE(status)) {
148 return (status); 137 return (status);
149 } 138 }
150 139
151 /* Convert and validate the handle */ 140 /* Convert and validate the handle */
152 141
153 node = acpi_ns_map_handle_to_node (handle); 142 node = acpi_ns_map_handle_to_node(handle);
154 if (!node) { 143 if (!node) {
155 status = AE_BAD_PARAMETER; 144 status = AE_BAD_PARAMETER;
156 goto unlock_and_exit; 145 goto unlock_and_exit;
@@ -159,22 +148,21 @@ acpi_get_parent (
159 /* Get the parent entry */ 148 /* Get the parent entry */
160 149
161 *ret_handle = 150 *ret_handle =
162 acpi_ns_convert_entry_to_handle (acpi_ns_get_parent_node (node)); 151 acpi_ns_convert_entry_to_handle(acpi_ns_get_parent_node(node));
163 152
164 /* Return exception if parent is null */ 153 /* Return exception if parent is null */
165 154
166 if (!acpi_ns_get_parent_node (node)) { 155 if (!acpi_ns_get_parent_node(node)) {
167 status = AE_NULL_ENTRY; 156 status = AE_NULL_ENTRY;
168 } 157 }
169 158
159 unlock_and_exit:
170 160
171unlock_and_exit: 161 (void)acpi_ut_release_mutex(ACPI_MTX_NAMESPACE);
172
173 (void) acpi_ut_release_mutex (ACPI_MTX_NAMESPACE);
174 return (status); 162 return (status);
175} 163}
176EXPORT_SYMBOL(acpi_get_parent);
177 164
165EXPORT_SYMBOL(acpi_get_parent);
178 166
179/******************************************************************************* 167/*******************************************************************************
180 * 168 *
@@ -195,17 +183,14 @@ EXPORT_SYMBOL(acpi_get_parent);
195 ******************************************************************************/ 183 ******************************************************************************/
196 184
197acpi_status 185acpi_status
198acpi_get_next_object ( 186acpi_get_next_object(acpi_object_type type,
199 acpi_object_type type, 187 acpi_handle parent,
200 acpi_handle parent, 188 acpi_handle child, acpi_handle * ret_handle)
201 acpi_handle child,
202 acpi_handle *ret_handle)
203{ 189{
204 acpi_status status; 190 acpi_status status;
205 struct acpi_namespace_node *node; 191 struct acpi_namespace_node *node;
206 struct acpi_namespace_node *parent_node = NULL; 192 struct acpi_namespace_node *parent_node = NULL;
207 struct acpi_namespace_node *child_node = NULL; 193 struct acpi_namespace_node *child_node = NULL;
208
209 194
210 /* Parameter validation */ 195 /* Parameter validation */
211 196
@@ -213,8 +198,8 @@ acpi_get_next_object (
213 return (AE_BAD_PARAMETER); 198 return (AE_BAD_PARAMETER);
214 } 199 }
215 200
216 status = acpi_ut_acquire_mutex (ACPI_MTX_NAMESPACE); 201 status = acpi_ut_acquire_mutex(ACPI_MTX_NAMESPACE);
217 if (ACPI_FAILURE (status)) { 202 if (ACPI_FAILURE(status)) {
218 return (status); 203 return (status);
219 } 204 }
220 205
@@ -223,17 +208,16 @@ acpi_get_next_object (
223 if (!child) { 208 if (!child) {
224 /* Start search at the beginning of the specified scope */ 209 /* Start search at the beginning of the specified scope */
225 210
226 parent_node = acpi_ns_map_handle_to_node (parent); 211 parent_node = acpi_ns_map_handle_to_node(parent);
227 if (!parent_node) { 212 if (!parent_node) {
228 status = AE_BAD_PARAMETER; 213 status = AE_BAD_PARAMETER;
229 goto unlock_and_exit; 214 goto unlock_and_exit;
230 } 215 }
231 } 216 } else {
232 else {
233 /* Non-null handle, ignore the parent */ 217 /* Non-null handle, ignore the parent */
234 /* Convert and validate the handle */ 218 /* Convert and validate the handle */
235 219
236 child_node = acpi_ns_map_handle_to_node (child); 220 child_node = acpi_ns_map_handle_to_node(child);
237 if (!child_node) { 221 if (!child_node) {
238 status = AE_BAD_PARAMETER; 222 status = AE_BAD_PARAMETER;
239 goto unlock_and_exit; 223 goto unlock_and_exit;
@@ -242,20 +226,19 @@ acpi_get_next_object (
242 226
243 /* Internal function does the real work */ 227 /* Internal function does the real work */
244 228
245 node = acpi_ns_get_next_node (type, parent_node, child_node); 229 node = acpi_ns_get_next_node(type, parent_node, child_node);
246 if (!node) { 230 if (!node) {
247 status = AE_NOT_FOUND; 231 status = AE_NOT_FOUND;
248 goto unlock_and_exit; 232 goto unlock_and_exit;
249 } 233 }
250 234
251 if (ret_handle) { 235 if (ret_handle) {
252 *ret_handle = acpi_ns_convert_entry_to_handle (node); 236 *ret_handle = acpi_ns_convert_entry_to_handle(node);
253 } 237 }
254 238
239 unlock_and_exit:
255 240
256unlock_and_exit: 241 (void)acpi_ut_release_mutex(ACPI_MTX_NAMESPACE);
257
258 (void) acpi_ut_release_mutex (ACPI_MTX_NAMESPACE);
259 return (status); 242 return (status);
260} 243}
261 244