aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/acpi/namespace/nsutils.c
diff options
context:
space:
mode:
authorLen Brown <len.brown@intel.com>2005-08-05 00:44:28 -0400
committerLen Brown <len.brown@intel.com>2005-08-05 00:45:14 -0400
commit4be44fcd3bf648b782f4460fd06dfae6c42ded4b (patch)
tree5b5b7d296ea58786f53b95e5eac9565ff66890b0 /drivers/acpi/namespace/nsutils.c
parentc65ade4dc8b486e8c8b9b0a6399789a5428e2039 (diff)
[ACPI] Lindent all ACPI files
Signed-off-by: Len Brown <len.brown@intel.com>
Diffstat (limited to 'drivers/acpi/namespace/nsutils.c')
-rw-r--r--drivers/acpi/namespace/nsutils.c502
1 files changed, 205 insertions, 297 deletions
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