aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/acpi/utilities
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/utilities
parentc65ade4dc8b486e8c8b9b0a6399789a5428e2039 (diff)
[ACPI] Lindent all ACPI files
Signed-off-by: Len Brown <len.brown@intel.com>
Diffstat (limited to 'drivers/acpi/utilities')
-rw-r--r--drivers/acpi/utilities/utalloc.c505
-rw-r--r--drivers/acpi/utilities/utcache.c149
-rw-r--r--drivers/acpi/utilities/utcopy.c556
-rw-r--r--drivers/acpi/utilities/utdebug.c330
-rw-r--r--drivers/acpi/utilities/utdelete.c325
-rw-r--r--drivers/acpi/utilities/uteval.c396
-rw-r--r--drivers/acpi/utilities/utglobal.c557
-rw-r--r--drivers/acpi/utilities/utinit.c135
-rw-r--r--drivers/acpi/utilities/utmath.c144
-rw-r--r--drivers/acpi/utilities/utmisc.c431
-rw-r--r--drivers/acpi/utilities/utmutex.c220
-rw-r--r--drivers/acpi/utilities/utobject.c324
-rw-r--r--drivers/acpi/utilities/utstate.c159
-rw-r--r--drivers/acpi/utilities/utxface.c267
14 files changed, 1973 insertions, 2525 deletions
diff --git a/drivers/acpi/utilities/utalloc.c b/drivers/acpi/utilities/utalloc.c
index 78270f50e625..068450b36475 100644
--- a/drivers/acpi/utilities/utalloc.c
+++ b/drivers/acpi/utilities/utalloc.c
@@ -41,45 +41,31 @@
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#define _COMPONENT ACPI_UTILITIES 46#define _COMPONENT ACPI_UTILITIES
48 ACPI_MODULE_NAME ("utalloc") 47ACPI_MODULE_NAME("utalloc")
49 48
50/* Local prototypes */ 49/* Local prototypes */
51
52#ifdef ACPI_DBG_TRACK_ALLOCATIONS 50#ifdef ACPI_DBG_TRACK_ALLOCATIONS
53static struct acpi_debug_mem_block * 51static struct acpi_debug_mem_block *acpi_ut_find_allocation(void *allocation);
54acpi_ut_find_allocation (
55 void *allocation);
56 52
57static acpi_status 53static acpi_status
58acpi_ut_track_allocation ( 54acpi_ut_track_allocation(struct acpi_debug_mem_block *address,
59 struct acpi_debug_mem_block *address, 55 acpi_size size,
60 acpi_size size, 56 u8 alloc_type, u32 component, char *module, u32 line);
61 u8 alloc_type,
62 u32 component,
63 char *module,
64 u32 line);
65 57
66static acpi_status 58static acpi_status
67acpi_ut_remove_allocation ( 59acpi_ut_remove_allocation(struct acpi_debug_mem_block *address,
68 struct acpi_debug_mem_block *address, 60 u32 component, char *module, u32 line);
69 u32 component, 61#endif /* ACPI_DBG_TRACK_ALLOCATIONS */
70 char *module,
71 u32 line);
72#endif /* ACPI_DBG_TRACK_ALLOCATIONS */
73 62
74#ifdef ACPI_DBG_TRACK_ALLOCATIONS 63#ifdef ACPI_DBG_TRACK_ALLOCATIONS
75static acpi_status 64static acpi_status
76acpi_ut_create_list ( 65acpi_ut_create_list(char *list_name,
77 char *list_name, 66 u16 object_size, struct acpi_memory_list **return_cache);
78 u16 object_size,
79 struct acpi_memory_list **return_cache);
80#endif 67#endif
81 68
82
83/******************************************************************************* 69/*******************************************************************************
84 * 70 *
85 * FUNCTION: acpi_ut_create_caches 71 * FUNCTION: acpi_ut_create_caches
@@ -92,60 +78,68 @@ acpi_ut_create_list (
92 * 78 *
93 ******************************************************************************/ 79 ******************************************************************************/
94 80
95acpi_status 81acpi_status acpi_ut_create_caches(void)
96acpi_ut_create_caches (
97 void)
98{ 82{
99 acpi_status status; 83 acpi_status status;
100
101 84
102#ifdef ACPI_DBG_TRACK_ALLOCATIONS 85#ifdef ACPI_DBG_TRACK_ALLOCATIONS
103 86
104 /* Memory allocation lists */ 87 /* Memory allocation lists */
105 88
106 status = acpi_ut_create_list ("Acpi-Global", 0, 89 status = acpi_ut_create_list("Acpi-Global", 0, &acpi_gbl_global_list);
107 &acpi_gbl_global_list); 90 if (ACPI_FAILURE(status)) {
108 if (ACPI_FAILURE (status)) {
109 return (status); 91 return (status);
110 } 92 }
111 93
112 status = acpi_ut_create_list ("Acpi-Namespace", sizeof (struct acpi_namespace_node), 94 status =
113 &acpi_gbl_ns_node_list); 95 acpi_ut_create_list("Acpi-Namespace",
114 if (ACPI_FAILURE (status)) { 96 sizeof(struct acpi_namespace_node),
97 &acpi_gbl_ns_node_list);
98 if (ACPI_FAILURE(status)) {
115 return (status); 99 return (status);
116 } 100 }
117#endif 101#endif
118 102
119 /* Object Caches, for frequently used objects */ 103 /* Object Caches, for frequently used objects */
120 104
121 status = acpi_os_create_cache ("acpi_state", sizeof (union acpi_generic_state), 105 status =
122 ACPI_MAX_STATE_CACHE_DEPTH, &acpi_gbl_state_cache); 106 acpi_os_create_cache("acpi_state", sizeof(union acpi_generic_state),
123 if (ACPI_FAILURE (status)) { 107 ACPI_MAX_STATE_CACHE_DEPTH,
108 &acpi_gbl_state_cache);
109 if (ACPI_FAILURE(status)) {
124 return (status); 110 return (status);
125 } 111 }
126 112
127 status = acpi_os_create_cache ("acpi_parse", sizeof (struct acpi_parse_obj_common), 113 status =
128 ACPI_MAX_PARSE_CACHE_DEPTH, &acpi_gbl_ps_node_cache); 114 acpi_os_create_cache("acpi_parse",
129 if (ACPI_FAILURE (status)) { 115 sizeof(struct acpi_parse_obj_common),
116 ACPI_MAX_PARSE_CACHE_DEPTH,
117 &acpi_gbl_ps_node_cache);
118 if (ACPI_FAILURE(status)) {
130 return (status); 119 return (status);
131 } 120 }
132 121
133 status = acpi_os_create_cache ("acpi_parse_ext", sizeof (struct acpi_parse_obj_named), 122 status =
134 ACPI_MAX_EXTPARSE_CACHE_DEPTH, &acpi_gbl_ps_node_ext_cache); 123 acpi_os_create_cache("acpi_parse_ext",
135 if (ACPI_FAILURE (status)) { 124 sizeof(struct acpi_parse_obj_named),
125 ACPI_MAX_EXTPARSE_CACHE_DEPTH,
126 &acpi_gbl_ps_node_ext_cache);
127 if (ACPI_FAILURE(status)) {
136 return (status); 128 return (status);
137 } 129 }
138 130
139 status = acpi_os_create_cache ("acpi_operand", sizeof (union acpi_operand_object), 131 status =
140 ACPI_MAX_OBJECT_CACHE_DEPTH, &acpi_gbl_operand_cache); 132 acpi_os_create_cache("acpi_operand",
141 if (ACPI_FAILURE (status)) { 133 sizeof(union acpi_operand_object),
134 ACPI_MAX_OBJECT_CACHE_DEPTH,
135 &acpi_gbl_operand_cache);
136 if (ACPI_FAILURE(status)) {
142 return (status); 137 return (status);
143 } 138 }
144 139
145 return (AE_OK); 140 return (AE_OK);
146} 141}
147 142
148
149/******************************************************************************* 143/*******************************************************************************
150 * 144 *
151 * FUNCTION: acpi_ut_delete_caches 145 * FUNCTION: acpi_ut_delete_caches
@@ -158,21 +152,19 @@ acpi_ut_create_caches (
158 * 152 *
159 ******************************************************************************/ 153 ******************************************************************************/
160 154
161acpi_status 155acpi_status acpi_ut_delete_caches(void)
162acpi_ut_delete_caches (
163 void)
164{ 156{
165 157
166 (void) acpi_os_delete_cache (acpi_gbl_state_cache); 158 (void)acpi_os_delete_cache(acpi_gbl_state_cache);
167 acpi_gbl_state_cache = NULL; 159 acpi_gbl_state_cache = NULL;
168 160
169 (void) acpi_os_delete_cache (acpi_gbl_operand_cache); 161 (void)acpi_os_delete_cache(acpi_gbl_operand_cache);
170 acpi_gbl_operand_cache = NULL; 162 acpi_gbl_operand_cache = NULL;
171 163
172 (void) acpi_os_delete_cache (acpi_gbl_ps_node_cache); 164 (void)acpi_os_delete_cache(acpi_gbl_ps_node_cache);
173 acpi_gbl_ps_node_cache = NULL; 165 acpi_gbl_ps_node_cache = NULL;
174 166
175 (void) acpi_os_delete_cache (acpi_gbl_ps_node_ext_cache); 167 (void)acpi_os_delete_cache(acpi_gbl_ps_node_ext_cache);
176 acpi_gbl_ps_node_ext_cache = NULL; 168 acpi_gbl_ps_node_ext_cache = NULL;
177 169
178 return (AE_OK); 170 return (AE_OK);
@@ -190,9 +182,7 @@ acpi_ut_delete_caches (
190 * 182 *
191 ******************************************************************************/ 183 ******************************************************************************/
192 184
193acpi_status 185acpi_status acpi_ut_validate_buffer(struct acpi_buffer * buffer)
194acpi_ut_validate_buffer (
195 struct acpi_buffer *buffer)
196{ 186{
197 187
198 /* Obviously, the structure pointer must be valid */ 188 /* Obviously, the structure pointer must be valid */
@@ -203,9 +193,9 @@ acpi_ut_validate_buffer (
203 193
204 /* Special semantics for the length */ 194 /* Special semantics for the length */
205 195
206 if ((buffer->length == ACPI_NO_BUFFER) || 196 if ((buffer->length == ACPI_NO_BUFFER) ||
207 (buffer->length == ACPI_ALLOCATE_BUFFER) || 197 (buffer->length == ACPI_ALLOCATE_BUFFER) ||
208 (buffer->length == ACPI_ALLOCATE_LOCAL_BUFFER)) { 198 (buffer->length == ACPI_ALLOCATE_LOCAL_BUFFER)) {
209 return (AE_OK); 199 return (AE_OK);
210 } 200 }
211 201
@@ -218,7 +208,6 @@ acpi_ut_validate_buffer (
218 return (AE_OK); 208 return (AE_OK);
219} 209}
220 210
221
222/******************************************************************************* 211/*******************************************************************************
223 * 212 *
224 * FUNCTION: acpi_ut_initialize_buffer 213 * FUNCTION: acpi_ut_initialize_buffer
@@ -234,12 +223,10 @@ acpi_ut_validate_buffer (
234 ******************************************************************************/ 223 ******************************************************************************/
235 224
236acpi_status 225acpi_status
237acpi_ut_initialize_buffer ( 226acpi_ut_initialize_buffer(struct acpi_buffer * buffer,
238 struct acpi_buffer *buffer, 227 acpi_size required_length)
239 acpi_size required_length)
240{ 228{
241 acpi_status status = AE_OK; 229 acpi_status status = AE_OK;
242
243 230
244 switch (buffer->length) { 231 switch (buffer->length) {
245 case ACPI_NO_BUFFER: 232 case ACPI_NO_BUFFER:
@@ -249,33 +236,30 @@ acpi_ut_initialize_buffer (
249 status = AE_BUFFER_OVERFLOW; 236 status = AE_BUFFER_OVERFLOW;
250 break; 237 break;
251 238
252
253 case ACPI_ALLOCATE_BUFFER: 239 case ACPI_ALLOCATE_BUFFER:
254 240
255 /* Allocate a new buffer */ 241 /* Allocate a new buffer */
256 242
257 buffer->pointer = acpi_os_allocate (required_length); 243 buffer->pointer = acpi_os_allocate(required_length);
258 if (!buffer->pointer) { 244 if (!buffer->pointer) {
259 return (AE_NO_MEMORY); 245 return (AE_NO_MEMORY);
260 } 246 }
261 247
262 /* Clear the buffer */ 248 /* Clear the buffer */
263 249
264 ACPI_MEMSET (buffer->pointer, 0, required_length); 250 ACPI_MEMSET(buffer->pointer, 0, required_length);
265 break; 251 break;
266 252
267
268 case ACPI_ALLOCATE_LOCAL_BUFFER: 253 case ACPI_ALLOCATE_LOCAL_BUFFER:
269 254
270 /* Allocate a new buffer with local interface to allow tracking */ 255 /* Allocate a new buffer with local interface to allow tracking */
271 256
272 buffer->pointer = ACPI_MEM_CALLOCATE (required_length); 257 buffer->pointer = ACPI_MEM_CALLOCATE(required_length);
273 if (!buffer->pointer) { 258 if (!buffer->pointer) {
274 return (AE_NO_MEMORY); 259 return (AE_NO_MEMORY);
275 } 260 }
276 break; 261 break;
277 262
278
279 default: 263 default:
280 264
281 /* Existing buffer: Validate the size of the buffer */ 265 /* Existing buffer: Validate the size of the buffer */
@@ -287,7 +271,7 @@ acpi_ut_initialize_buffer (
287 271
288 /* Clear the buffer */ 272 /* Clear the buffer */
289 273
290 ACPI_MEMSET (buffer->pointer, 0, required_length); 274 ACPI_MEMSET(buffer->pointer, 0, required_length);
291 break; 275 break;
292 } 276 }
293 277
@@ -295,7 +279,6 @@ acpi_ut_initialize_buffer (
295 return (status); 279 return (status);
296} 280}
297 281
298
299/******************************************************************************* 282/*******************************************************************************
300 * 283 *
301 * FUNCTION: acpi_ut_allocate 284 * FUNCTION: acpi_ut_allocate
@@ -311,41 +294,34 @@ acpi_ut_initialize_buffer (
311 * 294 *
312 ******************************************************************************/ 295 ******************************************************************************/
313 296
314void * 297void *acpi_ut_allocate(acpi_size size, u32 component, char *module, u32 line)
315acpi_ut_allocate (
316 acpi_size size,
317 u32 component,
318 char *module,
319 u32 line)
320{ 298{
321 void *allocation; 299 void *allocation;
322
323
324 ACPI_FUNCTION_TRACE_U32 ("ut_allocate", size);
325 300
301 ACPI_FUNCTION_TRACE_U32("ut_allocate", size);
326 302
327 /* Check for an inadvertent size of zero bytes */ 303 /* Check for an inadvertent size of zero bytes */
328 304
329 if (!size) { 305 if (!size) {
330 _ACPI_REPORT_ERROR (module, line, component, 306 _ACPI_REPORT_ERROR(module, line, component,
331 ("ut_allocate: Attempt to allocate zero bytes\n")); 307 ("ut_allocate: Attempt to allocate zero bytes\n"));
332 size = 1; 308 size = 1;
333 } 309 }
334 310
335 allocation = acpi_os_allocate (size); 311 allocation = acpi_os_allocate(size);
336 if (!allocation) { 312 if (!allocation) {
337 /* Report allocation error */ 313 /* Report allocation error */
338 314
339 _ACPI_REPORT_ERROR (module, line, component, 315 _ACPI_REPORT_ERROR(module, line, component,
340 ("ut_allocate: Could not allocate size %X\n", (u32) size)); 316 ("ut_allocate: Could not allocate size %X\n",
317 (u32) size));
341 318
342 return_PTR (NULL); 319 return_PTR(NULL);
343 } 320 }
344 321
345 return_PTR (allocation); 322 return_PTR(allocation);
346} 323}
347 324
348
349/******************************************************************************* 325/*******************************************************************************
350 * 326 *
351 * FUNCTION: acpi_ut_callocate 327 * FUNCTION: acpi_ut_callocate
@@ -361,43 +337,36 @@ acpi_ut_allocate (
361 * 337 *
362 ******************************************************************************/ 338 ******************************************************************************/
363 339
364void * 340void *acpi_ut_callocate(acpi_size size, u32 component, char *module, u32 line)
365acpi_ut_callocate (
366 acpi_size size,
367 u32 component,
368 char *module,
369 u32 line)
370{ 341{
371 void *allocation; 342 void *allocation;
372
373
374 ACPI_FUNCTION_TRACE_U32 ("ut_callocate", size);
375 343
344 ACPI_FUNCTION_TRACE_U32("ut_callocate", size);
376 345
377 /* Check for an inadvertent size of zero bytes */ 346 /* Check for an inadvertent size of zero bytes */
378 347
379 if (!size) { 348 if (!size) {
380 _ACPI_REPORT_ERROR (module, line, component, 349 _ACPI_REPORT_ERROR(module, line, component,
381 ("ut_callocate: Attempt to allocate zero bytes\n")); 350 ("ut_callocate: Attempt to allocate zero bytes\n"));
382 return_PTR (NULL); 351 return_PTR(NULL);
383 } 352 }
384 353
385 allocation = acpi_os_allocate (size); 354 allocation = acpi_os_allocate(size);
386 if (!allocation) { 355 if (!allocation) {
387 /* Report allocation error */ 356 /* Report allocation error */
388 357
389 _ACPI_REPORT_ERROR (module, line, component, 358 _ACPI_REPORT_ERROR(module, line, component,
390 ("ut_callocate: Could not allocate size %X\n", (u32) size)); 359 ("ut_callocate: Could not allocate size %X\n",
391 return_PTR (NULL); 360 (u32) size));
361 return_PTR(NULL);
392 } 362 }
393 363
394 /* Clear the memory block */ 364 /* Clear the memory block */
395 365
396 ACPI_MEMSET (allocation, 0, size); 366 ACPI_MEMSET(allocation, 0, size);
397 return_PTR (allocation); 367 return_PTR(allocation);
398} 368}
399 369
400
401#ifdef ACPI_DBG_TRACK_ALLOCATIONS 370#ifdef ACPI_DBG_TRACK_ALLOCATIONS
402/* 371/*
403 * These procedures are used for tracking memory leaks in the subsystem, and 372 * These procedures are used for tracking memory leaks in the subsystem, and
@@ -425,29 +394,25 @@ acpi_ut_callocate (
425 ******************************************************************************/ 394 ******************************************************************************/
426 395
427static acpi_status 396static acpi_status
428acpi_ut_create_list ( 397acpi_ut_create_list(char *list_name,
429 char *list_name, 398 u16 object_size, struct acpi_memory_list **return_cache)
430 u16 object_size,
431 struct acpi_memory_list **return_cache)
432{ 399{
433 struct acpi_memory_list *cache; 400 struct acpi_memory_list *cache;
434 401
435 402 cache = acpi_os_allocate(sizeof(struct acpi_memory_list));
436 cache = acpi_os_allocate (sizeof (struct acpi_memory_list));
437 if (!cache) { 403 if (!cache) {
438 return (AE_NO_MEMORY); 404 return (AE_NO_MEMORY);
439 } 405 }
440 406
441 ACPI_MEMSET (cache, 0, sizeof (struct acpi_memory_list)); 407 ACPI_MEMSET(cache, 0, sizeof(struct acpi_memory_list));
442 408
443 cache->list_name = list_name; 409 cache->list_name = list_name;
444 cache->object_size = object_size; 410 cache->object_size = object_size;
445 411
446 *return_cache = cache; 412 *return_cache = cache;
447 return (AE_OK); 413 return (AE_OK);
448} 414}
449 415
450
451/******************************************************************************* 416/*******************************************************************************
452 * 417 *
453 * FUNCTION: acpi_ut_allocate_and_track 418 * FUNCTION: acpi_ut_allocate_and_track
@@ -463,37 +428,33 @@ acpi_ut_create_list (
463 * 428 *
464 ******************************************************************************/ 429 ******************************************************************************/
465 430
466void * 431void *acpi_ut_allocate_and_track(acpi_size size,
467acpi_ut_allocate_and_track ( 432 u32 component, char *module, u32 line)
468 acpi_size size,
469 u32 component,
470 char *module,
471 u32 line)
472{ 433{
473 struct acpi_debug_mem_block *allocation; 434 struct acpi_debug_mem_block *allocation;
474 acpi_status status; 435 acpi_status status;
475
476 436
477 allocation = acpi_ut_allocate (size + sizeof (struct acpi_debug_mem_header), 437 allocation =
478 component, module, line); 438 acpi_ut_allocate(size + sizeof(struct acpi_debug_mem_header),
439 component, module, line);
479 if (!allocation) { 440 if (!allocation) {
480 return (NULL); 441 return (NULL);
481 } 442 }
482 443
483 status = acpi_ut_track_allocation (allocation, size, 444 status = acpi_ut_track_allocation(allocation, size,
484 ACPI_MEM_MALLOC, component, module, line); 445 ACPI_MEM_MALLOC, component, module,
485 if (ACPI_FAILURE (status)) { 446 line);
486 acpi_os_free (allocation); 447 if (ACPI_FAILURE(status)) {
448 acpi_os_free(allocation);
487 return (NULL); 449 return (NULL);
488 } 450 }
489 451
490 acpi_gbl_global_list->total_allocated++; 452 acpi_gbl_global_list->total_allocated++;
491 acpi_gbl_global_list->current_total_size += (u32) size; 453 acpi_gbl_global_list->current_total_size += (u32) size;
492 454
493 return ((void *) &allocation->user_space); 455 return ((void *)&allocation->user_space);
494} 456}
495 457
496
497/******************************************************************************* 458/*******************************************************************************
498 * 459 *
499 * FUNCTION: acpi_ut_callocate_and_track 460 * FUNCTION: acpi_ut_callocate_and_track
@@ -509,41 +470,38 @@ acpi_ut_allocate_and_track (
509 * 470 *
510 ******************************************************************************/ 471 ******************************************************************************/
511 472
512void * 473void *acpi_ut_callocate_and_track(acpi_size size,
513acpi_ut_callocate_and_track ( 474 u32 component, char *module, u32 line)
514 acpi_size size,
515 u32 component,
516 char *module,
517 u32 line)
518{ 475{
519 struct acpi_debug_mem_block *allocation; 476 struct acpi_debug_mem_block *allocation;
520 acpi_status status; 477 acpi_status status;
521
522 478
523 allocation = acpi_ut_callocate (size + sizeof (struct acpi_debug_mem_header), 479 allocation =
524 component, module, line); 480 acpi_ut_callocate(size + sizeof(struct acpi_debug_mem_header),
481 component, module, line);
525 if (!allocation) { 482 if (!allocation) {
526 /* Report allocation error */ 483 /* Report allocation error */
527 484
528 _ACPI_REPORT_ERROR (module, line, component, 485 _ACPI_REPORT_ERROR(module, line, component,
529 ("ut_callocate: Could not allocate size %X\n", (u32) size)); 486 ("ut_callocate: Could not allocate size %X\n",
487 (u32) size));
530 return (NULL); 488 return (NULL);
531 } 489 }
532 490
533 status = acpi_ut_track_allocation (allocation, size, 491 status = acpi_ut_track_allocation(allocation, size,
534 ACPI_MEM_CALLOC, component, module, line); 492 ACPI_MEM_CALLOC, component, module,
535 if (ACPI_FAILURE (status)) { 493 line);
536 acpi_os_free (allocation); 494 if (ACPI_FAILURE(status)) {
495 acpi_os_free(allocation);
537 return (NULL); 496 return (NULL);
538 } 497 }
539 498
540 acpi_gbl_global_list->total_allocated++; 499 acpi_gbl_global_list->total_allocated++;
541 acpi_gbl_global_list->current_total_size += (u32) size; 500 acpi_gbl_global_list->current_total_size += (u32) size;
542 501
543 return ((void *) &allocation->user_space); 502 return ((void *)&allocation->user_space);
544} 503}
545 504
546
547/******************************************************************************* 505/*******************************************************************************
548 * 506 *
549 * FUNCTION: acpi_ut_free_and_track 507 * FUNCTION: acpi_ut_free_and_track
@@ -560,47 +518,41 @@ acpi_ut_callocate_and_track (
560 ******************************************************************************/ 518 ******************************************************************************/
561 519
562void 520void
563acpi_ut_free_and_track ( 521acpi_ut_free_and_track(void *allocation, u32 component, char *module, u32 line)
564 void *allocation,
565 u32 component,
566 char *module,
567 u32 line)
568{ 522{
569 struct acpi_debug_mem_block *debug_block; 523 struct acpi_debug_mem_block *debug_block;
570 acpi_status status; 524 acpi_status status;
571
572
573 ACPI_FUNCTION_TRACE_PTR ("ut_free", allocation);
574 525
526 ACPI_FUNCTION_TRACE_PTR("ut_free", allocation);
575 527
576 if (NULL == allocation) { 528 if (NULL == allocation) {
577 _ACPI_REPORT_ERROR (module, line, component, 529 _ACPI_REPORT_ERROR(module, line, component,
578 ("acpi_ut_free: Attempt to delete a NULL address\n")); 530 ("acpi_ut_free: Attempt to delete a NULL address\n"));
579 531
580 return_VOID; 532 return_VOID;
581 } 533 }
582 534
583 debug_block = ACPI_CAST_PTR (struct acpi_debug_mem_block, 535 debug_block = ACPI_CAST_PTR(struct acpi_debug_mem_block,
584 (((char *) allocation) - sizeof (struct acpi_debug_mem_header))); 536 (((char *)allocation) -
537 sizeof(struct acpi_debug_mem_header)));
585 538
586 acpi_gbl_global_list->total_freed++; 539 acpi_gbl_global_list->total_freed++;
587 acpi_gbl_global_list->current_total_size -= debug_block->size; 540 acpi_gbl_global_list->current_total_size -= debug_block->size;
588 541
589 status = acpi_ut_remove_allocation (debug_block, 542 status = acpi_ut_remove_allocation(debug_block,
590 component, module, line); 543 component, module, line);
591 if (ACPI_FAILURE (status)) { 544 if (ACPI_FAILURE(status)) {
592 ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "Could not free memory, %s\n", 545 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, "Could not free memory, %s\n",
593 acpi_format_exception (status))); 546 acpi_format_exception(status)));
594 } 547 }
595 548
596 acpi_os_free (debug_block); 549 acpi_os_free(debug_block);
597 550
598 ACPI_DEBUG_PRINT ((ACPI_DB_ALLOCATIONS, "%p freed\n", allocation)); 551 ACPI_DEBUG_PRINT((ACPI_DB_ALLOCATIONS, "%p freed\n", allocation));
599 552
600 return_VOID; 553 return_VOID;
601} 554}
602 555
603
604/******************************************************************************* 556/*******************************************************************************
605 * 557 *
606 * FUNCTION: acpi_ut_find_allocation 558 * FUNCTION: acpi_ut_find_allocation
@@ -613,15 +565,11 @@ acpi_ut_free_and_track (
613 * 565 *
614 ******************************************************************************/ 566 ******************************************************************************/
615 567
616static struct acpi_debug_mem_block * 568static struct acpi_debug_mem_block *acpi_ut_find_allocation(void *allocation)
617acpi_ut_find_allocation (
618 void *allocation)
619{ 569{
620 struct acpi_debug_mem_block *element; 570 struct acpi_debug_mem_block *element;
621
622
623 ACPI_FUNCTION_ENTRY ();
624 571
572 ACPI_FUNCTION_ENTRY();
625 573
626 element = acpi_gbl_global_list->list_head; 574 element = acpi_gbl_global_list->list_head;
627 575
@@ -638,7 +586,6 @@ acpi_ut_find_allocation (
638 return (NULL); 586 return (NULL);
639} 587}
640 588
641
642/******************************************************************************* 589/*******************************************************************************
643 * 590 *
644 * FUNCTION: acpi_ut_track_allocation 591 * FUNCTION: acpi_ut_track_allocation
@@ -657,58 +604,51 @@ acpi_ut_find_allocation (
657 ******************************************************************************/ 604 ******************************************************************************/
658 605
659static acpi_status 606static acpi_status
660acpi_ut_track_allocation ( 607acpi_ut_track_allocation(struct acpi_debug_mem_block *allocation,
661 struct acpi_debug_mem_block *allocation, 608 acpi_size size,
662 acpi_size size, 609 u8 alloc_type, u32 component, char *module, u32 line)
663 u8 alloc_type,
664 u32 component,
665 char *module,
666 u32 line)
667{ 610{
668 struct acpi_memory_list *mem_list; 611 struct acpi_memory_list *mem_list;
669 struct acpi_debug_mem_block *element; 612 struct acpi_debug_mem_block *element;
670 acpi_status status = AE_OK; 613 acpi_status status = AE_OK;
671
672
673 ACPI_FUNCTION_TRACE_PTR ("ut_track_allocation", allocation);
674 614
615 ACPI_FUNCTION_TRACE_PTR("ut_track_allocation", allocation);
675 616
676 mem_list = acpi_gbl_global_list; 617 mem_list = acpi_gbl_global_list;
677 status = acpi_ut_acquire_mutex (ACPI_MTX_MEMORY); 618 status = acpi_ut_acquire_mutex(ACPI_MTX_MEMORY);
678 if (ACPI_FAILURE (status)) { 619 if (ACPI_FAILURE(status)) {
679 return_ACPI_STATUS (status); 620 return_ACPI_STATUS(status);
680 } 621 }
681 622
682 /* 623 /*
683 * Search list for this address to make sure it is not already on the list. 624 * Search list for this address to make sure it is not already on the list.
684 * This will catch several kinds of problems. 625 * This will catch several kinds of problems.
685 */ 626 */
686 element = acpi_ut_find_allocation (allocation); 627 element = acpi_ut_find_allocation(allocation);
687 if (element) { 628 if (element) {
688 ACPI_REPORT_ERROR (( 629 ACPI_REPORT_ERROR(("ut_track_allocation: Allocation already present in list! (%p)\n", allocation));
689 "ut_track_allocation: Allocation already present in list! (%p)\n",
690 allocation));
691 630
692 ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "Element %p Address %p\n", 631 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, "Element %p Address %p\n",
693 element, allocation)); 632 element, allocation));
694 633
695 goto unlock_and_exit; 634 goto unlock_and_exit;
696 } 635 }
697 636
698 /* Fill in the instance data. */ 637 /* Fill in the instance data. */
699 638
700 allocation->size = (u32) size; 639 allocation->size = (u32) size;
701 allocation->alloc_type = alloc_type; 640 allocation->alloc_type = alloc_type;
702 allocation->component = component; 641 allocation->component = component;
703 allocation->line = line; 642 allocation->line = line;
704 643
705 ACPI_STRNCPY (allocation->module, module, ACPI_MAX_MODULE_NAME); 644 ACPI_STRNCPY(allocation->module, module, ACPI_MAX_MODULE_NAME);
706 allocation->module[ACPI_MAX_MODULE_NAME-1] = 0; 645 allocation->module[ACPI_MAX_MODULE_NAME - 1] = 0;
707 646
708 /* Insert at list head */ 647 /* Insert at list head */
709 648
710 if (mem_list->list_head) { 649 if (mem_list->list_head) {
711 ((struct acpi_debug_mem_block *)(mem_list->list_head))->previous = allocation; 650 ((struct acpi_debug_mem_block *)(mem_list->list_head))->
651 previous = allocation;
712 } 652 }
713 653
714 allocation->next = mem_list->list_head; 654 allocation->next = mem_list->list_head;
@@ -716,13 +656,11 @@ acpi_ut_track_allocation (
716 656
717 mem_list->list_head = allocation; 657 mem_list->list_head = allocation;
718 658
719 659 unlock_and_exit:
720unlock_and_exit: 660 status = acpi_ut_release_mutex(ACPI_MTX_MEMORY);
721 status = acpi_ut_release_mutex (ACPI_MTX_MEMORY); 661 return_ACPI_STATUS(status);
722 return_ACPI_STATUS (status);
723} 662}
724 663
725
726/******************************************************************************* 664/*******************************************************************************
727 * 665 *
728 * FUNCTION: acpi_ut_remove_allocation 666 * FUNCTION: acpi_ut_remove_allocation
@@ -739,40 +677,34 @@ unlock_and_exit:
739 ******************************************************************************/ 677 ******************************************************************************/
740 678
741static acpi_status 679static acpi_status
742acpi_ut_remove_allocation ( 680acpi_ut_remove_allocation(struct acpi_debug_mem_block *allocation,
743 struct acpi_debug_mem_block *allocation, 681 u32 component, char *module, u32 line)
744 u32 component,
745 char *module,
746 u32 line)
747{ 682{
748 struct acpi_memory_list *mem_list; 683 struct acpi_memory_list *mem_list;
749 acpi_status status; 684 acpi_status status;
750
751
752 ACPI_FUNCTION_TRACE ("ut_remove_allocation");
753 685
686 ACPI_FUNCTION_TRACE("ut_remove_allocation");
754 687
755 mem_list = acpi_gbl_global_list; 688 mem_list = acpi_gbl_global_list;
756 if (NULL == mem_list->list_head) { 689 if (NULL == mem_list->list_head) {
757 /* No allocations! */ 690 /* No allocations! */
758 691
759 _ACPI_REPORT_ERROR (module, line, component, 692 _ACPI_REPORT_ERROR(module, line, component,
760 ("ut_remove_allocation: Empty allocation list, nothing to free!\n")); 693 ("ut_remove_allocation: Empty allocation list, nothing to free!\n"));
761 694
762 return_ACPI_STATUS (AE_OK); 695 return_ACPI_STATUS(AE_OK);
763 } 696 }
764 697
765 status = acpi_ut_acquire_mutex (ACPI_MTX_MEMORY); 698 status = acpi_ut_acquire_mutex(ACPI_MTX_MEMORY);
766 if (ACPI_FAILURE (status)) { 699 if (ACPI_FAILURE(status)) {
767 return_ACPI_STATUS (status); 700 return_ACPI_STATUS(status);
768 } 701 }
769 702
770 /* Unlink */ 703 /* Unlink */
771 704
772 if (allocation->previous) { 705 if (allocation->previous) {
773 (allocation->previous)->next = allocation->next; 706 (allocation->previous)->next = allocation->next;
774 } 707 } else {
775 else {
776 mem_list->list_head = allocation->next; 708 mem_list->list_head = allocation->next;
777 } 709 }
778 710
@@ -782,16 +714,15 @@ acpi_ut_remove_allocation (
782 714
783 /* Mark the segment as deleted */ 715 /* Mark the segment as deleted */
784 716
785 ACPI_MEMSET (&allocation->user_space, 0xEA, allocation->size); 717 ACPI_MEMSET(&allocation->user_space, 0xEA, allocation->size);
786 718
787 ACPI_DEBUG_PRINT ((ACPI_DB_ALLOCATIONS, "Freeing size 0%X\n", 719 ACPI_DEBUG_PRINT((ACPI_DB_ALLOCATIONS, "Freeing size 0%X\n",
788 allocation->size)); 720 allocation->size));
789 721
790 status = acpi_ut_release_mutex (ACPI_MTX_MEMORY); 722 status = acpi_ut_release_mutex(ACPI_MTX_MEMORY);
791 return_ACPI_STATUS (status); 723 return_ACPI_STATUS(status);
792} 724}
793 725
794
795/******************************************************************************* 726/*******************************************************************************
796 * 727 *
797 * FUNCTION: acpi_ut_dump_allocation_info 728 * FUNCTION: acpi_ut_dump_allocation_info
@@ -805,15 +736,13 @@ acpi_ut_remove_allocation (
805 ******************************************************************************/ 736 ******************************************************************************/
806 737
807#ifdef ACPI_FUTURE_USAGE 738#ifdef ACPI_FUTURE_USAGE
808void 739void acpi_ut_dump_allocation_info(void)
809acpi_ut_dump_allocation_info (
810 void)
811{ 740{
812/* 741/*
813 struct acpi_memory_list *mem_list; 742 struct acpi_memory_list *mem_list;
814*/ 743*/
815 744
816 ACPI_FUNCTION_TRACE ("ut_dump_allocation_info"); 745 ACPI_FUNCTION_TRACE("ut_dump_allocation_info");
817 746
818/* 747/*
819 ACPI_DEBUG_PRINT (TRACE_ALLOCATIONS | TRACE_TABLES, 748 ACPI_DEBUG_PRINT (TRACE_ALLOCATIONS | TRACE_TABLES,
@@ -826,7 +755,6 @@ acpi_ut_dump_allocation_info (
826 mem_list->max_concurrent_count, 755 mem_list->max_concurrent_count,
827 ROUND_UP_TO_1K (mem_list->max_concurrent_size))); 756 ROUND_UP_TO_1K (mem_list->max_concurrent_size)));
828 757
829
830 ACPI_DEBUG_PRINT (TRACE_ALLOCATIONS | TRACE_TABLES, 758 ACPI_DEBUG_PRINT (TRACE_ALLOCATIONS | TRACE_TABLES,
831 ("%30s: %4d (%3d Kb)\n", "Total (all) internal objects", 759 ("%30s: %4d (%3d Kb)\n", "Total (all) internal objects",
832 running_object_count, 760 running_object_count,
@@ -837,7 +765,6 @@ acpi_ut_dump_allocation_info (
837 running_alloc_count, 765 running_alloc_count,
838 ROUND_UP_TO_1K (running_alloc_size))); 766 ROUND_UP_TO_1K (running_alloc_size)));
839 767
840
841 ACPI_DEBUG_PRINT (TRACE_ALLOCATIONS | TRACE_TABLES, 768 ACPI_DEBUG_PRINT (TRACE_ALLOCATIONS | TRACE_TABLES,
842 ("%30s: %4d (%3d Kb)\n", "Current Nodes", 769 ("%30s: %4d (%3d Kb)\n", "Current Nodes",
843 acpi_gbl_current_node_count, 770 acpi_gbl_current_node_count,
@@ -851,8 +778,7 @@ acpi_ut_dump_allocation_info (
851*/ 778*/
852 return_VOID; 779 return_VOID;
853} 780}
854#endif /* ACPI_FUTURE_USAGE */ 781#endif /* ACPI_FUTURE_USAGE */
855
856 782
857/******************************************************************************* 783/*******************************************************************************
858 * 784 *
@@ -867,84 +793,87 @@ acpi_ut_dump_allocation_info (
867 * 793 *
868 ******************************************************************************/ 794 ******************************************************************************/
869 795
870void 796void acpi_ut_dump_allocations(u32 component, char *module)
871acpi_ut_dump_allocations (
872 u32 component,
873 char *module)
874{ 797{
875 struct acpi_debug_mem_block *element; 798 struct acpi_debug_mem_block *element;
876 union acpi_descriptor *descriptor; 799 union acpi_descriptor *descriptor;
877 u32 num_outstanding = 0; 800 u32 num_outstanding = 0;
878
879
880 ACPI_FUNCTION_TRACE ("ut_dump_allocations");
881 801
802 ACPI_FUNCTION_TRACE("ut_dump_allocations");
882 803
883 /* 804 /*
884 * Walk the allocation list. 805 * Walk the allocation list.
885 */ 806 */
886 if (ACPI_FAILURE (acpi_ut_acquire_mutex (ACPI_MTX_MEMORY))) { 807 if (ACPI_FAILURE(acpi_ut_acquire_mutex(ACPI_MTX_MEMORY))) {
887 return; 808 return;
888 } 809 }
889 810
890 element = acpi_gbl_global_list->list_head; 811 element = acpi_gbl_global_list->list_head;
891 while (element) { 812 while (element) {
892 if ((element->component & component) && 813 if ((element->component & component) &&
893 ((module == NULL) || (0 == ACPI_STRCMP (module, element->module)))) { 814 ((module == NULL)
815 || (0 == ACPI_STRCMP(module, element->module)))) {
894 /* Ignore allocated objects that are in a cache */ 816 /* Ignore allocated objects that are in a cache */
895 817
896 descriptor = ACPI_CAST_PTR (union acpi_descriptor, &element->user_space); 818 descriptor =
819 ACPI_CAST_PTR(union acpi_descriptor,
820 &element->user_space);
897 if (descriptor->descriptor_id != ACPI_DESC_TYPE_CACHED) { 821 if (descriptor->descriptor_id != ACPI_DESC_TYPE_CACHED) {
898 acpi_os_printf ("%p Len %04X %9.9s-%d [%s] ", 822 acpi_os_printf("%p Len %04X %9.9s-%d [%s] ",
899 descriptor, element->size, element->module, 823 descriptor, element->size,
900 element->line, acpi_ut_get_descriptor_name (descriptor)); 824 element->module, element->line,
825 acpi_ut_get_descriptor_name
826 (descriptor));
901 827
902 /* Most of the elements will be Operand objects. */ 828 /* Most of the elements will be Operand objects. */
903 829
904 switch (ACPI_GET_DESCRIPTOR_TYPE (descriptor)) { 830 switch (ACPI_GET_DESCRIPTOR_TYPE(descriptor)) {
905 case ACPI_DESC_TYPE_OPERAND: 831 case ACPI_DESC_TYPE_OPERAND:
906 acpi_os_printf ("%12.12s R%hd", 832 acpi_os_printf("%12.12s R%hd",
907 acpi_ut_get_type_name (descriptor->object.common.type), 833 acpi_ut_get_type_name
908 descriptor->object.common.reference_count); 834 (descriptor->object.
835 common.type),
836 descriptor->object.
837 common.reference_count);
909 break; 838 break;
910 839
911 case ACPI_DESC_TYPE_PARSER: 840 case ACPI_DESC_TYPE_PARSER:
912 acpi_os_printf ("aml_opcode %04hX", 841 acpi_os_printf("aml_opcode %04hX",
913 descriptor->op.asl.aml_opcode); 842 descriptor->op.asl.
843 aml_opcode);
914 break; 844 break;
915 845
916 case ACPI_DESC_TYPE_NAMED: 846 case ACPI_DESC_TYPE_NAMED:
917 acpi_os_printf ("%4.4s", 847 acpi_os_printf("%4.4s",
918 acpi_ut_get_node_name (&descriptor->node)); 848 acpi_ut_get_node_name
849 (&descriptor->node));
919 break; 850 break;
920 851
921 default: 852 default:
922 break; 853 break;
923 } 854 }
924 855
925 acpi_os_printf ( "\n"); 856 acpi_os_printf("\n");
926 num_outstanding++; 857 num_outstanding++;
927 } 858 }
928 } 859 }
929 element = element->next; 860 element = element->next;
930 } 861 }
931 862
932 (void) acpi_ut_release_mutex (ACPI_MTX_MEMORY); 863 (void)acpi_ut_release_mutex(ACPI_MTX_MEMORY);
933 864
934 /* Print summary */ 865 /* Print summary */
935 866
936 if (!num_outstanding) { 867 if (!num_outstanding) {
937 ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, 868 ACPI_DEBUG_PRINT((ACPI_DB_ERROR,
938 "No outstanding allocations.\n")); 869 "No outstanding allocations.\n"));
939 } 870 } else {
940 else { 871 ACPI_DEBUG_PRINT((ACPI_DB_ERROR,
941 ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, 872 "%d(%X) Outstanding allocations\n",
942 "%d(%X) Outstanding allocations\n", 873 num_outstanding, num_outstanding));
943 num_outstanding, num_outstanding));
944 } 874 }
945 875
946 return_VOID; 876 return_VOID;
947} 877}
948 878
949#endif /* #ifdef ACPI_DBG_TRACK_ALLOCATIONS */ 879#endif /* #ifdef ACPI_DBG_TRACK_ALLOCATIONS */
950
diff --git a/drivers/acpi/utilities/utcache.c b/drivers/acpi/utilities/utcache.c
index c0df0585c683..93d48681d276 100644
--- a/drivers/acpi/utilities/utcache.c
+++ b/drivers/acpi/utilities/utcache.c
@@ -41,12 +41,10 @@
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#define _COMPONENT ACPI_UTILITIES 46#define _COMPONENT ACPI_UTILITIES
48 ACPI_MODULE_NAME ("utcache") 47ACPI_MODULE_NAME("utcache")
49
50 48
51#ifdef ACPI_USE_LOCAL_CACHE 49#ifdef ACPI_USE_LOCAL_CACHE
52/******************************************************************************* 50/*******************************************************************************
@@ -63,19 +61,14 @@
63 * DESCRIPTION: Create a cache object 61 * DESCRIPTION: Create a cache object
64 * 62 *
65 ******************************************************************************/ 63 ******************************************************************************/
66
67acpi_status 64acpi_status
68acpi_os_create_cache ( 65acpi_os_create_cache(char *cache_name,
69 char *cache_name, 66 u16 object_size,
70 u16 object_size, 67 u16 max_depth, struct acpi_memory_list **return_cache)
71 u16 max_depth,
72 struct acpi_memory_list **return_cache)
73{ 68{
74 struct acpi_memory_list *cache; 69 struct acpi_memory_list *cache;
75
76
77 ACPI_FUNCTION_ENTRY ();
78 70
71 ACPI_FUNCTION_ENTRY();
79 72
80 if (!cache_name || !return_cache || (object_size < 16)) { 73 if (!cache_name || !return_cache || (object_size < 16)) {
81 return (AE_BAD_PARAMETER); 74 return (AE_BAD_PARAMETER);
@@ -83,24 +76,23 @@ acpi_os_create_cache (
83 76
84 /* Create the cache object */ 77 /* Create the cache object */
85 78
86 cache = acpi_os_allocate (sizeof (struct acpi_memory_list)); 79 cache = acpi_os_allocate(sizeof(struct acpi_memory_list));
87 if (!cache) { 80 if (!cache) {
88 return (AE_NO_MEMORY); 81 return (AE_NO_MEMORY);
89 } 82 }
90 83
91 /* Populate the cache object and return it */ 84 /* Populate the cache object and return it */
92 85
93 ACPI_MEMSET (cache, 0, sizeof (struct acpi_memory_list)); 86 ACPI_MEMSET(cache, 0, sizeof(struct acpi_memory_list));
94 cache->link_offset = 8; 87 cache->link_offset = 8;
95 cache->list_name = cache_name; 88 cache->list_name = cache_name;
96 cache->object_size = object_size; 89 cache->object_size = object_size;
97 cache->max_depth = max_depth; 90 cache->max_depth = max_depth;
98 91
99 *return_cache = cache; 92 *return_cache = cache;
100 return (AE_OK); 93 return (AE_OK);
101} 94}
102 95
103
104/******************************************************************************* 96/*******************************************************************************
105 * 97 *
106 * FUNCTION: acpi_os_purge_cache 98 * FUNCTION: acpi_os_purge_cache
@@ -113,15 +105,11 @@ acpi_os_create_cache (
113 * 105 *
114 ******************************************************************************/ 106 ******************************************************************************/
115 107
116acpi_status 108acpi_status acpi_os_purge_cache(struct acpi_memory_list * cache)
117acpi_os_purge_cache (
118 struct acpi_memory_list *cache)
119{ 109{
120 char *next; 110 char *next;
121
122
123 ACPI_FUNCTION_ENTRY ();
124 111
112 ACPI_FUNCTION_ENTRY();
125 113
126 if (!cache) { 114 if (!cache) {
127 return (AE_BAD_PARAMETER); 115 return (AE_BAD_PARAMETER);
@@ -132,9 +120,11 @@ acpi_os_purge_cache (
132 while (cache->list_head) { 120 while (cache->list_head) {
133 /* Delete and unlink one cached state object */ 121 /* Delete and unlink one cached state object */
134 122
135 next = *(ACPI_CAST_INDIRECT_PTR (char, 123 next = *(ACPI_CAST_INDIRECT_PTR(char,
136 &(((char *) cache->list_head)[cache->link_offset]))); 124 &(((char *)cache->
137 ACPI_MEM_FREE (cache->list_head); 125 list_head)[cache->
126 link_offset])));
127 ACPI_MEM_FREE(cache->list_head);
138 128
139 cache->list_head = next; 129 cache->list_head = next;
140 cache->current_depth--; 130 cache->current_depth--;
@@ -143,7 +133,6 @@ acpi_os_purge_cache (
143 return (AE_OK); 133 return (AE_OK);
144} 134}
145 135
146
147/******************************************************************************* 136/*******************************************************************************
148 * 137 *
149 * FUNCTION: acpi_os_delete_cache 138 * FUNCTION: acpi_os_delete_cache
@@ -157,30 +146,25 @@ acpi_os_purge_cache (
157 * 146 *
158 ******************************************************************************/ 147 ******************************************************************************/
159 148
160acpi_status 149acpi_status acpi_os_delete_cache(struct acpi_memory_list * cache)
161acpi_os_delete_cache (
162 struct acpi_memory_list *cache)
163{ 150{
164 acpi_status status; 151 acpi_status status;
165
166 152
167 ACPI_FUNCTION_ENTRY (); 153 ACPI_FUNCTION_ENTRY();
168 154
155 /* Purge all objects in the cache */
169 156
170 /* Purge all objects in the cache */ 157 status = acpi_os_purge_cache(cache);
171 158 if (ACPI_FAILURE(status)) {
172 status = acpi_os_purge_cache (cache);
173 if (ACPI_FAILURE (status)) {
174 return (status); 159 return (status);
175 } 160 }
176 161
177 /* Now we can delete the cache object */ 162 /* Now we can delete the cache object */
178 163
179 acpi_os_free (cache); 164 acpi_os_free(cache);
180 return (AE_OK); 165 return (AE_OK);
181} 166}
182 167
183
184/******************************************************************************* 168/*******************************************************************************
185 * 169 *
186 * FUNCTION: acpi_os_release_object 170 * FUNCTION: acpi_os_release_object
@@ -196,15 +180,11 @@ acpi_os_delete_cache (
196 ******************************************************************************/ 180 ******************************************************************************/
197 181
198acpi_status 182acpi_status
199acpi_os_release_object ( 183acpi_os_release_object(struct acpi_memory_list * cache, void *object)
200 struct acpi_memory_list *cache,
201 void *object)
202{ 184{
203 acpi_status status; 185 acpi_status status;
204
205
206 ACPI_FUNCTION_ENTRY ();
207 186
187 ACPI_FUNCTION_ENTRY();
208 188
209 if (!cache || !object) { 189 if (!cache || !object) {
210 return (AE_BAD_PARAMETER); 190 return (AE_BAD_PARAMETER);
@@ -213,37 +193,38 @@ acpi_os_release_object (
213 /* If cache is full, just free this object */ 193 /* If cache is full, just free this object */
214 194
215 if (cache->current_depth >= cache->max_depth) { 195 if (cache->current_depth >= cache->max_depth) {
216 ACPI_MEM_FREE (object); 196 ACPI_MEM_FREE(object);
217 ACPI_MEM_TRACKING (cache->total_freed++); 197 ACPI_MEM_TRACKING(cache->total_freed++);
218 } 198 }
219 199
220 /* Otherwise put this object back into the cache */ 200 /* Otherwise put this object back into the cache */
221 201
222 else { 202 else {
223 status = acpi_ut_acquire_mutex (ACPI_MTX_CACHES); 203 status = acpi_ut_acquire_mutex(ACPI_MTX_CACHES);
224 if (ACPI_FAILURE (status)) { 204 if (ACPI_FAILURE(status)) {
225 return (status); 205 return (status);
226 } 206 }
227 207
228 /* Mark the object as cached */ 208 /* Mark the object as cached */
229 209
230 ACPI_MEMSET (object, 0xCA, cache->object_size); 210 ACPI_MEMSET(object, 0xCA, cache->object_size);
231 ACPI_SET_DESCRIPTOR_TYPE (object, ACPI_DESC_TYPE_CACHED); 211 ACPI_SET_DESCRIPTOR_TYPE(object, ACPI_DESC_TYPE_CACHED);
232 212
233 /* Put the object at the head of the cache list */ 213 /* Put the object at the head of the cache list */
234 214
235 * (ACPI_CAST_INDIRECT_PTR (char, 215 *(ACPI_CAST_INDIRECT_PTR(char,
236 &(((char *) object)[cache->link_offset]))) = cache->list_head; 216 &(((char *)object)[cache->
217 link_offset]))) =
218 cache->list_head;
237 cache->list_head = object; 219 cache->list_head = object;
238 cache->current_depth++; 220 cache->current_depth++;
239 221
240 (void) acpi_ut_release_mutex (ACPI_MTX_CACHES); 222 (void)acpi_ut_release_mutex(ACPI_MTX_CACHES);
241 } 223 }
242 224
243 return (AE_OK); 225 return (AE_OK);
244} 226}
245 227
246
247/******************************************************************************* 228/*******************************************************************************
248 * 229 *
249 * FUNCTION: acpi_os_acquire_object 230 * FUNCTION: acpi_os_acquire_object
@@ -257,27 +238,23 @@ acpi_os_release_object (
257 * 238 *
258 ******************************************************************************/ 239 ******************************************************************************/
259 240
260void * 241void *acpi_os_acquire_object(struct acpi_memory_list *cache)
261acpi_os_acquire_object (
262 struct acpi_memory_list *cache)
263{ 242{
264 acpi_status status; 243 acpi_status status;
265 void *object; 244 void *object;
266
267
268 ACPI_FUNCTION_NAME ("os_acquire_object");
269 245
246 ACPI_FUNCTION_NAME("os_acquire_object");
270 247
271 if (!cache) { 248 if (!cache) {
272 return (NULL); 249 return (NULL);
273 } 250 }
274 251
275 status = acpi_ut_acquire_mutex (ACPI_MTX_CACHES); 252 status = acpi_ut_acquire_mutex(ACPI_MTX_CACHES);
276 if (ACPI_FAILURE (status)) { 253 if (ACPI_FAILURE(status)) {
277 return (NULL); 254 return (NULL);
278 } 255 }
279 256
280 ACPI_MEM_TRACKING (cache->requests++); 257 ACPI_MEM_TRACKING(cache->requests++);
281 258
282 /* Check the cache first */ 259 /* Check the cache first */
283 260
@@ -285,37 +262,39 @@ acpi_os_acquire_object (
285 /* There is an object available, use it */ 262 /* There is an object available, use it */
286 263
287 object = cache->list_head; 264 object = cache->list_head;
288 cache->list_head = *(ACPI_CAST_INDIRECT_PTR (char, 265 cache->list_head = *(ACPI_CAST_INDIRECT_PTR(char,
289 &(((char *) object)[cache->link_offset]))); 266 &(((char *)
267 object)[cache->
268 link_offset])));
290 269
291 cache->current_depth--; 270 cache->current_depth--;
292 271
293 ACPI_MEM_TRACKING (cache->hits++); 272 ACPI_MEM_TRACKING(cache->hits++);
294 ACPI_MEM_TRACKING (ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, 273 ACPI_MEM_TRACKING(ACPI_DEBUG_PRINT((ACPI_DB_EXEC,
295 "Object %p from %s cache\n", object, cache->list_name))); 274 "Object %p from %s cache\n",
275 object, cache->list_name)));
296 276
297 status = acpi_ut_release_mutex (ACPI_MTX_CACHES); 277 status = acpi_ut_release_mutex(ACPI_MTX_CACHES);
298 if (ACPI_FAILURE (status)) { 278 if (ACPI_FAILURE(status)) {
299 return (NULL); 279 return (NULL);
300 } 280 }
301 281
302 /* Clear (zero) the previously used Object */ 282 /* Clear (zero) the previously used Object */
303 283
304 ACPI_MEMSET (object, 0, cache->object_size); 284 ACPI_MEMSET(object, 0, cache->object_size);
305 } 285 } else {
306 else {
307 /* The cache is empty, create a new object */ 286 /* The cache is empty, create a new object */
308 287
309 ACPI_MEM_TRACKING (cache->total_allocated++); 288 ACPI_MEM_TRACKING(cache->total_allocated++);
310 289
311 /* Avoid deadlock with ACPI_MEM_CALLOCATE */ 290 /* Avoid deadlock with ACPI_MEM_CALLOCATE */
312 291
313 status = acpi_ut_release_mutex (ACPI_MTX_CACHES); 292 status = acpi_ut_release_mutex(ACPI_MTX_CACHES);
314 if (ACPI_FAILURE (status)) { 293 if (ACPI_FAILURE(status)) {
315 return (NULL); 294 return (NULL);
316 } 295 }
317 296
318 object = ACPI_MEM_CALLOCATE (cache->object_size); 297 object = ACPI_MEM_CALLOCATE(cache->object_size);
319 if (!object) { 298 if (!object) {
320 return (NULL); 299 return (NULL);
321 } 300 }
@@ -323,6 +302,4 @@ acpi_os_acquire_object (
323 302
324 return (object); 303 return (object);
325} 304}
326#endif /* ACPI_USE_LOCAL_CACHE */ 305#endif /* ACPI_USE_LOCAL_CACHE */
327
328
diff --git a/drivers/acpi/utilities/utcopy.c b/drivers/acpi/utilities/utcopy.c
index 31c30a32e5c9..5442b32de611 100644
--- a/drivers/acpi/utilities/utcopy.c
+++ b/drivers/acpi/utilities/utcopy.c
@@ -41,59 +41,46 @@
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 46
48
49#define _COMPONENT ACPI_UTILITIES 47#define _COMPONENT ACPI_UTILITIES
50 ACPI_MODULE_NAME ("utcopy") 48ACPI_MODULE_NAME("utcopy")
51 49
52/* Local prototypes */ 50/* Local prototypes */
53
54static acpi_status 51static acpi_status
55acpi_ut_copy_isimple_to_esimple ( 52acpi_ut_copy_isimple_to_esimple(union acpi_operand_object *internal_object,
56 union acpi_operand_object *internal_object, 53 union acpi_object *external_object,
57 union acpi_object *external_object, 54 u8 * data_space, acpi_size * buffer_space_used);
58 u8 *data_space,
59 acpi_size *buffer_space_used);
60 55
61static acpi_status 56static acpi_status
62acpi_ut_copy_ielement_to_ielement ( 57acpi_ut_copy_ielement_to_ielement(u8 object_type,
63 u8 object_type, 58 union acpi_operand_object *source_object,
64 union acpi_operand_object *source_object, 59 union acpi_generic_state *state,
65 union acpi_generic_state *state, 60 void *context);
66 void *context);
67 61
68static acpi_status 62static acpi_status
69acpi_ut_copy_ipackage_to_epackage ( 63acpi_ut_copy_ipackage_to_epackage(union acpi_operand_object *internal_object,
70 union acpi_operand_object *internal_object, 64 u8 * buffer, acpi_size * space_used);
71 u8 *buffer,
72 acpi_size *space_used);
73 65
74static acpi_status 66static acpi_status
75acpi_ut_copy_esimple_to_isimple( 67acpi_ut_copy_esimple_to_isimple(union acpi_object *user_obj,
76 union acpi_object *user_obj, 68 union acpi_operand_object **return_obj);
77 union acpi_operand_object **return_obj);
78 69
79static acpi_status 70static acpi_status
80acpi_ut_copy_simple_object ( 71acpi_ut_copy_simple_object(union acpi_operand_object *source_desc,
81 union acpi_operand_object *source_desc, 72 union acpi_operand_object *dest_desc);
82 union acpi_operand_object *dest_desc);
83 73
84static acpi_status 74static acpi_status
85acpi_ut_copy_ielement_to_eelement ( 75acpi_ut_copy_ielement_to_eelement(u8 object_type,
86 u8 object_type, 76 union acpi_operand_object *source_object,
87 union acpi_operand_object *source_object, 77 union acpi_generic_state *state,
88 union acpi_generic_state *state, 78 void *context);
89 void *context);
90 79
91static acpi_status 80static acpi_status
92acpi_ut_copy_ipackage_to_ipackage ( 81acpi_ut_copy_ipackage_to_ipackage(union acpi_operand_object *source_obj,
93 union acpi_operand_object *source_obj, 82 union acpi_operand_object *dest_obj,
94 union acpi_operand_object *dest_obj, 83 struct acpi_walk_state *walk_state);
95 struct acpi_walk_state *walk_state);
96
97 84
98/******************************************************************************* 85/*******************************************************************************
99 * 86 *
@@ -116,17 +103,13 @@ acpi_ut_copy_ipackage_to_ipackage (
116 ******************************************************************************/ 103 ******************************************************************************/
117 104
118static acpi_status 105static acpi_status
119acpi_ut_copy_isimple_to_esimple ( 106acpi_ut_copy_isimple_to_esimple(union acpi_operand_object *internal_object,
120 union acpi_operand_object *internal_object, 107 union acpi_object *external_object,
121 union acpi_object *external_object, 108 u8 * data_space, acpi_size * buffer_space_used)
122 u8 *data_space,
123 acpi_size *buffer_space_used)
124{ 109{
125 acpi_status status = AE_OK; 110 acpi_status status = AE_OK;
126
127
128 ACPI_FUNCTION_TRACE ("ut_copy_isimple_to_esimple");
129 111
112 ACPI_FUNCTION_TRACE("ut_copy_isimple_to_esimple");
130 113
131 *buffer_space_used = 0; 114 *buffer_space_used = 0;
132 115
@@ -135,54 +118,54 @@ acpi_ut_copy_isimple_to_esimple (
135 * package element) 118 * package element)
136 */ 119 */
137 if (!internal_object) { 120 if (!internal_object) {
138 return_ACPI_STATUS (AE_OK); 121 return_ACPI_STATUS(AE_OK);
139 } 122 }
140 123
141 /* Always clear the external object */ 124 /* Always clear the external object */
142 125
143 ACPI_MEMSET (external_object, 0, sizeof (union acpi_object)); 126 ACPI_MEMSET(external_object, 0, sizeof(union acpi_object));
144 127
145 /* 128 /*
146 * In general, the external object will be the same type as 129 * In general, the external object will be the same type as
147 * the internal object 130 * the internal object
148 */ 131 */
149 external_object->type = ACPI_GET_OBJECT_TYPE (internal_object); 132 external_object->type = ACPI_GET_OBJECT_TYPE(internal_object);
150 133
151 /* However, only a limited number of external types are supported */ 134 /* However, only a limited number of external types are supported */
152 135
153 switch (ACPI_GET_OBJECT_TYPE (internal_object)) { 136 switch (ACPI_GET_OBJECT_TYPE(internal_object)) {
154 case ACPI_TYPE_STRING: 137 case ACPI_TYPE_STRING:
155 138
156 external_object->string.pointer = (char *) data_space; 139 external_object->string.pointer = (char *)data_space;
157 external_object->string.length = internal_object->string.length; 140 external_object->string.length = internal_object->string.length;
158 *buffer_space_used = ACPI_ROUND_UP_TO_NATIVE_WORD ( 141 *buffer_space_used = ACPI_ROUND_UP_TO_NATIVE_WORD((acpi_size)
159 (acpi_size) internal_object->string.length + 1); 142 internal_object->
160 143 string.
161 ACPI_MEMCPY ((void *) data_space, 144 length + 1);
162 (void *) internal_object->string.pointer, 145
163 (acpi_size) internal_object->string.length + 1); 146 ACPI_MEMCPY((void *)data_space,
147 (void *)internal_object->string.pointer,
148 (acpi_size) internal_object->string.length + 1);
164 break; 149 break;
165 150
166
167 case ACPI_TYPE_BUFFER: 151 case ACPI_TYPE_BUFFER:
168 152
169 external_object->buffer.pointer = data_space; 153 external_object->buffer.pointer = data_space;
170 external_object->buffer.length = internal_object->buffer.length; 154 external_object->buffer.length = internal_object->buffer.length;
171 *buffer_space_used = ACPI_ROUND_UP_TO_NATIVE_WORD ( 155 *buffer_space_used =
172 internal_object->string.length); 156 ACPI_ROUND_UP_TO_NATIVE_WORD(internal_object->string.
157 length);
173 158
174 ACPI_MEMCPY ((void *) data_space, 159 ACPI_MEMCPY((void *)data_space,
175 (void *) internal_object->buffer.pointer, 160 (void *)internal_object->buffer.pointer,
176 internal_object->buffer.length); 161 internal_object->buffer.length);
177 break; 162 break;
178 163
179
180 case ACPI_TYPE_INTEGER: 164 case ACPI_TYPE_INTEGER:
181 165
182 external_object->integer.value = internal_object->integer.value; 166 external_object->integer.value = internal_object->integer.value;
183 break; 167 break;
184 168
185
186 case ACPI_TYPE_LOCAL_REFERENCE: 169 case ACPI_TYPE_LOCAL_REFERENCE:
187 170
188 /* 171 /*
@@ -199,41 +182,41 @@ acpi_ut_copy_isimple_to_esimple (
199 * to object containing a handle to an ACPI named object. 182 * to object containing a handle to an ACPI named object.
200 */ 183 */
201 external_object->type = ACPI_TYPE_ANY; 184 external_object->type = ACPI_TYPE_ANY;
202 external_object->reference.handle = internal_object->reference.node; 185 external_object->reference.handle =
186 internal_object->reference.node;
203 break; 187 break;
204 } 188 }
205 break; 189 break;
206 190
207
208 case ACPI_TYPE_PROCESSOR: 191 case ACPI_TYPE_PROCESSOR:
209 192
210 external_object->processor.proc_id = internal_object->processor.proc_id; 193 external_object->processor.proc_id =
211 external_object->processor.pblk_address = internal_object->processor.address; 194 internal_object->processor.proc_id;
212 external_object->processor.pblk_length = internal_object->processor.length; 195 external_object->processor.pblk_address =
196 internal_object->processor.address;
197 external_object->processor.pblk_length =
198 internal_object->processor.length;
213 break; 199 break;
214 200
215
216 case ACPI_TYPE_POWER: 201 case ACPI_TYPE_POWER:
217 202
218 external_object->power_resource.system_level = 203 external_object->power_resource.system_level =
219 internal_object->power_resource.system_level; 204 internal_object->power_resource.system_level;
220 205
221 external_object->power_resource.resource_order = 206 external_object->power_resource.resource_order =
222 internal_object->power_resource.resource_order; 207 internal_object->power_resource.resource_order;
223 break; 208 break;
224 209
225
226 default: 210 default:
227 /* 211 /*
228 * There is no corresponding external object type 212 * There is no corresponding external object type
229 */ 213 */
230 return_ACPI_STATUS (AE_SUPPORT); 214 return_ACPI_STATUS(AE_SUPPORT);
231 } 215 }
232 216
233 return_ACPI_STATUS (status); 217 return_ACPI_STATUS(status);
234} 218}
235 219
236
237/******************************************************************************* 220/*******************************************************************************
238 * 221 *
239 * FUNCTION: acpi_ut_copy_ielement_to_eelement 222 * FUNCTION: acpi_ut_copy_ielement_to_eelement
@@ -247,25 +230,23 @@ acpi_ut_copy_isimple_to_esimple (
247 ******************************************************************************/ 230 ******************************************************************************/
248 231
249static acpi_status 232static acpi_status
250acpi_ut_copy_ielement_to_eelement ( 233acpi_ut_copy_ielement_to_eelement(u8 object_type,
251 u8 object_type, 234 union acpi_operand_object *source_object,
252 union acpi_operand_object *source_object, 235 union acpi_generic_state *state,
253 union acpi_generic_state *state, 236 void *context)
254 void *context)
255{ 237{
256 acpi_status status = AE_OK; 238 acpi_status status = AE_OK;
257 struct acpi_pkg_info *info = (struct acpi_pkg_info *) context; 239 struct acpi_pkg_info *info = (struct acpi_pkg_info *)context;
258 acpi_size object_space; 240 acpi_size object_space;
259 u32 this_index; 241 u32 this_index;
260 union acpi_object *target_object; 242 union acpi_object *target_object;
261
262 243
263 ACPI_FUNCTION_ENTRY (); 244 ACPI_FUNCTION_ENTRY();
264 245
265 246 this_index = state->pkg.index;
266 this_index = state->pkg.index;
267 target_object = (union acpi_object *) 247 target_object = (union acpi_object *)
268 &((union acpi_object *)(state->pkg.dest_object))->package.elements[this_index]; 248 &((union acpi_object *)(state->pkg.dest_object))->package.
249 elements[this_index];
269 250
270 switch (object_type) { 251 switch (object_type) {
271 case ACPI_COPY_TYPE_SIMPLE: 252 case ACPI_COPY_TYPE_SIMPLE:
@@ -273,23 +254,24 @@ acpi_ut_copy_ielement_to_eelement (
273 /* 254 /*
274 * This is a simple or null object 255 * This is a simple or null object
275 */ 256 */
276 status = acpi_ut_copy_isimple_to_esimple (source_object, 257 status = acpi_ut_copy_isimple_to_esimple(source_object,
277 target_object, info->free_space, &object_space); 258 target_object,
278 if (ACPI_FAILURE (status)) { 259 info->free_space,
260 &object_space);
261 if (ACPI_FAILURE(status)) {
279 return (status); 262 return (status);
280 } 263 }
281 break; 264 break;
282 265
283
284 case ACPI_COPY_TYPE_PACKAGE: 266 case ACPI_COPY_TYPE_PACKAGE:
285 267
286 /* 268 /*
287 * Build the package object 269 * Build the package object
288 */ 270 */
289 target_object->type = ACPI_TYPE_PACKAGE; 271 target_object->type = ACPI_TYPE_PACKAGE;
290 target_object->package.count = source_object->package.count; 272 target_object->package.count = source_object->package.count;
291 target_object->package.elements = 273 target_object->package.elements =
292 ACPI_CAST_PTR (union acpi_object, info->free_space); 274 ACPI_CAST_PTR(union acpi_object, info->free_space);
293 275
294 /* 276 /*
295 * Pass the new package object back to the package walk routine 277 * Pass the new package object back to the package walk routine
@@ -300,22 +282,22 @@ acpi_ut_copy_ielement_to_eelement (
300 * Save space for the array of objects (Package elements) 282 * Save space for the array of objects (Package elements)
301 * update the buffer length counter 283 * update the buffer length counter
302 */ 284 */
303 object_space = ACPI_ROUND_UP_TO_NATIVE_WORD ( 285 object_space = ACPI_ROUND_UP_TO_NATIVE_WORD((acpi_size)
304 (acpi_size) target_object->package.count * 286 target_object->
305 sizeof (union acpi_object)); 287 package.count *
288 sizeof(union
289 acpi_object));
306 break; 290 break;
307 291
308
309 default: 292 default:
310 return (AE_BAD_PARAMETER); 293 return (AE_BAD_PARAMETER);
311 } 294 }
312 295
313 info->free_space += object_space; 296 info->free_space += object_space;
314 info->length += object_space; 297 info->length += object_space;
315 return (status); 298 return (status);
316} 299}
317 300
318
319/******************************************************************************* 301/*******************************************************************************
320 * 302 *
321 * FUNCTION: acpi_ut_copy_ipackage_to_epackage 303 * FUNCTION: acpi_ut_copy_ipackage_to_epackage
@@ -336,55 +318,51 @@ acpi_ut_copy_ielement_to_eelement (
336 ******************************************************************************/ 318 ******************************************************************************/
337 319
338static acpi_status 320static acpi_status
339acpi_ut_copy_ipackage_to_epackage ( 321acpi_ut_copy_ipackage_to_epackage(union acpi_operand_object *internal_object,
340 union acpi_operand_object *internal_object, 322 u8 * buffer, acpi_size * space_used)
341 u8 *buffer,
342 acpi_size *space_used)
343{ 323{
344 union acpi_object *external_object; 324 union acpi_object *external_object;
345 acpi_status status; 325 acpi_status status;
346 struct acpi_pkg_info info; 326 struct acpi_pkg_info info;
347
348
349 ACPI_FUNCTION_TRACE ("ut_copy_ipackage_to_epackage");
350 327
328 ACPI_FUNCTION_TRACE("ut_copy_ipackage_to_epackage");
351 329
352 /* 330 /*
353 * First package at head of the buffer 331 * First package at head of the buffer
354 */ 332 */
355 external_object = ACPI_CAST_PTR (union acpi_object, buffer); 333 external_object = ACPI_CAST_PTR(union acpi_object, buffer);
356 334
357 /* 335 /*
358 * Free space begins right after the first package 336 * Free space begins right after the first package
359 */ 337 */
360 info.length = ACPI_ROUND_UP_TO_NATIVE_WORD (sizeof (union acpi_object)); 338 info.length = ACPI_ROUND_UP_TO_NATIVE_WORD(sizeof(union acpi_object));
361 info.free_space = buffer + ACPI_ROUND_UP_TO_NATIVE_WORD ( 339 info.free_space =
362 sizeof (union acpi_object)); 340 buffer + ACPI_ROUND_UP_TO_NATIVE_WORD(sizeof(union acpi_object));
363 info.object_space = 0; 341 info.object_space = 0;
364 info.num_packages = 1; 342 info.num_packages = 1;
365 343
366 external_object->type = ACPI_GET_OBJECT_TYPE (internal_object); 344 external_object->type = ACPI_GET_OBJECT_TYPE(internal_object);
367 external_object->package.count = internal_object->package.count; 345 external_object->package.count = internal_object->package.count;
368 external_object->package.elements = ACPI_CAST_PTR (union acpi_object, 346 external_object->package.elements = ACPI_CAST_PTR(union acpi_object,
369 info.free_space); 347 info.free_space);
370 348
371 /* 349 /*
372 * Leave room for an array of ACPI_OBJECTS in the buffer 350 * Leave room for an array of ACPI_OBJECTS in the buffer
373 * and move the free space past it 351 * and move the free space past it
374 */ 352 */
375 info.length += (acpi_size) external_object->package.count * 353 info.length += (acpi_size) external_object->package.count *
376 ACPI_ROUND_UP_TO_NATIVE_WORD (sizeof (union acpi_object)); 354 ACPI_ROUND_UP_TO_NATIVE_WORD(sizeof(union acpi_object));
377 info.free_space += external_object->package.count * 355 info.free_space += external_object->package.count *
378 ACPI_ROUND_UP_TO_NATIVE_WORD (sizeof (union acpi_object)); 356 ACPI_ROUND_UP_TO_NATIVE_WORD(sizeof(union acpi_object));
379 357
380 status = acpi_ut_walk_package_tree (internal_object, external_object, 358 status = acpi_ut_walk_package_tree(internal_object, external_object,
381 acpi_ut_copy_ielement_to_eelement, &info); 359 acpi_ut_copy_ielement_to_eelement,
360 &info);
382 361
383 *space_used = info.length; 362 *space_used = info.length;
384 return_ACPI_STATUS (status); 363 return_ACPI_STATUS(status);
385} 364}
386 365
387
388/******************************************************************************* 366/*******************************************************************************
389 * 367 *
390 * FUNCTION: acpi_ut_copy_iobject_to_eobject 368 * FUNCTION: acpi_ut_copy_iobject_to_eobject
@@ -400,44 +378,45 @@ acpi_ut_copy_ipackage_to_epackage (
400 ******************************************************************************/ 378 ******************************************************************************/
401 379
402acpi_status 380acpi_status
403acpi_ut_copy_iobject_to_eobject ( 381acpi_ut_copy_iobject_to_eobject(union acpi_operand_object *internal_object,
404 union acpi_operand_object *internal_object, 382 struct acpi_buffer *ret_buffer)
405 struct acpi_buffer *ret_buffer)
406{ 383{
407 acpi_status status; 384 acpi_status status;
408 385
386 ACPI_FUNCTION_TRACE("ut_copy_iobject_to_eobject");
409 387
410 ACPI_FUNCTION_TRACE ("ut_copy_iobject_to_eobject"); 388 if (ACPI_GET_OBJECT_TYPE(internal_object) == ACPI_TYPE_PACKAGE) {
411
412
413 if (ACPI_GET_OBJECT_TYPE (internal_object) == ACPI_TYPE_PACKAGE) {
414 /* 389 /*
415 * Package object: Copy all subobjects (including 390 * Package object: Copy all subobjects (including
416 * nested packages) 391 * nested packages)
417 */ 392 */
418 status = acpi_ut_copy_ipackage_to_epackage (internal_object, 393 status = acpi_ut_copy_ipackage_to_epackage(internal_object,
419 ret_buffer->pointer, &ret_buffer->length); 394 ret_buffer->pointer,
420 } 395 &ret_buffer->length);
421 else { 396 } else {
422 /* 397 /*
423 * Build a simple object (no nested objects) 398 * Build a simple object (no nested objects)
424 */ 399 */
425 status = acpi_ut_copy_isimple_to_esimple (internal_object, 400 status = acpi_ut_copy_isimple_to_esimple(internal_object,
426 (union acpi_object *) ret_buffer->pointer, 401 (union acpi_object *)
427 ((u8 *) ret_buffer->pointer + 402 ret_buffer->pointer,
428 ACPI_ROUND_UP_TO_NATIVE_WORD (sizeof (union acpi_object))), 403 ((u8 *) ret_buffer->
429 &ret_buffer->length); 404 pointer +
405 ACPI_ROUND_UP_TO_NATIVE_WORD
406 (sizeof
407 (union
408 acpi_object))),
409 &ret_buffer->length);
430 /* 410 /*
431 * build simple does not include the object size in the length 411 * build simple does not include the object size in the length
432 * so we add it in here 412 * so we add it in here
433 */ 413 */
434 ret_buffer->length += sizeof (union acpi_object); 414 ret_buffer->length += sizeof(union acpi_object);
435 } 415 }
436 416
437 return_ACPI_STATUS (status); 417 return_ACPI_STATUS(status);
438} 418}
439 419
440
441/******************************************************************************* 420/*******************************************************************************
442 * 421 *
443 * FUNCTION: acpi_ut_copy_esimple_to_isimple 422 * FUNCTION: acpi_ut_copy_esimple_to_isimple
@@ -455,15 +434,12 @@ acpi_ut_copy_iobject_to_eobject (
455 ******************************************************************************/ 434 ******************************************************************************/
456 435
457static acpi_status 436static acpi_status
458acpi_ut_copy_esimple_to_isimple ( 437acpi_ut_copy_esimple_to_isimple(union acpi_object *external_object,
459 union acpi_object *external_object, 438 union acpi_operand_object **ret_internal_object)
460 union acpi_operand_object **ret_internal_object)
461{ 439{
462 union acpi_operand_object *internal_object; 440 union acpi_operand_object *internal_object;
463
464
465 ACPI_FUNCTION_TRACE ("ut_copy_esimple_to_isimple");
466 441
442 ACPI_FUNCTION_TRACE("ut_copy_esimple_to_isimple");
467 443
468 /* 444 /*
469 * Simple types supported are: String, Buffer, Integer 445 * Simple types supported are: String, Buffer, Integer
@@ -473,58 +449,57 @@ acpi_ut_copy_esimple_to_isimple (
473 case ACPI_TYPE_BUFFER: 449 case ACPI_TYPE_BUFFER:
474 case ACPI_TYPE_INTEGER: 450 case ACPI_TYPE_INTEGER:
475 451
476 internal_object = acpi_ut_create_internal_object ( 452 internal_object = acpi_ut_create_internal_object((u8)
477 (u8) external_object->type); 453 external_object->
454 type);
478 if (!internal_object) { 455 if (!internal_object) {
479 return_ACPI_STATUS (AE_NO_MEMORY); 456 return_ACPI_STATUS(AE_NO_MEMORY);
480 } 457 }
481 break; 458 break;
482 459
483 default: 460 default:
484 /* All other types are not supported */ 461 /* All other types are not supported */
485 462
486 return_ACPI_STATUS (AE_SUPPORT); 463 return_ACPI_STATUS(AE_SUPPORT);
487 } 464 }
488 465
489
490 /* Must COPY string and buffer contents */ 466 /* Must COPY string and buffer contents */
491 467
492 switch (external_object->type) { 468 switch (external_object->type) {
493 case ACPI_TYPE_STRING: 469 case ACPI_TYPE_STRING:
494 470
495 internal_object->string.pointer = 471 internal_object->string.pointer =
496 ACPI_MEM_CALLOCATE ((acpi_size) external_object->string.length + 1); 472 ACPI_MEM_CALLOCATE((acpi_size) external_object->string.
473 length + 1);
497 if (!internal_object->string.pointer) { 474 if (!internal_object->string.pointer) {
498 goto error_exit; 475 goto error_exit;
499 } 476 }
500 477
501 ACPI_MEMCPY (internal_object->string.pointer, 478 ACPI_MEMCPY(internal_object->string.pointer,
502 external_object->string.pointer, 479 external_object->string.pointer,
503 external_object->string.length); 480 external_object->string.length);
504 481
505 internal_object->string.length = external_object->string.length; 482 internal_object->string.length = external_object->string.length;
506 break; 483 break;
507 484
508
509 case ACPI_TYPE_BUFFER: 485 case ACPI_TYPE_BUFFER:
510 486
511 internal_object->buffer.pointer = 487 internal_object->buffer.pointer =
512 ACPI_MEM_CALLOCATE (external_object->buffer.length); 488 ACPI_MEM_CALLOCATE(external_object->buffer.length);
513 if (!internal_object->buffer.pointer) { 489 if (!internal_object->buffer.pointer) {
514 goto error_exit; 490 goto error_exit;
515 } 491 }
516 492
517 ACPI_MEMCPY (internal_object->buffer.pointer, 493 ACPI_MEMCPY(internal_object->buffer.pointer,
518 external_object->buffer.pointer, 494 external_object->buffer.pointer,
519 external_object->buffer.length); 495 external_object->buffer.length);
520 496
521 internal_object->buffer.length = external_object->buffer.length; 497 internal_object->buffer.length = external_object->buffer.length;
522 break; 498 break;
523 499
524
525 case ACPI_TYPE_INTEGER: 500 case ACPI_TYPE_INTEGER:
526 501
527 internal_object->integer.value = external_object->integer.value; 502 internal_object->integer.value = external_object->integer.value;
528 break; 503 break;
529 504
530 default: 505 default:
@@ -533,15 +508,13 @@ acpi_ut_copy_esimple_to_isimple (
533 } 508 }
534 509
535 *ret_internal_object = internal_object; 510 *ret_internal_object = internal_object;
536 return_ACPI_STATUS (AE_OK); 511 return_ACPI_STATUS(AE_OK);
537
538 512
539error_exit: 513 error_exit:
540 acpi_ut_remove_reference (internal_object); 514 acpi_ut_remove_reference(internal_object);
541 return_ACPI_STATUS (AE_NO_MEMORY); 515 return_ACPI_STATUS(AE_NO_MEMORY);
542} 516}
543 517
544
545#ifdef ACPI_FUTURE_IMPLEMENTATION 518#ifdef ACPI_FUTURE_IMPLEMENTATION
546/* Code to convert packages that are parameters to control methods */ 519/* Code to convert packages that are parameters to control methods */
547 520
@@ -565,22 +538,18 @@ error_exit:
565 ******************************************************************************/ 538 ******************************************************************************/
566 539
567static acpi_status 540static acpi_status
568acpi_ut_copy_epackage_to_ipackage ( 541acpi_ut_copy_epackage_to_ipackage(union acpi_operand_object *internal_object,
569 union acpi_operand_object *internal_object, 542 u8 * buffer, u32 * space_used)
570 u8 *buffer,
571 u32 *space_used)
572{ 543{
573 u8 *free_space; 544 u8 *free_space;
574 union acpi_object *external_object; 545 union acpi_object *external_object;
575 u32 length = 0; 546 u32 length = 0;
576 u32 this_index; 547 u32 this_index;
577 u32 object_space = 0; 548 u32 object_space = 0;
578 union acpi_operand_object *this_internal_obj; 549 union acpi_operand_object *this_internal_obj;
579 union acpi_object *this_external_obj; 550 union acpi_object *this_external_obj;
580
581
582 ACPI_FUNCTION_TRACE ("ut_copy_epackage_to_ipackage");
583 551
552 ACPI_FUNCTION_TRACE("ut_copy_epackage_to_ipackage");
584 553
585 /* 554 /*
586 * First package at head of the buffer 555 * First package at head of the buffer
@@ -592,24 +561,22 @@ acpi_ut_copy_epackage_to_ipackage (
592 */ 561 */
593 free_space = buffer + sizeof(union acpi_object); 562 free_space = buffer + sizeof(union acpi_object);
594 563
595 564 external_object->type = ACPI_GET_OBJECT_TYPE(internal_object);
596 external_object->type = ACPI_GET_OBJECT_TYPE (internal_object); 565 external_object->package.count = internal_object->package.count;
597 external_object->package.count = internal_object->package.count; 566 external_object->package.elements = (union acpi_object *)free_space;
598 external_object->package.elements = (union acpi_object *)free_space;
599 567
600 /* 568 /*
601 * Build an array of ACPI_OBJECTS in the buffer 569 * Build an array of ACPI_OBJECTS in the buffer
602 * and move the free space past it 570 * and move the free space past it
603 */ 571 */
604 free_space += external_object->package.count * sizeof(union acpi_object); 572 free_space +=
605 573 external_object->package.count * sizeof(union acpi_object);
606 574
607 /* Call walk_package */ 575 /* Call walk_package */
608 576
609} 577}
610 578
611#endif /* Future implementation */ 579#endif /* Future implementation */
612
613 580
614/******************************************************************************* 581/*******************************************************************************
615 * 582 *
@@ -625,37 +592,35 @@ acpi_ut_copy_epackage_to_ipackage (
625 ******************************************************************************/ 592 ******************************************************************************/
626 593
627acpi_status 594acpi_status
628acpi_ut_copy_eobject_to_iobject ( 595acpi_ut_copy_eobject_to_iobject(union acpi_object *external_object,
629 union acpi_object *external_object, 596 union acpi_operand_object **internal_object)
630 union acpi_operand_object **internal_object)
631{ 597{
632 acpi_status status; 598 acpi_status status;
633
634
635 ACPI_FUNCTION_TRACE ("ut_copy_eobject_to_iobject");
636 599
600 ACPI_FUNCTION_TRACE("ut_copy_eobject_to_iobject");
637 601
638 if (external_object->type == ACPI_TYPE_PACKAGE) { 602 if (external_object->type == ACPI_TYPE_PACKAGE) {
639 /* 603 /*
640 * Packages as external input to control methods are not supported, 604 * Packages as external input to control methods are not supported,
641 */ 605 */
642 ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, 606 ACPI_DEBUG_PRINT((ACPI_DB_ERROR,
643 "Packages as parameters not implemented!\n")); 607 "Packages as parameters not implemented!\n"));
644 608
645 return_ACPI_STATUS (AE_NOT_IMPLEMENTED); 609 return_ACPI_STATUS(AE_NOT_IMPLEMENTED);
646 } 610 }
647 611
648 else { 612 else {
649 /* 613 /*
650 * Build a simple object (no nested objects) 614 * Build a simple object (no nested objects)
651 */ 615 */
652 status = acpi_ut_copy_esimple_to_isimple (external_object, internal_object); 616 status =
617 acpi_ut_copy_esimple_to_isimple(external_object,
618 internal_object);
653 } 619 }
654 620
655 return_ACPI_STATUS (status); 621 return_ACPI_STATUS(status);
656} 622}
657 623
658
659/******************************************************************************* 624/*******************************************************************************
660 * 625 *
661 * FUNCTION: acpi_ut_copy_simple_object 626 * FUNCTION: acpi_ut_copy_simple_object
@@ -671,23 +636,21 @@ acpi_ut_copy_eobject_to_iobject (
671 ******************************************************************************/ 636 ******************************************************************************/
672 637
673static acpi_status 638static acpi_status
674acpi_ut_copy_simple_object ( 639acpi_ut_copy_simple_object(union acpi_operand_object *source_desc,
675 union acpi_operand_object *source_desc, 640 union acpi_operand_object *dest_desc)
676 union acpi_operand_object *dest_desc)
677{ 641{
678 u16 reference_count; 642 u16 reference_count;
679 union acpi_operand_object *next_object; 643 union acpi_operand_object *next_object;
680
681 644
682 /* Save fields from destination that we don't want to overwrite */ 645 /* Save fields from destination that we don't want to overwrite */
683 646
684 reference_count = dest_desc->common.reference_count; 647 reference_count = dest_desc->common.reference_count;
685 next_object = dest_desc->common.next_object; 648 next_object = dest_desc->common.next_object;
686 649
687 /* Copy the entire source object over the destination object*/ 650 /* Copy the entire source object over the destination object */
688 651
689 ACPI_MEMCPY ((char *) dest_desc, (char *) source_desc, 652 ACPI_MEMCPY((char *)dest_desc, (char *)source_desc,
690 sizeof (union acpi_operand_object)); 653 sizeof(union acpi_operand_object));
691 654
692 /* Restore the saved fields */ 655 /* Restore the saved fields */
693 656
@@ -700,7 +663,7 @@ acpi_ut_copy_simple_object (
700 663
701 /* Handle the objects with extra data */ 664 /* Handle the objects with extra data */
702 665
703 switch (ACPI_GET_OBJECT_TYPE (dest_desc)) { 666 switch (ACPI_GET_OBJECT_TYPE(dest_desc)) {
704 case ACPI_TYPE_BUFFER: 667 case ACPI_TYPE_BUFFER:
705 /* 668 /*
706 * Allocate and copy the actual buffer if and only if: 669 * Allocate and copy the actual buffer if and only if:
@@ -708,18 +671,18 @@ acpi_ut_copy_simple_object (
708 * 2) The buffer has a length > 0 671 * 2) The buffer has a length > 0
709 */ 672 */
710 if ((source_desc->buffer.pointer) && 673 if ((source_desc->buffer.pointer) &&
711 (source_desc->buffer.length)) { 674 (source_desc->buffer.length)) {
712 dest_desc->buffer.pointer = 675 dest_desc->buffer.pointer =
713 ACPI_MEM_ALLOCATE (source_desc->buffer.length); 676 ACPI_MEM_ALLOCATE(source_desc->buffer.length);
714 if (!dest_desc->buffer.pointer) { 677 if (!dest_desc->buffer.pointer) {
715 return (AE_NO_MEMORY); 678 return (AE_NO_MEMORY);
716 } 679 }
717 680
718 /* Copy the actual buffer data */ 681 /* Copy the actual buffer data */
719 682
720 ACPI_MEMCPY (dest_desc->buffer.pointer, 683 ACPI_MEMCPY(dest_desc->buffer.pointer,
721 source_desc->buffer.pointer, 684 source_desc->buffer.pointer,
722 source_desc->buffer.length); 685 source_desc->buffer.length);
723 } 686 }
724 break; 687 break;
725 688
@@ -731,15 +694,17 @@ acpi_ut_copy_simple_object (
731 */ 694 */
732 if (source_desc->string.pointer) { 695 if (source_desc->string.pointer) {
733 dest_desc->string.pointer = 696 dest_desc->string.pointer =
734 ACPI_MEM_ALLOCATE ((acpi_size) source_desc->string.length + 1); 697 ACPI_MEM_ALLOCATE((acpi_size) source_desc->string.
698 length + 1);
735 if (!dest_desc->string.pointer) { 699 if (!dest_desc->string.pointer) {
736 return (AE_NO_MEMORY); 700 return (AE_NO_MEMORY);
737 } 701 }
738 702
739 /* Copy the actual string data */ 703 /* Copy the actual string data */
740 704
741 ACPI_MEMCPY (dest_desc->string.pointer, source_desc->string.pointer, 705 ACPI_MEMCPY(dest_desc->string.pointer,
742 (acpi_size) source_desc->string.length + 1); 706 source_desc->string.pointer,
707 (acpi_size) source_desc->string.length + 1);
743 } 708 }
744 break; 709 break;
745 710
@@ -748,7 +713,7 @@ acpi_ut_copy_simple_object (
748 * We copied the reference object, so we now must add a reference 713 * We copied the reference object, so we now must add a reference
749 * to the object pointed to by the reference 714 * to the object pointed to by the reference
750 */ 715 */
751 acpi_ut_add_reference (source_desc->reference.object); 716 acpi_ut_add_reference(source_desc->reference.object);
752 break; 717 break;
753 718
754 default: 719 default:
@@ -759,7 +724,6 @@ acpi_ut_copy_simple_object (
759 return (AE_OK); 724 return (AE_OK);
760} 725}
761 726
762
763/******************************************************************************* 727/*******************************************************************************
764 * 728 *
765 * FUNCTION: acpi_ut_copy_ielement_to_ielement 729 * FUNCTION: acpi_ut_copy_ielement_to_ielement
@@ -773,24 +737,21 @@ acpi_ut_copy_simple_object (
773 ******************************************************************************/ 737 ******************************************************************************/
774 738
775static acpi_status 739static acpi_status
776acpi_ut_copy_ielement_to_ielement ( 740acpi_ut_copy_ielement_to_ielement(u8 object_type,
777 u8 object_type, 741 union acpi_operand_object *source_object,
778 union acpi_operand_object *source_object, 742 union acpi_generic_state *state,
779 union acpi_generic_state *state, 743 void *context)
780 void *context)
781{ 744{
782 acpi_status status = AE_OK; 745 acpi_status status = AE_OK;
783 u32 this_index; 746 u32 this_index;
784 union acpi_operand_object **this_target_ptr; 747 union acpi_operand_object **this_target_ptr;
785 union acpi_operand_object *target_object; 748 union acpi_operand_object *target_object;
786 749
750 ACPI_FUNCTION_ENTRY();
787 751
788 ACPI_FUNCTION_ENTRY (); 752 this_index = state->pkg.index;
789
790
791 this_index = state->pkg.index;
792 this_target_ptr = (union acpi_operand_object **) 753 this_target_ptr = (union acpi_operand_object **)
793 &state->pkg.dest_object->package.elements[this_index]; 754 &state->pkg.dest_object->package.elements[this_index];
794 755
795 switch (object_type) { 756 switch (object_type) {
796 case ACPI_COPY_TYPE_SIMPLE: 757 case ACPI_COPY_TYPE_SIMPLE:
@@ -801,34 +762,36 @@ acpi_ut_copy_ielement_to_ielement (
801 /* 762 /*
802 * This is a simple object, just copy it 763 * This is a simple object, just copy it
803 */ 764 */
804 target_object = acpi_ut_create_internal_object ( 765 target_object =
805 ACPI_GET_OBJECT_TYPE (source_object)); 766 acpi_ut_create_internal_object(ACPI_GET_OBJECT_TYPE
767 (source_object));
806 if (!target_object) { 768 if (!target_object) {
807 return (AE_NO_MEMORY); 769 return (AE_NO_MEMORY);
808 } 770 }
809 771
810 status = acpi_ut_copy_simple_object (source_object, target_object); 772 status =
811 if (ACPI_FAILURE (status)) { 773 acpi_ut_copy_simple_object(source_object,
774 target_object);
775 if (ACPI_FAILURE(status)) {
812 goto error_exit; 776 goto error_exit;
813 } 777 }
814 778
815 *this_target_ptr = target_object; 779 *this_target_ptr = target_object;
816 } 780 } else {
817 else {
818 /* Pass through a null element */ 781 /* Pass through a null element */
819 782
820 *this_target_ptr = NULL; 783 *this_target_ptr = NULL;
821 } 784 }
822 break; 785 break;
823 786
824
825 case ACPI_COPY_TYPE_PACKAGE: 787 case ACPI_COPY_TYPE_PACKAGE:
826 788
827 /* 789 /*
828 * This object is a package - go down another nesting level 790 * This object is a package - go down another nesting level
829 * Create and build the package object 791 * Create and build the package object
830 */ 792 */
831 target_object = acpi_ut_create_internal_object (ACPI_TYPE_PACKAGE); 793 target_object =
794 acpi_ut_create_internal_object(ACPI_TYPE_PACKAGE);
832 if (!target_object) { 795 if (!target_object) {
833 return (AE_NO_MEMORY); 796 return (AE_NO_MEMORY);
834 } 797 }
@@ -840,8 +803,8 @@ acpi_ut_copy_ielement_to_ielement (
840 * Create the object array 803 * Create the object array
841 */ 804 */
842 target_object->package.elements = 805 target_object->package.elements =
843 ACPI_MEM_CALLOCATE (((acpi_size) source_object->package.count + 1) * 806 ACPI_MEM_CALLOCATE(((acpi_size) source_object->package.
844 sizeof (void *)); 807 count + 1) * sizeof(void *));
845 if (!target_object->package.elements) { 808 if (!target_object->package.elements) {
846 status = AE_NO_MEMORY; 809 status = AE_NO_MEMORY;
847 goto error_exit; 810 goto error_exit;
@@ -858,19 +821,17 @@ acpi_ut_copy_ielement_to_ielement (
858 *this_target_ptr = target_object; 821 *this_target_ptr = target_object;
859 break; 822 break;
860 823
861
862 default: 824 default:
863 return (AE_BAD_PARAMETER); 825 return (AE_BAD_PARAMETER);
864 } 826 }
865 827
866 return (status); 828 return (status);
867 829
868error_exit: 830 error_exit:
869 acpi_ut_remove_reference (target_object); 831 acpi_ut_remove_reference(target_object);
870 return (status); 832 return (status);
871} 833}
872 834
873
874/******************************************************************************* 835/*******************************************************************************
875 * 836 *
876 * FUNCTION: acpi_ut_copy_ipackage_to_ipackage 837 * FUNCTION: acpi_ut_copy_ipackage_to_ipackage
@@ -886,49 +847,46 @@ error_exit:
886 ******************************************************************************/ 847 ******************************************************************************/
887 848
888static acpi_status 849static acpi_status
889acpi_ut_copy_ipackage_to_ipackage ( 850acpi_ut_copy_ipackage_to_ipackage(union acpi_operand_object *source_obj,
890 union acpi_operand_object *source_obj, 851 union acpi_operand_object *dest_obj,
891 union acpi_operand_object *dest_obj, 852 struct acpi_walk_state *walk_state)
892 struct acpi_walk_state *walk_state)
893{ 853{
894 acpi_status status = AE_OK; 854 acpi_status status = AE_OK;
895
896
897 ACPI_FUNCTION_TRACE ("ut_copy_ipackage_to_ipackage");
898 855
856 ACPI_FUNCTION_TRACE("ut_copy_ipackage_to_ipackage");
899 857
900 dest_obj->common.type = ACPI_GET_OBJECT_TYPE (source_obj); 858 dest_obj->common.type = ACPI_GET_OBJECT_TYPE(source_obj);
901 dest_obj->common.flags = source_obj->common.flags; 859 dest_obj->common.flags = source_obj->common.flags;
902 dest_obj->package.count = source_obj->package.count; 860 dest_obj->package.count = source_obj->package.count;
903 861
904 /* 862 /*
905 * Create the object array and walk the source package tree 863 * Create the object array and walk the source package tree
906 */ 864 */
907 dest_obj->package.elements = ACPI_MEM_CALLOCATE ( 865 dest_obj->package.elements = ACPI_MEM_CALLOCATE(((acpi_size)
908 ((acpi_size) source_obj->package.count + 1) * 866 source_obj->package.
909 sizeof (void *)); 867 count +
868 1) * sizeof(void *));
910 if (!dest_obj->package.elements) { 869 if (!dest_obj->package.elements) {
911 ACPI_REPORT_ERROR ( 870 ACPI_REPORT_ERROR(("aml_build_copy_internal_package_object: Package allocation failure\n"));
912 ("aml_build_copy_internal_package_object: Package allocation failure\n")); 871 return_ACPI_STATUS(AE_NO_MEMORY);
913 return_ACPI_STATUS (AE_NO_MEMORY);
914 } 872 }
915 873
916 /* 874 /*
917 * Copy the package element-by-element by walking the package "tree". 875 * Copy the package element-by-element by walking the package "tree".
918 * This handles nested packages of arbitrary depth. 876 * This handles nested packages of arbitrary depth.
919 */ 877 */
920 status = acpi_ut_walk_package_tree (source_obj, dest_obj, 878 status = acpi_ut_walk_package_tree(source_obj, dest_obj,
921 acpi_ut_copy_ielement_to_ielement, walk_state); 879 acpi_ut_copy_ielement_to_ielement,
922 if (ACPI_FAILURE (status)) { 880 walk_state);
881 if (ACPI_FAILURE(status)) {
923 /* On failure, delete the destination package object */ 882 /* On failure, delete the destination package object */
924 883
925 acpi_ut_remove_reference (dest_obj); 884 acpi_ut_remove_reference(dest_obj);
926 } 885 }
927 886
928 return_ACPI_STATUS (status); 887 return_ACPI_STATUS(status);
929} 888}
930 889
931
932/******************************************************************************* 890/*******************************************************************************
933 * 891 *
934 * FUNCTION: acpi_ut_copy_iobject_to_iobject 892 * FUNCTION: acpi_ut_copy_iobject_to_iobject
@@ -944,35 +902,31 @@ acpi_ut_copy_ipackage_to_ipackage (
944 ******************************************************************************/ 902 ******************************************************************************/
945 903
946acpi_status 904acpi_status
947acpi_ut_copy_iobject_to_iobject ( 905acpi_ut_copy_iobject_to_iobject(union acpi_operand_object *source_desc,
948 union acpi_operand_object *source_desc, 906 union acpi_operand_object **dest_desc,
949 union acpi_operand_object **dest_desc, 907 struct acpi_walk_state *walk_state)
950 struct acpi_walk_state *walk_state)
951{ 908{
952 acpi_status status = AE_OK; 909 acpi_status status = AE_OK;
953
954
955 ACPI_FUNCTION_TRACE ("ut_copy_iobject_to_iobject");
956 910
911 ACPI_FUNCTION_TRACE("ut_copy_iobject_to_iobject");
957 912
958 /* Create the top level object */ 913 /* Create the top level object */
959 914
960 *dest_desc = acpi_ut_create_internal_object (ACPI_GET_OBJECT_TYPE (source_desc)); 915 *dest_desc =
916 acpi_ut_create_internal_object(ACPI_GET_OBJECT_TYPE(source_desc));
961 if (!*dest_desc) { 917 if (!*dest_desc) {
962 return_ACPI_STATUS (AE_NO_MEMORY); 918 return_ACPI_STATUS(AE_NO_MEMORY);
963 } 919 }
964 920
965 /* Copy the object and possible subobjects */ 921 /* Copy the object and possible subobjects */
966 922
967 if (ACPI_GET_OBJECT_TYPE (source_desc) == ACPI_TYPE_PACKAGE) { 923 if (ACPI_GET_OBJECT_TYPE(source_desc) == ACPI_TYPE_PACKAGE) {
968 status = acpi_ut_copy_ipackage_to_ipackage (source_desc, *dest_desc, 924 status =
969 walk_state); 925 acpi_ut_copy_ipackage_to_ipackage(source_desc, *dest_desc,
970 } 926 walk_state);
971 else { 927 } else {
972 status = acpi_ut_copy_simple_object (source_desc, *dest_desc); 928 status = acpi_ut_copy_simple_object(source_desc, *dest_desc);
973 } 929 }
974 930
975 return_ACPI_STATUS (status); 931 return_ACPI_STATUS(status);
976} 932}
977
978
diff --git a/drivers/acpi/utilities/utdebug.c b/drivers/acpi/utilities/utdebug.c
index c27cbb7f5c54..081a778aba88 100644
--- a/drivers/acpi/utilities/utdebug.c
+++ b/drivers/acpi/utilities/utdebug.c
@@ -46,21 +46,16 @@
46#include <acpi/acpi.h> 46#include <acpi/acpi.h>
47 47
48#define _COMPONENT ACPI_UTILITIES 48#define _COMPONENT ACPI_UTILITIES
49 ACPI_MODULE_NAME ("utdebug") 49ACPI_MODULE_NAME("utdebug")
50
51 50
52#ifdef ACPI_DEBUG_OUTPUT 51#ifdef ACPI_DEBUG_OUTPUT
53 52static u32 acpi_gbl_prev_thread_id = 0xFFFFFFFF;
54static u32 acpi_gbl_prev_thread_id = 0xFFFFFFFF; 53static char *acpi_gbl_fn_entry_str = "----Entry";
55static char *acpi_gbl_fn_entry_str = "----Entry"; 54static char *acpi_gbl_fn_exit_str = "----Exit-";
56static char *acpi_gbl_fn_exit_str = "----Exit-";
57 55
58/* Local prototypes */ 56/* Local prototypes */
59 57
60static const char * 58static const char *acpi_ut_trim_function_name(const char *function_name);
61acpi_ut_trim_function_name (
62 const char *function_name);
63
64 59
65/******************************************************************************* 60/*******************************************************************************
66 * 61 *
@@ -74,17 +69,13 @@ acpi_ut_trim_function_name (
74 * 69 *
75 ******************************************************************************/ 70 ******************************************************************************/
76 71
77void 72void acpi_ut_init_stack_ptr_trace(void)
78acpi_ut_init_stack_ptr_trace (
79 void)
80{ 73{
81 u32 current_sp; 74 u32 current_sp;
82
83 75
84 acpi_gbl_entry_stack_pointer = ACPI_PTR_DIFF (&current_sp, NULL); 76 acpi_gbl_entry_stack_pointer = ACPI_PTR_DIFF(&current_sp, NULL);
85} 77}
86 78
87
88/******************************************************************************* 79/*******************************************************************************
89 * 80 *
90 * FUNCTION: acpi_ut_track_stack_ptr 81 * FUNCTION: acpi_ut_track_stack_ptr
@@ -97,14 +88,11 @@ acpi_ut_init_stack_ptr_trace (
97 * 88 *
98 ******************************************************************************/ 89 ******************************************************************************/
99 90
100void 91void acpi_ut_track_stack_ptr(void)
101acpi_ut_track_stack_ptr (
102 void)
103{ 92{
104 acpi_size current_sp; 93 acpi_size current_sp;
105 94
106 95 current_sp = ACPI_PTR_DIFF(&current_sp, NULL);
107 current_sp = ACPI_PTR_DIFF (&current_sp, NULL);
108 96
109 if (current_sp < acpi_gbl_lowest_stack_pointer) { 97 if (current_sp < acpi_gbl_lowest_stack_pointer) {
110 acpi_gbl_lowest_stack_pointer = current_sp; 98 acpi_gbl_lowest_stack_pointer = current_sp;
@@ -115,7 +103,6 @@ acpi_ut_track_stack_ptr (
115 } 103 }
116} 104}
117 105
118
119/******************************************************************************* 106/*******************************************************************************
120 * 107 *
121 * FUNCTION: acpi_ut_trim_function_name 108 * FUNCTION: acpi_ut_trim_function_name
@@ -130,20 +117,18 @@ acpi_ut_track_stack_ptr (
130 * 117 *
131 ******************************************************************************/ 118 ******************************************************************************/
132 119
133static const char * 120static const char *acpi_ut_trim_function_name(const char *function_name)
134acpi_ut_trim_function_name (
135 const char *function_name)
136{ 121{
137 122
138 /* All Function names are longer than 4 chars, check is safe */ 123 /* All Function names are longer than 4 chars, check is safe */
139 124
140 if (*(ACPI_CAST_PTR (u32, function_name)) == ACPI_FUNCTION_PREFIX1) { 125 if (*(ACPI_CAST_PTR(u32, function_name)) == ACPI_FUNCTION_PREFIX1) {
141 /* This is the case where the original source has not been modified */ 126 /* This is the case where the original source has not been modified */
142 127
143 return (function_name + 4); 128 return (function_name + 4);
144 } 129 }
145 130
146 if (*(ACPI_CAST_PTR (u32, function_name)) == ACPI_FUNCTION_PREFIX2) { 131 if (*(ACPI_CAST_PTR(u32, function_name)) == ACPI_FUNCTION_PREFIX2) {
147 /* This is the case where the source has been 'linuxized' */ 132 /* This is the case where the source has been 'linuxized' */
148 133
149 return (function_name + 5); 134 return (function_name + 5);
@@ -152,7 +137,6 @@ acpi_ut_trim_function_name (
152 return (function_name); 137 return (function_name);
153} 138}
154 139
155
156/******************************************************************************* 140/*******************************************************************************
157 * 141 *
158 * FUNCTION: acpi_ut_debug_print 142 * FUNCTION: acpi_ut_debug_print
@@ -172,38 +156,33 @@ acpi_ut_trim_function_name (
172 * 156 *
173 ******************************************************************************/ 157 ******************************************************************************/
174 158
175void ACPI_INTERNAL_VAR_XFACE 159void ACPI_INTERNAL_VAR_XFACE
176acpi_ut_debug_print ( 160acpi_ut_debug_print(u32 requested_debug_level,
177 u32 requested_debug_level, 161 u32 line_number,
178 u32 line_number, 162 const char *function_name,
179 const char *function_name, 163 char *module_name, u32 component_id, char *format, ...)
180 char *module_name,
181 u32 component_id,
182 char *format,
183 ...)
184{ 164{
185 u32 thread_id; 165 u32 thread_id;
186 va_list args; 166 va_list args;
187
188 167
189 /* 168 /*
190 * Stay silent if the debug level or component ID is disabled 169 * Stay silent if the debug level or component ID is disabled
191 */ 170 */
192 if (!(requested_debug_level & acpi_dbg_level) || 171 if (!(requested_debug_level & acpi_dbg_level) ||
193 !(component_id & acpi_dbg_layer)) { 172 !(component_id & acpi_dbg_layer)) {
194 return; 173 return;
195 } 174 }
196 175
197 /* 176 /*
198 * Thread tracking and context switch notification 177 * Thread tracking and context switch notification
199 */ 178 */
200 thread_id = acpi_os_get_thread_id (); 179 thread_id = acpi_os_get_thread_id();
201 180
202 if (thread_id != acpi_gbl_prev_thread_id) { 181 if (thread_id != acpi_gbl_prev_thread_id) {
203 if (ACPI_LV_THREADS & acpi_dbg_level) { 182 if (ACPI_LV_THREADS & acpi_dbg_level) {
204 acpi_os_printf ( 183 acpi_os_printf
205 "\n**** Context Switch from TID %X to TID %X ****\n\n", 184 ("\n**** Context Switch from TID %X to TID %X ****\n\n",
206 acpi_gbl_prev_thread_id, thread_id); 185 acpi_gbl_prev_thread_id, thread_id);
207 } 186 }
208 187
209 acpi_gbl_prev_thread_id = thread_id; 188 acpi_gbl_prev_thread_id = thread_id;
@@ -213,17 +192,18 @@ acpi_ut_debug_print (
213 * Display the module name, current line number, thread ID (if requested), 192 * Display the module name, current line number, thread ID (if requested),
214 * current procedure nesting level, and the current procedure name 193 * current procedure nesting level, and the current procedure name
215 */ 194 */
216 acpi_os_printf ("%8s-%04ld ", module_name, line_number); 195 acpi_os_printf("%8s-%04ld ", module_name, line_number);
217 196
218 if (ACPI_LV_THREADS & acpi_dbg_level) { 197 if (ACPI_LV_THREADS & acpi_dbg_level) {
219 acpi_os_printf ("[%04lX] ", thread_id); 198 acpi_os_printf("[%04lX] ", thread_id);
220 } 199 }
221 200
222 acpi_os_printf ("[%02ld] %-22.22s: ", 201 acpi_os_printf("[%02ld] %-22.22s: ",
223 acpi_gbl_nesting_level, acpi_ut_trim_function_name (function_name)); 202 acpi_gbl_nesting_level,
203 acpi_ut_trim_function_name(function_name));
224 204
225 va_start (args, format); 205 va_start(args, format);
226 acpi_os_vprintf (format, args); 206 acpi_os_vprintf(format, args);
227} 207}
228 208
229EXPORT_SYMBOL(acpi_ut_debug_print); 209EXPORT_SYMBOL(acpi_ut_debug_print);
@@ -247,29 +227,24 @@ EXPORT_SYMBOL(acpi_ut_debug_print);
247 * 227 *
248 ******************************************************************************/ 228 ******************************************************************************/
249 229
250void ACPI_INTERNAL_VAR_XFACE 230void ACPI_INTERNAL_VAR_XFACE
251acpi_ut_debug_print_raw ( 231acpi_ut_debug_print_raw(u32 requested_debug_level,
252 u32 requested_debug_level, 232 u32 line_number,
253 u32 line_number, 233 const char *function_name,
254 const char *function_name, 234 char *module_name, u32 component_id, char *format, ...)
255 char *module_name,
256 u32 component_id,
257 char *format,
258 ...)
259{ 235{
260 va_list args; 236 va_list args;
261
262 237
263 if (!(requested_debug_level & acpi_dbg_level) || 238 if (!(requested_debug_level & acpi_dbg_level) ||
264 !(component_id & acpi_dbg_layer)) { 239 !(component_id & acpi_dbg_layer)) {
265 return; 240 return;
266 } 241 }
267 242
268 va_start (args, format); 243 va_start(args, format);
269 acpi_os_vprintf (format, args); 244 acpi_os_vprintf(format, args);
270} 245}
271EXPORT_SYMBOL(acpi_ut_debug_print_raw);
272 246
247EXPORT_SYMBOL(acpi_ut_debug_print_raw);
273 248
274/******************************************************************************* 249/*******************************************************************************
275 * 250 *
@@ -288,22 +263,19 @@ EXPORT_SYMBOL(acpi_ut_debug_print_raw);
288 ******************************************************************************/ 263 ******************************************************************************/
289 264
290void 265void
291acpi_ut_trace ( 266acpi_ut_trace(u32 line_number,
292 u32 line_number, 267 const char *function_name, char *module_name, u32 component_id)
293 const char *function_name,
294 char *module_name,
295 u32 component_id)
296{ 268{
297 269
298 acpi_gbl_nesting_level++; 270 acpi_gbl_nesting_level++;
299 acpi_ut_track_stack_ptr (); 271 acpi_ut_track_stack_ptr();
300 272
301 acpi_ut_debug_print (ACPI_LV_FUNCTIONS, 273 acpi_ut_debug_print(ACPI_LV_FUNCTIONS,
302 line_number, function_name, module_name, component_id, 274 line_number, function_name, module_name,
303 "%s\n", acpi_gbl_fn_entry_str); 275 component_id, "%s\n", acpi_gbl_fn_entry_str);
304} 276}
305EXPORT_SYMBOL(acpi_ut_trace);
306 277
278EXPORT_SYMBOL(acpi_ut_trace);
307 279
308/******************************************************************************* 280/*******************************************************************************
309 * 281 *
@@ -323,22 +295,19 @@ EXPORT_SYMBOL(acpi_ut_trace);
323 ******************************************************************************/ 295 ******************************************************************************/
324 296
325void 297void
326acpi_ut_trace_ptr ( 298acpi_ut_trace_ptr(u32 line_number,
327 u32 line_number, 299 const char *function_name,
328 const char *function_name, 300 char *module_name, u32 component_id, void *pointer)
329 char *module_name,
330 u32 component_id,
331 void *pointer)
332{ 301{
333 acpi_gbl_nesting_level++; 302 acpi_gbl_nesting_level++;
334 acpi_ut_track_stack_ptr (); 303 acpi_ut_track_stack_ptr();
335 304
336 acpi_ut_debug_print (ACPI_LV_FUNCTIONS, 305 acpi_ut_debug_print(ACPI_LV_FUNCTIONS,
337 line_number, function_name, module_name, component_id, 306 line_number, function_name, module_name,
338 "%s %p\n", acpi_gbl_fn_entry_str, pointer); 307 component_id, "%s %p\n", acpi_gbl_fn_entry_str,
308 pointer);
339} 309}
340 310
341
342/******************************************************************************* 311/*******************************************************************************
343 * 312 *
344 * FUNCTION: acpi_ut_trace_str 313 * FUNCTION: acpi_ut_trace_str
@@ -357,23 +326,20 @@ acpi_ut_trace_ptr (
357 ******************************************************************************/ 326 ******************************************************************************/
358 327
359void 328void
360acpi_ut_trace_str ( 329acpi_ut_trace_str(u32 line_number,
361 u32 line_number, 330 const char *function_name,
362 const char *function_name, 331 char *module_name, u32 component_id, char *string)
363 char *module_name,
364 u32 component_id,
365 char *string)
366{ 332{
367 333
368 acpi_gbl_nesting_level++; 334 acpi_gbl_nesting_level++;
369 acpi_ut_track_stack_ptr (); 335 acpi_ut_track_stack_ptr();
370 336
371 acpi_ut_debug_print (ACPI_LV_FUNCTIONS, 337 acpi_ut_debug_print(ACPI_LV_FUNCTIONS,
372 line_number, function_name, module_name, component_id, 338 line_number, function_name, module_name,
373 "%s %s\n", acpi_gbl_fn_entry_str, string); 339 component_id, "%s %s\n", acpi_gbl_fn_entry_str,
340 string);
374} 341}
375 342
376
377/******************************************************************************* 343/*******************************************************************************
378 * 344 *
379 * FUNCTION: acpi_ut_trace_u32 345 * FUNCTION: acpi_ut_trace_u32
@@ -392,23 +358,20 @@ acpi_ut_trace_str (
392 ******************************************************************************/ 358 ******************************************************************************/
393 359
394void 360void
395acpi_ut_trace_u32 ( 361acpi_ut_trace_u32(u32 line_number,
396 u32 line_number, 362 const char *function_name,
397 const char *function_name, 363 char *module_name, u32 component_id, u32 integer)
398 char *module_name,
399 u32 component_id,
400 u32 integer)
401{ 364{
402 365
403 acpi_gbl_nesting_level++; 366 acpi_gbl_nesting_level++;
404 acpi_ut_track_stack_ptr (); 367 acpi_ut_track_stack_ptr();
405 368
406 acpi_ut_debug_print (ACPI_LV_FUNCTIONS, 369 acpi_ut_debug_print(ACPI_LV_FUNCTIONS,
407 line_number, function_name, module_name, component_id, 370 line_number, function_name, module_name,
408 "%s %08X\n", acpi_gbl_fn_entry_str, integer); 371 component_id, "%s %08X\n", acpi_gbl_fn_entry_str,
372 integer);
409} 373}
410 374
411
412/******************************************************************************* 375/*******************************************************************************
413 * 376 *
414 * FUNCTION: acpi_ut_exit 377 * FUNCTION: acpi_ut_exit
@@ -426,21 +389,18 @@ acpi_ut_trace_u32 (
426 ******************************************************************************/ 389 ******************************************************************************/
427 390
428void 391void
429acpi_ut_exit ( 392acpi_ut_exit(u32 line_number,
430 u32 line_number, 393 const char *function_name, char *module_name, u32 component_id)
431 const char *function_name,
432 char *module_name,
433 u32 component_id)
434{ 394{
435 395
436 acpi_ut_debug_print (ACPI_LV_FUNCTIONS, 396 acpi_ut_debug_print(ACPI_LV_FUNCTIONS,
437 line_number, function_name, module_name, component_id, 397 line_number, function_name, module_name,
438 "%s\n", acpi_gbl_fn_exit_str); 398 component_id, "%s\n", acpi_gbl_fn_exit_str);
439 399
440 acpi_gbl_nesting_level--; 400 acpi_gbl_nesting_level--;
441} 401}
442EXPORT_SYMBOL(acpi_ut_exit);
443 402
403EXPORT_SYMBOL(acpi_ut_exit);
444 404
445/******************************************************************************* 405/*******************************************************************************
446 * 406 *
@@ -460,31 +420,29 @@ EXPORT_SYMBOL(acpi_ut_exit);
460 ******************************************************************************/ 420 ******************************************************************************/
461 421
462void 422void
463acpi_ut_status_exit ( 423acpi_ut_status_exit(u32 line_number,
464 u32 line_number, 424 const char *function_name,
465 const char *function_name, 425 char *module_name, u32 component_id, acpi_status status)
466 char *module_name,
467 u32 component_id,
468 acpi_status status)
469{ 426{
470 427
471 if (ACPI_SUCCESS (status)) { 428 if (ACPI_SUCCESS(status)) {
472 acpi_ut_debug_print (ACPI_LV_FUNCTIONS, 429 acpi_ut_debug_print(ACPI_LV_FUNCTIONS,
473 line_number, function_name, module_name, component_id, 430 line_number, function_name, module_name,
474 "%s %s\n", acpi_gbl_fn_exit_str, 431 component_id, "%s %s\n",
475 acpi_format_exception (status)); 432 acpi_gbl_fn_exit_str,
476 } 433 acpi_format_exception(status));
477 else { 434 } else {
478 acpi_ut_debug_print (ACPI_LV_FUNCTIONS, 435 acpi_ut_debug_print(ACPI_LV_FUNCTIONS,
479 line_number, function_name, module_name, component_id, 436 line_number, function_name, module_name,
480 "%s ****Exception****: %s\n", acpi_gbl_fn_exit_str, 437 component_id, "%s ****Exception****: %s\n",
481 acpi_format_exception (status)); 438 acpi_gbl_fn_exit_str,
439 acpi_format_exception(status));
482 } 440 }
483 441
484 acpi_gbl_nesting_level--; 442 acpi_gbl_nesting_level--;
485} 443}
486EXPORT_SYMBOL(acpi_ut_status_exit);
487 444
445EXPORT_SYMBOL(acpi_ut_status_exit);
488 446
489/******************************************************************************* 447/*******************************************************************************
490 * 448 *
@@ -504,23 +462,20 @@ EXPORT_SYMBOL(acpi_ut_status_exit);
504 ******************************************************************************/ 462 ******************************************************************************/
505 463
506void 464void
507acpi_ut_value_exit ( 465acpi_ut_value_exit(u32 line_number,
508 u32 line_number, 466 const char *function_name,
509 const char *function_name, 467 char *module_name, u32 component_id, acpi_integer value)
510 char *module_name,
511 u32 component_id,
512 acpi_integer value)
513{ 468{
514 469
515 acpi_ut_debug_print (ACPI_LV_FUNCTIONS, 470 acpi_ut_debug_print(ACPI_LV_FUNCTIONS,
516 line_number, function_name, module_name, component_id, 471 line_number, function_name, module_name,
517 "%s %8.8X%8.8X\n", acpi_gbl_fn_exit_str, 472 component_id, "%s %8.8X%8.8X\n",
518 ACPI_FORMAT_UINT64 (value)); 473 acpi_gbl_fn_exit_str, ACPI_FORMAT_UINT64(value));
519 474
520 acpi_gbl_nesting_level--; 475 acpi_gbl_nesting_level--;
521} 476}
522EXPORT_SYMBOL(acpi_ut_value_exit);
523 477
478EXPORT_SYMBOL(acpi_ut_value_exit);
524 479
525/******************************************************************************* 480/*******************************************************************************
526 * 481 *
@@ -540,24 +495,20 @@ EXPORT_SYMBOL(acpi_ut_value_exit);
540 ******************************************************************************/ 495 ******************************************************************************/
541 496
542void 497void
543acpi_ut_ptr_exit ( 498acpi_ut_ptr_exit(u32 line_number,
544 u32 line_number, 499 const char *function_name,
545 const char *function_name, 500 char *module_name, u32 component_id, u8 * ptr)
546 char *module_name,
547 u32 component_id,
548 u8 *ptr)
549{ 501{
550 502
551 acpi_ut_debug_print (ACPI_LV_FUNCTIONS, 503 acpi_ut_debug_print(ACPI_LV_FUNCTIONS,
552 line_number, function_name, module_name, component_id, 504 line_number, function_name, module_name,
553 "%s %p\n", acpi_gbl_fn_exit_str, ptr); 505 component_id, "%s %p\n", acpi_gbl_fn_exit_str, ptr);
554 506
555 acpi_gbl_nesting_level--; 507 acpi_gbl_nesting_level--;
556} 508}
557 509
558#endif 510#endif
559 511
560
561/******************************************************************************* 512/*******************************************************************************
562 * 513 *
563 * FUNCTION: acpi_ut_dump_buffer 514 * FUNCTION: acpi_ut_dump_buffer
@@ -573,23 +524,17 @@ acpi_ut_ptr_exit (
573 * 524 *
574 ******************************************************************************/ 525 ******************************************************************************/
575 526
576void 527void acpi_ut_dump_buffer(u8 * buffer, u32 count, u32 display, u32 component_id)
577acpi_ut_dump_buffer (
578 u8 *buffer,
579 u32 count,
580 u32 display,
581 u32 component_id)
582{ 528{
583 acpi_native_uint i = 0; 529 acpi_native_uint i = 0;
584 acpi_native_uint j; 530 acpi_native_uint j;
585 u32 temp32; 531 u32 temp32;
586 u8 buf_char; 532 u8 buf_char;
587
588 533
589 /* Only dump the buffer if tracing is enabled */ 534 /* Only dump the buffer if tracing is enabled */
590 535
591 if (!((ACPI_LV_TABLES & acpi_dbg_level) && 536 if (!((ACPI_LV_TABLES & acpi_dbg_level) &&
592 (component_id & acpi_dbg_layer))) { 537 (component_id & acpi_dbg_layer))) {
593 return; 538 return;
594 } 539 }
595 540
@@ -602,7 +547,7 @@ acpi_ut_dump_buffer (
602 while (i < count) { 547 while (i < count) {
603 /* Print current offset */ 548 /* Print current offset */
604 549
605 acpi_os_printf ("%6.4X: ", (u32) i); 550 acpi_os_printf("%6.4X: ", (u32) i);
606 551
607 /* Print 16 hex chars */ 552 /* Print 16 hex chars */
608 553
@@ -610,39 +555,36 @@ acpi_ut_dump_buffer (
610 if (i + j >= count) { 555 if (i + j >= count) {
611 /* Dump fill spaces */ 556 /* Dump fill spaces */
612 557
613 acpi_os_printf ("%*s", ((display * 2) + 1), " "); 558 acpi_os_printf("%*s", ((display * 2) + 1), " ");
614 j += (acpi_native_uint) display; 559 j += (acpi_native_uint) display;
615 continue; 560 continue;
616 } 561 }
617 562
618 switch (display) { 563 switch (display) {
619 default: /* Default is BYTE display */ 564 default: /* Default is BYTE display */
620 565
621 acpi_os_printf ("%02X ", buffer[i + j]); 566 acpi_os_printf("%02X ", buffer[i + j]);
622 break; 567 break;
623 568
624
625 case DB_WORD_DISPLAY: 569 case DB_WORD_DISPLAY:
626 570
627 ACPI_MOVE_16_TO_32 (&temp32, &buffer[i + j]); 571 ACPI_MOVE_16_TO_32(&temp32, &buffer[i + j]);
628 acpi_os_printf ("%04X ", temp32); 572 acpi_os_printf("%04X ", temp32);
629 break; 573 break;
630 574
631
632 case DB_DWORD_DISPLAY: 575 case DB_DWORD_DISPLAY:
633 576
634 ACPI_MOVE_32_TO_32 (&temp32, &buffer[i + j]); 577 ACPI_MOVE_32_TO_32(&temp32, &buffer[i + j]);
635 acpi_os_printf ("%08X ", temp32); 578 acpi_os_printf("%08X ", temp32);
636 break; 579 break;
637 580
638
639 case DB_QWORD_DISPLAY: 581 case DB_QWORD_DISPLAY:
640 582
641 ACPI_MOVE_32_TO_32 (&temp32, &buffer[i + j]); 583 ACPI_MOVE_32_TO_32(&temp32, &buffer[i + j]);
642 acpi_os_printf ("%08X", temp32); 584 acpi_os_printf("%08X", temp32);
643 585
644 ACPI_MOVE_32_TO_32 (&temp32, &buffer[i + j + 4]); 586 ACPI_MOVE_32_TO_32(&temp32, &buffer[i + j + 4]);
645 acpi_os_printf ("%08X ", temp32); 587 acpi_os_printf("%08X ", temp32);
646 break; 588 break;
647 } 589 }
648 590
@@ -653,28 +595,26 @@ acpi_ut_dump_buffer (
653 * Print the ASCII equivalent characters but watch out for the bad 595 * Print the ASCII equivalent characters but watch out for the bad
654 * unprintable ones (printable chars are 0x20 through 0x7E) 596 * unprintable ones (printable chars are 0x20 through 0x7E)
655 */ 597 */
656 acpi_os_printf (" "); 598 acpi_os_printf(" ");
657 for (j = 0; j < 16; j++) { 599 for (j = 0; j < 16; j++) {
658 if (i + j >= count) { 600 if (i + j >= count) {
659 acpi_os_printf ("\n"); 601 acpi_os_printf("\n");
660 return; 602 return;
661 } 603 }
662 604
663 buf_char = buffer[i + j]; 605 buf_char = buffer[i + j];
664 if (ACPI_IS_PRINT (buf_char)) { 606 if (ACPI_IS_PRINT(buf_char)) {
665 acpi_os_printf ("%c", buf_char); 607 acpi_os_printf("%c", buf_char);
666 } 608 } else {
667 else { 609 acpi_os_printf(".");
668 acpi_os_printf (".");
669 } 610 }
670 } 611 }
671 612
672 /* Done with that line. */ 613 /* Done with that line. */
673 614
674 acpi_os_printf ("\n"); 615 acpi_os_printf("\n");
675 i += 16; 616 i += 16;
676 } 617 }
677 618
678 return; 619 return;
679} 620}
680
diff --git a/drivers/acpi/utilities/utdelete.c b/drivers/acpi/utilities/utdelete.c
index eeafb324c504..2bc878f7a127 100644
--- a/drivers/acpi/utilities/utdelete.c
+++ b/drivers/acpi/utilities/utdelete.c
@@ -41,7 +41,6 @@
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/acinterp.h> 45#include <acpi/acinterp.h>
47#include <acpi/acnamesp.h> 46#include <acpi/acnamesp.h>
@@ -49,19 +48,13 @@
49#include <acpi/amlcode.h> 48#include <acpi/amlcode.h>
50 49
51#define _COMPONENT ACPI_UTILITIES 50#define _COMPONENT ACPI_UTILITIES
52 ACPI_MODULE_NAME ("utdelete") 51ACPI_MODULE_NAME("utdelete")
53 52
54/* Local prototypes */ 53/* Local prototypes */
54static void acpi_ut_delete_internal_obj(union acpi_operand_object *object);
55 55
56static void 56static void
57acpi_ut_delete_internal_obj ( 57acpi_ut_update_ref_count(union acpi_operand_object *object, u32 action);
58 union acpi_operand_object *object);
59
60static void
61acpi_ut_update_ref_count (
62 union acpi_operand_object *object,
63 u32 action);
64
65 58
66/******************************************************************************* 59/*******************************************************************************
67 * 60 *
@@ -76,18 +69,14 @@ acpi_ut_update_ref_count (
76 * 69 *
77 ******************************************************************************/ 70 ******************************************************************************/
78 71
79static void 72static void acpi_ut_delete_internal_obj(union acpi_operand_object *object)
80acpi_ut_delete_internal_obj (
81 union acpi_operand_object *object)
82{ 73{
83 void *obj_pointer = NULL; 74 void *obj_pointer = NULL;
84 union acpi_operand_object *handler_desc; 75 union acpi_operand_object *handler_desc;
85 union acpi_operand_object *second_desc; 76 union acpi_operand_object *second_desc;
86 union acpi_operand_object *next_desc; 77 union acpi_operand_object *next_desc;
87
88
89 ACPI_FUNCTION_TRACE_PTR ("ut_delete_internal_obj", object);
90 78
79 ACPI_FUNCTION_TRACE_PTR("ut_delete_internal_obj", object);
91 80
92 if (!object) { 81 if (!object) {
93 return_VOID; 82 return_VOID;
@@ -97,11 +86,12 @@ acpi_ut_delete_internal_obj (
97 * Must delete or free any pointers within the object that are not 86 * Must delete or free any pointers within the object that are not
98 * actual ACPI objects (for example, a raw buffer pointer). 87 * actual ACPI objects (for example, a raw buffer pointer).
99 */ 88 */
100 switch (ACPI_GET_OBJECT_TYPE (object)) { 89 switch (ACPI_GET_OBJECT_TYPE(object)) {
101 case ACPI_TYPE_STRING: 90 case ACPI_TYPE_STRING:
102 91
103 ACPI_DEBUG_PRINT ((ACPI_DB_ALLOCATIONS, "**** String %p, ptr %p\n", 92 ACPI_DEBUG_PRINT((ACPI_DB_ALLOCATIONS,
104 object, object->string.pointer)); 93 "**** String %p, ptr %p\n", object,
94 object->string.pointer));
105 95
106 /* Free the actual string buffer */ 96 /* Free the actual string buffer */
107 97
@@ -112,11 +102,11 @@ acpi_ut_delete_internal_obj (
112 } 102 }
113 break; 103 break;
114 104
115
116 case ACPI_TYPE_BUFFER: 105 case ACPI_TYPE_BUFFER:
117 106
118 ACPI_DEBUG_PRINT ((ACPI_DB_ALLOCATIONS, "**** Buffer %p, ptr %p\n", 107 ACPI_DEBUG_PRINT((ACPI_DB_ALLOCATIONS,
119 object, object->buffer.pointer)); 108 "**** Buffer %p, ptr %p\n", object,
109 object->buffer.pointer));
120 110
121 /* Free the actual buffer */ 111 /* Free the actual buffer */
122 112
@@ -127,11 +117,11 @@ acpi_ut_delete_internal_obj (
127 } 117 }
128 break; 118 break;
129 119
130
131 case ACPI_TYPE_PACKAGE: 120 case ACPI_TYPE_PACKAGE:
132 121
133 ACPI_DEBUG_PRINT ((ACPI_DB_ALLOCATIONS, " **** Package of count %X\n", 122 ACPI_DEBUG_PRINT((ACPI_DB_ALLOCATIONS,
134 object->package.count)); 123 " **** Package of count %X\n",
124 object->package.count));
135 125
136 /* 126 /*
137 * Elements of the package are not handled here, they are deleted 127 * Elements of the package are not handled here, they are deleted
@@ -143,11 +133,11 @@ acpi_ut_delete_internal_obj (
143 obj_pointer = object->package.elements; 133 obj_pointer = object->package.elements;
144 break; 134 break;
145 135
146
147 case ACPI_TYPE_DEVICE: 136 case ACPI_TYPE_DEVICE:
148 137
149 if (object->device.gpe_block) { 138 if (object->device.gpe_block) {
150 (void) acpi_ev_delete_gpe_block (object->device.gpe_block); 139 (void)acpi_ev_delete_gpe_block(object->device.
140 gpe_block);
151 } 141 }
152 142
153 /* Walk the handler list for this device */ 143 /* Walk the handler list for this device */
@@ -155,54 +145,51 @@ acpi_ut_delete_internal_obj (
155 handler_desc = object->device.handler; 145 handler_desc = object->device.handler;
156 while (handler_desc) { 146 while (handler_desc) {
157 next_desc = handler_desc->address_space.next; 147 next_desc = handler_desc->address_space.next;
158 acpi_ut_remove_reference (handler_desc); 148 acpi_ut_remove_reference(handler_desc);
159 handler_desc = next_desc; 149 handler_desc = next_desc;
160 } 150 }
161 break; 151 break;
162 152
163
164 case ACPI_TYPE_MUTEX: 153 case ACPI_TYPE_MUTEX:
165 154
166 ACPI_DEBUG_PRINT ((ACPI_DB_ALLOCATIONS, 155 ACPI_DEBUG_PRINT((ACPI_DB_ALLOCATIONS,
167 "***** Mutex %p, Semaphore %p\n", 156 "***** Mutex %p, Semaphore %p\n",
168 object, object->mutex.semaphore)); 157 object, object->mutex.semaphore));
169 158
170 acpi_ex_unlink_mutex (object); 159 acpi_ex_unlink_mutex(object);
171 (void) acpi_os_delete_semaphore (object->mutex.semaphore); 160 (void)acpi_os_delete_semaphore(object->mutex.semaphore);
172 break; 161 break;
173 162
174
175 case ACPI_TYPE_EVENT: 163 case ACPI_TYPE_EVENT:
176 164
177 ACPI_DEBUG_PRINT ((ACPI_DB_ALLOCATIONS, 165 ACPI_DEBUG_PRINT((ACPI_DB_ALLOCATIONS,
178 "***** Event %p, Semaphore %p\n", 166 "***** Event %p, Semaphore %p\n",
179 object, object->event.semaphore)); 167 object, object->event.semaphore));
180 168
181 (void) acpi_os_delete_semaphore (object->event.semaphore); 169 (void)acpi_os_delete_semaphore(object->event.semaphore);
182 object->event.semaphore = NULL; 170 object->event.semaphore = NULL;
183 break; 171 break;
184 172
185
186 case ACPI_TYPE_METHOD: 173 case ACPI_TYPE_METHOD:
187 174
188 ACPI_DEBUG_PRINT ((ACPI_DB_ALLOCATIONS, 175 ACPI_DEBUG_PRINT((ACPI_DB_ALLOCATIONS,
189 "***** Method %p\n", object)); 176 "***** Method %p\n", object));
190 177
191 /* Delete the method semaphore if it exists */ 178 /* Delete the method semaphore if it exists */
192 179
193 if (object->method.semaphore) { 180 if (object->method.semaphore) {
194 (void) acpi_os_delete_semaphore (object->method.semaphore); 181 (void)acpi_os_delete_semaphore(object->method.
182 semaphore);
195 object->method.semaphore = NULL; 183 object->method.semaphore = NULL;
196 } 184 }
197 break; 185 break;
198 186
199
200 case ACPI_TYPE_REGION: 187 case ACPI_TYPE_REGION:
201 188
202 ACPI_DEBUG_PRINT ((ACPI_DB_ALLOCATIONS, 189 ACPI_DEBUG_PRINT((ACPI_DB_ALLOCATIONS,
203 "***** Region %p\n", object)); 190 "***** Region %p\n", object));
204 191
205 second_desc = acpi_ns_get_secondary_object (object); 192 second_desc = acpi_ns_get_secondary_object(object);
206 if (second_desc) { 193 if (second_desc) {
207 /* 194 /*
208 * Free the region_context if and only if the handler is one of the 195 * Free the region_context if and only if the handler is one of the
@@ -211,32 +198,33 @@ acpi_ut_delete_internal_obj (
211 */ 198 */
212 handler_desc = object->region.handler; 199 handler_desc = object->region.handler;
213 if (handler_desc) { 200 if (handler_desc) {
214 if (handler_desc->address_space.hflags & ACPI_ADDR_HANDLER_DEFAULT_INSTALLED) { 201 if (handler_desc->address_space.
215 obj_pointer = second_desc->extra.region_context; 202 hflags &
203 ACPI_ADDR_HANDLER_DEFAULT_INSTALLED) {
204 obj_pointer =
205 second_desc->extra.region_context;
216 } 206 }
217 207
218 acpi_ut_remove_reference (handler_desc); 208 acpi_ut_remove_reference(handler_desc);
219 } 209 }
220 210
221 /* Now we can free the Extra object */ 211 /* Now we can free the Extra object */
222 212
223 acpi_ut_delete_object_desc (second_desc); 213 acpi_ut_delete_object_desc(second_desc);
224 } 214 }
225 break; 215 break;
226 216
227
228 case ACPI_TYPE_BUFFER_FIELD: 217 case ACPI_TYPE_BUFFER_FIELD:
229 218
230 ACPI_DEBUG_PRINT ((ACPI_DB_ALLOCATIONS, 219 ACPI_DEBUG_PRINT((ACPI_DB_ALLOCATIONS,
231 "***** Buffer Field %p\n", object)); 220 "***** Buffer Field %p\n", object));
232 221
233 second_desc = acpi_ns_get_secondary_object (object); 222 second_desc = acpi_ns_get_secondary_object(object);
234 if (second_desc) { 223 if (second_desc) {
235 acpi_ut_delete_object_desc (second_desc); 224 acpi_ut_delete_object_desc(second_desc);
236 } 225 }
237 break; 226 break;
238 227
239
240 default: 228 default:
241 break; 229 break;
242 } 230 }
@@ -244,21 +232,20 @@ acpi_ut_delete_internal_obj (
244 /* Free any allocated memory (pointer within the object) found above */ 232 /* Free any allocated memory (pointer within the object) found above */
245 233
246 if (obj_pointer) { 234 if (obj_pointer) {
247 ACPI_DEBUG_PRINT ((ACPI_DB_ALLOCATIONS, "Deleting Object Subptr %p\n", 235 ACPI_DEBUG_PRINT((ACPI_DB_ALLOCATIONS,
248 obj_pointer)); 236 "Deleting Object Subptr %p\n", obj_pointer));
249 ACPI_MEM_FREE (obj_pointer); 237 ACPI_MEM_FREE(obj_pointer);
250 } 238 }
251 239
252 /* Now the object can be safely deleted */ 240 /* Now the object can be safely deleted */
253 241
254 ACPI_DEBUG_PRINT ((ACPI_DB_ALLOCATIONS, "Deleting Object %p [%s]\n", 242 ACPI_DEBUG_PRINT((ACPI_DB_ALLOCATIONS, "Deleting Object %p [%s]\n",
255 object, acpi_ut_get_object_type_name (object))); 243 object, acpi_ut_get_object_type_name(object)));
256 244
257 acpi_ut_delete_object_desc (object); 245 acpi_ut_delete_object_desc(object);
258 return_VOID; 246 return_VOID;
259} 247}
260 248
261
262/******************************************************************************* 249/*******************************************************************************
263 * 250 *
264 * FUNCTION: acpi_ut_delete_internal_object_list 251 * FUNCTION: acpi_ut_delete_internal_object_list
@@ -272,29 +259,24 @@ acpi_ut_delete_internal_obj (
272 * 259 *
273 ******************************************************************************/ 260 ******************************************************************************/
274 261
275void 262void acpi_ut_delete_internal_object_list(union acpi_operand_object **obj_list)
276acpi_ut_delete_internal_object_list (
277 union acpi_operand_object **obj_list)
278{ 263{
279 union acpi_operand_object **internal_obj; 264 union acpi_operand_object **internal_obj;
280
281
282 ACPI_FUNCTION_TRACE ("ut_delete_internal_object_list");
283 265
266 ACPI_FUNCTION_TRACE("ut_delete_internal_object_list");
284 267
285 /* Walk the null-terminated internal list */ 268 /* Walk the null-terminated internal list */
286 269
287 for (internal_obj = obj_list; *internal_obj; internal_obj++) { 270 for (internal_obj = obj_list; *internal_obj; internal_obj++) {
288 acpi_ut_remove_reference (*internal_obj); 271 acpi_ut_remove_reference(*internal_obj);
289 } 272 }
290 273
291 /* Free the combined parameter pointer list and object array */ 274 /* Free the combined parameter pointer list and object array */
292 275
293 ACPI_MEM_FREE (obj_list); 276 ACPI_MEM_FREE(obj_list);
294 return_VOID; 277 return_VOID;
295} 278}
296 279
297
298/******************************************************************************* 280/*******************************************************************************
299 * 281 *
300 * FUNCTION: acpi_ut_update_ref_count 282 * FUNCTION: acpi_ut_update_ref_count
@@ -309,16 +291,12 @@ acpi_ut_delete_internal_object_list (
309 ******************************************************************************/ 291 ******************************************************************************/
310 292
311static void 293static void
312acpi_ut_update_ref_count ( 294acpi_ut_update_ref_count(union acpi_operand_object *object, u32 action)
313 union acpi_operand_object *object,
314 u32 action)
315{ 295{
316 u16 count; 296 u16 count;
317 u16 new_count; 297 u16 new_count;
318
319
320 ACPI_FUNCTION_NAME ("ut_update_ref_count");
321 298
299 ACPI_FUNCTION_NAME("ut_update_ref_count");
322 300
323 if (!object) { 301 if (!object) {
324 return; 302 return;
@@ -338,58 +316,55 @@ acpi_ut_update_ref_count (
338 new_count++; 316 new_count++;
339 object->common.reference_count = new_count; 317 object->common.reference_count = new_count;
340 318
341 ACPI_DEBUG_PRINT ((ACPI_DB_ALLOCATIONS, 319 ACPI_DEBUG_PRINT((ACPI_DB_ALLOCATIONS,
342 "Obj %p Refs=%X, [Incremented]\n", 320 "Obj %p Refs=%X, [Incremented]\n",
343 object, new_count)); 321 object, new_count));
344 break; 322 break;
345 323
346
347 case REF_DECREMENT: 324 case REF_DECREMENT:
348 325
349 if (count < 1) { 326 if (count < 1) {
350 ACPI_DEBUG_PRINT ((ACPI_DB_ALLOCATIONS, 327 ACPI_DEBUG_PRINT((ACPI_DB_ALLOCATIONS,
351 "Obj %p Refs=%X, can't decrement! (Set to 0)\n", 328 "Obj %p Refs=%X, can't decrement! (Set to 0)\n",
352 object, new_count)); 329 object, new_count));
353 330
354 new_count = 0; 331 new_count = 0;
355 } 332 } else {
356 else {
357 new_count--; 333 new_count--;
358 334
359 ACPI_DEBUG_PRINT ((ACPI_DB_ALLOCATIONS, 335 ACPI_DEBUG_PRINT((ACPI_DB_ALLOCATIONS,
360 "Obj %p Refs=%X, [Decremented]\n", 336 "Obj %p Refs=%X, [Decremented]\n",
361 object, new_count)); 337 object, new_count));
362 } 338 }
363 339
364 if (ACPI_GET_OBJECT_TYPE (object) == ACPI_TYPE_METHOD) { 340 if (ACPI_GET_OBJECT_TYPE(object) == ACPI_TYPE_METHOD) {
365 ACPI_DEBUG_PRINT ((ACPI_DB_ALLOCATIONS, 341 ACPI_DEBUG_PRINT((ACPI_DB_ALLOCATIONS,
366 "Method Obj %p Refs=%X, [Decremented]\n", 342 "Method Obj %p Refs=%X, [Decremented]\n",
367 object, new_count)); 343 object, new_count));
368 } 344 }
369 345
370 object->common.reference_count = new_count; 346 object->common.reference_count = new_count;
371 if (new_count == 0) { 347 if (new_count == 0) {
372 acpi_ut_delete_internal_obj (object); 348 acpi_ut_delete_internal_obj(object);
373 } 349 }
374 350
375 break; 351 break;
376 352
377
378 case REF_FORCE_DELETE: 353 case REF_FORCE_DELETE:
379 354
380 ACPI_DEBUG_PRINT ((ACPI_DB_ALLOCATIONS, 355 ACPI_DEBUG_PRINT((ACPI_DB_ALLOCATIONS,
381 "Obj %p Refs=%X, Force delete! (Set to 0)\n", 356 "Obj %p Refs=%X, Force delete! (Set to 0)\n",
382 object, count)); 357 object, count));
383 358
384 new_count = 0; 359 new_count = 0;
385 object->common.reference_count = new_count; 360 object->common.reference_count = new_count;
386 acpi_ut_delete_internal_obj (object); 361 acpi_ut_delete_internal_obj(object);
387 break; 362 break;
388 363
389
390 default: 364 default:
391 365
392 ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "Unknown action (%X)\n", action)); 366 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, "Unknown action (%X)\n",
367 action));
393 break; 368 break;
394 } 369 }
395 370
@@ -399,15 +374,14 @@ acpi_ut_update_ref_count (
399 */ 374 */
400 if (count > ACPI_MAX_REFERENCE_COUNT) { 375 if (count > ACPI_MAX_REFERENCE_COUNT) {
401 376
402 ACPI_DEBUG_PRINT ((ACPI_DB_WARN, 377 ACPI_DEBUG_PRINT((ACPI_DB_WARN,
403 "**** Warning **** Large Reference Count (%X) in object %p\n\n", 378 "**** Warning **** Large Reference Count (%X) in object %p\n\n",
404 count, object)); 379 count, object));
405 } 380 }
406 381
407 return; 382 return;
408} 383}
409 384
410
411/******************************************************************************* 385/*******************************************************************************
412 * 386 *
413 * FUNCTION: acpi_ut_update_object_reference 387 * FUNCTION: acpi_ut_update_object_reference
@@ -431,38 +405,36 @@ acpi_ut_update_ref_count (
431 ******************************************************************************/ 405 ******************************************************************************/
432 406
433acpi_status 407acpi_status
434acpi_ut_update_object_reference ( 408acpi_ut_update_object_reference(union acpi_operand_object * object, u16 action)
435 union acpi_operand_object *object,
436 u16 action)
437{ 409{
438 acpi_status status = AE_OK; 410 acpi_status status = AE_OK;
439 union acpi_generic_state *state_list = NULL; 411 union acpi_generic_state *state_list = NULL;
440 union acpi_operand_object *next_object = NULL; 412 union acpi_operand_object *next_object = NULL;
441 union acpi_generic_state *state; 413 union acpi_generic_state *state;
442 acpi_native_uint i; 414 acpi_native_uint i;
443
444
445 ACPI_FUNCTION_TRACE_PTR ("ut_update_object_reference", object);
446 415
416 ACPI_FUNCTION_TRACE_PTR("ut_update_object_reference", object);
447 417
448 while (object) { 418 while (object) {
449 /* Make sure that this isn't a namespace handle */ 419 /* Make sure that this isn't a namespace handle */
450 420
451 if (ACPI_GET_DESCRIPTOR_TYPE (object) == ACPI_DESC_TYPE_NAMED) { 421 if (ACPI_GET_DESCRIPTOR_TYPE(object) == ACPI_DESC_TYPE_NAMED) {
452 ACPI_DEBUG_PRINT ((ACPI_DB_ALLOCATIONS, 422 ACPI_DEBUG_PRINT((ACPI_DB_ALLOCATIONS,
453 "Object %p is NS handle\n", object)); 423 "Object %p is NS handle\n", object));
454 return_ACPI_STATUS (AE_OK); 424 return_ACPI_STATUS(AE_OK);
455 } 425 }
456 426
457 /* 427 /*
458 * All sub-objects must have their reference count incremented also. 428 * All sub-objects must have their reference count incremented also.
459 * Different object types have different subobjects. 429 * Different object types have different subobjects.
460 */ 430 */
461 switch (ACPI_GET_OBJECT_TYPE (object)) { 431 switch (ACPI_GET_OBJECT_TYPE(object)) {
462 case ACPI_TYPE_DEVICE: 432 case ACPI_TYPE_DEVICE:
463 433
464 acpi_ut_update_ref_count (object->device.system_notify, action); 434 acpi_ut_update_ref_count(object->device.system_notify,
465 acpi_ut_update_ref_count (object->device.device_notify, action); 435 action);
436 acpi_ut_update_ref_count(object->device.device_notify,
437 action);
466 break; 438 break;
467 439
468 case ACPI_TYPE_PACKAGE: 440 case ACPI_TYPE_PACKAGE:
@@ -476,9 +448,11 @@ acpi_ut_update_object_reference (
476 * Note: There can be null elements within the package, 448 * Note: There can be null elements within the package,
477 * these are simply ignored 449 * these are simply ignored
478 */ 450 */
479 status = acpi_ut_create_update_state_and_push ( 451 status =
480 object->package.elements[i], action, &state_list); 452 acpi_ut_create_update_state_and_push
481 if (ACPI_FAILURE (status)) { 453 (object->package.elements[i], action,
454 &state_list);
455 if (ACPI_FAILURE(status)) {
482 goto error_exit; 456 goto error_exit;
483 } 457 }
484 } 458 }
@@ -497,9 +471,13 @@ acpi_ut_update_object_reference (
497 case ACPI_TYPE_LOCAL_BANK_FIELD: 471 case ACPI_TYPE_LOCAL_BANK_FIELD:
498 472
499 next_object = object->bank_field.bank_obj; 473 next_object = object->bank_field.bank_obj;
500 status = acpi_ut_create_update_state_and_push ( 474 status =
501 object->bank_field.region_obj, action, &state_list); 475 acpi_ut_create_update_state_and_push(object->
502 if (ACPI_FAILURE (status)) { 476 bank_field.
477 region_obj,
478 action,
479 &state_list);
480 if (ACPI_FAILURE(status)) {
503 goto error_exit; 481 goto error_exit;
504 } 482 }
505 break; 483 break;
@@ -507,9 +485,13 @@ acpi_ut_update_object_reference (
507 case ACPI_TYPE_LOCAL_INDEX_FIELD: 485 case ACPI_TYPE_LOCAL_INDEX_FIELD:
508 486
509 next_object = object->index_field.index_obj; 487 next_object = object->index_field.index_obj;
510 status = acpi_ut_create_update_state_and_push ( 488 status =
511 object->index_field.data_obj, action, &state_list); 489 acpi_ut_create_update_state_and_push(object->
512 if (ACPI_FAILURE (status)) { 490 index_field.
491 data_obj,
492 action,
493 &state_list);
494 if (ACPI_FAILURE(status)) {
513 goto error_exit; 495 goto error_exit;
514 } 496 }
515 break; 497 break;
@@ -526,7 +508,7 @@ acpi_ut_update_object_reference (
526 508
527 case ACPI_TYPE_REGION: 509 case ACPI_TYPE_REGION:
528 default: 510 default:
529 break;/* No subobjects */ 511 break; /* No subobjects */
530 } 512 }
531 513
532 /* 514 /*
@@ -534,7 +516,7 @@ acpi_ut_update_object_reference (
534 * happen after we update the sub-objects in case this causes the 516 * happen after we update the sub-objects in case this causes the
535 * main object to be deleted. 517 * main object to be deleted.
536 */ 518 */
537 acpi_ut_update_ref_count (object, action); 519 acpi_ut_update_ref_count(object, action);
538 object = NULL; 520 object = NULL;
539 521
540 /* Move on to the next object to be updated */ 522 /* Move on to the next object to be updated */
@@ -542,25 +524,23 @@ acpi_ut_update_object_reference (
542 if (next_object) { 524 if (next_object) {
543 object = next_object; 525 object = next_object;
544 next_object = NULL; 526 next_object = NULL;
545 } 527 } else if (state_list) {
546 else if (state_list) { 528 state = acpi_ut_pop_generic_state(&state_list);
547 state = acpi_ut_pop_generic_state (&state_list);
548 object = state->update.object; 529 object = state->update.object;
549 acpi_ut_delete_generic_state (state); 530 acpi_ut_delete_generic_state(state);
550 } 531 }
551 } 532 }
552 533
553 return_ACPI_STATUS (AE_OK); 534 return_ACPI_STATUS(AE_OK);
554 535
555error_exit: 536 error_exit:
556 537
557 ACPI_REPORT_ERROR (("Could not update object reference count, %s\n", 538 ACPI_REPORT_ERROR(("Could not update object reference count, %s\n",
558 acpi_format_exception (status))); 539 acpi_format_exception(status)));
559 540
560 return_ACPI_STATUS (status); 541 return_ACPI_STATUS(status);
561} 542}
562 543
563
564/******************************************************************************* 544/*******************************************************************************
565 * 545 *
566 * FUNCTION: acpi_ut_add_reference 546 * FUNCTION: acpi_ut_add_reference
@@ -574,31 +554,27 @@ error_exit:
574 * 554 *
575 ******************************************************************************/ 555 ******************************************************************************/
576 556
577void 557void acpi_ut_add_reference(union acpi_operand_object *object)
578acpi_ut_add_reference (
579 union acpi_operand_object *object)
580{ 558{
581 559
582 ACPI_FUNCTION_TRACE_PTR ("ut_add_reference", object); 560 ACPI_FUNCTION_TRACE_PTR("ut_add_reference", object);
583
584 561
585 /* Ensure that we have a valid object */ 562 /* Ensure that we have a valid object */
586 563
587 if (!acpi_ut_valid_internal_object (object)) { 564 if (!acpi_ut_valid_internal_object(object)) {
588 return_VOID; 565 return_VOID;
589 } 566 }
590 567
591 ACPI_DEBUG_PRINT ((ACPI_DB_ALLOCATIONS, 568 ACPI_DEBUG_PRINT((ACPI_DB_ALLOCATIONS,
592 "Obj %p Current Refs=%X [To Be Incremented]\n", 569 "Obj %p Current Refs=%X [To Be Incremented]\n",
593 object, object->common.reference_count)); 570 object, object->common.reference_count));
594 571
595 /* Increment the reference count */ 572 /* Increment the reference count */
596 573
597 (void) acpi_ut_update_object_reference (object, REF_INCREMENT); 574 (void)acpi_ut_update_object_reference(object, REF_INCREMENT);
598 return_VOID; 575 return_VOID;
599} 576}
600 577
601
602/******************************************************************************* 578/*******************************************************************************
603 * 579 *
604 * FUNCTION: acpi_ut_remove_reference 580 * FUNCTION: acpi_ut_remove_reference
@@ -611,13 +587,10 @@ acpi_ut_add_reference (
611 * 587 *
612 ******************************************************************************/ 588 ******************************************************************************/
613 589
614void 590void acpi_ut_remove_reference(union acpi_operand_object *object)
615acpi_ut_remove_reference (
616 union acpi_operand_object *object)
617{ 591{
618 592
619 ACPI_FUNCTION_TRACE_PTR ("ut_remove_reference", object); 593 ACPI_FUNCTION_TRACE_PTR("ut_remove_reference", object);
620
621 594
622 /* 595 /*
623 * Allow a NULL pointer to be passed in, just ignore it. This saves 596 * Allow a NULL pointer to be passed in, just ignore it. This saves
@@ -625,27 +598,25 @@ acpi_ut_remove_reference (
625 * 598 *
626 */ 599 */
627 if (!object || 600 if (!object ||
628 (ACPI_GET_DESCRIPTOR_TYPE (object) == ACPI_DESC_TYPE_NAMED)) { 601 (ACPI_GET_DESCRIPTOR_TYPE(object) == ACPI_DESC_TYPE_NAMED)) {
629 return_VOID; 602 return_VOID;
630 } 603 }
631 604
632 /* Ensure that we have a valid object */ 605 /* Ensure that we have a valid object */
633 606
634 if (!acpi_ut_valid_internal_object (object)) { 607 if (!acpi_ut_valid_internal_object(object)) {
635 return_VOID; 608 return_VOID;
636 } 609 }
637 610
638 ACPI_DEBUG_PRINT ((ACPI_DB_ALLOCATIONS, 611 ACPI_DEBUG_PRINT((ACPI_DB_ALLOCATIONS,
639 "Obj %p Current Refs=%X [To Be Decremented]\n", 612 "Obj %p Current Refs=%X [To Be Decremented]\n",
640 object, object->common.reference_count)); 613 object, object->common.reference_count));
641 614
642 /* 615 /*
643 * Decrement the reference count, and only actually delete the object 616 * Decrement the reference count, and only actually delete the object
644 * if the reference count becomes 0. (Must also decrement the ref count 617 * if the reference count becomes 0. (Must also decrement the ref count
645 * of all subobjects!) 618 * of all subobjects!)
646 */ 619 */
647 (void) acpi_ut_update_object_reference (object, REF_DECREMENT); 620 (void)acpi_ut_update_object_reference(object, REF_DECREMENT);
648 return_VOID; 621 return_VOID;
649} 622}
650
651
diff --git a/drivers/acpi/utilities/uteval.c b/drivers/acpi/utilities/uteval.c
index 00046dd5d925..7b81d5ef3c32 100644
--- a/drivers/acpi/utilities/uteval.c
+++ b/drivers/acpi/utilities/uteval.c
@@ -41,28 +41,20 @@
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/acinterp.h> 46#include <acpi/acinterp.h>
48 47
49
50#define _COMPONENT ACPI_UTILITIES 48#define _COMPONENT ACPI_UTILITIES
51 ACPI_MODULE_NAME ("uteval") 49ACPI_MODULE_NAME("uteval")
52 50
53/* Local prototypes */ 51/* Local prototypes */
54
55static void 52static void
56acpi_ut_copy_id_string ( 53acpi_ut_copy_id_string(char *destination, char *source, acpi_size max_length);
57 char *destination,
58 char *source,
59 acpi_size max_length);
60 54
61static acpi_status 55static acpi_status
62acpi_ut_translate_one_cid ( 56acpi_ut_translate_one_cid(union acpi_operand_object *obj_desc,
63 union acpi_operand_object *obj_desc, 57 struct acpi_compatible_id *one_cid);
64 struct acpi_compatible_id *one_cid);
65
66 58
67/******************************************************************************* 59/*******************************************************************************
68 * 60 *
@@ -77,37 +69,33 @@ acpi_ut_translate_one_cid (
77 * 69 *
78 ******************************************************************************/ 70 ******************************************************************************/
79 71
80acpi_status 72acpi_status acpi_ut_osi_implementation(struct acpi_walk_state *walk_state)
81acpi_ut_osi_implementation (
82 struct acpi_walk_state *walk_state)
83{ 73{
84 union acpi_operand_object *string_desc; 74 union acpi_operand_object *string_desc;
85 union acpi_operand_object *return_desc; 75 union acpi_operand_object *return_desc;
86 acpi_native_uint i; 76 acpi_native_uint i;
87
88
89 ACPI_FUNCTION_TRACE ("ut_osi_implementation");
90 77
78 ACPI_FUNCTION_TRACE("ut_osi_implementation");
91 79
92 /* Validate the string input argument */ 80 /* Validate the string input argument */
93 81
94 string_desc = walk_state->arguments[0].object; 82 string_desc = walk_state->arguments[0].object;
95 if (!string_desc || (string_desc->common.type != ACPI_TYPE_STRING)) { 83 if (!string_desc || (string_desc->common.type != ACPI_TYPE_STRING)) {
96 return_ACPI_STATUS (AE_TYPE); 84 return_ACPI_STATUS(AE_TYPE);
97 } 85 }
98 86
99 /* Create a return object (Default value = 0) */ 87 /* Create a return object (Default value = 0) */
100 88
101 return_desc = acpi_ut_create_internal_object (ACPI_TYPE_INTEGER); 89 return_desc = acpi_ut_create_internal_object(ACPI_TYPE_INTEGER);
102 if (!return_desc) { 90 if (!return_desc) {
103 return_ACPI_STATUS (AE_NO_MEMORY); 91 return_ACPI_STATUS(AE_NO_MEMORY);
104 } 92 }
105 93
106 /* Compare input string to table of supported strings */ 94 /* Compare input string to table of supported strings */
107 95
108 for (i = 0; i < ACPI_NUM_OSI_STRINGS; i++) { 96 for (i = 0; i < ACPI_NUM_OSI_STRINGS; i++) {
109 if (!ACPI_STRCMP (string_desc->string.pointer, 97 if (!ACPI_STRCMP(string_desc->string.pointer,
110 (char *) acpi_gbl_valid_osi_strings[i])) { 98 (char *)acpi_gbl_valid_osi_strings[i])) {
111 /* This string is supported */ 99 /* This string is supported */
112 100
113 return_desc->integer.value = 0xFFFFFFFF; 101 return_desc->integer.value = 0xFFFFFFFF;
@@ -116,10 +104,9 @@ acpi_ut_osi_implementation (
116 } 104 }
117 105
118 walk_state->return_desc = return_desc; 106 walk_state->return_desc = return_desc;
119 return_ACPI_STATUS (AE_CTRL_TERMINATE); 107 return_ACPI_STATUS(AE_CTRL_TERMINATE);
120} 108}
121 109
122
123/******************************************************************************* 110/*******************************************************************************
124 * 111 *
125 * FUNCTION: acpi_ut_evaluate_object 112 * FUNCTION: acpi_ut_evaluate_object
@@ -140,19 +127,16 @@ acpi_ut_osi_implementation (
140 ******************************************************************************/ 127 ******************************************************************************/
141 128
142acpi_status 129acpi_status
143acpi_ut_evaluate_object ( 130acpi_ut_evaluate_object(struct acpi_namespace_node *prefix_node,
144 struct acpi_namespace_node *prefix_node, 131 char *path,
145 char *path, 132 u32 expected_return_btypes,
146 u32 expected_return_btypes, 133 union acpi_operand_object **return_desc)
147 union acpi_operand_object **return_desc)
148{ 134{
149 struct acpi_parameter_info info; 135 struct acpi_parameter_info info;
150 acpi_status status; 136 acpi_status status;
151 u32 return_btype; 137 u32 return_btype;
152
153
154 ACPI_FUNCTION_TRACE ("ut_evaluate_object");
155 138
139 ACPI_FUNCTION_TRACE("ut_evaluate_object");
156 140
157 info.node = prefix_node; 141 info.node = prefix_node;
158 info.parameters = NULL; 142 info.parameters = NULL;
@@ -160,36 +144,38 @@ acpi_ut_evaluate_object (
160 144
161 /* Evaluate the object/method */ 145 /* Evaluate the object/method */
162 146
163 status = acpi_ns_evaluate_relative (path, &info); 147 status = acpi_ns_evaluate_relative(path, &info);
164 if (ACPI_FAILURE (status)) { 148 if (ACPI_FAILURE(status)) {
165 if (status == AE_NOT_FOUND) { 149 if (status == AE_NOT_FOUND) {
166 ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "[%4.4s.%s] was not found\n", 150 ACPI_DEBUG_PRINT((ACPI_DB_EXEC,
167 acpi_ut_get_node_name (prefix_node), path)); 151 "[%4.4s.%s] was not found\n",
168 } 152 acpi_ut_get_node_name(prefix_node),
169 else { 153 path));
170 ACPI_REPORT_METHOD_ERROR ("Method execution failed", 154 } else {
171 prefix_node, path, status); 155 ACPI_REPORT_METHOD_ERROR("Method execution failed",
156 prefix_node, path, status);
172 } 157 }
173 158
174 return_ACPI_STATUS (status); 159 return_ACPI_STATUS(status);
175 } 160 }
176 161
177 /* Did we get a return object? */ 162 /* Did we get a return object? */
178 163
179 if (!info.return_object) { 164 if (!info.return_object) {
180 if (expected_return_btypes) { 165 if (expected_return_btypes) {
181 ACPI_REPORT_METHOD_ERROR ("No object was returned from", 166 ACPI_REPORT_METHOD_ERROR("No object was returned from",
182 prefix_node, path, AE_NOT_EXIST); 167 prefix_node, path,
168 AE_NOT_EXIST);
183 169
184 return_ACPI_STATUS (AE_NOT_EXIST); 170 return_ACPI_STATUS(AE_NOT_EXIST);
185 } 171 }
186 172
187 return_ACPI_STATUS (AE_OK); 173 return_ACPI_STATUS(AE_OK);
188 } 174 }
189 175
190 /* Map the return object type to the bitmapped type */ 176 /* Map the return object type to the bitmapped type */
191 177
192 switch (ACPI_GET_OBJECT_TYPE (info.return_object)) { 178 switch (ACPI_GET_OBJECT_TYPE(info.return_object)) {
193 case ACPI_TYPE_INTEGER: 179 case ACPI_TYPE_INTEGER:
194 return_btype = ACPI_BTYPE_INTEGER; 180 return_btype = ACPI_BTYPE_INTEGER;
195 break; 181 break;
@@ -211,41 +197,41 @@ acpi_ut_evaluate_object (
211 break; 197 break;
212 } 198 }
213 199
214 if ((acpi_gbl_enable_interpreter_slack) && 200 if ((acpi_gbl_enable_interpreter_slack) && (!expected_return_btypes)) {
215 (!expected_return_btypes)) {
216 /* 201 /*
217 * We received a return object, but one was not expected. This can 202 * We received a return object, but one was not expected. This can
218 * happen frequently if the "implicit return" feature is enabled. 203 * happen frequently if the "implicit return" feature is enabled.
219 * Just delete the return object and return AE_OK. 204 * Just delete the return object and return AE_OK.
220 */ 205 */
221 acpi_ut_remove_reference (info.return_object); 206 acpi_ut_remove_reference(info.return_object);
222 return_ACPI_STATUS (AE_OK); 207 return_ACPI_STATUS(AE_OK);
223 } 208 }
224 209
225 /* Is the return object one of the expected types? */ 210 /* Is the return object one of the expected types? */
226 211
227 if (!(expected_return_btypes & return_btype)) { 212 if (!(expected_return_btypes & return_btype)) {
228 ACPI_REPORT_METHOD_ERROR ("Return object type is incorrect", 213 ACPI_REPORT_METHOD_ERROR("Return object type is incorrect",
229 prefix_node, path, AE_TYPE); 214 prefix_node, path, AE_TYPE);
230 215
231 ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, 216 ACPI_DEBUG_PRINT((ACPI_DB_ERROR,
232 "Type returned from %s was incorrect: %s, expected Btypes: %X\n", 217 "Type returned from %s was incorrect: %s, expected Btypes: %X\n",
233 path, acpi_ut_get_object_type_name (info.return_object), 218 path,
234 expected_return_btypes)); 219 acpi_ut_get_object_type_name(info.
220 return_object),
221 expected_return_btypes));
235 222
236 /* On error exit, we must delete the return object */ 223 /* On error exit, we must delete the return object */
237 224
238 acpi_ut_remove_reference (info.return_object); 225 acpi_ut_remove_reference(info.return_object);
239 return_ACPI_STATUS (AE_TYPE); 226 return_ACPI_STATUS(AE_TYPE);
240 } 227 }
241 228
242 /* Object type is OK, return it */ 229 /* Object type is OK, return it */
243 230
244 *return_desc = info.return_object; 231 *return_desc = info.return_object;
245 return_ACPI_STATUS (AE_OK); 232 return_ACPI_STATUS(AE_OK);
246} 233}
247 234
248
249/******************************************************************************* 235/*******************************************************************************
250 * 236 *
251 * FUNCTION: acpi_ut_evaluate_numeric_object 237 * FUNCTION: acpi_ut_evaluate_numeric_object
@@ -264,22 +250,19 @@ acpi_ut_evaluate_object (
264 ******************************************************************************/ 250 ******************************************************************************/
265 251
266acpi_status 252acpi_status
267acpi_ut_evaluate_numeric_object ( 253acpi_ut_evaluate_numeric_object(char *object_name,
268 char *object_name, 254 struct acpi_namespace_node *device_node,
269 struct acpi_namespace_node *device_node, 255 acpi_integer * address)
270 acpi_integer *address)
271{ 256{
272 union acpi_operand_object *obj_desc; 257 union acpi_operand_object *obj_desc;
273 acpi_status status; 258 acpi_status status;
274
275 259
276 ACPI_FUNCTION_TRACE ("ut_evaluate_numeric_object"); 260 ACPI_FUNCTION_TRACE("ut_evaluate_numeric_object");
277 261
278 262 status = acpi_ut_evaluate_object(device_node, object_name,
279 status = acpi_ut_evaluate_object (device_node, object_name, 263 ACPI_BTYPE_INTEGER, &obj_desc);
280 ACPI_BTYPE_INTEGER, &obj_desc); 264 if (ACPI_FAILURE(status)) {
281 if (ACPI_FAILURE (status)) { 265 return_ACPI_STATUS(status);
282 return_ACPI_STATUS (status);
283 } 266 }
284 267
285 /* Get the returned Integer */ 268 /* Get the returned Integer */
@@ -288,11 +271,10 @@ acpi_ut_evaluate_numeric_object (
288 271
289 /* On exit, we must delete the return object */ 272 /* On exit, we must delete the return object */
290 273
291 acpi_ut_remove_reference (obj_desc); 274 acpi_ut_remove_reference(obj_desc);
292 return_ACPI_STATUS (status); 275 return_ACPI_STATUS(status);
293} 276}
294 277
295
296/******************************************************************************* 278/*******************************************************************************
297 * 279 *
298 * FUNCTION: acpi_ut_copy_id_string 280 * FUNCTION: acpi_ut_copy_id_string
@@ -310,10 +292,7 @@ acpi_ut_evaluate_numeric_object (
310 ******************************************************************************/ 292 ******************************************************************************/
311 293
312static void 294static void
313acpi_ut_copy_id_string ( 295acpi_ut_copy_id_string(char *destination, char *source, acpi_size max_length)
314 char *destination,
315 char *source,
316 acpi_size max_length)
317{ 296{
318 297
319 /* 298 /*
@@ -328,10 +307,9 @@ acpi_ut_copy_id_string (
328 307
329 /* Do the actual copy */ 308 /* Do the actual copy */
330 309
331 ACPI_STRNCPY (destination, source, max_length); 310 ACPI_STRNCPY(destination, source, max_length);
332} 311}
333 312
334
335/******************************************************************************* 313/*******************************************************************************
336 * 314 *
337 * FUNCTION: acpi_ut_execute_HID 315 * FUNCTION: acpi_ut_execute_HID
@@ -349,42 +327,39 @@ acpi_ut_copy_id_string (
349 ******************************************************************************/ 327 ******************************************************************************/
350 328
351acpi_status 329acpi_status
352acpi_ut_execute_HID ( 330acpi_ut_execute_HID(struct acpi_namespace_node *device_node,
353 struct acpi_namespace_node *device_node, 331 struct acpi_device_id *hid)
354 struct acpi_device_id *hid)
355{ 332{
356 union acpi_operand_object *obj_desc; 333 union acpi_operand_object *obj_desc;
357 acpi_status status; 334 acpi_status status;
358
359 335
360 ACPI_FUNCTION_TRACE ("ut_execute_HID"); 336 ACPI_FUNCTION_TRACE("ut_execute_HID");
361 337
362 338 status = acpi_ut_evaluate_object(device_node, METHOD_NAME__HID,
363 status = acpi_ut_evaluate_object (device_node, METHOD_NAME__HID, 339 ACPI_BTYPE_INTEGER | ACPI_BTYPE_STRING,
364 ACPI_BTYPE_INTEGER | ACPI_BTYPE_STRING, &obj_desc); 340 &obj_desc);
365 if (ACPI_FAILURE (status)) { 341 if (ACPI_FAILURE(status)) {
366 return_ACPI_STATUS (status); 342 return_ACPI_STATUS(status);
367 } 343 }
368 344
369 if (ACPI_GET_OBJECT_TYPE (obj_desc) == ACPI_TYPE_INTEGER) { 345 if (ACPI_GET_OBJECT_TYPE(obj_desc) == ACPI_TYPE_INTEGER) {
370 /* Convert the Numeric HID to string */ 346 /* Convert the Numeric HID to string */
371 347
372 acpi_ex_eisa_id_to_string ((u32) obj_desc->integer.value, hid->value); 348 acpi_ex_eisa_id_to_string((u32) obj_desc->integer.value,
373 } 349 hid->value);
374 else { 350 } else {
375 /* Copy the String HID from the returned object */ 351 /* Copy the String HID from the returned object */
376 352
377 acpi_ut_copy_id_string (hid->value, obj_desc->string.pointer, 353 acpi_ut_copy_id_string(hid->value, obj_desc->string.pointer,
378 sizeof (hid->value)); 354 sizeof(hid->value));
379 } 355 }
380 356
381 /* On exit, we must delete the return object */ 357 /* On exit, we must delete the return object */
382 358
383 acpi_ut_remove_reference (obj_desc); 359 acpi_ut_remove_reference(obj_desc);
384 return_ACPI_STATUS (status); 360 return_ACPI_STATUS(status);
385} 361}
386 362
387
388/******************************************************************************* 363/*******************************************************************************
389 * 364 *
390 * FUNCTION: acpi_ut_translate_one_cid 365 * FUNCTION: acpi_ut_translate_one_cid
@@ -403,18 +378,17 @@ acpi_ut_execute_HID (
403 ******************************************************************************/ 378 ******************************************************************************/
404 379
405static acpi_status 380static acpi_status
406acpi_ut_translate_one_cid ( 381acpi_ut_translate_one_cid(union acpi_operand_object *obj_desc,
407 union acpi_operand_object *obj_desc, 382 struct acpi_compatible_id *one_cid)
408 struct acpi_compatible_id *one_cid)
409{ 383{
410 384
411 385 switch (ACPI_GET_OBJECT_TYPE(obj_desc)) {
412 switch (ACPI_GET_OBJECT_TYPE (obj_desc)) {
413 case ACPI_TYPE_INTEGER: 386 case ACPI_TYPE_INTEGER:
414 387
415 /* Convert the Numeric CID to string */ 388 /* Convert the Numeric CID to string */
416 389
417 acpi_ex_eisa_id_to_string ((u32) obj_desc->integer.value, one_cid->value); 390 acpi_ex_eisa_id_to_string((u32) obj_desc->integer.value,
391 one_cid->value);
418 return (AE_OK); 392 return (AE_OK);
419 393
420 case ACPI_TYPE_STRING: 394 case ACPI_TYPE_STRING:
@@ -425,8 +399,8 @@ acpi_ut_translate_one_cid (
425 399
426 /* Copy the String CID from the returned object */ 400 /* Copy the String CID from the returned object */
427 401
428 acpi_ut_copy_id_string (one_cid->value, obj_desc->string.pointer, 402 acpi_ut_copy_id_string(one_cid->value, obj_desc->string.pointer,
429 ACPI_MAX_CID_LENGTH); 403 ACPI_MAX_CID_LENGTH);
430 return (AE_OK); 404 return (AE_OK);
431 405
432 default: 406 default:
@@ -435,7 +409,6 @@ acpi_ut_translate_one_cid (
435 } 409 }
436} 410}
437 411
438
439/******************************************************************************* 412/*******************************************************************************
440 * 413 *
441 * FUNCTION: acpi_ut_execute_CID 414 * FUNCTION: acpi_ut_execute_CID
@@ -453,45 +426,42 @@ acpi_ut_translate_one_cid (
453 ******************************************************************************/ 426 ******************************************************************************/
454 427
455acpi_status 428acpi_status
456acpi_ut_execute_CID ( 429acpi_ut_execute_CID(struct acpi_namespace_node * device_node,
457 struct acpi_namespace_node *device_node, 430 struct acpi_compatible_id_list ** return_cid_list)
458 struct acpi_compatible_id_list **return_cid_list)
459{ 431{
460 union acpi_operand_object *obj_desc; 432 union acpi_operand_object *obj_desc;
461 acpi_status status; 433 acpi_status status;
462 u32 count; 434 u32 count;
463 u32 size; 435 u32 size;
464 struct acpi_compatible_id_list *cid_list; 436 struct acpi_compatible_id_list *cid_list;
465 acpi_native_uint i; 437 acpi_native_uint i;
466
467
468 ACPI_FUNCTION_TRACE ("ut_execute_CID");
469 438
439 ACPI_FUNCTION_TRACE("ut_execute_CID");
470 440
471 /* Evaluate the _CID method for this device */ 441 /* Evaluate the _CID method for this device */
472 442
473 status = acpi_ut_evaluate_object (device_node, METHOD_NAME__CID, 443 status = acpi_ut_evaluate_object(device_node, METHOD_NAME__CID,
474 ACPI_BTYPE_INTEGER | ACPI_BTYPE_STRING | ACPI_BTYPE_PACKAGE, 444 ACPI_BTYPE_INTEGER | ACPI_BTYPE_STRING
475 &obj_desc); 445 | ACPI_BTYPE_PACKAGE, &obj_desc);
476 if (ACPI_FAILURE (status)) { 446 if (ACPI_FAILURE(status)) {
477 return_ACPI_STATUS (status); 447 return_ACPI_STATUS(status);
478 } 448 }
479 449
480 /* Get the number of _CIDs returned */ 450 /* Get the number of _CIDs returned */
481 451
482 count = 1; 452 count = 1;
483 if (ACPI_GET_OBJECT_TYPE (obj_desc) == ACPI_TYPE_PACKAGE) { 453 if (ACPI_GET_OBJECT_TYPE(obj_desc) == ACPI_TYPE_PACKAGE) {
484 count = obj_desc->package.count; 454 count = obj_desc->package.count;
485 } 455 }
486 456
487 /* Allocate a worst-case buffer for the _CIDs */ 457 /* Allocate a worst-case buffer for the _CIDs */
488 458
489 size = (((count - 1) * sizeof (struct acpi_compatible_id)) + 459 size = (((count - 1) * sizeof(struct acpi_compatible_id)) +
490 sizeof (struct acpi_compatible_id_list)); 460 sizeof(struct acpi_compatible_id_list));
491 461
492 cid_list = ACPI_MEM_CALLOCATE ((acpi_size) size); 462 cid_list = ACPI_MEM_CALLOCATE((acpi_size) size);
493 if (!cid_list) { 463 if (!cid_list) {
494 return_ACPI_STATUS (AE_NO_MEMORY); 464 return_ACPI_STATUS(AE_NO_MEMORY);
495 } 465 }
496 466
497 /* Init CID list */ 467 /* Init CID list */
@@ -508,39 +478,38 @@ acpi_ut_execute_CID (
508 478
509 /* The _CID object can be either a single CID or a package (list) of CIDs */ 479 /* The _CID object can be either a single CID or a package (list) of CIDs */
510 480
511 if (ACPI_GET_OBJECT_TYPE (obj_desc) == ACPI_TYPE_PACKAGE) { 481 if (ACPI_GET_OBJECT_TYPE(obj_desc) == ACPI_TYPE_PACKAGE) {
512 /* Translate each package element */ 482 /* Translate each package element */
513 483
514 for (i = 0; i < count; i++) { 484 for (i = 0; i < count; i++) {
515 status = acpi_ut_translate_one_cid (obj_desc->package.elements[i], 485 status =
516 &cid_list->id[i]); 486 acpi_ut_translate_one_cid(obj_desc->package.
517 if (ACPI_FAILURE (status)) { 487 elements[i],
488 &cid_list->id[i]);
489 if (ACPI_FAILURE(status)) {
518 break; 490 break;
519 } 491 }
520 } 492 }
521 } 493 } else {
522 else {
523 /* Only one CID, translate to a string */ 494 /* Only one CID, translate to a string */
524 495
525 status = acpi_ut_translate_one_cid (obj_desc, cid_list->id); 496 status = acpi_ut_translate_one_cid(obj_desc, cid_list->id);
526 } 497 }
527 498
528 /* Cleanup on error */ 499 /* Cleanup on error */
529 500
530 if (ACPI_FAILURE (status)) { 501 if (ACPI_FAILURE(status)) {
531 ACPI_MEM_FREE (cid_list); 502 ACPI_MEM_FREE(cid_list);
532 } 503 } else {
533 else {
534 *return_cid_list = cid_list; 504 *return_cid_list = cid_list;
535 } 505 }
536 506
537 /* On exit, we must delete the _CID return object */ 507 /* On exit, we must delete the _CID return object */
538 508
539 acpi_ut_remove_reference (obj_desc); 509 acpi_ut_remove_reference(obj_desc);
540 return_ACPI_STATUS (status); 510 return_ACPI_STATUS(status);
541} 511}
542 512
543
544/******************************************************************************* 513/*******************************************************************************
545 * 514 *
546 * FUNCTION: acpi_ut_execute_UID 515 * FUNCTION: acpi_ut_execute_UID
@@ -558,42 +527,39 @@ acpi_ut_execute_CID (
558 ******************************************************************************/ 527 ******************************************************************************/
559 528
560acpi_status 529acpi_status
561acpi_ut_execute_UID ( 530acpi_ut_execute_UID(struct acpi_namespace_node *device_node,
562 struct acpi_namespace_node *device_node, 531 struct acpi_device_id *uid)
563 struct acpi_device_id *uid)
564{ 532{
565 union acpi_operand_object *obj_desc; 533 union acpi_operand_object *obj_desc;
566 acpi_status status; 534 acpi_status status;
567
568
569 ACPI_FUNCTION_TRACE ("ut_execute_UID");
570 535
536 ACPI_FUNCTION_TRACE("ut_execute_UID");
571 537
572 status = acpi_ut_evaluate_object (device_node, METHOD_NAME__UID, 538 status = acpi_ut_evaluate_object(device_node, METHOD_NAME__UID,
573 ACPI_BTYPE_INTEGER | ACPI_BTYPE_STRING, &obj_desc); 539 ACPI_BTYPE_INTEGER | ACPI_BTYPE_STRING,
574 if (ACPI_FAILURE (status)) { 540 &obj_desc);
575 return_ACPI_STATUS (status); 541 if (ACPI_FAILURE(status)) {
542 return_ACPI_STATUS(status);
576 } 543 }
577 544
578 if (ACPI_GET_OBJECT_TYPE (obj_desc) == ACPI_TYPE_INTEGER) { 545 if (ACPI_GET_OBJECT_TYPE(obj_desc) == ACPI_TYPE_INTEGER) {
579 /* Convert the Numeric UID to string */ 546 /* Convert the Numeric UID to string */
580 547
581 acpi_ex_unsigned_integer_to_string (obj_desc->integer.value, uid->value); 548 acpi_ex_unsigned_integer_to_string(obj_desc->integer.value,
582 } 549 uid->value);
583 else { 550 } else {
584 /* Copy the String UID from the returned object */ 551 /* Copy the String UID from the returned object */
585 552
586 acpi_ut_copy_id_string (uid->value, obj_desc->string.pointer, 553 acpi_ut_copy_id_string(uid->value, obj_desc->string.pointer,
587 sizeof (uid->value)); 554 sizeof(uid->value));
588 } 555 }
589 556
590 /* On exit, we must delete the return object */ 557 /* On exit, we must delete the return object */
591 558
592 acpi_ut_remove_reference (obj_desc); 559 acpi_ut_remove_reference(obj_desc);
593 return_ACPI_STATUS (status); 560 return_ACPI_STATUS(status);
594} 561}
595 562
596
597/******************************************************************************* 563/*******************************************************************************
598 * 564 *
599 * FUNCTION: acpi_ut_execute_STA 565 * FUNCTION: acpi_ut_execute_STA
@@ -611,30 +577,26 @@ acpi_ut_execute_UID (
611 ******************************************************************************/ 577 ******************************************************************************/
612 578
613acpi_status 579acpi_status
614acpi_ut_execute_STA ( 580acpi_ut_execute_STA(struct acpi_namespace_node *device_node, u32 * flags)
615 struct acpi_namespace_node *device_node,
616 u32 *flags)
617{ 581{
618 union acpi_operand_object *obj_desc; 582 union acpi_operand_object *obj_desc;
619 acpi_status status; 583 acpi_status status;
620
621 584
622 ACPI_FUNCTION_TRACE ("ut_execute_STA"); 585 ACPI_FUNCTION_TRACE("ut_execute_STA");
623 586
624 587 status = acpi_ut_evaluate_object(device_node, METHOD_NAME__STA,
625 status = acpi_ut_evaluate_object (device_node, METHOD_NAME__STA, 588 ACPI_BTYPE_INTEGER, &obj_desc);
626 ACPI_BTYPE_INTEGER, &obj_desc); 589 if (ACPI_FAILURE(status)) {
627 if (ACPI_FAILURE (status)) {
628 if (AE_NOT_FOUND == status) { 590 if (AE_NOT_FOUND == status) {
629 ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, 591 ACPI_DEBUG_PRINT((ACPI_DB_EXEC,
630 "_STA on %4.4s was not found, assuming device is present\n", 592 "_STA on %4.4s was not found, assuming device is present\n",
631 acpi_ut_get_node_name (device_node))); 593 acpi_ut_get_node_name(device_node)));
632 594
633 *flags = 0x0F; 595 *flags = 0x0F;
634 status = AE_OK; 596 status = AE_OK;
635 } 597 }
636 598
637 return_ACPI_STATUS (status); 599 return_ACPI_STATUS(status);
638 } 600 }
639 601
640 /* Extract the status flags */ 602 /* Extract the status flags */
@@ -643,11 +605,10 @@ acpi_ut_execute_STA (
643 605
644 /* On exit, we must delete the return object */ 606 /* On exit, we must delete the return object */
645 607
646 acpi_ut_remove_reference (obj_desc); 608 acpi_ut_remove_reference(obj_desc);
647 return_ACPI_STATUS (status); 609 return_ACPI_STATUS(status);
648} 610}
649 611
650
651/******************************************************************************* 612/*******************************************************************************
652 * 613 *
653 * FUNCTION: acpi_ut_execute_Sxds 614 * FUNCTION: acpi_ut_execute_Sxds
@@ -665,44 +626,45 @@ acpi_ut_execute_STA (
665 ******************************************************************************/ 626 ******************************************************************************/
666 627
667acpi_status 628acpi_status
668acpi_ut_execute_sxds ( 629acpi_ut_execute_sxds(struct acpi_namespace_node *device_node, u8 * highest)
669 struct acpi_namespace_node *device_node,
670 u8 *highest)
671{ 630{
672 union acpi_operand_object *obj_desc; 631 union acpi_operand_object *obj_desc;
673 acpi_status status; 632 acpi_status status;
674 u32 i; 633 u32 i;
675
676
677 ACPI_FUNCTION_TRACE ("ut_execute_Sxds");
678 634
635 ACPI_FUNCTION_TRACE("ut_execute_Sxds");
679 636
680 for (i = 0; i < 4; i++) { 637 for (i = 0; i < 4; i++) {
681 highest[i] = 0xFF; 638 highest[i] = 0xFF;
682 status = acpi_ut_evaluate_object (device_node, 639 status = acpi_ut_evaluate_object(device_node,
683 (char *) acpi_gbl_highest_dstate_names[i], 640 (char *)
684 ACPI_BTYPE_INTEGER, &obj_desc); 641 acpi_gbl_highest_dstate_names
685 if (ACPI_FAILURE (status)) { 642 [i], ACPI_BTYPE_INTEGER,
643 &obj_desc);
644 if (ACPI_FAILURE(status)) {
686 if (status != AE_NOT_FOUND) { 645 if (status != AE_NOT_FOUND) {
687 ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, 646 ACPI_DEBUG_PRINT((ACPI_DB_EXEC,
688 "%s on Device %4.4s, %s\n", 647 "%s on Device %4.4s, %s\n",
689 (char *) acpi_gbl_highest_dstate_names[i], 648 (char *)
690 acpi_ut_get_node_name (device_node), 649 acpi_gbl_highest_dstate_names
691 acpi_format_exception (status))); 650 [i],
692 651 acpi_ut_get_node_name
693 return_ACPI_STATUS (status); 652 (device_node),
653 acpi_format_exception
654 (status)));
655
656 return_ACPI_STATUS(status);
694 } 657 }
695 } 658 } else {
696 else {
697 /* Extract the Dstate value */ 659 /* Extract the Dstate value */
698 660
699 highest[i] = (u8) obj_desc->integer.value; 661 highest[i] = (u8) obj_desc->integer.value;
700 662
701 /* Delete the return object */ 663 /* Delete the return object */
702 664
703 acpi_ut_remove_reference (obj_desc); 665 acpi_ut_remove_reference(obj_desc);
704 } 666 }
705 } 667 }
706 668
707 return_ACPI_STATUS (AE_OK); 669 return_ACPI_STATUS(AE_OK);
708} 670}
diff --git a/drivers/acpi/utilities/utglobal.c b/drivers/acpi/utilities/utglobal.c
index 0e4161c81076..399e64b51886 100644
--- a/drivers/acpi/utilities/utglobal.c
+++ b/drivers/acpi/utilities/utglobal.c
@@ -48,8 +48,7 @@
48#include <acpi/acnamesp.h> 48#include <acpi/acnamesp.h>
49 49
50#define _COMPONENT ACPI_UTILITIES 50#define _COMPONENT ACPI_UTILITIES
51 ACPI_MODULE_NAME ("utglobal") 51ACPI_MODULE_NAME("utglobal")
52
53 52
54/******************************************************************************* 53/*******************************************************************************
55 * 54 *
@@ -63,17 +62,12 @@
63 * DESCRIPTION: This function translates an ACPI exception into an ASCII string. 62 * DESCRIPTION: This function translates an ACPI exception into an ASCII string.
64 * 63 *
65 ******************************************************************************/ 64 ******************************************************************************/
66 65const char *acpi_format_exception(acpi_status status)
67const char *
68acpi_format_exception (
69 acpi_status status)
70{ 66{
71 acpi_status sub_status; 67 acpi_status sub_status;
72 const char *exception = NULL; 68 const char *exception = NULL;
73
74
75 ACPI_FUNCTION_NAME ("format_exception");
76 69
70 ACPI_FUNCTION_NAME("format_exception");
77 71
78 sub_status = (status & ~AE_CODE_MASK); 72 sub_status = (status & ~AE_CODE_MASK);
79 73
@@ -81,35 +75,39 @@ acpi_format_exception (
81 case AE_CODE_ENVIRONMENTAL: 75 case AE_CODE_ENVIRONMENTAL:
82 76
83 if (sub_status <= AE_CODE_ENV_MAX) { 77 if (sub_status <= AE_CODE_ENV_MAX) {
84 exception = acpi_gbl_exception_names_env [sub_status]; 78 exception = acpi_gbl_exception_names_env[sub_status];
85 } 79 }
86 break; 80 break;
87 81
88 case AE_CODE_PROGRAMMER: 82 case AE_CODE_PROGRAMMER:
89 83
90 if (sub_status <= AE_CODE_PGM_MAX) { 84 if (sub_status <= AE_CODE_PGM_MAX) {
91 exception = acpi_gbl_exception_names_pgm [sub_status -1]; 85 exception =
86 acpi_gbl_exception_names_pgm[sub_status - 1];
92 } 87 }
93 break; 88 break;
94 89
95 case AE_CODE_ACPI_TABLES: 90 case AE_CODE_ACPI_TABLES:
96 91
97 if (sub_status <= AE_CODE_TBL_MAX) { 92 if (sub_status <= AE_CODE_TBL_MAX) {
98 exception = acpi_gbl_exception_names_tbl [sub_status -1]; 93 exception =
94 acpi_gbl_exception_names_tbl[sub_status - 1];
99 } 95 }
100 break; 96 break;
101 97
102 case AE_CODE_AML: 98 case AE_CODE_AML:
103 99
104 if (sub_status <= AE_CODE_AML_MAX) { 100 if (sub_status <= AE_CODE_AML_MAX) {
105 exception = acpi_gbl_exception_names_aml [sub_status -1]; 101 exception =
102 acpi_gbl_exception_names_aml[sub_status - 1];
106 } 103 }
107 break; 104 break;
108 105
109 case AE_CODE_CONTROL: 106 case AE_CODE_CONTROL:
110 107
111 if (sub_status <= AE_CODE_CTRL_MAX) { 108 if (sub_status <= AE_CODE_CTRL_MAX) {
112 exception = acpi_gbl_exception_names_ctrl [sub_status -1]; 109 exception =
110 acpi_gbl_exception_names_ctrl[sub_status - 1];
113 } 111 }
114 break; 112 break;
115 113
@@ -120,16 +118,15 @@ acpi_format_exception (
120 if (!exception) { 118 if (!exception) {
121 /* Exception code was not recognized */ 119 /* Exception code was not recognized */
122 120
123 ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, 121 ACPI_DEBUG_PRINT((ACPI_DB_ERROR,
124 "Unknown exception code: 0x%8.8X\n", status)); 122 "Unknown exception code: 0x%8.8X\n", status));
125 123
126 return ((const char *) "UNKNOWN_STATUS_CODE"); 124 return ((const char *)"UNKNOWN_STATUS_CODE");
127 } 125 }
128 126
129 return ((const char *) exception); 127 return ((const char *)exception);
130} 128}
131 129
132
133/******************************************************************************* 130/*******************************************************************************
134 * 131 *
135 * Static global variable initialization. 132 * Static global variable initialization.
@@ -142,34 +139,32 @@ acpi_format_exception (
142 */ 139 */
143 140
144/* Debug switch - level and trace mask */ 141/* Debug switch - level and trace mask */
145u32 acpi_dbg_level = ACPI_DEBUG_DEFAULT; 142u32 acpi_dbg_level = ACPI_DEBUG_DEFAULT;
146EXPORT_SYMBOL(acpi_dbg_level); 143EXPORT_SYMBOL(acpi_dbg_level);
147 144
148/* Debug switch - layer (component) mask */ 145/* Debug switch - layer (component) mask */
149 146
150u32 acpi_dbg_layer = ACPI_COMPONENT_DEFAULT | ACPI_ALL_DRIVERS; 147u32 acpi_dbg_layer = ACPI_COMPONENT_DEFAULT | ACPI_ALL_DRIVERS;
151EXPORT_SYMBOL(acpi_dbg_layer); 148EXPORT_SYMBOL(acpi_dbg_layer);
152u32 acpi_gbl_nesting_level = 0; 149u32 acpi_gbl_nesting_level = 0;
153
154 150
155/* Debugger globals */ 151/* Debugger globals */
156 152
157u8 acpi_gbl_db_terminate_threads = FALSE; 153u8 acpi_gbl_db_terminate_threads = FALSE;
158u8 acpi_gbl_abort_method = FALSE; 154u8 acpi_gbl_abort_method = FALSE;
159u8 acpi_gbl_method_executing = FALSE; 155u8 acpi_gbl_method_executing = FALSE;
160 156
161/* System flags */ 157/* System flags */
162 158
163u32 acpi_gbl_startup_flags = 0; 159u32 acpi_gbl_startup_flags = 0;
164 160
165/* System starts uninitialized */ 161/* System starts uninitialized */
166 162
167u8 acpi_gbl_shutdown = TRUE; 163u8 acpi_gbl_shutdown = TRUE;
168 164
169const u8 acpi_gbl_decode_to8bit [8] = {1,2,4,8,16,32,64,128}; 165const u8 acpi_gbl_decode_to8bit[8] = { 1, 2, 4, 8, 16, 32, 64, 128 };
170 166
171const char *acpi_gbl_sleep_state_names[ACPI_S_STATE_COUNT] = 167const char *acpi_gbl_sleep_state_names[ACPI_S_STATE_COUNT] = {
172{
173 "\\_S0_", 168 "\\_S0_",
174 "\\_S1_", 169 "\\_S1_",
175 "\\_S2_", 170 "\\_S2_",
@@ -178,8 +173,7 @@ const char *acpi_gbl_sleep_state_names[ACPI_S_STATE_COU
178 "\\_S5_" 173 "\\_S5_"
179}; 174};
180 175
181const char *acpi_gbl_highest_dstate_names[4] = 176const char *acpi_gbl_highest_dstate_names[4] = {
182{
183 "_S1D", 177 "_S1D",
184 "_S2D", 178 "_S2D",
185 "_S3D", 179 "_S3D",
@@ -190,8 +184,7 @@ const char *acpi_gbl_highest_dstate_names[4] =
190 * Strings supported by the _OSI predefined (internal) method. 184 * Strings supported by the _OSI predefined (internal) method.
191 * When adding strings, be sure to update ACPI_NUM_OSI_STRINGS. 185 * When adding strings, be sure to update ACPI_NUM_OSI_STRINGS.
192 */ 186 */
193const char *acpi_gbl_valid_osi_strings[ACPI_NUM_OSI_STRINGS] = 187const char *acpi_gbl_valid_osi_strings[ACPI_NUM_OSI_STRINGS] = {
194{
195 /* Operating System Vendor Strings */ 188 /* Operating System Vendor Strings */
196 189
197 "Linux", 190 "Linux",
@@ -209,7 +202,6 @@ const char *acpi_gbl_valid_osi_strings[ACPI_NUM_OSI_STR
209 "Extended Address Space Descriptor" 202 "Extended Address Space Descriptor"
210}; 203};
211 204
212
213/******************************************************************************* 205/*******************************************************************************
214 * 206 *
215 * Namespace globals 207 * Namespace globals
@@ -225,74 +217,70 @@ const char *acpi_gbl_valid_osi_strings[ACPI_NUM_OSI_STR
225 * 2) _TZ_ is defined to be a thermal zone in order to allow ASL code to 217 * 2) _TZ_ is defined to be a thermal zone in order to allow ASL code to
226 * perform a Notify() operation on it. 218 * perform a Notify() operation on it.
227 */ 219 */
228const struct acpi_predefined_names acpi_gbl_pre_defined_names[] = 220const struct acpi_predefined_names acpi_gbl_pre_defined_names[] =
229{ {"_GPE", ACPI_TYPE_LOCAL_SCOPE, NULL}, 221 { {"_GPE", ACPI_TYPE_LOCAL_SCOPE, NULL},
230 {"_PR_", ACPI_TYPE_LOCAL_SCOPE, NULL}, 222{"_PR_", ACPI_TYPE_LOCAL_SCOPE, NULL},
231 {"_SB_", ACPI_TYPE_DEVICE, NULL}, 223{"_SB_", ACPI_TYPE_DEVICE, NULL},
232 {"_SI_", ACPI_TYPE_LOCAL_SCOPE, NULL}, 224{"_SI_", ACPI_TYPE_LOCAL_SCOPE, NULL},
233 {"_TZ_", ACPI_TYPE_THERMAL, NULL}, 225{"_TZ_", ACPI_TYPE_THERMAL, NULL},
234 {"_REV", ACPI_TYPE_INTEGER, (char *) ACPI_CA_SUPPORT_LEVEL}, 226{"_REV", ACPI_TYPE_INTEGER, (char *)ACPI_CA_SUPPORT_LEVEL},
235 {"_OS_", ACPI_TYPE_STRING, ACPI_OS_NAME}, 227{"_OS_", ACPI_TYPE_STRING, ACPI_OS_NAME},
236 {"_GL_", ACPI_TYPE_MUTEX, (char *) 1}, 228{"_GL_", ACPI_TYPE_MUTEX, (char *)1},
237 229
238#if !defined (ACPI_NO_METHOD_EXECUTION) || defined (ACPI_CONSTANT_EVAL_ONLY) 230#if !defined (ACPI_NO_METHOD_EXECUTION) || defined (ACPI_CONSTANT_EVAL_ONLY)
239 {"_OSI", ACPI_TYPE_METHOD, (char *) 1}, 231{"_OSI", ACPI_TYPE_METHOD, (char *)1},
240#endif 232#endif
241 233
242 /* Table terminator */ 234 /* Table terminator */
243 235
244 {NULL, ACPI_TYPE_ANY, NULL} 236{NULL, ACPI_TYPE_ANY, NULL}
245}; 237};
246 238
247/* 239/*
248 * Properties of the ACPI Object Types, both internal and external. 240 * Properties of the ACPI Object Types, both internal and external.
249 * The table is indexed by values of acpi_object_type 241 * The table is indexed by values of acpi_object_type
250 */ 242 */
251const u8 acpi_gbl_ns_properties[] = 243const u8 acpi_gbl_ns_properties[] = {
252{ 244 ACPI_NS_NORMAL, /* 00 Any */
253 ACPI_NS_NORMAL, /* 00 Any */ 245 ACPI_NS_NORMAL, /* 01 Number */
254 ACPI_NS_NORMAL, /* 01 Number */ 246 ACPI_NS_NORMAL, /* 02 String */
255 ACPI_NS_NORMAL, /* 02 String */ 247 ACPI_NS_NORMAL, /* 03 Buffer */
256 ACPI_NS_NORMAL, /* 03 Buffer */ 248 ACPI_NS_NORMAL, /* 04 Package */
257 ACPI_NS_NORMAL, /* 04 Package */ 249 ACPI_NS_NORMAL, /* 05 field_unit */
258 ACPI_NS_NORMAL, /* 05 field_unit */ 250 ACPI_NS_NEWSCOPE, /* 06 Device */
259 ACPI_NS_NEWSCOPE, /* 06 Device */ 251 ACPI_NS_NORMAL, /* 07 Event */
260 ACPI_NS_NORMAL, /* 07 Event */ 252 ACPI_NS_NEWSCOPE, /* 08 Method */
261 ACPI_NS_NEWSCOPE, /* 08 Method */ 253 ACPI_NS_NORMAL, /* 09 Mutex */
262 ACPI_NS_NORMAL, /* 09 Mutex */ 254 ACPI_NS_NORMAL, /* 10 Region */
263 ACPI_NS_NORMAL, /* 10 Region */ 255 ACPI_NS_NEWSCOPE, /* 11 Power */
264 ACPI_NS_NEWSCOPE, /* 11 Power */ 256 ACPI_NS_NEWSCOPE, /* 12 Processor */
265 ACPI_NS_NEWSCOPE, /* 12 Processor */ 257 ACPI_NS_NEWSCOPE, /* 13 Thermal */
266 ACPI_NS_NEWSCOPE, /* 13 Thermal */ 258 ACPI_NS_NORMAL, /* 14 buffer_field */
267 ACPI_NS_NORMAL, /* 14 buffer_field */ 259 ACPI_NS_NORMAL, /* 15 ddb_handle */
268 ACPI_NS_NORMAL, /* 15 ddb_handle */ 260 ACPI_NS_NORMAL, /* 16 Debug Object */
269 ACPI_NS_NORMAL, /* 16 Debug Object */ 261 ACPI_NS_NORMAL, /* 17 def_field */
270 ACPI_NS_NORMAL, /* 17 def_field */ 262 ACPI_NS_NORMAL, /* 18 bank_field */
271 ACPI_NS_NORMAL, /* 18 bank_field */ 263 ACPI_NS_NORMAL, /* 19 index_field */
272 ACPI_NS_NORMAL, /* 19 index_field */ 264 ACPI_NS_NORMAL, /* 20 Reference */
273 ACPI_NS_NORMAL, /* 20 Reference */ 265 ACPI_NS_NORMAL, /* 21 Alias */
274 ACPI_NS_NORMAL, /* 21 Alias */ 266 ACPI_NS_NORMAL, /* 22 method_alias */
275 ACPI_NS_NORMAL, /* 22 method_alias */ 267 ACPI_NS_NORMAL, /* 23 Notify */
276 ACPI_NS_NORMAL, /* 23 Notify */ 268 ACPI_NS_NORMAL, /* 24 Address Handler */
277 ACPI_NS_NORMAL, /* 24 Address Handler */ 269 ACPI_NS_NEWSCOPE | ACPI_NS_LOCAL, /* 25 Resource Desc */
278 ACPI_NS_NEWSCOPE | ACPI_NS_LOCAL, /* 25 Resource Desc */ 270 ACPI_NS_NEWSCOPE | ACPI_NS_LOCAL, /* 26 Resource Field */
279 ACPI_NS_NEWSCOPE | ACPI_NS_LOCAL, /* 26 Resource Field */ 271 ACPI_NS_NEWSCOPE, /* 27 Scope */
280 ACPI_NS_NEWSCOPE, /* 27 Scope */ 272 ACPI_NS_NORMAL, /* 28 Extra */
281 ACPI_NS_NORMAL, /* 28 Extra */ 273 ACPI_NS_NORMAL, /* 29 Data */
282 ACPI_NS_NORMAL, /* 29 Data */ 274 ACPI_NS_NORMAL /* 30 Invalid */
283 ACPI_NS_NORMAL /* 30 Invalid */
284}; 275};
285 276
286
287/* Hex to ASCII conversion table */ 277/* Hex to ASCII conversion table */
288 278
289static const char acpi_gbl_hex_to_ascii[] = 279static const char acpi_gbl_hex_to_ascii[] = {
290{ 280 '0', '1', '2', '3', '4', '5', '6', '7',
291 '0','1','2','3','4','5','6','7', 281 '8', '9', 'A', 'B', 'C', 'D', 'E', 'F'
292 '8','9','A','B','C','D','E','F'
293}; 282};
294 283
295
296/******************************************************************************* 284/*******************************************************************************
297 * 285 *
298 * FUNCTION: acpi_ut_hex_to_ascii_char 286 * FUNCTION: acpi_ut_hex_to_ascii_char
@@ -307,16 +295,12 @@ static const char acpi_gbl_hex_to_ascii[] =
307 * 295 *
308 ******************************************************************************/ 296 ******************************************************************************/
309 297
310char 298char acpi_ut_hex_to_ascii_char(acpi_integer integer, u32 position)
311acpi_ut_hex_to_ascii_char (
312 acpi_integer integer,
313 u32 position)
314{ 299{
315 300
316 return (acpi_gbl_hex_to_ascii[(integer >> position) & 0xF]); 301 return (acpi_gbl_hex_to_ascii[(integer >> position) & 0xF]);
317} 302}
318 303
319
320/******************************************************************************* 304/*******************************************************************************
321 * 305 *
322 * Table name globals 306 * Table name globals
@@ -330,67 +314,139 @@ acpi_ut_hex_to_ascii_char (
330 * 314 *
331 ******************************************************************************/ 315 ******************************************************************************/
332 316
333struct acpi_table_list acpi_gbl_table_lists[NUM_ACPI_TABLE_TYPES]; 317struct acpi_table_list acpi_gbl_table_lists[NUM_ACPI_TABLE_TYPES];
334 318
335struct acpi_table_support acpi_gbl_table_data[NUM_ACPI_TABLE_TYPES] = 319struct acpi_table_support acpi_gbl_table_data[NUM_ACPI_TABLE_TYPES] = {
336{
337 /*********** Name, Signature, Global typed pointer Signature size, Type How many allowed?, Contains valid AML? */ 320 /*********** Name, Signature, Global typed pointer Signature size, Type How many allowed?, Contains valid AML? */
338 321
339 /* RSDP 0 */ {RSDP_NAME, RSDP_SIG, NULL, sizeof (RSDP_SIG)-1, ACPI_TABLE_ROOT | ACPI_TABLE_SINGLE}, 322 /* RSDP 0 */ {RSDP_NAME, RSDP_SIG, NULL, sizeof(RSDP_SIG) - 1,
340 /* DSDT 1 */ {DSDT_SIG, DSDT_SIG, (void *) &acpi_gbl_DSDT, sizeof (DSDT_SIG)-1, ACPI_TABLE_SECONDARY| ACPI_TABLE_SINGLE | ACPI_TABLE_EXECUTABLE}, 323 ACPI_TABLE_ROOT | ACPI_TABLE_SINGLE}
341 /* FADT 2 */ {FADT_SIG, FADT_SIG, (void *) &acpi_gbl_FADT, sizeof (FADT_SIG)-1, ACPI_TABLE_PRIMARY | ACPI_TABLE_SINGLE}, 324 ,
342 /* FACS 3 */ {FACS_SIG, FACS_SIG, (void *) &acpi_gbl_FACS, sizeof (FACS_SIG)-1, ACPI_TABLE_SECONDARY| ACPI_TABLE_SINGLE}, 325 /* DSDT 1 */ {DSDT_SIG, DSDT_SIG, (void *)&acpi_gbl_DSDT,
343 /* PSDT 4 */ {PSDT_SIG, PSDT_SIG, NULL, sizeof (PSDT_SIG)-1, ACPI_TABLE_PRIMARY | ACPI_TABLE_MULTIPLE | ACPI_TABLE_EXECUTABLE}, 326 sizeof(DSDT_SIG) - 1,
344 /* SSDT 5 */ {SSDT_SIG, SSDT_SIG, NULL, sizeof (SSDT_SIG)-1, ACPI_TABLE_PRIMARY | ACPI_TABLE_MULTIPLE | ACPI_TABLE_EXECUTABLE}, 327 ACPI_TABLE_SECONDARY | ACPI_TABLE_SINGLE |
345 /* XSDT 6 */ {XSDT_SIG, XSDT_SIG, NULL, sizeof (RSDT_SIG)-1, ACPI_TABLE_ROOT | ACPI_TABLE_SINGLE}, 328 ACPI_TABLE_EXECUTABLE}
329 ,
330 /* FADT 2 */ {FADT_SIG, FADT_SIG, (void *)&acpi_gbl_FADT,
331 sizeof(FADT_SIG) - 1,
332 ACPI_TABLE_PRIMARY | ACPI_TABLE_SINGLE}
333 ,
334 /* FACS 3 */ {FACS_SIG, FACS_SIG, (void *)&acpi_gbl_FACS,
335 sizeof(FACS_SIG) - 1,
336 ACPI_TABLE_SECONDARY | ACPI_TABLE_SINGLE}
337 ,
338 /* PSDT 4 */ {PSDT_SIG, PSDT_SIG, NULL, sizeof(PSDT_SIG) - 1,
339 ACPI_TABLE_PRIMARY | ACPI_TABLE_MULTIPLE |
340 ACPI_TABLE_EXECUTABLE}
341 ,
342 /* SSDT 5 */ {SSDT_SIG, SSDT_SIG, NULL, sizeof(SSDT_SIG) - 1,
343 ACPI_TABLE_PRIMARY | ACPI_TABLE_MULTIPLE |
344 ACPI_TABLE_EXECUTABLE}
345 ,
346 /* XSDT 6 */ {XSDT_SIG, XSDT_SIG, NULL, sizeof(RSDT_SIG) - 1,
347 ACPI_TABLE_ROOT | ACPI_TABLE_SINGLE}
348 ,
346}; 349};
347 350
348
349/****************************************************************************** 351/******************************************************************************
350 * 352 *
351 * Event and Hardware globals 353 * Event and Hardware globals
352 * 354 *
353 ******************************************************************************/ 355 ******************************************************************************/
354 356
355struct acpi_bit_register_info acpi_gbl_bit_register_info[ACPI_NUM_BITREG] = 357struct acpi_bit_register_info acpi_gbl_bit_register_info[ACPI_NUM_BITREG] = {
356{
357 /* Name Parent Register Register Bit Position Register Bit Mask */ 358 /* Name Parent Register Register Bit Position Register Bit Mask */
358 359
359 /* ACPI_BITREG_TIMER_STATUS */ {ACPI_REGISTER_PM1_STATUS, ACPI_BITPOSITION_TIMER_STATUS, ACPI_BITMASK_TIMER_STATUS}, 360 /* ACPI_BITREG_TIMER_STATUS */ {ACPI_REGISTER_PM1_STATUS,
360 /* ACPI_BITREG_BUS_MASTER_STATUS */ {ACPI_REGISTER_PM1_STATUS, ACPI_BITPOSITION_BUS_MASTER_STATUS, ACPI_BITMASK_BUS_MASTER_STATUS}, 361 ACPI_BITPOSITION_TIMER_STATUS,
361 /* ACPI_BITREG_GLOBAL_LOCK_STATUS */ {ACPI_REGISTER_PM1_STATUS, ACPI_BITPOSITION_GLOBAL_LOCK_STATUS, ACPI_BITMASK_GLOBAL_LOCK_STATUS}, 362 ACPI_BITMASK_TIMER_STATUS},
362 /* ACPI_BITREG_POWER_BUTTON_STATUS */ {ACPI_REGISTER_PM1_STATUS, ACPI_BITPOSITION_POWER_BUTTON_STATUS, ACPI_BITMASK_POWER_BUTTON_STATUS}, 363 /* ACPI_BITREG_BUS_MASTER_STATUS */ {ACPI_REGISTER_PM1_STATUS,
363 /* ACPI_BITREG_SLEEP_BUTTON_STATUS */ {ACPI_REGISTER_PM1_STATUS, ACPI_BITPOSITION_SLEEP_BUTTON_STATUS, ACPI_BITMASK_SLEEP_BUTTON_STATUS}, 364 ACPI_BITPOSITION_BUS_MASTER_STATUS,
364 /* ACPI_BITREG_RT_CLOCK_STATUS */ {ACPI_REGISTER_PM1_STATUS, ACPI_BITPOSITION_RT_CLOCK_STATUS, ACPI_BITMASK_RT_CLOCK_STATUS}, 365 ACPI_BITMASK_BUS_MASTER_STATUS},
365 /* ACPI_BITREG_WAKE_STATUS */ {ACPI_REGISTER_PM1_STATUS, ACPI_BITPOSITION_WAKE_STATUS, ACPI_BITMASK_WAKE_STATUS}, 366 /* ACPI_BITREG_GLOBAL_LOCK_STATUS */ {ACPI_REGISTER_PM1_STATUS,
366 /* ACPI_BITREG_PCIEXP_WAKE_STATUS */ {ACPI_REGISTER_PM1_STATUS, ACPI_BITPOSITION_PCIEXP_WAKE_STATUS, ACPI_BITMASK_PCIEXP_WAKE_STATUS}, 367 ACPI_BITPOSITION_GLOBAL_LOCK_STATUS,
367 368 ACPI_BITMASK_GLOBAL_LOCK_STATUS},
368 /* ACPI_BITREG_TIMER_ENABLE */ {ACPI_REGISTER_PM1_ENABLE, ACPI_BITPOSITION_TIMER_ENABLE, ACPI_BITMASK_TIMER_ENABLE}, 369 /* ACPI_BITREG_POWER_BUTTON_STATUS */ {ACPI_REGISTER_PM1_STATUS,
369 /* ACPI_BITREG_GLOBAL_LOCK_ENABLE */ {ACPI_REGISTER_PM1_ENABLE, ACPI_BITPOSITION_GLOBAL_LOCK_ENABLE, ACPI_BITMASK_GLOBAL_LOCK_ENABLE}, 370 ACPI_BITPOSITION_POWER_BUTTON_STATUS,
370 /* ACPI_BITREG_POWER_BUTTON_ENABLE */ {ACPI_REGISTER_PM1_ENABLE, ACPI_BITPOSITION_POWER_BUTTON_ENABLE, ACPI_BITMASK_POWER_BUTTON_ENABLE}, 371 ACPI_BITMASK_POWER_BUTTON_STATUS},
371 /* ACPI_BITREG_SLEEP_BUTTON_ENABLE */ {ACPI_REGISTER_PM1_ENABLE, ACPI_BITPOSITION_SLEEP_BUTTON_ENABLE, ACPI_BITMASK_SLEEP_BUTTON_ENABLE}, 372 /* ACPI_BITREG_SLEEP_BUTTON_STATUS */ {ACPI_REGISTER_PM1_STATUS,
372 /* ACPI_BITREG_RT_CLOCK_ENABLE */ {ACPI_REGISTER_PM1_ENABLE, ACPI_BITPOSITION_RT_CLOCK_ENABLE, ACPI_BITMASK_RT_CLOCK_ENABLE}, 373 ACPI_BITPOSITION_SLEEP_BUTTON_STATUS,
373 /* ACPI_BITREG_WAKE_ENABLE */ {ACPI_REGISTER_PM1_ENABLE, 0, 0}, 374 ACPI_BITMASK_SLEEP_BUTTON_STATUS},
374 /* ACPI_BITREG_PCIEXP_WAKE_DISABLE */ {ACPI_REGISTER_PM1_ENABLE, ACPI_BITPOSITION_PCIEXP_WAKE_DISABLE, ACPI_BITMASK_PCIEXP_WAKE_DISABLE}, 375 /* ACPI_BITREG_RT_CLOCK_STATUS */ {ACPI_REGISTER_PM1_STATUS,
375 376 ACPI_BITPOSITION_RT_CLOCK_STATUS,
376 /* ACPI_BITREG_SCI_ENABLE */ {ACPI_REGISTER_PM1_CONTROL, ACPI_BITPOSITION_SCI_ENABLE, ACPI_BITMASK_SCI_ENABLE}, 377 ACPI_BITMASK_RT_CLOCK_STATUS},
377 /* ACPI_BITREG_BUS_MASTER_RLD */ {ACPI_REGISTER_PM1_CONTROL, ACPI_BITPOSITION_BUS_MASTER_RLD, ACPI_BITMASK_BUS_MASTER_RLD}, 378 /* ACPI_BITREG_WAKE_STATUS */ {ACPI_REGISTER_PM1_STATUS,
378 /* ACPI_BITREG_GLOBAL_LOCK_RELEASE */ {ACPI_REGISTER_PM1_CONTROL, ACPI_BITPOSITION_GLOBAL_LOCK_RELEASE, ACPI_BITMASK_GLOBAL_LOCK_RELEASE}, 379 ACPI_BITPOSITION_WAKE_STATUS,
379 /* ACPI_BITREG_SLEEP_TYPE_A */ {ACPI_REGISTER_PM1_CONTROL, ACPI_BITPOSITION_SLEEP_TYPE_X, ACPI_BITMASK_SLEEP_TYPE_X}, 380 ACPI_BITMASK_WAKE_STATUS},
380 /* ACPI_BITREG_SLEEP_TYPE_B */ {ACPI_REGISTER_PM1_CONTROL, ACPI_BITPOSITION_SLEEP_TYPE_X, ACPI_BITMASK_SLEEP_TYPE_X}, 381 /* ACPI_BITREG_PCIEXP_WAKE_STATUS */ {ACPI_REGISTER_PM1_STATUS,
381 /* ACPI_BITREG_SLEEP_ENABLE */ {ACPI_REGISTER_PM1_CONTROL, ACPI_BITPOSITION_SLEEP_ENABLE, ACPI_BITMASK_SLEEP_ENABLE}, 382 ACPI_BITPOSITION_PCIEXP_WAKE_STATUS,
382 383 ACPI_BITMASK_PCIEXP_WAKE_STATUS},
383 /* ACPI_BITREG_ARB_DIS */ {ACPI_REGISTER_PM2_CONTROL, ACPI_BITPOSITION_ARB_DISABLE, ACPI_BITMASK_ARB_DISABLE} 384
385 /* ACPI_BITREG_TIMER_ENABLE */ {ACPI_REGISTER_PM1_ENABLE,
386 ACPI_BITPOSITION_TIMER_ENABLE,
387 ACPI_BITMASK_TIMER_ENABLE},
388 /* ACPI_BITREG_GLOBAL_LOCK_ENABLE */ {ACPI_REGISTER_PM1_ENABLE,
389 ACPI_BITPOSITION_GLOBAL_LOCK_ENABLE,
390 ACPI_BITMASK_GLOBAL_LOCK_ENABLE},
391 /* ACPI_BITREG_POWER_BUTTON_ENABLE */ {ACPI_REGISTER_PM1_ENABLE,
392 ACPI_BITPOSITION_POWER_BUTTON_ENABLE,
393 ACPI_BITMASK_POWER_BUTTON_ENABLE},
394 /* ACPI_BITREG_SLEEP_BUTTON_ENABLE */ {ACPI_REGISTER_PM1_ENABLE,
395 ACPI_BITPOSITION_SLEEP_BUTTON_ENABLE,
396 ACPI_BITMASK_SLEEP_BUTTON_ENABLE},
397 /* ACPI_BITREG_RT_CLOCK_ENABLE */ {ACPI_REGISTER_PM1_ENABLE,
398 ACPI_BITPOSITION_RT_CLOCK_ENABLE,
399 ACPI_BITMASK_RT_CLOCK_ENABLE},
400 /* ACPI_BITREG_WAKE_ENABLE */ {ACPI_REGISTER_PM1_ENABLE, 0, 0},
401 /* ACPI_BITREG_PCIEXP_WAKE_DISABLE */ {ACPI_REGISTER_PM1_ENABLE,
402 ACPI_BITPOSITION_PCIEXP_WAKE_DISABLE,
403 ACPI_BITMASK_PCIEXP_WAKE_DISABLE},
404
405 /* ACPI_BITREG_SCI_ENABLE */ {ACPI_REGISTER_PM1_CONTROL,
406 ACPI_BITPOSITION_SCI_ENABLE,
407 ACPI_BITMASK_SCI_ENABLE},
408 /* ACPI_BITREG_BUS_MASTER_RLD */ {ACPI_REGISTER_PM1_CONTROL,
409 ACPI_BITPOSITION_BUS_MASTER_RLD,
410 ACPI_BITMASK_BUS_MASTER_RLD},
411 /* ACPI_BITREG_GLOBAL_LOCK_RELEASE */ {ACPI_REGISTER_PM1_CONTROL,
412 ACPI_BITPOSITION_GLOBAL_LOCK_RELEASE,
413 ACPI_BITMASK_GLOBAL_LOCK_RELEASE},
414 /* ACPI_BITREG_SLEEP_TYPE_A */ {ACPI_REGISTER_PM1_CONTROL,
415 ACPI_BITPOSITION_SLEEP_TYPE_X,
416 ACPI_BITMASK_SLEEP_TYPE_X},
417 /* ACPI_BITREG_SLEEP_TYPE_B */ {ACPI_REGISTER_PM1_CONTROL,
418 ACPI_BITPOSITION_SLEEP_TYPE_X,
419 ACPI_BITMASK_SLEEP_TYPE_X},
420 /* ACPI_BITREG_SLEEP_ENABLE */ {ACPI_REGISTER_PM1_CONTROL,
421 ACPI_BITPOSITION_SLEEP_ENABLE,
422 ACPI_BITMASK_SLEEP_ENABLE},
423
424 /* ACPI_BITREG_ARB_DIS */ {ACPI_REGISTER_PM2_CONTROL,
425 ACPI_BITPOSITION_ARB_DISABLE,
426 ACPI_BITMASK_ARB_DISABLE}
384}; 427};
385 428
386 429struct acpi_fixed_event_info acpi_gbl_fixed_event_info[ACPI_NUM_FIXED_EVENTS] = {
387struct acpi_fixed_event_info acpi_gbl_fixed_event_info[ACPI_NUM_FIXED_EVENTS] = 430 /* ACPI_EVENT_PMTIMER */ {ACPI_BITREG_TIMER_STATUS,
388{ 431 ACPI_BITREG_TIMER_ENABLE,
389 /* ACPI_EVENT_PMTIMER */ {ACPI_BITREG_TIMER_STATUS, ACPI_BITREG_TIMER_ENABLE, ACPI_BITMASK_TIMER_STATUS, ACPI_BITMASK_TIMER_ENABLE}, 432 ACPI_BITMASK_TIMER_STATUS,
390 /* ACPI_EVENT_GLOBAL */ {ACPI_BITREG_GLOBAL_LOCK_STATUS, ACPI_BITREG_GLOBAL_LOCK_ENABLE, ACPI_BITMASK_GLOBAL_LOCK_STATUS, ACPI_BITMASK_GLOBAL_LOCK_ENABLE}, 433 ACPI_BITMASK_TIMER_ENABLE},
391 /* ACPI_EVENT_POWER_BUTTON */ {ACPI_BITREG_POWER_BUTTON_STATUS, ACPI_BITREG_POWER_BUTTON_ENABLE, ACPI_BITMASK_POWER_BUTTON_STATUS, ACPI_BITMASK_POWER_BUTTON_ENABLE}, 434 /* ACPI_EVENT_GLOBAL */ {ACPI_BITREG_GLOBAL_LOCK_STATUS,
392 /* ACPI_EVENT_SLEEP_BUTTON */ {ACPI_BITREG_SLEEP_BUTTON_STATUS, ACPI_BITREG_SLEEP_BUTTON_ENABLE, ACPI_BITMASK_SLEEP_BUTTON_STATUS, ACPI_BITMASK_SLEEP_BUTTON_ENABLE}, 435 ACPI_BITREG_GLOBAL_LOCK_ENABLE,
393 /* ACPI_EVENT_RTC */ {ACPI_BITREG_RT_CLOCK_STATUS, ACPI_BITREG_RT_CLOCK_ENABLE, ACPI_BITMASK_RT_CLOCK_STATUS, ACPI_BITMASK_RT_CLOCK_ENABLE}, 436 ACPI_BITMASK_GLOBAL_LOCK_STATUS,
437 ACPI_BITMASK_GLOBAL_LOCK_ENABLE},
438 /* ACPI_EVENT_POWER_BUTTON */ {ACPI_BITREG_POWER_BUTTON_STATUS,
439 ACPI_BITREG_POWER_BUTTON_ENABLE,
440 ACPI_BITMASK_POWER_BUTTON_STATUS,
441 ACPI_BITMASK_POWER_BUTTON_ENABLE},
442 /* ACPI_EVENT_SLEEP_BUTTON */ {ACPI_BITREG_SLEEP_BUTTON_STATUS,
443 ACPI_BITREG_SLEEP_BUTTON_ENABLE,
444 ACPI_BITMASK_SLEEP_BUTTON_STATUS,
445 ACPI_BITMASK_SLEEP_BUTTON_ENABLE},
446 /* ACPI_EVENT_RTC */ {ACPI_BITREG_RT_CLOCK_STATUS,
447 ACPI_BITREG_RT_CLOCK_ENABLE,
448 ACPI_BITMASK_RT_CLOCK_STATUS,
449 ACPI_BITMASK_RT_CLOCK_ENABLE},
394}; 450};
395 451
396/******************************************************************************* 452/*******************************************************************************
@@ -407,8 +463,7 @@ struct acpi_fixed_event_info acpi_gbl_fixed_event_info[ACPI_NUM_FIXED_EVE
407 463
408/* Region type decoding */ 464/* Region type decoding */
409 465
410const char *acpi_gbl_region_types[ACPI_NUM_PREDEFINED_REGIONS] = 466const char *acpi_gbl_region_types[ACPI_NUM_PREDEFINED_REGIONS] = {
411{
412/*! [Begin] no source code translation (keep these ASL Keywords as-is) */ 467/*! [Begin] no source code translation (keep these ASL Keywords as-is) */
413 "SystemMemory", 468 "SystemMemory",
414 "SystemIO", 469 "SystemIO",
@@ -421,25 +476,18 @@ const char *acpi_gbl_region_types[ACPI_NUM_PREDEFINED_REGIONS] =
421/*! [End] no source code translation !*/ 476/*! [End] no source code translation !*/
422}; 477};
423 478
424 479char *acpi_ut_get_region_name(u8 space_id)
425char *
426acpi_ut_get_region_name (
427 u8 space_id)
428{ 480{
429 481
430 if (space_id >= ACPI_USER_REGION_BEGIN) 482 if (space_id >= ACPI_USER_REGION_BEGIN) {
431 {
432 return ("user_defined_region"); 483 return ("user_defined_region");
433 } 484 } else if (space_id >= ACPI_NUM_PREDEFINED_REGIONS) {
434 else if (space_id >= ACPI_NUM_PREDEFINED_REGIONS)
435 {
436 return ("invalid_space_id"); 485 return ("invalid_space_id");
437 } 486 }
438 487
439 return ((char *) acpi_gbl_region_types[space_id]); 488 return ((char *)acpi_gbl_region_types[space_id]);
440} 489}
441 490
442
443/******************************************************************************* 491/*******************************************************************************
444 * 492 *
445 * FUNCTION: acpi_ut_get_event_name 493 * FUNCTION: acpi_ut_get_event_name
@@ -454,8 +502,7 @@ acpi_ut_get_region_name (
454 502
455/* Event type decoding */ 503/* Event type decoding */
456 504
457static const char *acpi_gbl_event_types[ACPI_NUM_FIXED_EVENTS] = 505static const char *acpi_gbl_event_types[ACPI_NUM_FIXED_EVENTS] = {
458{
459 "PM_Timer", 506 "PM_Timer",
460 "global_lock", 507 "global_lock",
461 "power_button", 508 "power_button",
@@ -463,21 +510,16 @@ static const char *acpi_gbl_event_types[ACPI_NUM_FIXED_EVENTS] =
463 "real_time_clock", 510 "real_time_clock",
464}; 511};
465 512
466 513char *acpi_ut_get_event_name(u32 event_id)
467char *
468acpi_ut_get_event_name (
469 u32 event_id)
470{ 514{
471 515
472 if (event_id > ACPI_EVENT_MAX) 516 if (event_id > ACPI_EVENT_MAX) {
473 {
474 return ("invalid_event_iD"); 517 return ("invalid_event_iD");
475 } 518 }
476 519
477 return ((char *) acpi_gbl_event_types[event_id]); 520 return ((char *)acpi_gbl_event_types[event_id]);
478} 521}
479 522
480
481/******************************************************************************* 523/*******************************************************************************
482 * 524 *
483 * FUNCTION: acpi_ut_get_type_name 525 * FUNCTION: acpi_ut_get_type_name
@@ -498,12 +540,11 @@ acpi_ut_get_event_name (
498 * when stored in a table it really means that we have thus far seen no 540 * when stored in a table it really means that we have thus far seen no
499 * evidence to indicate what type is actually going to be stored for this entry. 541 * evidence to indicate what type is actually going to be stored for this entry.
500 */ 542 */
501static const char acpi_gbl_bad_type[] = "UNDEFINED"; 543static const char acpi_gbl_bad_type[] = "UNDEFINED";
502 544
503/* Printable names of the ACPI object types */ 545/* Printable names of the ACPI object types */
504 546
505static const char *acpi_gbl_ns_type_names[] = 547static const char *acpi_gbl_ns_type_names[] = {
506{
507 /* 00 */ "Untyped", 548 /* 00 */ "Untyped",
508 /* 01 */ "Integer", 549 /* 01 */ "Integer",
509 /* 02 */ "String", 550 /* 02 */ "String",
@@ -537,35 +578,26 @@ static const char *acpi_gbl_ns_type_names[] =
537 /* 30 */ "Invalid" 578 /* 30 */ "Invalid"
538}; 579};
539 580
540 581char *acpi_ut_get_type_name(acpi_object_type type)
541char *
542acpi_ut_get_type_name (
543 acpi_object_type type)
544{ 582{
545 583
546 if (type > ACPI_TYPE_INVALID) 584 if (type > ACPI_TYPE_INVALID) {
547 { 585 return ((char *)acpi_gbl_bad_type);
548 return ((char *) acpi_gbl_bad_type);
549 } 586 }
550 587
551 return ((char *) acpi_gbl_ns_type_names[type]); 588 return ((char *)acpi_gbl_ns_type_names[type]);
552} 589}
553 590
554 591char *acpi_ut_get_object_type_name(union acpi_operand_object *obj_desc)
555char *
556acpi_ut_get_object_type_name (
557 union acpi_operand_object *obj_desc)
558{ 592{
559 593
560 if (!obj_desc) 594 if (!obj_desc) {
561 {
562 return ("[NULL Object Descriptor]"); 595 return ("[NULL Object Descriptor]");
563 } 596 }
564 597
565 return (acpi_ut_get_type_name (ACPI_GET_OBJECT_TYPE (obj_desc))); 598 return (acpi_ut_get_type_name(ACPI_GET_OBJECT_TYPE(obj_desc)));
566} 599}
567 600
568
569/******************************************************************************* 601/*******************************************************************************
570 * 602 *
571 * FUNCTION: acpi_ut_get_node_name 603 * FUNCTION: acpi_ut_get_node_name
@@ -578,39 +610,31 @@ acpi_ut_get_object_type_name (
578 * 610 *
579 ******************************************************************************/ 611 ******************************************************************************/
580 612
581char * 613char *acpi_ut_get_node_name(void *object)
582acpi_ut_get_node_name (
583 void *object)
584{ 614{
585 struct acpi_namespace_node *node = (struct acpi_namespace_node *) object; 615 struct acpi_namespace_node *node = (struct acpi_namespace_node *)object;
586
587 616
588 /* Must return a string of exactly 4 characters == ACPI_NAME_SIZE */ 617 /* Must return a string of exactly 4 characters == ACPI_NAME_SIZE */
589 618
590 if (!object) 619 if (!object) {
591 {
592 return ("NULL"); 620 return ("NULL");
593 } 621 }
594 622
595 /* Check for Root node */ 623 /* Check for Root node */
596 624
597 if ((object == ACPI_ROOT_OBJECT) || 625 if ((object == ACPI_ROOT_OBJECT) || (object == acpi_gbl_root_node)) {
598 (object == acpi_gbl_root_node))
599 {
600 return ("\"\\\" "); 626 return ("\"\\\" ");
601 } 627 }
602 628
603 /* Descriptor must be a namespace node */ 629 /* Descriptor must be a namespace node */
604 630
605 if (node->descriptor != ACPI_DESC_TYPE_NAMED) 631 if (node->descriptor != ACPI_DESC_TYPE_NAMED) {
606 {
607 return ("####"); 632 return ("####");
608 } 633 }
609 634
610 /* Name must be a valid ACPI name */ 635 /* Name must be a valid ACPI name */
611 636
612 if (!acpi_ut_valid_acpi_name (* (u32 *) node->name.ascii)) 637 if (!acpi_ut_valid_acpi_name(*(u32 *) node->name.ascii)) {
613 {
614 return ("????"); 638 return ("????");
615 } 639 }
616 640
@@ -619,7 +643,6 @@ acpi_ut_get_node_name (
619 return (node->name.ascii); 643 return (node->name.ascii);
620} 644}
621 645
622
623/******************************************************************************* 646/*******************************************************************************
624 * 647 *
625 * FUNCTION: acpi_ut_get_descriptor_name 648 * FUNCTION: acpi_ut_get_descriptor_name
@@ -634,8 +657,7 @@ acpi_ut_get_node_name (
634 657
635/* Printable names of object descriptor types */ 658/* Printable names of object descriptor types */
636 659
637static const char *acpi_gbl_desc_type_names[] = 660static const char *acpi_gbl_desc_type_names[] = {
638{
639 /* 00 */ "Invalid", 661 /* 00 */ "Invalid",
640 /* 01 */ "Cached", 662 /* 01 */ "Cached",
641 /* 02 */ "State-Generic", 663 /* 02 */ "State-Generic",
@@ -654,27 +676,22 @@ static const char *acpi_gbl_desc_type_names[] =
654 /* 15 */ "Node" 676 /* 15 */ "Node"
655}; 677};
656 678
657 679char *acpi_ut_get_descriptor_name(void *object)
658char *
659acpi_ut_get_descriptor_name (
660 void *object)
661{ 680{
662 681
663 if (!object) 682 if (!object) {
664 {
665 return ("NULL OBJECT"); 683 return ("NULL OBJECT");
666 } 684 }
667 685
668 if (ACPI_GET_DESCRIPTOR_TYPE (object) > ACPI_DESC_TYPE_MAX) 686 if (ACPI_GET_DESCRIPTOR_TYPE(object) > ACPI_DESC_TYPE_MAX) {
669 { 687 return ((char *)acpi_gbl_bad_type);
670 return ((char *) acpi_gbl_bad_type);
671 } 688 }
672 689
673 return ((char *) acpi_gbl_desc_type_names[ACPI_GET_DESCRIPTOR_TYPE (object)]); 690 return ((char *)
691 acpi_gbl_desc_type_names[ACPI_GET_DESCRIPTOR_TYPE(object)]);
674 692
675} 693}
676 694
677
678#if defined(ACPI_DEBUG_OUTPUT) || defined(ACPI_DEBUGGER) 695#if defined(ACPI_DEBUG_OUTPUT) || defined(ACPI_DEBUGGER)
679/* 696/*
680 * Strings and procedures used for debug only 697 * Strings and procedures used for debug only
@@ -693,13 +710,10 @@ acpi_ut_get_descriptor_name (
693 * 710 *
694 ******************************************************************************/ 711 ******************************************************************************/
695 712
696char * 713char *acpi_ut_get_mutex_name(u32 mutex_id)
697acpi_ut_get_mutex_name (
698 u32 mutex_id)
699{ 714{
700 715
701 if (mutex_id > MAX_MUTEX) 716 if (mutex_id > MAX_MUTEX) {
702 {
703 return ("Invalid Mutex ID"); 717 return ("Invalid Mutex ID");
704 } 718 }
705 719
@@ -707,7 +721,6 @@ acpi_ut_get_mutex_name (
707} 721}
708#endif 722#endif
709 723
710
711/******************************************************************************* 724/*******************************************************************************
712 * 725 *
713 * FUNCTION: acpi_ut_valid_object_type 726 * FUNCTION: acpi_ut_valid_object_type
@@ -720,13 +733,10 @@ acpi_ut_get_mutex_name (
720 * 733 *
721 ******************************************************************************/ 734 ******************************************************************************/
722 735
723u8 736u8 acpi_ut_valid_object_type(acpi_object_type type)
724acpi_ut_valid_object_type (
725 acpi_object_type type)
726{ 737{
727 738
728 if (type > ACPI_TYPE_LOCAL_MAX) 739 if (type > ACPI_TYPE_LOCAL_MAX) {
729 {
730 /* Note: Assumes all TYPEs are contiguous (external/local) */ 740 /* Note: Assumes all TYPEs are contiguous (external/local) */
731 741
732 return (FALSE); 742 return (FALSE);
@@ -735,7 +745,6 @@ acpi_ut_valid_object_type (
735 return (TRUE); 745 return (TRUE);
736} 746}
737 747
738
739/******************************************************************************* 748/*******************************************************************************
740 * 749 *
741 * FUNCTION: acpi_ut_init_globals 750 * FUNCTION: acpi_ut_init_globals
@@ -749,106 +758,96 @@ acpi_ut_valid_object_type (
749 * 758 *
750 ******************************************************************************/ 759 ******************************************************************************/
751 760
752void 761void acpi_ut_init_globals(void)
753acpi_ut_init_globals (
754 void)
755{ 762{
756 acpi_status status; 763 acpi_status status;
757 u32 i; 764 u32 i;
758
759
760 ACPI_FUNCTION_TRACE ("ut_init_globals");
761 765
766 ACPI_FUNCTION_TRACE("ut_init_globals");
762 767
763 /* Create all memory caches */ 768 /* Create all memory caches */
764 769
765 status = acpi_ut_create_caches (); 770 status = acpi_ut_create_caches();
766 if (ACPI_FAILURE (status)) 771 if (ACPI_FAILURE(status)) {
767 {
768 return; 772 return;
769 } 773 }
770 774
771 /* ACPI table structure */ 775 /* ACPI table structure */
772 776
773 for (i = 0; i < NUM_ACPI_TABLE_TYPES; i++) 777 for (i = 0; i < NUM_ACPI_TABLE_TYPES; i++) {
774 { 778 acpi_gbl_table_lists[i].next = NULL;
775 acpi_gbl_table_lists[i].next = NULL; 779 acpi_gbl_table_lists[i].count = 0;
776 acpi_gbl_table_lists[i].count = 0;
777 } 780 }
778 781
779 /* Mutex locked flags */ 782 /* Mutex locked flags */
780 783
781 for (i = 0; i < NUM_MUTEX; i++) 784 for (i = 0; i < NUM_MUTEX; i++) {
782 { 785 acpi_gbl_mutex_info[i].mutex = NULL;
783 acpi_gbl_mutex_info[i].mutex = NULL; 786 acpi_gbl_mutex_info[i].thread_id = ACPI_MUTEX_NOT_ACQUIRED;
784 acpi_gbl_mutex_info[i].thread_id = ACPI_MUTEX_NOT_ACQUIRED; 787 acpi_gbl_mutex_info[i].use_count = 0;
785 acpi_gbl_mutex_info[i].use_count = 0;
786 } 788 }
787 789
788 /* GPE support */ 790 /* GPE support */
789 791
790 acpi_gbl_gpe_xrupt_list_head = NULL; 792 acpi_gbl_gpe_xrupt_list_head = NULL;
791 acpi_gbl_gpe_fadt_blocks[0] = NULL; 793 acpi_gbl_gpe_fadt_blocks[0] = NULL;
792 acpi_gbl_gpe_fadt_blocks[1] = NULL; 794 acpi_gbl_gpe_fadt_blocks[1] = NULL;
793 795
794 /* Global notify handlers */ 796 /* Global notify handlers */
795 797
796 acpi_gbl_system_notify.handler = NULL; 798 acpi_gbl_system_notify.handler = NULL;
797 acpi_gbl_device_notify.handler = NULL; 799 acpi_gbl_device_notify.handler = NULL;
798 acpi_gbl_exception_handler = NULL; 800 acpi_gbl_exception_handler = NULL;
799 acpi_gbl_init_handler = NULL; 801 acpi_gbl_init_handler = NULL;
800 802
801 /* Global "typed" ACPI table pointers */ 803 /* Global "typed" ACPI table pointers */
802 804
803 acpi_gbl_RSDP = NULL; 805 acpi_gbl_RSDP = NULL;
804 acpi_gbl_XSDT = NULL; 806 acpi_gbl_XSDT = NULL;
805 acpi_gbl_FACS = NULL; 807 acpi_gbl_FACS = NULL;
806 acpi_gbl_FADT = NULL; 808 acpi_gbl_FADT = NULL;
807 acpi_gbl_DSDT = NULL; 809 acpi_gbl_DSDT = NULL;
808 810
809 /* Global Lock support */ 811 /* Global Lock support */
810 812
811 acpi_gbl_global_lock_acquired = FALSE; 813 acpi_gbl_global_lock_acquired = FALSE;
812 acpi_gbl_global_lock_thread_count = 0; 814 acpi_gbl_global_lock_thread_count = 0;
813 acpi_gbl_global_lock_handle = 0; 815 acpi_gbl_global_lock_handle = 0;
814 816
815 /* Miscellaneous variables */ 817 /* Miscellaneous variables */
816 818
817 acpi_gbl_table_flags = ACPI_PHYSICAL_POINTER; 819 acpi_gbl_table_flags = ACPI_PHYSICAL_POINTER;
818 acpi_gbl_rsdp_original_location = 0; 820 acpi_gbl_rsdp_original_location = 0;
819 acpi_gbl_cm_single_step = FALSE; 821 acpi_gbl_cm_single_step = FALSE;
820 acpi_gbl_db_terminate_threads = FALSE; 822 acpi_gbl_db_terminate_threads = FALSE;
821 acpi_gbl_shutdown = FALSE; 823 acpi_gbl_shutdown = FALSE;
822 acpi_gbl_ns_lookup_count = 0; 824 acpi_gbl_ns_lookup_count = 0;
823 acpi_gbl_ps_find_count = 0; 825 acpi_gbl_ps_find_count = 0;
824 acpi_gbl_acpi_hardware_present = TRUE; 826 acpi_gbl_acpi_hardware_present = TRUE;
825 acpi_gbl_owner_id_mask = 0; 827 acpi_gbl_owner_id_mask = 0;
826 acpi_gbl_debugger_configuration = DEBUGGER_THREADING; 828 acpi_gbl_debugger_configuration = DEBUGGER_THREADING;
827 acpi_gbl_db_output_flags = ACPI_DB_CONSOLE_OUTPUT; 829 acpi_gbl_db_output_flags = ACPI_DB_CONSOLE_OUTPUT;
828 830
829 /* Hardware oriented */ 831 /* Hardware oriented */
830 832
831 acpi_gbl_events_initialized = FALSE; 833 acpi_gbl_events_initialized = FALSE;
832 acpi_gbl_system_awake_and_running = TRUE; 834 acpi_gbl_system_awake_and_running = TRUE;
833 835
834 /* Namespace */ 836 /* Namespace */
835 837
836 acpi_gbl_root_node = NULL; 838 acpi_gbl_root_node = NULL;
837 839
838 acpi_gbl_root_node_struct.name.integer = ACPI_ROOT_NAME; 840 acpi_gbl_root_node_struct.name.integer = ACPI_ROOT_NAME;
839 acpi_gbl_root_node_struct.descriptor = ACPI_DESC_TYPE_NAMED; 841 acpi_gbl_root_node_struct.descriptor = ACPI_DESC_TYPE_NAMED;
840 acpi_gbl_root_node_struct.type = ACPI_TYPE_DEVICE; 842 acpi_gbl_root_node_struct.type = ACPI_TYPE_DEVICE;
841 acpi_gbl_root_node_struct.child = NULL; 843 acpi_gbl_root_node_struct.child = NULL;
842 acpi_gbl_root_node_struct.peer = NULL; 844 acpi_gbl_root_node_struct.peer = NULL;
843 acpi_gbl_root_node_struct.object = NULL; 845 acpi_gbl_root_node_struct.object = NULL;
844 acpi_gbl_root_node_struct.flags = ANOBJ_END_OF_PEER_LIST; 846 acpi_gbl_root_node_struct.flags = ANOBJ_END_OF_PEER_LIST;
845
846 847
847#ifdef ACPI_DEBUG_OUTPUT 848#ifdef ACPI_DEBUG_OUTPUT
848 acpi_gbl_lowest_stack_pointer = ACPI_SIZE_MAX; 849 acpi_gbl_lowest_stack_pointer = ACPI_SIZE_MAX;
849#endif 850#endif
850 851
851 return_VOID; 852 return_VOID;
852} 853}
853
854
diff --git a/drivers/acpi/utilities/utinit.c b/drivers/acpi/utilities/utinit.c
index fd7ceba83229..9dde82b0beaf 100644
--- a/drivers/acpi/utilities/utinit.c
+++ b/drivers/acpi/utilities/utinit.c
@@ -41,25 +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#include <acpi/acevents.h> 46#include <acpi/acevents.h>
48 47
49#define _COMPONENT ACPI_UTILITIES 48#define _COMPONENT ACPI_UTILITIES
50 ACPI_MODULE_NAME ("utinit") 49ACPI_MODULE_NAME("utinit")
51 50
52/* Local prototypes */ 51/* Local prototypes */
53
54static void 52static void
55acpi_ut_fadt_register_error ( 53acpi_ut_fadt_register_error(char *register_name, u32 value, acpi_size offset);
56 char *register_name,
57 u32 value,
58 acpi_size offset);
59
60static void acpi_ut_terminate (
61 void);
62 54
55static void acpi_ut_terminate(void);
63 56
64/******************************************************************************* 57/*******************************************************************************
65 * 58 *
@@ -76,18 +69,14 @@ static void acpi_ut_terminate (
76 ******************************************************************************/ 69 ******************************************************************************/
77 70
78static void 71static void
79acpi_ut_fadt_register_error ( 72acpi_ut_fadt_register_error(char *register_name, u32 value, acpi_size offset)
80 char *register_name,
81 u32 value,
82 acpi_size offset)
83{ 73{
84 74
85 ACPI_REPORT_WARNING ( 75 ACPI_REPORT_WARNING(("Invalid FADT value %s=%X at offset %X FADT=%p\n",
86 ("Invalid FADT value %s=%X at offset %X FADT=%p\n", 76 register_name, value, (u32) offset,
87 register_name, value, (u32) offset, acpi_gbl_FADT)); 77 acpi_gbl_FADT));
88} 78}
89 79
90
91/****************************************************************************** 80/******************************************************************************
92 * 81 *
93 * FUNCTION: acpi_ut_validate_fadt 82 * FUNCTION: acpi_ut_validate_fadt
@@ -100,9 +89,7 @@ acpi_ut_fadt_register_error (
100 * 89 *
101 ******************************************************************************/ 90 ******************************************************************************/
102 91
103acpi_status 92acpi_status acpi_ut_validate_fadt(void)
104acpi_ut_validate_fadt (
105 void)
106{ 93{
107 94
108 /* 95 /*
@@ -110,64 +97,66 @@ acpi_ut_validate_fadt (
110 * but don't abort on any problems, just display error 97 * but don't abort on any problems, just display error
111 */ 98 */
112 if (acpi_gbl_FADT->pm1_evt_len < 4) { 99 if (acpi_gbl_FADT->pm1_evt_len < 4) {
113 acpi_ut_fadt_register_error ("PM1_EVT_LEN", 100 acpi_ut_fadt_register_error("PM1_EVT_LEN",
114 (u32) acpi_gbl_FADT->pm1_evt_len, 101 (u32) acpi_gbl_FADT->pm1_evt_len,
115 ACPI_FADT_OFFSET (pm1_evt_len)); 102 ACPI_FADT_OFFSET(pm1_evt_len));
116 } 103 }
117 104
118 if (!acpi_gbl_FADT->pm1_cnt_len) { 105 if (!acpi_gbl_FADT->pm1_cnt_len) {
119 acpi_ut_fadt_register_error ("PM1_CNT_LEN", 0, 106 acpi_ut_fadt_register_error("PM1_CNT_LEN", 0,
120 ACPI_FADT_OFFSET (pm1_cnt_len)); 107 ACPI_FADT_OFFSET(pm1_cnt_len));
121 } 108 }
122 109
123 if (!acpi_gbl_FADT->xpm1a_evt_blk.address) { 110 if (!acpi_gbl_FADT->xpm1a_evt_blk.address) {
124 acpi_ut_fadt_register_error ("X_PM1a_EVT_BLK", 0, 111 acpi_ut_fadt_register_error("X_PM1a_EVT_BLK", 0,
125 ACPI_FADT_OFFSET (xpm1a_evt_blk.address)); 112 ACPI_FADT_OFFSET(xpm1a_evt_blk.
113 address));
126 } 114 }
127 115
128 if (!acpi_gbl_FADT->xpm1a_cnt_blk.address) { 116 if (!acpi_gbl_FADT->xpm1a_cnt_blk.address) {
129 acpi_ut_fadt_register_error ("X_PM1a_CNT_BLK", 0, 117 acpi_ut_fadt_register_error("X_PM1a_CNT_BLK", 0,
130 ACPI_FADT_OFFSET (xpm1a_cnt_blk.address)); 118 ACPI_FADT_OFFSET(xpm1a_cnt_blk.
119 address));
131 } 120 }
132 121
133 if (!acpi_gbl_FADT->xpm_tmr_blk.address) { 122 if (!acpi_gbl_FADT->xpm_tmr_blk.address) {
134 acpi_ut_fadt_register_error ("X_PM_TMR_BLK", 0, 123 acpi_ut_fadt_register_error("X_PM_TMR_BLK", 0,
135 ACPI_FADT_OFFSET (xpm_tmr_blk.address)); 124 ACPI_FADT_OFFSET(xpm_tmr_blk.
125 address));
136 } 126 }
137 127
138 if ((acpi_gbl_FADT->xpm2_cnt_blk.address && 128 if ((acpi_gbl_FADT->xpm2_cnt_blk.address &&
139 !acpi_gbl_FADT->pm2_cnt_len)) { 129 !acpi_gbl_FADT->pm2_cnt_len)) {
140 acpi_ut_fadt_register_error ("PM2_CNT_LEN", 130 acpi_ut_fadt_register_error("PM2_CNT_LEN",
141 (u32) acpi_gbl_FADT->pm2_cnt_len, 131 (u32) acpi_gbl_FADT->pm2_cnt_len,
142 ACPI_FADT_OFFSET (pm2_cnt_len)); 132 ACPI_FADT_OFFSET(pm2_cnt_len));
143 } 133 }
144 134
145 if (acpi_gbl_FADT->pm_tm_len < 4) { 135 if (acpi_gbl_FADT->pm_tm_len < 4) {
146 acpi_ut_fadt_register_error ("PM_TM_LEN", 136 acpi_ut_fadt_register_error("PM_TM_LEN",
147 (u32) acpi_gbl_FADT->pm_tm_len, 137 (u32) acpi_gbl_FADT->pm_tm_len,
148 ACPI_FADT_OFFSET (pm_tm_len)); 138 ACPI_FADT_OFFSET(pm_tm_len));
149 } 139 }
150 140
151 /* Length of GPE blocks must be a multiple of 2 */ 141 /* Length of GPE blocks must be a multiple of 2 */
152 142
153 if (acpi_gbl_FADT->xgpe0_blk.address && 143 if (acpi_gbl_FADT->xgpe0_blk.address &&
154 (acpi_gbl_FADT->gpe0_blk_len & 1)) { 144 (acpi_gbl_FADT->gpe0_blk_len & 1)) {
155 acpi_ut_fadt_register_error ("(x)GPE0_BLK_LEN", 145 acpi_ut_fadt_register_error("(x)GPE0_BLK_LEN",
156 (u32) acpi_gbl_FADT->gpe0_blk_len, 146 (u32) acpi_gbl_FADT->gpe0_blk_len,
157 ACPI_FADT_OFFSET (gpe0_blk_len)); 147 ACPI_FADT_OFFSET(gpe0_blk_len));
158 } 148 }
159 149
160 if (acpi_gbl_FADT->xgpe1_blk.address && 150 if (acpi_gbl_FADT->xgpe1_blk.address &&
161 (acpi_gbl_FADT->gpe1_blk_len & 1)) { 151 (acpi_gbl_FADT->gpe1_blk_len & 1)) {
162 acpi_ut_fadt_register_error ("(x)GPE1_BLK_LEN", 152 acpi_ut_fadt_register_error("(x)GPE1_BLK_LEN",
163 (u32) acpi_gbl_FADT->gpe1_blk_len, 153 (u32) acpi_gbl_FADT->gpe1_blk_len,
164 ACPI_FADT_OFFSET (gpe1_blk_len)); 154 ACPI_FADT_OFFSET(gpe1_blk_len));
165 } 155 }
166 156
167 return (AE_OK); 157 return (AE_OK);
168} 158}
169 159
170
171/****************************************************************************** 160/******************************************************************************
172 * 161 *
173 * FUNCTION: acpi_ut_terminate 162 * FUNCTION: acpi_ut_terminate
@@ -180,18 +169,14 @@ acpi_ut_validate_fadt (
180 * 169 *
181 ******************************************************************************/ 170 ******************************************************************************/
182 171
183static void 172static void acpi_ut_terminate(void)
184acpi_ut_terminate (
185 void)
186{ 173{
187 struct acpi_gpe_block_info *gpe_block; 174 struct acpi_gpe_block_info *gpe_block;
188 struct acpi_gpe_block_info *next_gpe_block; 175 struct acpi_gpe_block_info *next_gpe_block;
189 struct acpi_gpe_xrupt_info *gpe_xrupt_info; 176 struct acpi_gpe_xrupt_info *gpe_xrupt_info;
190 struct acpi_gpe_xrupt_info *next_gpe_xrupt_info; 177 struct acpi_gpe_xrupt_info *next_gpe_xrupt_info;
191
192
193 ACPI_FUNCTION_TRACE ("ut_terminate");
194 178
179 ACPI_FUNCTION_TRACE("ut_terminate");
195 180
196 /* Free global tables, etc. */ 181 /* Free global tables, etc. */
197 /* Free global GPE blocks and related info structures */ 182 /* Free global GPE blocks and related info structures */
@@ -201,21 +186,20 @@ acpi_ut_terminate (
201 gpe_block = gpe_xrupt_info->gpe_block_list_head; 186 gpe_block = gpe_xrupt_info->gpe_block_list_head;
202 while (gpe_block) { 187 while (gpe_block) {
203 next_gpe_block = gpe_block->next; 188 next_gpe_block = gpe_block->next;
204 ACPI_MEM_FREE (gpe_block->event_info); 189 ACPI_MEM_FREE(gpe_block->event_info);
205 ACPI_MEM_FREE (gpe_block->register_info); 190 ACPI_MEM_FREE(gpe_block->register_info);
206 ACPI_MEM_FREE (gpe_block); 191 ACPI_MEM_FREE(gpe_block);
207 192
208 gpe_block = next_gpe_block; 193 gpe_block = next_gpe_block;
209 } 194 }
210 next_gpe_xrupt_info = gpe_xrupt_info->next; 195 next_gpe_xrupt_info = gpe_xrupt_info->next;
211 ACPI_MEM_FREE (gpe_xrupt_info); 196 ACPI_MEM_FREE(gpe_xrupt_info);
212 gpe_xrupt_info = next_gpe_xrupt_info; 197 gpe_xrupt_info = next_gpe_xrupt_info;
213 } 198 }
214 199
215 return_VOID; 200 return_VOID;
216} 201}
217 202
218
219/******************************************************************************* 203/*******************************************************************************
220 * 204 *
221 * FUNCTION: acpi_ut_subsystem_shutdown 205 * FUNCTION: acpi_ut_subsystem_shutdown
@@ -229,50 +213,45 @@ acpi_ut_terminate (
229 * 213 *
230 ******************************************************************************/ 214 ******************************************************************************/
231 215
232void 216void acpi_ut_subsystem_shutdown(void)
233acpi_ut_subsystem_shutdown (
234 void)
235{ 217{
236 218
237 ACPI_FUNCTION_TRACE ("ut_subsystem_shutdown"); 219 ACPI_FUNCTION_TRACE("ut_subsystem_shutdown");
238 220
239 /* Just exit if subsystem is already shutdown */ 221 /* Just exit if subsystem is already shutdown */
240 222
241 if (acpi_gbl_shutdown) { 223 if (acpi_gbl_shutdown) {
242 ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, 224 ACPI_DEBUG_PRINT((ACPI_DB_ERROR,
243 "ACPI Subsystem is already terminated\n")); 225 "ACPI Subsystem is already terminated\n"));
244 return_VOID; 226 return_VOID;
245 } 227 }
246 228
247 /* Subsystem appears active, go ahead and shut it down */ 229 /* Subsystem appears active, go ahead and shut it down */
248 230
249 acpi_gbl_shutdown = TRUE; 231 acpi_gbl_shutdown = TRUE;
250 ACPI_DEBUG_PRINT ((ACPI_DB_INFO, 232 ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Shutting down ACPI Subsystem...\n"));
251 "Shutting down ACPI Subsystem...\n"));
252 233
253 /* Close the acpi_event Handling */ 234 /* Close the acpi_event Handling */
254 235
255 acpi_ev_terminate (); 236 acpi_ev_terminate();
256 237
257 /* Close the Namespace */ 238 /* Close the Namespace */
258 239
259 acpi_ns_terminate (); 240 acpi_ns_terminate();
260 241
261 /* Close the globals */ 242 /* Close the globals */
262 243
263 acpi_ut_terminate (); 244 acpi_ut_terminate();
264 245
265 /* Purge the local caches */ 246 /* Purge the local caches */
266 247
267 (void) acpi_ut_delete_caches (); 248 (void)acpi_ut_delete_caches();
268 249
269 /* Debug only - display leftover memory allocation, if any */ 250 /* Debug only - display leftover memory allocation, if any */
270 251
271#ifdef ACPI_DBG_TRACK_ALLOCATIONS 252#ifdef ACPI_DBG_TRACK_ALLOCATIONS
272 acpi_ut_dump_allocations (ACPI_UINT32_MAX, NULL); 253 acpi_ut_dump_allocations(ACPI_UINT32_MAX, NULL);
273#endif 254#endif
274 255
275 return_VOID; 256 return_VOID;
276} 257}
277
278
diff --git a/drivers/acpi/utilities/utmath.c b/drivers/acpi/utilities/utmath.c
index 0d527c91543c..68a0a6f94129 100644
--- a/drivers/acpi/utilities/utmath.c
+++ b/drivers/acpi/utilities/utmath.c
@@ -41,19 +41,16 @@
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#define _COMPONENT ACPI_UTILITIES 46#define _COMPONENT ACPI_UTILITIES
49 ACPI_MODULE_NAME ("utmath") 47ACPI_MODULE_NAME("utmath")
50 48
51/* 49/*
52 * Support for double-precision integer divide. This code is included here 50 * Support for double-precision integer divide. This code is included here
53 * in order to support kernel environments where the double-precision math 51 * in order to support kernel environments where the double-precision math
54 * library is not available. 52 * library is not available.
55 */ 53 */
56
57#ifndef ACPI_USE_NATIVE_DIVIDE 54#ifndef ACPI_USE_NATIVE_DIVIDE
58/******************************************************************************* 55/*******************************************************************************
59 * 56 *
@@ -71,27 +68,22 @@
71 * 32-bit remainder. 68 * 32-bit remainder.
72 * 69 *
73 ******************************************************************************/ 70 ******************************************************************************/
74
75acpi_status 71acpi_status
76acpi_ut_short_divide ( 72acpi_ut_short_divide(acpi_integer dividend,
77 acpi_integer dividend, 73 u32 divisor,
78 u32 divisor, 74 acpi_integer * out_quotient, u32 * out_remainder)
79 acpi_integer *out_quotient,
80 u32 *out_remainder)
81{ 75{
82 union uint64_overlay dividend_ovl; 76 union uint64_overlay dividend_ovl;
83 union uint64_overlay quotient; 77 union uint64_overlay quotient;
84 u32 remainder32; 78 u32 remainder32;
85
86
87 ACPI_FUNCTION_TRACE ("ut_short_divide");
88 79
80 ACPI_FUNCTION_TRACE("ut_short_divide");
89 81
90 /* Always check for a zero divisor */ 82 /* Always check for a zero divisor */
91 83
92 if (divisor == 0) { 84 if (divisor == 0) {
93 ACPI_REPORT_ERROR (("acpi_ut_short_divide: Divide by zero\n")); 85 ACPI_REPORT_ERROR(("acpi_ut_short_divide: Divide by zero\n"));
94 return_ACPI_STATUS (AE_AML_DIVIDE_BY_ZERO); 86 return_ACPI_STATUS(AE_AML_DIVIDE_BY_ZERO);
95 } 87 }
96 88
97 dividend_ovl.full = dividend; 89 dividend_ovl.full = dividend;
@@ -100,9 +92,9 @@ acpi_ut_short_divide (
100 * The quotient is 64 bits, the remainder is always 32 bits, 92 * The quotient is 64 bits, the remainder is always 32 bits,
101 * and is generated by the second divide. 93 * and is generated by the second divide.
102 */ 94 */
103 ACPI_DIV_64_BY_32 (0, dividend_ovl.part.hi, divisor, 95 ACPI_DIV_64_BY_32(0, dividend_ovl.part.hi, divisor,
104 quotient.part.hi, remainder32); 96 quotient.part.hi, remainder32);
105 ACPI_DIV_64_BY_32 (remainder32, dividend_ovl.part.lo, divisor, 97 ACPI_DIV_64_BY_32(remainder32, dividend_ovl.part.lo, divisor,
106 quotient.part.lo, remainder32); 98 quotient.part.lo, remainder32);
107 99
108 /* Return only what was requested */ 100 /* Return only what was requested */
@@ -114,10 +106,9 @@ acpi_ut_short_divide (
114 *out_remainder = remainder32; 106 *out_remainder = remainder32;
115 } 107 }
116 108
117 return_ACPI_STATUS (AE_OK); 109 return_ACPI_STATUS(AE_OK);
118} 110}
119 111
120
121/******************************************************************************* 112/*******************************************************************************
122 * 113 *
123 * FUNCTION: acpi_ut_divide 114 * FUNCTION: acpi_ut_divide
@@ -134,34 +125,30 @@ acpi_ut_short_divide (
134 ******************************************************************************/ 125 ******************************************************************************/
135 126
136acpi_status 127acpi_status
137acpi_ut_divide ( 128acpi_ut_divide(acpi_integer in_dividend,
138 acpi_integer in_dividend, 129 acpi_integer in_divisor,
139 acpi_integer in_divisor, 130 acpi_integer * out_quotient, acpi_integer * out_remainder)
140 acpi_integer *out_quotient,
141 acpi_integer *out_remainder)
142{ 131{
143 union uint64_overlay dividend; 132 union uint64_overlay dividend;
144 union uint64_overlay divisor; 133 union uint64_overlay divisor;
145 union uint64_overlay quotient; 134 union uint64_overlay quotient;
146 union uint64_overlay remainder; 135 union uint64_overlay remainder;
147 union uint64_overlay normalized_dividend; 136 union uint64_overlay normalized_dividend;
148 union uint64_overlay normalized_divisor; 137 union uint64_overlay normalized_divisor;
149 u32 partial1; 138 u32 partial1;
150 union uint64_overlay partial2; 139 union uint64_overlay partial2;
151 union uint64_overlay partial3; 140 union uint64_overlay partial3;
152 141
153 142 ACPI_FUNCTION_TRACE("ut_divide");
154 ACPI_FUNCTION_TRACE ("ut_divide");
155
156 143
157 /* Always check for a zero divisor */ 144 /* Always check for a zero divisor */
158 145
159 if (in_divisor == 0) { 146 if (in_divisor == 0) {
160 ACPI_REPORT_ERROR (("acpi_ut_divide: Divide by zero\n")); 147 ACPI_REPORT_ERROR(("acpi_ut_divide: Divide by zero\n"));
161 return_ACPI_STATUS (AE_AML_DIVIDE_BY_ZERO); 148 return_ACPI_STATUS(AE_AML_DIVIDE_BY_ZERO);
162 } 149 }
163 150
164 divisor.full = in_divisor; 151 divisor.full = in_divisor;
165 dividend.full = in_dividend; 152 dividend.full = in_dividend;
166 if (divisor.part.hi == 0) { 153 if (divisor.part.hi == 0) {
167 /* 154 /*
@@ -174,9 +161,9 @@ acpi_ut_divide (
174 * The quotient is 64 bits, the remainder is always 32 bits, 161 * The quotient is 64 bits, the remainder is always 32 bits,
175 * and is generated by the second divide. 162 * and is generated by the second divide.
176 */ 163 */
177 ACPI_DIV_64_BY_32 (0, dividend.part.hi, divisor.part.lo, 164 ACPI_DIV_64_BY_32(0, dividend.part.hi, divisor.part.lo,
178 quotient.part.hi, partial1); 165 quotient.part.hi, partial1);
179 ACPI_DIV_64_BY_32 (partial1, dividend.part.lo, divisor.part.lo, 166 ACPI_DIV_64_BY_32(partial1, dividend.part.lo, divisor.part.lo,
180 quotient.part.lo, remainder.part.lo); 167 quotient.part.lo, remainder.part.lo);
181 } 168 }
182 169
@@ -185,23 +172,23 @@ acpi_ut_divide (
185 * 2) The general case where the divisor is a full 64 bits 172 * 2) The general case where the divisor is a full 64 bits
186 * is more difficult 173 * is more difficult
187 */ 174 */
188 quotient.part.hi = 0; 175 quotient.part.hi = 0;
189 normalized_dividend = dividend; 176 normalized_dividend = dividend;
190 normalized_divisor = divisor; 177 normalized_divisor = divisor;
191 178
192 /* Normalize the operands (shift until the divisor is < 32 bits) */ 179 /* Normalize the operands (shift until the divisor is < 32 bits) */
193 180
194 do { 181 do {
195 ACPI_SHIFT_RIGHT_64 (normalized_divisor.part.hi, 182 ACPI_SHIFT_RIGHT_64(normalized_divisor.part.hi,
196 normalized_divisor.part.lo); 183 normalized_divisor.part.lo);
197 ACPI_SHIFT_RIGHT_64 (normalized_dividend.part.hi, 184 ACPI_SHIFT_RIGHT_64(normalized_dividend.part.hi,
198 normalized_dividend.part.lo); 185 normalized_dividend.part.lo);
199 186
200 } while (normalized_divisor.part.hi != 0); 187 } while (normalized_divisor.part.hi != 0);
201 188
202 /* Partial divide */ 189 /* Partial divide */
203 190
204 ACPI_DIV_64_BY_32 (normalized_dividend.part.hi, 191 ACPI_DIV_64_BY_32(normalized_dividend.part.hi,
205 normalized_dividend.part.lo, 192 normalized_dividend.part.lo,
206 normalized_divisor.part.lo, 193 normalized_divisor.part.lo,
207 quotient.part.lo, partial1); 194 quotient.part.lo, partial1);
@@ -210,8 +197,9 @@ acpi_ut_divide (
210 * The quotient is always 32 bits, and simply requires adjustment. 197 * The quotient is always 32 bits, and simply requires adjustment.
211 * The 64-bit remainder must be generated. 198 * The 64-bit remainder must be generated.
212 */ 199 */
213 partial1 = quotient.part.lo * divisor.part.hi; 200 partial1 = quotient.part.lo * divisor.part.hi;
214 partial2.full = (acpi_integer) quotient.part.lo * divisor.part.lo; 201 partial2.full =
202 (acpi_integer) quotient.part.lo * divisor.part.lo;
215 partial3.full = (acpi_integer) partial2.part.hi + partial1; 203 partial3.full = (acpi_integer) partial2.part.hi + partial1;
216 204
217 remainder.part.hi = partial3.part.lo; 205 remainder.part.hi = partial3.part.lo;
@@ -224,16 +212,15 @@ acpi_ut_divide (
224 quotient.part.lo--; 212 quotient.part.lo--;
225 remainder.full -= divisor.full; 213 remainder.full -= divisor.full;
226 } 214 }
227 } 215 } else {
228 else {
229 quotient.part.lo--; 216 quotient.part.lo--;
230 remainder.full -= divisor.full; 217 remainder.full -= divisor.full;
231 } 218 }
232 } 219 }
233 220
234 remainder.full = remainder.full - dividend.full; 221 remainder.full = remainder.full - dividend.full;
235 remainder.part.hi = (u32) -((s32) remainder.part.hi); 222 remainder.part.hi = (u32) - ((s32) remainder.part.hi);
236 remainder.part.lo = (u32) -((s32) remainder.part.lo); 223 remainder.part.lo = (u32) - ((s32) remainder.part.lo);
237 224
238 if (remainder.part.lo) { 225 if (remainder.part.lo) {
239 remainder.part.hi--; 226 remainder.part.hi--;
@@ -250,11 +237,10 @@ acpi_ut_divide (
250 *out_remainder = remainder.full; 237 *out_remainder = remainder.full;
251 } 238 }
252 239
253 return_ACPI_STATUS (AE_OK); 240 return_ACPI_STATUS(AE_OK);
254} 241}
255 242
256#else 243#else
257
258/******************************************************************************* 244/*******************************************************************************
259 * 245 *
260 * FUNCTION: acpi_ut_short_divide, acpi_ut_divide 246 * FUNCTION: acpi_ut_short_divide, acpi_ut_divide
@@ -269,23 +255,19 @@ acpi_ut_divide (
269 * perform the divide. 255 * perform the divide.
270 * 256 *
271 ******************************************************************************/ 257 ******************************************************************************/
272
273acpi_status 258acpi_status
274acpi_ut_short_divide ( 259acpi_ut_short_divide(acpi_integer in_dividend,
275 acpi_integer in_dividend, 260 u32 divisor,
276 u32 divisor, 261 acpi_integer * out_quotient, u32 * out_remainder)
277 acpi_integer *out_quotient,
278 u32 *out_remainder)
279{ 262{
280 263
281 ACPI_FUNCTION_TRACE ("ut_short_divide"); 264 ACPI_FUNCTION_TRACE("ut_short_divide");
282
283 265
284 /* Always check for a zero divisor */ 266 /* Always check for a zero divisor */
285 267
286 if (divisor == 0) { 268 if (divisor == 0) {
287 ACPI_REPORT_ERROR (("acpi_ut_short_divide: Divide by zero\n")); 269 ACPI_REPORT_ERROR(("acpi_ut_short_divide: Divide by zero\n"));
288 return_ACPI_STATUS (AE_AML_DIVIDE_BY_ZERO); 270 return_ACPI_STATUS(AE_AML_DIVIDE_BY_ZERO);
289 } 271 }
290 272
291 /* Return only what was requested */ 273 /* Return only what was requested */
@@ -297,27 +279,23 @@ acpi_ut_short_divide (
297 *out_remainder = (u32) in_dividend % divisor; 279 *out_remainder = (u32) in_dividend % divisor;
298 } 280 }
299 281
300 return_ACPI_STATUS (AE_OK); 282 return_ACPI_STATUS(AE_OK);
301} 283}
302 284
303acpi_status 285acpi_status
304acpi_ut_divide ( 286acpi_ut_divide(acpi_integer in_dividend,
305 acpi_integer in_dividend, 287 acpi_integer in_divisor,
306 acpi_integer in_divisor, 288 acpi_integer * out_quotient, acpi_integer * out_remainder)
307 acpi_integer *out_quotient,
308 acpi_integer *out_remainder)
309{ 289{
310 ACPI_FUNCTION_TRACE ("ut_divide"); 290 ACPI_FUNCTION_TRACE("ut_divide");
311
312 291
313 /* Always check for a zero divisor */ 292 /* Always check for a zero divisor */
314 293
315 if (in_divisor == 0) { 294 if (in_divisor == 0) {
316 ACPI_REPORT_ERROR (("acpi_ut_divide: Divide by zero\n")); 295 ACPI_REPORT_ERROR(("acpi_ut_divide: Divide by zero\n"));
317 return_ACPI_STATUS (AE_AML_DIVIDE_BY_ZERO); 296 return_ACPI_STATUS(AE_AML_DIVIDE_BY_ZERO);
318 } 297 }
319 298
320
321 /* Return only what was requested */ 299 /* Return only what was requested */
322 300
323 if (out_quotient) { 301 if (out_quotient) {
@@ -327,9 +305,7 @@ acpi_ut_divide (
327 *out_remainder = in_dividend % in_divisor; 305 *out_remainder = in_dividend % in_divisor;
328 } 306 }
329 307
330 return_ACPI_STATUS (AE_OK); 308 return_ACPI_STATUS(AE_OK);
331} 309}
332 310
333#endif 311#endif
334
335
diff --git a/drivers/acpi/utilities/utmisc.c b/drivers/acpi/utilities/utmisc.c
index 1d350b302a34..474fe7cb6c09 100644
--- a/drivers/acpi/utilities/utmisc.c
+++ b/drivers/acpi/utilities/utmisc.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_UTILITIES 47#define _COMPONENT ACPI_UTILITIES
50 ACPI_MODULE_NAME ("utmisc") 48ACPI_MODULE_NAME("utmisc")
51
52 49
53/******************************************************************************* 50/*******************************************************************************
54 * 51 *
@@ -63,23 +60,18 @@
63 * when the method exits or the table is unloaded. 60 * when the method exits or the table is unloaded.
64 * 61 *
65 ******************************************************************************/ 62 ******************************************************************************/
66 63acpi_status acpi_ut_allocate_owner_id(acpi_owner_id * owner_id)
67acpi_status
68acpi_ut_allocate_owner_id (
69 acpi_owner_id *owner_id)
70{ 64{
71 acpi_native_uint i; 65 acpi_native_uint i;
72 acpi_status status; 66 acpi_status status;
73
74
75 ACPI_FUNCTION_TRACE ("ut_allocate_owner_id");
76 67
68 ACPI_FUNCTION_TRACE("ut_allocate_owner_id");
77 69
78 /* Mutex for the global ID mask */ 70 /* Mutex for the global ID mask */
79 71
80 status = acpi_ut_acquire_mutex (ACPI_MTX_CACHES); 72 status = acpi_ut_acquire_mutex(ACPI_MTX_CACHES);
81 if (ACPI_FAILURE (status)) { 73 if (ACPI_FAILURE(status)) {
82 return_ACPI_STATUS (status); 74 return_ACPI_STATUS(status);
83 } 75 }
84 76
85 /* Find a free owner ID */ 77 /* Find a free owner ID */
@@ -101,15 +93,13 @@ acpi_ut_allocate_owner_id (
101 */ 93 */
102 *owner_id = 0; 94 *owner_id = 0;
103 status = AE_OWNER_ID_LIMIT; 95 status = AE_OWNER_ID_LIMIT;
104 ACPI_REPORT_ERROR (( 96 ACPI_REPORT_ERROR(("Could not allocate new owner_id (32 max), AE_OWNER_ID_LIMIT\n"));
105 "Could not allocate new owner_id (32 max), AE_OWNER_ID_LIMIT\n"));
106 97
107exit: 98 exit:
108 (void) acpi_ut_release_mutex (ACPI_MTX_CACHES); 99 (void)acpi_ut_release_mutex(ACPI_MTX_CACHES);
109 return_ACPI_STATUS (status); 100 return_ACPI_STATUS(status);
110} 101}
111 102
112
113/******************************************************************************* 103/*******************************************************************************
114 * 104 *
115 * FUNCTION: acpi_ut_release_owner_id 105 * FUNCTION: acpi_ut_release_owner_id
@@ -124,16 +114,12 @@ exit:
124 * 114 *
125 ******************************************************************************/ 115 ******************************************************************************/
126 116
127void 117void acpi_ut_release_owner_id(acpi_owner_id * owner_id_ptr)
128acpi_ut_release_owner_id (
129 acpi_owner_id *owner_id_ptr)
130{ 118{
131 acpi_owner_id owner_id = *owner_id_ptr; 119 acpi_owner_id owner_id = *owner_id_ptr;
132 acpi_status status; 120 acpi_status status;
133
134
135 ACPI_FUNCTION_TRACE ("ut_release_owner_id");
136 121
122 ACPI_FUNCTION_TRACE("ut_release_owner_id");
137 123
138 /* Always clear the input owner_id (zero is an invalid ID) */ 124 /* Always clear the input owner_id (zero is an invalid ID) */
139 125
@@ -142,18 +128,18 @@ acpi_ut_release_owner_id (
142 /* Zero is not a valid owner_iD */ 128 /* Zero is not a valid owner_iD */
143 129
144 if ((owner_id == 0) || (owner_id > 32)) { 130 if ((owner_id == 0) || (owner_id > 32)) {
145 ACPI_REPORT_ERROR (("Invalid owner_id: %2.2X\n", owner_id)); 131 ACPI_REPORT_ERROR(("Invalid owner_id: %2.2X\n", owner_id));
146 return_VOID; 132 return_VOID;
147 } 133 }
148 134
149 /* Mutex for the global ID mask */ 135 /* Mutex for the global ID mask */
150 136
151 status = acpi_ut_acquire_mutex (ACPI_MTX_CACHES); 137 status = acpi_ut_acquire_mutex(ACPI_MTX_CACHES);
152 if (ACPI_FAILURE (status)) { 138 if (ACPI_FAILURE(status)) {
153 return_VOID; 139 return_VOID;
154 } 140 }
155 141
156 owner_id--; /* Normalize to zero */ 142 owner_id--; /* Normalize to zero */
157 143
158 /* Free the owner ID only if it is valid */ 144 /* Free the owner ID only if it is valid */
159 145
@@ -161,11 +147,10 @@ acpi_ut_release_owner_id (
161 acpi_gbl_owner_id_mask ^= (1 << owner_id); 147 acpi_gbl_owner_id_mask ^= (1 << owner_id);
162 } 148 }
163 149
164 (void) acpi_ut_release_mutex (ACPI_MTX_CACHES); 150 (void)acpi_ut_release_mutex(ACPI_MTX_CACHES);
165 return_VOID; 151 return_VOID;
166} 152}
167 153
168
169/******************************************************************************* 154/*******************************************************************************
170 * 155 *
171 * FUNCTION: acpi_ut_strupr (strupr) 156 * FUNCTION: acpi_ut_strupr (strupr)
@@ -180,15 +165,11 @@ acpi_ut_release_owner_id (
180 * 165 *
181 ******************************************************************************/ 166 ******************************************************************************/
182 167
183void 168void acpi_ut_strupr(char *src_string)
184acpi_ut_strupr (
185 char *src_string)
186{ 169{
187 char *string; 170 char *string;
188
189
190 ACPI_FUNCTION_ENTRY ();
191 171
172 ACPI_FUNCTION_ENTRY();
192 173
193 if (!src_string) { 174 if (!src_string) {
194 return; 175 return;
@@ -197,13 +178,12 @@ acpi_ut_strupr (
197 /* Walk entire string, uppercasing the letters */ 178 /* Walk entire string, uppercasing the letters */
198 179
199 for (string = src_string; *string; string++) { 180 for (string = src_string; *string; string++) {
200 *string = (char) ACPI_TOUPPER (*string); 181 *string = (char)ACPI_TOUPPER(*string);
201 } 182 }
202 183
203 return; 184 return;
204} 185}
205 186
206
207/******************************************************************************* 187/*******************************************************************************
208 * 188 *
209 * FUNCTION: acpi_ut_print_string 189 * FUNCTION: acpi_ut_print_string
@@ -218,85 +198,77 @@ acpi_ut_strupr (
218 * 198 *
219 ******************************************************************************/ 199 ******************************************************************************/
220 200
221void 201void acpi_ut_print_string(char *string, u8 max_length)
222acpi_ut_print_string (
223 char *string,
224 u8 max_length)
225{ 202{
226 u32 i; 203 u32 i;
227
228 204
229 if (!string) { 205 if (!string) {
230 acpi_os_printf ("<\"NULL STRING PTR\">"); 206 acpi_os_printf("<\"NULL STRING PTR\">");
231 return; 207 return;
232 } 208 }
233 209
234 acpi_os_printf ("\""); 210 acpi_os_printf("\"");
235 for (i = 0; string[i] && (i < max_length); i++) { 211 for (i = 0; string[i] && (i < max_length); i++) {
236 /* Escape sequences */ 212 /* Escape sequences */
237 213
238 switch (string[i]) { 214 switch (string[i]) {
239 case 0x07: 215 case 0x07:
240 acpi_os_printf ("\\a"); /* BELL */ 216 acpi_os_printf("\\a"); /* BELL */
241 break; 217 break;
242 218
243 case 0x08: 219 case 0x08:
244 acpi_os_printf ("\\b"); /* BACKSPACE */ 220 acpi_os_printf("\\b"); /* BACKSPACE */
245 break; 221 break;
246 222
247 case 0x0C: 223 case 0x0C:
248 acpi_os_printf ("\\f"); /* FORMFEED */ 224 acpi_os_printf("\\f"); /* FORMFEED */
249 break; 225 break;
250 226
251 case 0x0A: 227 case 0x0A:
252 acpi_os_printf ("\\n"); /* LINEFEED */ 228 acpi_os_printf("\\n"); /* LINEFEED */
253 break; 229 break;
254 230
255 case 0x0D: 231 case 0x0D:
256 acpi_os_printf ("\\r"); /* CARRIAGE RETURN*/ 232 acpi_os_printf("\\r"); /* CARRIAGE RETURN */
257 break; 233 break;
258 234
259 case 0x09: 235 case 0x09:
260 acpi_os_printf ("\\t"); /* HORIZONTAL TAB */ 236 acpi_os_printf("\\t"); /* HORIZONTAL TAB */
261 break; 237 break;
262 238
263 case 0x0B: 239 case 0x0B:
264 acpi_os_printf ("\\v"); /* VERTICAL TAB */ 240 acpi_os_printf("\\v"); /* VERTICAL TAB */
265 break; 241 break;
266 242
267 case '\'': /* Single Quote */ 243 case '\'': /* Single Quote */
268 case '\"': /* Double Quote */ 244 case '\"': /* Double Quote */
269 case '\\': /* Backslash */ 245 case '\\': /* Backslash */
270 acpi_os_printf ("\\%c", (int) string[i]); 246 acpi_os_printf("\\%c", (int)string[i]);
271 break; 247 break;
272 248
273 default: 249 default:
274 250
275 /* Check for printable character or hex escape */ 251 /* Check for printable character or hex escape */
276 252
277 if (ACPI_IS_PRINT (string[i])) 253 if (ACPI_IS_PRINT(string[i])) {
278 {
279 /* This is a normal character */ 254 /* This is a normal character */
280 255
281 acpi_os_printf ("%c", (int) string[i]); 256 acpi_os_printf("%c", (int)string[i]);
282 } 257 } else {
283 else
284 {
285 /* All others will be Hex escapes */ 258 /* All others will be Hex escapes */
286 259
287 acpi_os_printf ("\\x%2.2X", (s32) string[i]); 260 acpi_os_printf("\\x%2.2X", (s32) string[i]);
288 } 261 }
289 break; 262 break;
290 } 263 }
291 } 264 }
292 acpi_os_printf ("\""); 265 acpi_os_printf("\"");
293 266
294 if (i == max_length && string[i]) { 267 if (i == max_length && string[i]) {
295 acpi_os_printf ("..."); 268 acpi_os_printf("...");
296 } 269 }
297} 270}
298 271
299
300/******************************************************************************* 272/*******************************************************************************
301 * 273 *
302 * FUNCTION: acpi_ut_dword_byte_swap 274 * FUNCTION: acpi_ut_dword_byte_swap
@@ -309,22 +281,18 @@ acpi_ut_print_string (
309 * 281 *
310 ******************************************************************************/ 282 ******************************************************************************/
311 283
312u32 284u32 acpi_ut_dword_byte_swap(u32 value)
313acpi_ut_dword_byte_swap (
314 u32 value)
315{ 285{
316 union { 286 union {
317 u32 value; 287 u32 value;
318 u8 bytes[4]; 288 u8 bytes[4];
319 } out; 289 } out;
320 union { 290 union {
321 u32 value; 291 u32 value;
322 u8 bytes[4]; 292 u8 bytes[4];
323 } in; 293 } in;
324 294
325 295 ACPI_FUNCTION_ENTRY();
326 ACPI_FUNCTION_ENTRY ();
327
328 296
329 in.value = value; 297 in.value = value;
330 298
@@ -336,7 +304,6 @@ acpi_ut_dword_byte_swap (
336 return (out.value); 304 return (out.value);
337} 305}
338 306
339
340/******************************************************************************* 307/*******************************************************************************
341 * 308 *
342 * FUNCTION: acpi_ut_set_integer_width 309 * FUNCTION: acpi_ut_set_integer_width
@@ -352,24 +319,20 @@ acpi_ut_dword_byte_swap (
352 * 319 *
353 ******************************************************************************/ 320 ******************************************************************************/
354 321
355void 322void acpi_ut_set_integer_width(u8 revision)
356acpi_ut_set_integer_width (
357 u8 revision)
358{ 323{
359 324
360 if (revision <= 1) { 325 if (revision <= 1) {
361 acpi_gbl_integer_bit_width = 32; 326 acpi_gbl_integer_bit_width = 32;
362 acpi_gbl_integer_nybble_width = 8; 327 acpi_gbl_integer_nybble_width = 8;
363 acpi_gbl_integer_byte_width = 4; 328 acpi_gbl_integer_byte_width = 4;
364 } 329 } else {
365 else {
366 acpi_gbl_integer_bit_width = 64; 330 acpi_gbl_integer_bit_width = 64;
367 acpi_gbl_integer_nybble_width = 16; 331 acpi_gbl_integer_nybble_width = 16;
368 acpi_gbl_integer_byte_width = 8; 332 acpi_gbl_integer_byte_width = 8;
369 } 333 }
370} 334}
371 335
372
373#ifdef ACPI_DEBUG_OUTPUT 336#ifdef ACPI_DEBUG_OUTPUT
374/******************************************************************************* 337/*******************************************************************************
375 * 338 *
@@ -387,17 +350,14 @@ acpi_ut_set_integer_width (
387 ******************************************************************************/ 350 ******************************************************************************/
388 351
389void 352void
390acpi_ut_display_init_pathname ( 353acpi_ut_display_init_pathname(u8 type,
391 u8 type, 354 struct acpi_namespace_node *obj_handle,
392 struct acpi_namespace_node *obj_handle, 355 char *path)
393 char *path)
394{ 356{
395 acpi_status status; 357 acpi_status status;
396 struct acpi_buffer buffer; 358 struct acpi_buffer buffer;
397
398
399 ACPI_FUNCTION_ENTRY ();
400 359
360 ACPI_FUNCTION_ENTRY();
401 361
402 /* Only print the path if the appropriate debug level is enabled */ 362 /* Only print the path if the appropriate debug level is enabled */
403 363
@@ -408,8 +368,8 @@ acpi_ut_display_init_pathname (
408 /* Get the full pathname to the node */ 368 /* Get the full pathname to the node */
409 369
410 buffer.length = ACPI_ALLOCATE_LOCAL_BUFFER; 370 buffer.length = ACPI_ALLOCATE_LOCAL_BUFFER;
411 status = acpi_ns_handle_to_pathname (obj_handle, &buffer); 371 status = acpi_ns_handle_to_pathname(obj_handle, &buffer);
412 if (ACPI_FAILURE (status)) { 372 if (ACPI_FAILURE(status)) {
413 return; 373 return;
414 } 374 }
415 375
@@ -417,31 +377,30 @@ acpi_ut_display_init_pathname (
417 377
418 switch (type) { 378 switch (type) {
419 case ACPI_TYPE_METHOD: 379 case ACPI_TYPE_METHOD:
420 acpi_os_printf ("Executing "); 380 acpi_os_printf("Executing ");
421 break; 381 break;
422 382
423 default: 383 default:
424 acpi_os_printf ("Initializing "); 384 acpi_os_printf("Initializing ");
425 break; 385 break;
426 } 386 }
427 387
428 /* Print the object type and pathname */ 388 /* Print the object type and pathname */
429 389
430 acpi_os_printf ("%-12s %s", 390 acpi_os_printf("%-12s %s",
431 acpi_ut_get_type_name (type), (char *) buffer.pointer); 391 acpi_ut_get_type_name(type), (char *)buffer.pointer);
432 392
433 /* Extra path is used to append names like _STA, _INI, etc. */ 393 /* Extra path is used to append names like _STA, _INI, etc. */
434 394
435 if (path) { 395 if (path) {
436 acpi_os_printf (".%s", path); 396 acpi_os_printf(".%s", path);
437 } 397 }
438 acpi_os_printf ("\n"); 398 acpi_os_printf("\n");
439 399
440 ACPI_MEM_FREE (buffer.pointer); 400 ACPI_MEM_FREE(buffer.pointer);
441} 401}
442#endif 402#endif
443 403
444
445/******************************************************************************* 404/*******************************************************************************
446 * 405 *
447 * FUNCTION: acpi_ut_valid_acpi_name 406 * FUNCTION: acpi_ut_valid_acpi_name
@@ -457,25 +416,21 @@ acpi_ut_display_init_pathname (
457 * 416 *
458 ******************************************************************************/ 417 ******************************************************************************/
459 418
460u8 419u8 acpi_ut_valid_acpi_name(u32 name)
461acpi_ut_valid_acpi_name (
462 u32 name)
463{ 420{
464 char *name_ptr = (char *) &name; 421 char *name_ptr = (char *)&name;
465 char character; 422 char character;
466 acpi_native_uint i; 423 acpi_native_uint i;
467
468
469 ACPI_FUNCTION_ENTRY ();
470 424
425 ACPI_FUNCTION_ENTRY();
471 426
472 for (i = 0; i < ACPI_NAME_SIZE; i++) { 427 for (i = 0; i < ACPI_NAME_SIZE; i++) {
473 character = *name_ptr; 428 character = *name_ptr;
474 name_ptr++; 429 name_ptr++;
475 430
476 if (!((character == '_') || 431 if (!((character == '_') ||
477 (character >= 'A' && character <= 'Z') || 432 (character >= 'A' && character <= 'Z') ||
478 (character >= '0' && character <= '9'))) { 433 (character >= '0' && character <= '9'))) {
479 return (FALSE); 434 return (FALSE);
480 } 435 }
481 } 436 }
@@ -483,7 +438,6 @@ acpi_ut_valid_acpi_name (
483 return (TRUE); 438 return (TRUE);
484} 439}
485 440
486
487/******************************************************************************* 441/*******************************************************************************
488 * 442 *
489 * FUNCTION: acpi_ut_valid_acpi_character 443 * FUNCTION: acpi_ut_valid_acpi_character
@@ -496,19 +450,16 @@ acpi_ut_valid_acpi_name (
496 * 450 *
497 ******************************************************************************/ 451 ******************************************************************************/
498 452
499u8 453u8 acpi_ut_valid_acpi_character(char character)
500acpi_ut_valid_acpi_character (
501 char character)
502{ 454{
503 455
504 ACPI_FUNCTION_ENTRY (); 456 ACPI_FUNCTION_ENTRY();
505 457
506 return ((u8) ((character == '_') || 458 return ((u8) ((character == '_') ||
507 (character >= 'A' && character <= 'Z') || 459 (character >= 'A' && character <= 'Z') ||
508 (character >= '0' && character <= '9'))); 460 (character >= '0' && character <= '9')));
509} 461}
510 462
511
512/******************************************************************************* 463/*******************************************************************************
513 * 464 *
514 * FUNCTION: acpi_ut_strtoul64 465 * FUNCTION: acpi_ut_strtoul64
@@ -525,18 +476,13 @@ acpi_ut_valid_acpi_character (
525 ******************************************************************************/ 476 ******************************************************************************/
526 477
527acpi_status 478acpi_status
528acpi_ut_strtoul64 ( 479acpi_ut_strtoul64(char *string, u32 base, acpi_integer * ret_integer)
529 char *string,
530 u32 base,
531 acpi_integer *ret_integer)
532{ 480{
533 u32 this_digit = 0; 481 u32 this_digit = 0;
534 acpi_integer return_value = 0; 482 acpi_integer return_value = 0;
535 acpi_integer quotient; 483 acpi_integer quotient;
536
537
538 ACPI_FUNCTION_TRACE ("ut_stroul64");
539 484
485 ACPI_FUNCTION_TRACE("ut_stroul64");
540 486
541 if ((!string) || !(*string)) { 487 if ((!string) || !(*string)) {
542 goto error_exit; 488 goto error_exit;
@@ -550,12 +496,12 @@ acpi_ut_strtoul64 (
550 496
551 default: 497 default:
552 /* Invalid Base */ 498 /* Invalid Base */
553 return_ACPI_STATUS (AE_BAD_PARAMETER); 499 return_ACPI_STATUS(AE_BAD_PARAMETER);
554 } 500 }
555 501
556 /* Skip over any white space in the buffer */ 502 /* Skip over any white space in the buffer */
557 503
558 while (ACPI_IS_SPACE (*string) || *string == '\t') { 504 while (ACPI_IS_SPACE(*string) || *string == '\t') {
559 string++; 505 string++;
560 } 506 }
561 507
@@ -564,12 +510,10 @@ acpi_ut_strtoul64 (
564 * determine if it is decimal or hexadecimal: 510 * determine if it is decimal or hexadecimal:
565 */ 511 */
566 if (base == 0) { 512 if (base == 0) {
567 if ((*string == '0') && 513 if ((*string == '0') && (ACPI_TOLOWER(*(string + 1)) == 'x')) {
568 (ACPI_TOLOWER (*(string + 1)) == 'x')) {
569 base = 16; 514 base = 16;
570 string += 2; 515 string += 2;
571 } 516 } else {
572 else {
573 base = 10; 517 base = 10;
574 } 518 }
575 } 519 }
@@ -579,8 +523,7 @@ acpi_ut_strtoul64 (
579 * 0 or 0x, if they are present. 523 * 0 or 0x, if they are present.
580 */ 524 */
581 if ((base == 16) && 525 if ((base == 16) &&
582 (*string == '0') && 526 (*string == '0') && (ACPI_TOLOWER(*(string + 1)) == 'x')) {
583 (ACPI_TOLOWER (*(string + 1)) == 'x')) {
584 string += 2; 527 string += 2;
585 } 528 }
586 529
@@ -593,25 +536,23 @@ acpi_ut_strtoul64 (
593 /* Main loop: convert the string to a 64-bit integer */ 536 /* Main loop: convert the string to a 64-bit integer */
594 537
595 while (*string) { 538 while (*string) {
596 if (ACPI_IS_DIGIT (*string)) { 539 if (ACPI_IS_DIGIT(*string)) {
597 /* Convert ASCII 0-9 to Decimal value */ 540 /* Convert ASCII 0-9 to Decimal value */
598 541
599 this_digit = ((u8) *string) - '0'; 542 this_digit = ((u8) * string) - '0';
600 } 543 } else {
601 else {
602 if (base == 10) { 544 if (base == 10) {
603 /* Digit is out of range */ 545 /* Digit is out of range */
604 546
605 goto error_exit; 547 goto error_exit;
606 } 548 }
607 549
608 this_digit = (u8) ACPI_TOUPPER (*string); 550 this_digit = (u8) ACPI_TOUPPER(*string);
609 if (ACPI_IS_XDIGIT ((char) this_digit)) { 551 if (ACPI_IS_XDIGIT((char)this_digit)) {
610 /* Convert ASCII Hex char to value */ 552 /* Convert ASCII Hex char to value */
611 553
612 this_digit = this_digit - 'A' + 10; 554 this_digit = this_digit - 'A' + 10;
613 } 555 } else {
614 else {
615 /* 556 /*
616 * We allow non-hex chars, just stop now, same as end-of-string. 557 * We allow non-hex chars, just stop now, same as end-of-string.
617 * See ACPI spec, string-to-integer conversion. 558 * See ACPI spec, string-to-integer conversion.
@@ -622,8 +563,10 @@ acpi_ut_strtoul64 (
622 563
623 /* Divide the digit into the correct position */ 564 /* Divide the digit into the correct position */
624 565
625 (void) acpi_ut_short_divide ((ACPI_INTEGER_MAX - (acpi_integer) this_digit), 566 (void)
626 base, &quotient, NULL); 567 acpi_ut_short_divide((ACPI_INTEGER_MAX -
568 (acpi_integer) this_digit), base,
569 &quotient, NULL);
627 if (return_value > quotient) { 570 if (return_value > quotient) {
628 goto error_exit; 571 goto error_exit;
629 } 572 }
@@ -636,21 +579,18 @@ acpi_ut_strtoul64 (
636 /* All done, normal exit */ 579 /* All done, normal exit */
637 580
638 *ret_integer = return_value; 581 *ret_integer = return_value;
639 return_ACPI_STATUS (AE_OK); 582 return_ACPI_STATUS(AE_OK);
640 583
641 584 error_exit:
642error_exit:
643 /* Base was set/validated above */ 585 /* Base was set/validated above */
644 586
645 if (base == 10) { 587 if (base == 10) {
646 return_ACPI_STATUS (AE_BAD_DECIMAL_CONSTANT); 588 return_ACPI_STATUS(AE_BAD_DECIMAL_CONSTANT);
647 } 589 } else {
648 else { 590 return_ACPI_STATUS(AE_BAD_HEX_CONSTANT);
649 return_ACPI_STATUS (AE_BAD_HEX_CONSTANT);
650 } 591 }
651} 592}
652 593
653
654/******************************************************************************* 594/*******************************************************************************
655 * 595 *
656 * FUNCTION: acpi_ut_create_update_state_and_push 596 * FUNCTION: acpi_ut_create_update_state_and_push
@@ -666,16 +606,13 @@ error_exit:
666 ******************************************************************************/ 606 ******************************************************************************/
667 607
668acpi_status 608acpi_status
669acpi_ut_create_update_state_and_push ( 609acpi_ut_create_update_state_and_push(union acpi_operand_object *object,
670 union acpi_operand_object *object, 610 u16 action,
671 u16 action, 611 union acpi_generic_state **state_list)
672 union acpi_generic_state **state_list)
673{ 612{
674 union acpi_generic_state *state; 613 union acpi_generic_state *state;
675
676
677 ACPI_FUNCTION_ENTRY ();
678 614
615 ACPI_FUNCTION_ENTRY();
679 616
680 /* Ignore null objects; these are expected */ 617 /* Ignore null objects; these are expected */
681 618
@@ -683,16 +620,15 @@ acpi_ut_create_update_state_and_push (
683 return (AE_OK); 620 return (AE_OK);
684 } 621 }
685 622
686 state = acpi_ut_create_update_state (object, action); 623 state = acpi_ut_create_update_state(object, action);
687 if (!state) { 624 if (!state) {
688 return (AE_NO_MEMORY); 625 return (AE_NO_MEMORY);
689 } 626 }
690 627
691 acpi_ut_push_generic_state (state_list, state); 628 acpi_ut_push_generic_state(state_list, state);
692 return (AE_OK); 629 return (AE_OK);
693} 630}
694 631
695
696/******************************************************************************* 632/*******************************************************************************
697 * 633 *
698 * FUNCTION: acpi_ut_walk_package_tree 634 * FUNCTION: acpi_ut_walk_package_tree
@@ -709,33 +645,29 @@ acpi_ut_create_update_state_and_push (
709 ******************************************************************************/ 645 ******************************************************************************/
710 646
711acpi_status 647acpi_status
712acpi_ut_walk_package_tree ( 648acpi_ut_walk_package_tree(union acpi_operand_object * source_object,
713 union acpi_operand_object *source_object, 649 void *target_object,
714 void *target_object, 650 acpi_pkg_callback walk_callback, void *context)
715 acpi_pkg_callback walk_callback,
716 void *context)
717{ 651{
718 acpi_status status = AE_OK; 652 acpi_status status = AE_OK;
719 union acpi_generic_state *state_list = NULL; 653 union acpi_generic_state *state_list = NULL;
720 union acpi_generic_state *state; 654 union acpi_generic_state *state;
721 u32 this_index; 655 u32 this_index;
722 union acpi_operand_object *this_source_obj; 656 union acpi_operand_object *this_source_obj;
723
724 657
725 ACPI_FUNCTION_TRACE ("ut_walk_package_tree"); 658 ACPI_FUNCTION_TRACE("ut_walk_package_tree");
726 659
727 660 state = acpi_ut_create_pkg_state(source_object, target_object, 0);
728 state = acpi_ut_create_pkg_state (source_object, target_object, 0);
729 if (!state) { 661 if (!state) {
730 return_ACPI_STATUS (AE_NO_MEMORY); 662 return_ACPI_STATUS(AE_NO_MEMORY);
731 } 663 }
732 664
733 while (state) { 665 while (state) {
734 /* Get one element of the package */ 666 /* Get one element of the package */
735 667
736 this_index = state->pkg.index; 668 this_index = state->pkg.index;
737 this_source_obj = (union acpi_operand_object *) 669 this_source_obj = (union acpi_operand_object *)
738 state->pkg.source_object->package.elements[this_index]; 670 state->pkg.source_object->package.elements[this_index];
739 671
740 /* 672 /*
741 * Check for: 673 * Check for:
@@ -746,16 +678,20 @@ acpi_ut_walk_package_tree (
746 * case below. 678 * case below.
747 */ 679 */
748 if ((!this_source_obj) || 680 if ((!this_source_obj) ||
749 (ACPI_GET_DESCRIPTOR_TYPE (this_source_obj) != ACPI_DESC_TYPE_OPERAND) || 681 (ACPI_GET_DESCRIPTOR_TYPE(this_source_obj) !=
750 (ACPI_GET_OBJECT_TYPE (this_source_obj) != ACPI_TYPE_PACKAGE)) { 682 ACPI_DESC_TYPE_OPERAND)
751 status = walk_callback (ACPI_COPY_TYPE_SIMPLE, this_source_obj, 683 || (ACPI_GET_OBJECT_TYPE(this_source_obj) !=
752 state, context); 684 ACPI_TYPE_PACKAGE)) {
753 if (ACPI_FAILURE (status)) { 685 status =
754 return_ACPI_STATUS (status); 686 walk_callback(ACPI_COPY_TYPE_SIMPLE,
687 this_source_obj, state, context);
688 if (ACPI_FAILURE(status)) {
689 return_ACPI_STATUS(status);
755 } 690 }
756 691
757 state->pkg.index++; 692 state->pkg.index++;
758 while (state->pkg.index >= state->pkg.source_object->package.count) { 693 while (state->pkg.index >=
694 state->pkg.source_object->package.count) {
759 /* 695 /*
760 * We've handled all of the objects at this level, This means 696 * We've handled all of the objects at this level, This means
761 * that we have just completed a package. That package may 697 * that we have just completed a package. That package may
@@ -763,8 +699,8 @@ acpi_ut_walk_package_tree (
763 * 699 *
764 * Delete this state and pop the previous state (package). 700 * Delete this state and pop the previous state (package).
765 */ 701 */
766 acpi_ut_delete_generic_state (state); 702 acpi_ut_delete_generic_state(state);
767 state = acpi_ut_pop_generic_state (&state_list); 703 state = acpi_ut_pop_generic_state(&state_list);
768 704
769 /* Finished when there are no more states */ 705 /* Finished when there are no more states */
770 706
@@ -774,7 +710,7 @@ acpi_ut_walk_package_tree (
774 * package just add the length of the package objects 710 * package just add the length of the package objects
775 * and exit 711 * and exit
776 */ 712 */
777 return_ACPI_STATUS (AE_OK); 713 return_ACPI_STATUS(AE_OK);
778 } 714 }
779 715
780 /* 716 /*
@@ -783,35 +719,35 @@ acpi_ut_walk_package_tree (
783 */ 719 */
784 state->pkg.index++; 720 state->pkg.index++;
785 } 721 }
786 } 722 } else {
787 else {
788 /* This is a subobject of type package */ 723 /* This is a subobject of type package */
789 724
790 status = walk_callback (ACPI_COPY_TYPE_PACKAGE, this_source_obj, 725 status =
791 state, context); 726 walk_callback(ACPI_COPY_TYPE_PACKAGE,
792 if (ACPI_FAILURE (status)) { 727 this_source_obj, state, context);
793 return_ACPI_STATUS (status); 728 if (ACPI_FAILURE(status)) {
729 return_ACPI_STATUS(status);
794 } 730 }
795 731
796 /* 732 /*
797 * Push the current state and create a new one 733 * Push the current state and create a new one
798 * The callback above returned a new target package object. 734 * The callback above returned a new target package object.
799 */ 735 */
800 acpi_ut_push_generic_state (&state_list, state); 736 acpi_ut_push_generic_state(&state_list, state);
801 state = acpi_ut_create_pkg_state (this_source_obj, 737 state = acpi_ut_create_pkg_state(this_source_obj,
802 state->pkg.this_target_obj, 0); 738 state->pkg.
739 this_target_obj, 0);
803 if (!state) { 740 if (!state) {
804 return_ACPI_STATUS (AE_NO_MEMORY); 741 return_ACPI_STATUS(AE_NO_MEMORY);
805 } 742 }
806 } 743 }
807 } 744 }
808 745
809 /* We should never get here */ 746 /* We should never get here */
810 747
811 return_ACPI_STATUS (AE_AML_INTERNAL); 748 return_ACPI_STATUS(AE_AML_INTERNAL);
812} 749}
813 750
814
815/******************************************************************************* 751/*******************************************************************************
816 * 752 *
817 * FUNCTION: acpi_ut_generate_checksum 753 * FUNCTION: acpi_ut_generate_checksum
@@ -825,23 +761,18 @@ acpi_ut_walk_package_tree (
825 * 761 *
826 ******************************************************************************/ 762 ******************************************************************************/
827 763
828u8 764u8 acpi_ut_generate_checksum(u8 * buffer, u32 length)
829acpi_ut_generate_checksum (
830 u8 *buffer,
831 u32 length)
832{ 765{
833 u32 i; 766 u32 i;
834 signed char sum = 0; 767 signed char sum = 0;
835
836 768
837 for (i = 0; i < length; i++) { 769 for (i = 0; i < length; i++) {
838 sum = (signed char) (sum + buffer[i]); 770 sum = (signed char)(sum + buffer[i]);
839 } 771 }
840 772
841 return ((u8) (0 - sum)); 773 return ((u8) (0 - sum));
842} 774}
843 775
844
845/******************************************************************************* 776/*******************************************************************************
846 * 777 *
847 * FUNCTION: acpi_ut_get_resource_end_tag 778 * FUNCTION: acpi_ut_get_resource_end_tag
@@ -854,17 +785,13 @@ acpi_ut_generate_checksum (
854 * 785 *
855 ******************************************************************************/ 786 ******************************************************************************/
856 787
857 788u8 *acpi_ut_get_resource_end_tag(union acpi_operand_object * obj_desc)
858u8 *
859acpi_ut_get_resource_end_tag (
860 union acpi_operand_object *obj_desc)
861{ 789{
862 u8 buffer_byte; 790 u8 buffer_byte;
863 u8 *buffer; 791 u8 *buffer;
864 u8 *end_buffer; 792 u8 *end_buffer;
865 793
866 794 buffer = obj_desc->buffer.pointer;
867 buffer = obj_desc->buffer.pointer;
868 end_buffer = buffer + obj_desc->buffer.length; 795 end_buffer = buffer + obj_desc->buffer.length;
869 796
870 while (buffer < end_buffer) { 797 while (buffer < end_buffer) {
@@ -872,12 +799,12 @@ acpi_ut_get_resource_end_tag (
872 if (buffer_byte & ACPI_RDESC_TYPE_MASK) { 799 if (buffer_byte & ACPI_RDESC_TYPE_MASK) {
873 /* Large Descriptor - Length is next 2 bytes */ 800 /* Large Descriptor - Length is next 2 bytes */
874 801
875 buffer += ((*(buffer+1) | (*(buffer+2) << 8)) + 3); 802 buffer += ((*(buffer + 1) | (*(buffer + 2) << 8)) + 3);
876 } 803 } else {
877 else {
878 /* Small Descriptor. End Tag will be found here */ 804 /* Small Descriptor. End Tag will be found here */
879 805
880 if ((buffer_byte & ACPI_RDESC_SMALL_MASK) == ACPI_RDESC_TYPE_END_TAG) { 806 if ((buffer_byte & ACPI_RDESC_SMALL_MASK) ==
807 ACPI_RDESC_TYPE_END_TAG) {
881 /* Found the end tag descriptor, all done. */ 808 /* Found the end tag descriptor, all done. */
882 809
883 return (buffer); 810 return (buffer);
@@ -894,7 +821,6 @@ acpi_ut_get_resource_end_tag (
894 return (NULL); 821 return (NULL);
895} 822}
896 823
897
898/******************************************************************************* 824/*******************************************************************************
899 * 825 *
900 * FUNCTION: acpi_ut_report_error 826 * FUNCTION: acpi_ut_report_error
@@ -909,17 +835,12 @@ acpi_ut_get_resource_end_tag (
909 * 835 *
910 ******************************************************************************/ 836 ******************************************************************************/
911 837
912void 838void acpi_ut_report_error(char *module_name, u32 line_number, u32 component_id)
913acpi_ut_report_error (
914 char *module_name,
915 u32 line_number,
916 u32 component_id)
917{ 839{
918 840
919 acpi_os_printf ("%8s-%04d: *** Error: ", module_name, line_number); 841 acpi_os_printf("%8s-%04d: *** Error: ", module_name, line_number);
920} 842}
921 843
922
923/******************************************************************************* 844/*******************************************************************************
924 * 845 *
925 * FUNCTION: acpi_ut_report_warning 846 * FUNCTION: acpi_ut_report_warning
@@ -935,16 +856,12 @@ acpi_ut_report_error (
935 ******************************************************************************/ 856 ******************************************************************************/
936 857
937void 858void
938acpi_ut_report_warning ( 859acpi_ut_report_warning(char *module_name, u32 line_number, u32 component_id)
939 char *module_name,
940 u32 line_number,
941 u32 component_id)
942{ 860{
943 861
944 acpi_os_printf ("%8s-%04d: *** Warning: ", module_name, line_number); 862 acpi_os_printf("%8s-%04d: *** Warning: ", module_name, line_number);
945} 863}
946 864
947
948/******************************************************************************* 865/*******************************************************************************
949 * 866 *
950 * FUNCTION: acpi_ut_report_info 867 * FUNCTION: acpi_ut_report_info
@@ -959,14 +876,8 @@ acpi_ut_report_warning (
959 * 876 *
960 ******************************************************************************/ 877 ******************************************************************************/
961 878
962void 879void acpi_ut_report_info(char *module_name, u32 line_number, u32 component_id)
963acpi_ut_report_info (
964 char *module_name,
965 u32 line_number,
966 u32 component_id)
967{ 880{
968 881
969 acpi_os_printf ("%8s-%04d: *** Info: ", module_name, line_number); 882 acpi_os_printf("%8s-%04d: *** Info: ", module_name, line_number);
970} 883}
971
972
diff --git a/drivers/acpi/utilities/utmutex.c b/drivers/acpi/utilities/utmutex.c
index 0699b6be62b6..90134c56ece9 100644
--- a/drivers/acpi/utilities/utmutex.c
+++ b/drivers/acpi/utilities/utmutex.c
@@ -41,22 +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#define _COMPONENT ACPI_UTILITIES 46#define _COMPONENT ACPI_UTILITIES
48 ACPI_MODULE_NAME ("utmutex") 47ACPI_MODULE_NAME("utmutex")
49 48
50/* Local prototypes */ 49/* Local prototypes */
50static acpi_status acpi_ut_create_mutex(acpi_mutex_handle mutex_id);
51 51
52static acpi_status 52static acpi_status acpi_ut_delete_mutex(acpi_mutex_handle mutex_id);
53acpi_ut_create_mutex (
54 acpi_mutex_handle mutex_id);
55
56static acpi_status
57acpi_ut_delete_mutex (
58 acpi_mutex_handle mutex_id);
59
60 53
61/******************************************************************************* 54/*******************************************************************************
62 * 55 *
@@ -70,32 +63,27 @@ acpi_ut_delete_mutex (
70 * 63 *
71 ******************************************************************************/ 64 ******************************************************************************/
72 65
73acpi_status 66acpi_status acpi_ut_mutex_initialize(void)
74acpi_ut_mutex_initialize (
75 void)
76{ 67{
77 u32 i; 68 u32 i;
78 acpi_status status; 69 acpi_status status;
79
80
81 ACPI_FUNCTION_TRACE ("ut_mutex_initialize");
82 70
71 ACPI_FUNCTION_TRACE("ut_mutex_initialize");
83 72
84 /* 73 /*
85 * Create each of the predefined mutex objects 74 * Create each of the predefined mutex objects
86 */ 75 */
87 for (i = 0; i < NUM_MUTEX; i++) { 76 for (i = 0; i < NUM_MUTEX; i++) {
88 status = acpi_ut_create_mutex (i); 77 status = acpi_ut_create_mutex(i);
89 if (ACPI_FAILURE (status)) { 78 if (ACPI_FAILURE(status)) {
90 return_ACPI_STATUS (status); 79 return_ACPI_STATUS(status);
91 } 80 }
92 } 81 }
93 82
94 status = acpi_os_create_lock (&acpi_gbl_gpe_lock); 83 status = acpi_os_create_lock(&acpi_gbl_gpe_lock);
95 return_ACPI_STATUS (status); 84 return_ACPI_STATUS(status);
96} 85}
97 86
98
99/******************************************************************************* 87/*******************************************************************************
100 * 88 *
101 * FUNCTION: acpi_ut_mutex_terminate 89 * FUNCTION: acpi_ut_mutex_terminate
@@ -108,28 +96,23 @@ acpi_ut_mutex_initialize (
108 * 96 *
109 ******************************************************************************/ 97 ******************************************************************************/
110 98
111void 99void acpi_ut_mutex_terminate(void)
112acpi_ut_mutex_terminate (
113 void)
114{ 100{
115 u32 i; 101 u32 i;
116
117
118 ACPI_FUNCTION_TRACE ("ut_mutex_terminate");
119 102
103 ACPI_FUNCTION_TRACE("ut_mutex_terminate");
120 104
121 /* 105 /*
122 * Delete each predefined mutex object 106 * Delete each predefined mutex object
123 */ 107 */
124 for (i = 0; i < NUM_MUTEX; i++) { 108 for (i = 0; i < NUM_MUTEX; i++) {
125 (void) acpi_ut_delete_mutex (i); 109 (void)acpi_ut_delete_mutex(i);
126 } 110 }
127 111
128 acpi_os_delete_lock (acpi_gbl_gpe_lock); 112 acpi_os_delete_lock(acpi_gbl_gpe_lock);
129 return_VOID; 113 return_VOID;
130} 114}
131 115
132
133/******************************************************************************* 116/*******************************************************************************
134 * 117 *
135 * FUNCTION: acpi_ut_create_mutex 118 * FUNCTION: acpi_ut_create_mutex
@@ -142,31 +125,28 @@ acpi_ut_mutex_terminate (
142 * 125 *
143 ******************************************************************************/ 126 ******************************************************************************/
144 127
145static acpi_status 128static acpi_status acpi_ut_create_mutex(acpi_mutex_handle mutex_id)
146acpi_ut_create_mutex (
147 acpi_mutex_handle mutex_id)
148{ 129{
149 acpi_status status = AE_OK; 130 acpi_status status = AE_OK;
150
151
152 ACPI_FUNCTION_TRACE_U32 ("ut_create_mutex", mutex_id);
153 131
132 ACPI_FUNCTION_TRACE_U32("ut_create_mutex", mutex_id);
154 133
155 if (mutex_id > MAX_MUTEX) { 134 if (mutex_id > MAX_MUTEX) {
156 return_ACPI_STATUS (AE_BAD_PARAMETER); 135 return_ACPI_STATUS(AE_BAD_PARAMETER);
157 } 136 }
158 137
159 if (!acpi_gbl_mutex_info[mutex_id].mutex) { 138 if (!acpi_gbl_mutex_info[mutex_id].mutex) {
160 status = acpi_os_create_semaphore (1, 1, 139 status = acpi_os_create_semaphore(1, 1,
161 &acpi_gbl_mutex_info[mutex_id].mutex); 140 &acpi_gbl_mutex_info
162 acpi_gbl_mutex_info[mutex_id].thread_id = ACPI_MUTEX_NOT_ACQUIRED; 141 [mutex_id].mutex);
142 acpi_gbl_mutex_info[mutex_id].thread_id =
143 ACPI_MUTEX_NOT_ACQUIRED;
163 acpi_gbl_mutex_info[mutex_id].use_count = 0; 144 acpi_gbl_mutex_info[mutex_id].use_count = 0;
164 } 145 }
165 146
166 return_ACPI_STATUS (status); 147 return_ACPI_STATUS(status);
167} 148}
168 149
169
170/******************************************************************************* 150/*******************************************************************************
171 * 151 *
172 * FUNCTION: acpi_ut_delete_mutex 152 * FUNCTION: acpi_ut_delete_mutex
@@ -179,29 +159,24 @@ acpi_ut_create_mutex (
179 * 159 *
180 ******************************************************************************/ 160 ******************************************************************************/
181 161
182static acpi_status 162static acpi_status acpi_ut_delete_mutex(acpi_mutex_handle mutex_id)
183acpi_ut_delete_mutex (
184 acpi_mutex_handle mutex_id)
185{ 163{
186 acpi_status status; 164 acpi_status status;
187
188
189 ACPI_FUNCTION_TRACE_U32 ("ut_delete_mutex", mutex_id);
190 165
166 ACPI_FUNCTION_TRACE_U32("ut_delete_mutex", mutex_id);
191 167
192 if (mutex_id > MAX_MUTEX) { 168 if (mutex_id > MAX_MUTEX) {
193 return_ACPI_STATUS (AE_BAD_PARAMETER); 169 return_ACPI_STATUS(AE_BAD_PARAMETER);
194 } 170 }
195 171
196 status = acpi_os_delete_semaphore (acpi_gbl_mutex_info[mutex_id].mutex); 172 status = acpi_os_delete_semaphore(acpi_gbl_mutex_info[mutex_id].mutex);
197 173
198 acpi_gbl_mutex_info[mutex_id].mutex = NULL; 174 acpi_gbl_mutex_info[mutex_id].mutex = NULL;
199 acpi_gbl_mutex_info[mutex_id].thread_id = ACPI_MUTEX_NOT_ACQUIRED; 175 acpi_gbl_mutex_info[mutex_id].thread_id = ACPI_MUTEX_NOT_ACQUIRED;
200 176
201 return_ACPI_STATUS (status); 177 return_ACPI_STATUS(status);
202} 178}
203 179
204
205/******************************************************************************* 180/*******************************************************************************
206 * 181 *
207 * FUNCTION: acpi_ut_acquire_mutex 182 * FUNCTION: acpi_ut_acquire_mutex
@@ -214,26 +189,22 @@ acpi_ut_delete_mutex (
214 * 189 *
215 ******************************************************************************/ 190 ******************************************************************************/
216 191
217acpi_status 192acpi_status acpi_ut_acquire_mutex(acpi_mutex_handle mutex_id)
218acpi_ut_acquire_mutex (
219 acpi_mutex_handle mutex_id)
220{ 193{
221 acpi_status status; 194 acpi_status status;
222 u32 this_thread_id; 195 u32 this_thread_id;
223
224
225 ACPI_FUNCTION_NAME ("ut_acquire_mutex");
226 196
197 ACPI_FUNCTION_NAME("ut_acquire_mutex");
227 198
228 if (mutex_id > MAX_MUTEX) { 199 if (mutex_id > MAX_MUTEX) {
229 return (AE_BAD_PARAMETER); 200 return (AE_BAD_PARAMETER);
230 } 201 }
231 202
232 this_thread_id = acpi_os_get_thread_id (); 203 this_thread_id = acpi_os_get_thread_id();
233 204
234#ifdef ACPI_MUTEX_DEBUG 205#ifdef ACPI_MUTEX_DEBUG
235 { 206 {
236 u32 i; 207 u32 i;
237 /* 208 /*
238 * Mutex debug code, for internal debugging only. 209 * Mutex debug code, for internal debugging only.
239 * 210 *
@@ -245,17 +216,21 @@ acpi_ut_acquire_mutex (
245 for (i = mutex_id; i < MAX_MUTEX; i++) { 216 for (i = mutex_id; i < MAX_MUTEX; i++) {
246 if (acpi_gbl_mutex_info[i].owner_id == this_thread_id) { 217 if (acpi_gbl_mutex_info[i].owner_id == this_thread_id) {
247 if (i == mutex_id) { 218 if (i == mutex_id) {
248 ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, 219 ACPI_DEBUG_PRINT((ACPI_DB_ERROR,
249 "Mutex [%s] already acquired by this thread [%X]\n", 220 "Mutex [%s] already acquired by this thread [%X]\n",
250 acpi_ut_get_mutex_name (mutex_id), this_thread_id)); 221 acpi_ut_get_mutex_name
222 (mutex_id),
223 this_thread_id));
251 224
252 return (AE_ALREADY_ACQUIRED); 225 return (AE_ALREADY_ACQUIRED);
253 } 226 }
254 227
255 ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, 228 ACPI_DEBUG_PRINT((ACPI_DB_ERROR,
256 "Invalid acquire order: Thread %X owns [%s], wants [%s]\n", 229 "Invalid acquire order: Thread %X owns [%s], wants [%s]\n",
257 this_thread_id, acpi_ut_get_mutex_name (i), 230 this_thread_id,
258 acpi_ut_get_mutex_name (mutex_id))); 231 acpi_ut_get_mutex_name(i),
232 acpi_ut_get_mutex_name
233 (mutex_id)));
259 234
260 return (AE_ACQUIRE_DEADLOCK); 235 return (AE_ACQUIRE_DEADLOCK);
261 } 236 }
@@ -263,30 +238,31 @@ acpi_ut_acquire_mutex (
263 } 238 }
264#endif 239#endif
265 240
266 ACPI_DEBUG_PRINT ((ACPI_DB_MUTEX, 241 ACPI_DEBUG_PRINT((ACPI_DB_MUTEX,
267 "Thread %X attempting to acquire Mutex [%s]\n", 242 "Thread %X attempting to acquire Mutex [%s]\n",
268 this_thread_id, acpi_ut_get_mutex_name (mutex_id))); 243 this_thread_id, acpi_ut_get_mutex_name(mutex_id)));
269 244
270 status = acpi_os_wait_semaphore (acpi_gbl_mutex_info[mutex_id].mutex, 245 status = acpi_os_wait_semaphore(acpi_gbl_mutex_info[mutex_id].mutex,
271 1, ACPI_WAIT_FOREVER); 246 1, ACPI_WAIT_FOREVER);
272 if (ACPI_SUCCESS (status)) { 247 if (ACPI_SUCCESS(status)) {
273 ACPI_DEBUG_PRINT ((ACPI_DB_MUTEX, "Thread %X acquired Mutex [%s]\n", 248 ACPI_DEBUG_PRINT((ACPI_DB_MUTEX,
274 this_thread_id, acpi_ut_get_mutex_name (mutex_id))); 249 "Thread %X acquired Mutex [%s]\n",
250 this_thread_id,
251 acpi_ut_get_mutex_name(mutex_id)));
275 252
276 acpi_gbl_mutex_info[mutex_id].use_count++; 253 acpi_gbl_mutex_info[mutex_id].use_count++;
277 acpi_gbl_mutex_info[mutex_id].thread_id = this_thread_id; 254 acpi_gbl_mutex_info[mutex_id].thread_id = this_thread_id;
278 } 255 } else {
279 else { 256 ACPI_DEBUG_PRINT((ACPI_DB_ERROR,
280 ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, 257 "Thread %X could not acquire Mutex [%s] %s\n",
281 "Thread %X could not acquire Mutex [%s] %s\n", 258 this_thread_id,
282 this_thread_id, acpi_ut_get_mutex_name (mutex_id), 259 acpi_ut_get_mutex_name(mutex_id),
283 acpi_format_exception (status))); 260 acpi_format_exception(status)));
284 } 261 }
285 262
286 return (status); 263 return (status);
287} 264}
288 265
289
290/******************************************************************************* 266/*******************************************************************************
291 * 267 *
292 * FUNCTION: acpi_ut_release_mutex 268 * FUNCTION: acpi_ut_release_mutex
@@ -299,21 +275,17 @@ acpi_ut_acquire_mutex (
299 * 275 *
300 ******************************************************************************/ 276 ******************************************************************************/
301 277
302acpi_status 278acpi_status acpi_ut_release_mutex(acpi_mutex_handle mutex_id)
303acpi_ut_release_mutex (
304 acpi_mutex_handle mutex_id)
305{ 279{
306 acpi_status status; 280 acpi_status status;
307 u32 this_thread_id; 281 u32 this_thread_id;
308
309 282
310 ACPI_FUNCTION_NAME ("ut_release_mutex"); 283 ACPI_FUNCTION_NAME("ut_release_mutex");
311 284
312 285 this_thread_id = acpi_os_get_thread_id();
313 this_thread_id = acpi_os_get_thread_id (); 286 ACPI_DEBUG_PRINT((ACPI_DB_MUTEX,
314 ACPI_DEBUG_PRINT ((ACPI_DB_MUTEX, 287 "Thread %X releasing Mutex [%s]\n", this_thread_id,
315 "Thread %X releasing Mutex [%s]\n", this_thread_id, 288 acpi_ut_get_mutex_name(mutex_id)));
316 acpi_ut_get_mutex_name (mutex_id)));
317 289
318 if (mutex_id > MAX_MUTEX) { 290 if (mutex_id > MAX_MUTEX) {
319 return (AE_BAD_PARAMETER); 291 return (AE_BAD_PARAMETER);
@@ -323,16 +295,15 @@ acpi_ut_release_mutex (
323 * Mutex must be acquired in order to release it! 295 * Mutex must be acquired in order to release it!
324 */ 296 */
325 if (acpi_gbl_mutex_info[mutex_id].thread_id == ACPI_MUTEX_NOT_ACQUIRED) { 297 if (acpi_gbl_mutex_info[mutex_id].thread_id == ACPI_MUTEX_NOT_ACQUIRED) {
326 ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, 298 ACPI_DEBUG_PRINT((ACPI_DB_ERROR,
327 "Mutex [%s] is not acquired, cannot release\n", 299 "Mutex [%s] is not acquired, cannot release\n",
328 acpi_ut_get_mutex_name (mutex_id))); 300 acpi_ut_get_mutex_name(mutex_id)));
329 301
330 return (AE_NOT_ACQUIRED); 302 return (AE_NOT_ACQUIRED);
331 } 303 }
332
333#ifdef ACPI_MUTEX_DEBUG 304#ifdef ACPI_MUTEX_DEBUG
334 { 305 {
335 u32 i; 306 u32 i;
336 /* 307 /*
337 * Mutex debug code, for internal debugging only. 308 * Mutex debug code, for internal debugging only.
338 * 309 *
@@ -347,9 +318,11 @@ acpi_ut_release_mutex (
347 continue; 318 continue;
348 } 319 }
349 320
350 ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, 321 ACPI_DEBUG_PRINT((ACPI_DB_ERROR,
351 "Invalid release order: owns [%s], releasing [%s]\n", 322 "Invalid release order: owns [%s], releasing [%s]\n",
352 acpi_ut_get_mutex_name (i), acpi_ut_get_mutex_name (mutex_id))); 323 acpi_ut_get_mutex_name(i),
324 acpi_ut_get_mutex_name
325 (mutex_id)));
353 326
354 return (AE_RELEASE_DEADLOCK); 327 return (AE_RELEASE_DEADLOCK);
355 } 328 }
@@ -361,20 +334,21 @@ acpi_ut_release_mutex (
361 334
362 acpi_gbl_mutex_info[mutex_id].thread_id = ACPI_MUTEX_NOT_ACQUIRED; 335 acpi_gbl_mutex_info[mutex_id].thread_id = ACPI_MUTEX_NOT_ACQUIRED;
363 336
364 status = acpi_os_signal_semaphore (acpi_gbl_mutex_info[mutex_id].mutex, 1); 337 status =
365 338 acpi_os_signal_semaphore(acpi_gbl_mutex_info[mutex_id].mutex, 1);
366 if (ACPI_FAILURE (status)) { 339
367 ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, 340 if (ACPI_FAILURE(status)) {
368 "Thread %X could not release Mutex [%s] %s\n", 341 ACPI_DEBUG_PRINT((ACPI_DB_ERROR,
369 this_thread_id, acpi_ut_get_mutex_name (mutex_id), 342 "Thread %X could not release Mutex [%s] %s\n",
370 acpi_format_exception (status))); 343 this_thread_id,
371 } 344 acpi_ut_get_mutex_name(mutex_id),
372 else { 345 acpi_format_exception(status)));
373 ACPI_DEBUG_PRINT ((ACPI_DB_MUTEX, "Thread %X released Mutex [%s]\n", 346 } else {
374 this_thread_id, acpi_ut_get_mutex_name (mutex_id))); 347 ACPI_DEBUG_PRINT((ACPI_DB_MUTEX,
348 "Thread %X released Mutex [%s]\n",
349 this_thread_id,
350 acpi_ut_get_mutex_name(mutex_id)));
375 } 351 }
376 352
377 return (status); 353 return (status);
378} 354}
379
380
diff --git a/drivers/acpi/utilities/utobject.c b/drivers/acpi/utilities/utobject.c
index 19178e142951..3015e1540053 100644
--- a/drivers/acpi/utilities/utobject.c
+++ b/drivers/acpi/utilities/utobject.c
@@ -41,34 +41,26 @@
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/amlcode.h> 46#include <acpi/amlcode.h>
48 47
49
50#define _COMPONENT ACPI_UTILITIES 48#define _COMPONENT ACPI_UTILITIES
51 ACPI_MODULE_NAME ("utobject") 49ACPI_MODULE_NAME("utobject")
52 50
53/* Local prototypes */ 51/* Local prototypes */
54
55static acpi_status 52static acpi_status
56acpi_ut_get_simple_object_size ( 53acpi_ut_get_simple_object_size(union acpi_operand_object *obj,
57 union acpi_operand_object *obj, 54 acpi_size * obj_length);
58 acpi_size *obj_length);
59 55
60static acpi_status 56static acpi_status
61acpi_ut_get_package_object_size ( 57acpi_ut_get_package_object_size(union acpi_operand_object *obj,
62 union acpi_operand_object *obj, 58 acpi_size * obj_length);
63 acpi_size *obj_length);
64 59
65static acpi_status 60static acpi_status
66acpi_ut_get_element_length ( 61acpi_ut_get_element_length(u8 object_type,
67 u8 object_type, 62 union acpi_operand_object *source_object,
68 union acpi_operand_object *source_object, 63 union acpi_generic_state *state, void *context);
69 union acpi_generic_state *state,
70 void *context);
71
72 64
73/******************************************************************************* 65/*******************************************************************************
74 * 66 *
@@ -91,26 +83,25 @@ acpi_ut_get_element_length (
91 * 83 *
92 ******************************************************************************/ 84 ******************************************************************************/
93 85
94union acpi_operand_object * 86union acpi_operand_object *acpi_ut_create_internal_object_dbg(char *module_name,
95acpi_ut_create_internal_object_dbg ( 87 u32 line_number,
96 char *module_name, 88 u32 component_id,
97 u32 line_number, 89 acpi_object_type
98 u32 component_id, 90 type)
99 acpi_object_type type)
100{ 91{
101 union acpi_operand_object *object; 92 union acpi_operand_object *object;
102 union acpi_operand_object *second_object; 93 union acpi_operand_object *second_object;
103
104
105 ACPI_FUNCTION_TRACE_STR ("ut_create_internal_object_dbg",
106 acpi_ut_get_type_name (type));
107 94
95 ACPI_FUNCTION_TRACE_STR("ut_create_internal_object_dbg",
96 acpi_ut_get_type_name(type));
108 97
109 /* Allocate the raw object descriptor */ 98 /* Allocate the raw object descriptor */
110 99
111 object = acpi_ut_allocate_object_desc_dbg (module_name, line_number, component_id); 100 object =
101 acpi_ut_allocate_object_desc_dbg(module_name, line_number,
102 component_id);
112 if (!object) { 103 if (!object) {
113 return_PTR (NULL); 104 return_PTR(NULL);
114 } 105 }
115 106
116 switch (type) { 107 switch (type) {
@@ -119,11 +110,12 @@ acpi_ut_create_internal_object_dbg (
119 110
120 /* These types require a secondary object */ 111 /* These types require a secondary object */
121 112
122 second_object = acpi_ut_allocate_object_desc_dbg (module_name, 113 second_object = acpi_ut_allocate_object_desc_dbg(module_name,
123 line_number, component_id); 114 line_number,
115 component_id);
124 if (!second_object) { 116 if (!second_object) {
125 acpi_ut_delete_object_desc (object); 117 acpi_ut_delete_object_desc(object);
126 return_PTR (NULL); 118 return_PTR(NULL);
127 } 119 }
128 120
129 second_object->common.type = ACPI_TYPE_LOCAL_EXTRA; 121 second_object->common.type = ACPI_TYPE_LOCAL_EXTRA;
@@ -149,10 +141,9 @@ acpi_ut_create_internal_object_dbg (
149 141
150 /* Any per-type initialization should go here */ 142 /* Any per-type initialization should go here */
151 143
152 return_PTR (object); 144 return_PTR(object);
153} 145}
154 146
155
156/******************************************************************************* 147/*******************************************************************************
157 * 148 *
158 * FUNCTION: acpi_ut_create_buffer_object 149 * FUNCTION: acpi_ut_create_buffer_object
@@ -165,22 +156,18 @@ acpi_ut_create_internal_object_dbg (
165 * 156 *
166 ******************************************************************************/ 157 ******************************************************************************/
167 158
168union acpi_operand_object * 159union acpi_operand_object *acpi_ut_create_buffer_object(acpi_size buffer_size)
169acpi_ut_create_buffer_object (
170 acpi_size buffer_size)
171{ 160{
172 union acpi_operand_object *buffer_desc; 161 union acpi_operand_object *buffer_desc;
173 u8 *buffer = NULL; 162 u8 *buffer = NULL;
174
175
176 ACPI_FUNCTION_TRACE_U32 ("ut_create_buffer_object", buffer_size);
177 163
164 ACPI_FUNCTION_TRACE_U32("ut_create_buffer_object", buffer_size);
178 165
179 /* Create a new Buffer object */ 166 /* Create a new Buffer object */
180 167
181 buffer_desc = acpi_ut_create_internal_object (ACPI_TYPE_BUFFER); 168 buffer_desc = acpi_ut_create_internal_object(ACPI_TYPE_BUFFER);
182 if (!buffer_desc) { 169 if (!buffer_desc) {
183 return_PTR (NULL); 170 return_PTR(NULL);
184 } 171 }
185 172
186 /* Create an actual buffer only if size > 0 */ 173 /* Create an actual buffer only if size > 0 */
@@ -188,12 +175,11 @@ acpi_ut_create_buffer_object (
188 if (buffer_size > 0) { 175 if (buffer_size > 0) {
189 /* Allocate the actual buffer */ 176 /* Allocate the actual buffer */
190 177
191 buffer = ACPI_MEM_CALLOCATE (buffer_size); 178 buffer = ACPI_MEM_CALLOCATE(buffer_size);
192 if (!buffer) { 179 if (!buffer) {
193 ACPI_REPORT_ERROR (("create_buffer: could not allocate size %X\n", 180 ACPI_REPORT_ERROR(("create_buffer: could not allocate size %X\n", (u32) buffer_size));
194 (u32) buffer_size)); 181 acpi_ut_remove_reference(buffer_desc);
195 acpi_ut_remove_reference (buffer_desc); 182 return_PTR(NULL);
196 return_PTR (NULL);
197 } 183 }
198 } 184 }
199 185
@@ -205,10 +191,9 @@ acpi_ut_create_buffer_object (
205 191
206 /* Return the new buffer descriptor */ 192 /* Return the new buffer descriptor */
207 193
208 return_PTR (buffer_desc); 194 return_PTR(buffer_desc);
209} 195}
210 196
211
212/******************************************************************************* 197/*******************************************************************************
213 * 198 *
214 * FUNCTION: acpi_ut_create_string_object 199 * FUNCTION: acpi_ut_create_string_object
@@ -223,34 +208,29 @@ acpi_ut_create_buffer_object (
223 * 208 *
224 ******************************************************************************/ 209 ******************************************************************************/
225 210
226union acpi_operand_object * 211union acpi_operand_object *acpi_ut_create_string_object(acpi_size string_size)
227acpi_ut_create_string_object (
228 acpi_size string_size)
229{ 212{
230 union acpi_operand_object *string_desc; 213 union acpi_operand_object *string_desc;
231 char *string; 214 char *string;
232
233
234 ACPI_FUNCTION_TRACE_U32 ("ut_create_string_object", string_size);
235 215
216 ACPI_FUNCTION_TRACE_U32("ut_create_string_object", string_size);
236 217
237 /* Create a new String object */ 218 /* Create a new String object */
238 219
239 string_desc = acpi_ut_create_internal_object (ACPI_TYPE_STRING); 220 string_desc = acpi_ut_create_internal_object(ACPI_TYPE_STRING);
240 if (!string_desc) { 221 if (!string_desc) {
241 return_PTR (NULL); 222 return_PTR(NULL);
242 } 223 }
243 224
244 /* 225 /*
245 * Allocate the actual string buffer -- (Size + 1) for NULL terminator. 226 * Allocate the actual string buffer -- (Size + 1) for NULL terminator.
246 * NOTE: Zero-length strings are NULL terminated 227 * NOTE: Zero-length strings are NULL terminated
247 */ 228 */
248 string = ACPI_MEM_CALLOCATE (string_size + 1); 229 string = ACPI_MEM_CALLOCATE(string_size + 1);
249 if (!string) { 230 if (!string) {
250 ACPI_REPORT_ERROR (("create_string: could not allocate size %X\n", 231 ACPI_REPORT_ERROR(("create_string: could not allocate size %X\n", (u32) string_size));
251 (u32) string_size)); 232 acpi_ut_remove_reference(string_desc);
252 acpi_ut_remove_reference (string_desc); 233 return_PTR(NULL);
253 return_PTR (NULL);
254 } 234 }
255 235
256 /* Complete string object initialization */ 236 /* Complete string object initialization */
@@ -260,10 +240,9 @@ acpi_ut_create_string_object (
260 240
261 /* Return the new string descriptor */ 241 /* Return the new string descriptor */
262 242
263 return_PTR (string_desc); 243 return_PTR(string_desc);
264} 244}
265 245
266
267/******************************************************************************* 246/*******************************************************************************
268 * 247 *
269 * FUNCTION: acpi_ut_valid_internal_object 248 * FUNCTION: acpi_ut_valid_internal_object
@@ -276,24 +255,21 @@ acpi_ut_create_string_object (
276 * 255 *
277 ******************************************************************************/ 256 ******************************************************************************/
278 257
279u8 258u8 acpi_ut_valid_internal_object(void *object)
280acpi_ut_valid_internal_object (
281 void *object)
282{ 259{
283 260
284 ACPI_FUNCTION_NAME ("ut_valid_internal_object"); 261 ACPI_FUNCTION_NAME("ut_valid_internal_object");
285
286 262
287 /* Check for a null pointer */ 263 /* Check for a null pointer */
288 264
289 if (!object) { 265 if (!object) {
290 ACPI_DEBUG_PRINT ((ACPI_DB_INFO, "**** Null Object Ptr\n")); 266 ACPI_DEBUG_PRINT((ACPI_DB_INFO, "**** Null Object Ptr\n"));
291 return (FALSE); 267 return (FALSE);
292 } 268 }
293 269
294 /* Check the descriptor type field */ 270 /* Check the descriptor type field */
295 271
296 switch (ACPI_GET_DESCRIPTOR_TYPE (object)) { 272 switch (ACPI_GET_DESCRIPTOR_TYPE(object)) {
297 case ACPI_DESC_TYPE_OPERAND: 273 case ACPI_DESC_TYPE_OPERAND:
298 274
299 /* The object appears to be a valid union acpi_operand_object */ 275 /* The object appears to be a valid union acpi_operand_object */
@@ -301,16 +277,15 @@ acpi_ut_valid_internal_object (
301 return (TRUE); 277 return (TRUE);
302 278
303 default: 279 default:
304 ACPI_DEBUG_PRINT ((ACPI_DB_INFO, 280 ACPI_DEBUG_PRINT((ACPI_DB_INFO,
305 "%p is not not an ACPI operand obj [%s]\n", 281 "%p is not not an ACPI operand obj [%s]\n",
306 object, acpi_ut_get_descriptor_name (object))); 282 object, acpi_ut_get_descriptor_name(object)));
307 break; 283 break;
308 } 284 }
309 285
310 return (FALSE); 286 return (FALSE);
311} 287}
312 288
313
314/******************************************************************************* 289/*******************************************************************************
315 * 290 *
316 * FUNCTION: acpi_ut_allocate_object_desc_dbg 291 * FUNCTION: acpi_ut_allocate_object_desc_dbg
@@ -326,37 +301,31 @@ acpi_ut_valid_internal_object (
326 * 301 *
327 ******************************************************************************/ 302 ******************************************************************************/
328 303
329void * 304void *acpi_ut_allocate_object_desc_dbg(char *module_name,
330acpi_ut_allocate_object_desc_dbg ( 305 u32 line_number, u32 component_id)
331 char *module_name,
332 u32 line_number,
333 u32 component_id)
334{ 306{
335 union acpi_operand_object *object; 307 union acpi_operand_object *object;
336
337 308
338 ACPI_FUNCTION_TRACE ("ut_allocate_object_desc_dbg"); 309 ACPI_FUNCTION_TRACE("ut_allocate_object_desc_dbg");
339 310
340 311 object = acpi_os_acquire_object(acpi_gbl_operand_cache);
341 object = acpi_os_acquire_object (acpi_gbl_operand_cache);
342 if (!object) { 312 if (!object) {
343 _ACPI_REPORT_ERROR (module_name, line_number, component_id, 313 _ACPI_REPORT_ERROR(module_name, line_number, component_id,
344 ("Could not allocate an object descriptor\n")); 314 ("Could not allocate an object descriptor\n"));
345 315
346 return_PTR (NULL); 316 return_PTR(NULL);
347 } 317 }
348 318
349 /* Mark the descriptor type */ 319 /* Mark the descriptor type */
350 memset(object, 0, sizeof(union acpi_operand_object)); 320 memset(object, 0, sizeof(union acpi_operand_object));
351 ACPI_SET_DESCRIPTOR_TYPE (object, ACPI_DESC_TYPE_OPERAND); 321 ACPI_SET_DESCRIPTOR_TYPE(object, ACPI_DESC_TYPE_OPERAND);
352 322
353 ACPI_DEBUG_PRINT ((ACPI_DB_ALLOCATIONS, "%p Size %X\n", 323 ACPI_DEBUG_PRINT((ACPI_DB_ALLOCATIONS, "%p Size %X\n",
354 object, (u32) sizeof (union acpi_operand_object))); 324 object, (u32) sizeof(union acpi_operand_object)));
355 325
356 return_PTR (object); 326 return_PTR(object);
357} 327}
358 328
359
360/******************************************************************************* 329/*******************************************************************************
361 * 330 *
362 * FUNCTION: acpi_ut_delete_object_desc 331 * FUNCTION: acpi_ut_delete_object_desc
@@ -369,27 +338,23 @@ acpi_ut_allocate_object_desc_dbg (
369 * 338 *
370 ******************************************************************************/ 339 ******************************************************************************/
371 340
372void 341void acpi_ut_delete_object_desc(union acpi_operand_object *object)
373acpi_ut_delete_object_desc (
374 union acpi_operand_object *object)
375{ 342{
376 ACPI_FUNCTION_TRACE_PTR ("ut_delete_object_desc", object); 343 ACPI_FUNCTION_TRACE_PTR("ut_delete_object_desc", object);
377
378 344
379 /* Object must be an union acpi_operand_object */ 345 /* Object must be an union acpi_operand_object */
380 346
381 if (ACPI_GET_DESCRIPTOR_TYPE (object) != ACPI_DESC_TYPE_OPERAND) { 347 if (ACPI_GET_DESCRIPTOR_TYPE(object) != ACPI_DESC_TYPE_OPERAND) {
382 ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, 348 ACPI_DEBUG_PRINT((ACPI_DB_ERROR,
383 "%p is not an ACPI Operand object [%s]\n", object, 349 "%p is not an ACPI Operand object [%s]\n",
384 acpi_ut_get_descriptor_name (object))); 350 object, acpi_ut_get_descriptor_name(object)));
385 return_VOID; 351 return_VOID;
386 } 352 }
387 353
388 (void) acpi_os_release_object (acpi_gbl_operand_cache, object); 354 (void)acpi_os_release_object(acpi_gbl_operand_cache, object);
389 return_VOID; 355 return_VOID;
390} 356}
391 357
392
393/******************************************************************************* 358/*******************************************************************************
394 * 359 *
395 * FUNCTION: acpi_ut_get_simple_object_size 360 * FUNCTION: acpi_ut_get_simple_object_size
@@ -408,16 +373,13 @@ acpi_ut_delete_object_desc (
408 ******************************************************************************/ 373 ******************************************************************************/
409 374
410static acpi_status 375static acpi_status
411acpi_ut_get_simple_object_size ( 376acpi_ut_get_simple_object_size(union acpi_operand_object *internal_object,
412 union acpi_operand_object *internal_object, 377 acpi_size * obj_length)
413 acpi_size *obj_length)
414{ 378{
415 acpi_size length; 379 acpi_size length;
416 acpi_status status = AE_OK; 380 acpi_status status = AE_OK;
417
418
419 ACPI_FUNCTION_TRACE_PTR ("ut_get_simple_object_size", internal_object);
420 381
382 ACPI_FUNCTION_TRACE_PTR("ut_get_simple_object_size", internal_object);
421 383
422 /* 384 /*
423 * Handle a null object (Could be a uninitialized package 385 * Handle a null object (Could be a uninitialized package
@@ -425,18 +387,18 @@ acpi_ut_get_simple_object_size (
425 */ 387 */
426 if (!internal_object) { 388 if (!internal_object) {
427 *obj_length = 0; 389 *obj_length = 0;
428 return_ACPI_STATUS (AE_OK); 390 return_ACPI_STATUS(AE_OK);
429 } 391 }
430 392
431 /* Start with the length of the Acpi object */ 393 /* Start with the length of the Acpi object */
432 394
433 length = sizeof (union acpi_object); 395 length = sizeof(union acpi_object);
434 396
435 if (ACPI_GET_DESCRIPTOR_TYPE (internal_object) == ACPI_DESC_TYPE_NAMED) { 397 if (ACPI_GET_DESCRIPTOR_TYPE(internal_object) == ACPI_DESC_TYPE_NAMED) {
436 /* Object is a named object (reference), just return the length */ 398 /* Object is a named object (reference), just return the length */
437 399
438 *obj_length = ACPI_ROUND_UP_TO_NATIVE_WORD (length); 400 *obj_length = ACPI_ROUND_UP_TO_NATIVE_WORD(length);
439 return_ACPI_STATUS (status); 401 return_ACPI_STATUS(status);
440 } 402 }
441 403
442 /* 404 /*
@@ -445,19 +407,17 @@ acpi_ut_get_simple_object_size (
445 * must be accessed bytewise or there may be alignment problems on 407 * must be accessed bytewise or there may be alignment problems on
446 * certain processors 408 * certain processors
447 */ 409 */
448 switch (ACPI_GET_OBJECT_TYPE (internal_object)) { 410 switch (ACPI_GET_OBJECT_TYPE(internal_object)) {
449 case ACPI_TYPE_STRING: 411 case ACPI_TYPE_STRING:
450 412
451 length += (acpi_size) internal_object->string.length + 1; 413 length += (acpi_size) internal_object->string.length + 1;
452 break; 414 break;
453 415
454
455 case ACPI_TYPE_BUFFER: 416 case ACPI_TYPE_BUFFER:
456 417
457 length += (acpi_size) internal_object->buffer.length; 418 length += (acpi_size) internal_object->buffer.length;
458 break; 419 break;
459 420
460
461 case ACPI_TYPE_INTEGER: 421 case ACPI_TYPE_INTEGER:
462 case ACPI_TYPE_PROCESSOR: 422 case ACPI_TYPE_PROCESSOR:
463 case ACPI_TYPE_POWER: 423 case ACPI_TYPE_POWER:
@@ -467,7 +427,6 @@ acpi_ut_get_simple_object_size (
467 */ 427 */
468 break; 428 break;
469 429
470
471 case ACPI_TYPE_LOCAL_REFERENCE: 430 case ACPI_TYPE_LOCAL_REFERENCE:
472 431
473 switch (internal_object->reference.opcode) { 432 switch (internal_object->reference.opcode) {
@@ -477,8 +436,10 @@ acpi_ut_get_simple_object_size (
477 * Get the actual length of the full pathname to this object. 436 * Get the actual length of the full pathname to this object.
478 * The reference will be converted to the pathname to the object 437 * The reference will be converted to the pathname to the object
479 */ 438 */
480 length += ACPI_ROUND_UP_TO_NATIVE_WORD ( 439 length +=
481 acpi_ns_get_pathname_length (internal_object->reference.node)); 440 ACPI_ROUND_UP_TO_NATIVE_WORD
441 (acpi_ns_get_pathname_length
442 (internal_object->reference.node));
482 break; 443 break;
483 444
484 default: 445 default:
@@ -488,19 +449,21 @@ acpi_ut_get_simple_object_size (
488 * Notably, Locals and Args are not supported, but this may be 449 * Notably, Locals and Args are not supported, but this may be
489 * required eventually. 450 * required eventually.
490 */ 451 */
491 ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, 452 ACPI_DEBUG_PRINT((ACPI_DB_ERROR,
492 "Unsupported Reference opcode=%X in object %p\n", 453 "Unsupported Reference opcode=%X in object %p\n",
493 internal_object->reference.opcode, internal_object)); 454 internal_object->reference.opcode,
455 internal_object));
494 status = AE_TYPE; 456 status = AE_TYPE;
495 break; 457 break;
496 } 458 }
497 break; 459 break;
498 460
499
500 default: 461 default:
501 462
502 ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "Unsupported type=%X in object %p\n", 463 ACPI_DEBUG_PRINT((ACPI_DB_ERROR,
503 ACPI_GET_OBJECT_TYPE (internal_object), internal_object)); 464 "Unsupported type=%X in object %p\n",
465 ACPI_GET_OBJECT_TYPE(internal_object),
466 internal_object));
504 status = AE_TYPE; 467 status = AE_TYPE;
505 break; 468 break;
506 } 469 }
@@ -511,11 +474,10 @@ acpi_ut_get_simple_object_size (
511 * on a machine word boundary. (preventing alignment faults on some 474 * on a machine word boundary. (preventing alignment faults on some
512 * machines.) 475 * machines.)
513 */ 476 */
514 *obj_length = ACPI_ROUND_UP_TO_NATIVE_WORD (length); 477 *obj_length = ACPI_ROUND_UP_TO_NATIVE_WORD(length);
515 return_ACPI_STATUS (status); 478 return_ACPI_STATUS(status);
516} 479}
517 480
518
519/******************************************************************************* 481/*******************************************************************************
520 * 482 *
521 * FUNCTION: acpi_ut_get_element_length 483 * FUNCTION: acpi_ut_get_element_length
@@ -529,16 +491,13 @@ acpi_ut_get_simple_object_size (
529 ******************************************************************************/ 491 ******************************************************************************/
530 492
531static acpi_status 493static acpi_status
532acpi_ut_get_element_length ( 494acpi_ut_get_element_length(u8 object_type,
533 u8 object_type, 495 union acpi_operand_object *source_object,
534 union acpi_operand_object *source_object, 496 union acpi_generic_state *state, void *context)
535 union acpi_generic_state *state,
536 void *context)
537{ 497{
538 acpi_status status = AE_OK; 498 acpi_status status = AE_OK;
539 struct acpi_pkg_info *info = (struct acpi_pkg_info *) context; 499 struct acpi_pkg_info *info = (struct acpi_pkg_info *)context;
540 acpi_size object_space; 500 acpi_size object_space;
541
542 501
543 switch (object_type) { 502 switch (object_type) {
544 case ACPI_COPY_TYPE_SIMPLE: 503 case ACPI_COPY_TYPE_SIMPLE:
@@ -547,15 +506,16 @@ acpi_ut_get_element_length (
547 * Simple object - just get the size (Null object/entry is handled 506 * Simple object - just get the size (Null object/entry is handled
548 * here also) and sum it into the running package length 507 * here also) and sum it into the running package length
549 */ 508 */
550 status = acpi_ut_get_simple_object_size (source_object, &object_space); 509 status =
551 if (ACPI_FAILURE (status)) { 510 acpi_ut_get_simple_object_size(source_object,
511 &object_space);
512 if (ACPI_FAILURE(status)) {
552 return (status); 513 return (status);
553 } 514 }
554 515
555 info->length += object_space; 516 info->length += object_space;
556 break; 517 break;
557 518
558
559 case ACPI_COPY_TYPE_PACKAGE: 519 case ACPI_COPY_TYPE_PACKAGE:
560 520
561 /* Package object - nothing much to do here, let the walk handle it */ 521 /* Package object - nothing much to do here, let the walk handle it */
@@ -564,7 +524,6 @@ acpi_ut_get_element_length (
564 state->pkg.this_target_obj = NULL; 524 state->pkg.this_target_obj = NULL;
565 break; 525 break;
566 526
567
568 default: 527 default:
569 528
570 /* No other types allowed */ 529 /* No other types allowed */
@@ -575,7 +534,6 @@ acpi_ut_get_element_length (
575 return (status); 534 return (status);
576} 535}
577 536
578
579/******************************************************************************* 537/*******************************************************************************
580 * 538 *
581 * FUNCTION: acpi_ut_get_package_object_size 539 * FUNCTION: acpi_ut_get_package_object_size
@@ -594,25 +552,22 @@ acpi_ut_get_element_length (
594 ******************************************************************************/ 552 ******************************************************************************/
595 553
596static acpi_status 554static acpi_status
597acpi_ut_get_package_object_size ( 555acpi_ut_get_package_object_size(union acpi_operand_object *internal_object,
598 union acpi_operand_object *internal_object, 556 acpi_size * obj_length)
599 acpi_size *obj_length)
600{ 557{
601 acpi_status status; 558 acpi_status status;
602 struct acpi_pkg_info info; 559 struct acpi_pkg_info info;
603 560
561 ACPI_FUNCTION_TRACE_PTR("ut_get_package_object_size", internal_object);
604 562
605 ACPI_FUNCTION_TRACE_PTR ("ut_get_package_object_size", internal_object); 563 info.length = 0;
606
607
608 info.length = 0;
609 info.object_space = 0; 564 info.object_space = 0;
610 info.num_packages = 1; 565 info.num_packages = 1;
611 566
612 status = acpi_ut_walk_package_tree (internal_object, NULL, 567 status = acpi_ut_walk_package_tree(internal_object, NULL,
613 acpi_ut_get_element_length, &info); 568 acpi_ut_get_element_length, &info);
614 if (ACPI_FAILURE (status)) { 569 if (ACPI_FAILURE(status)) {
615 return_ACPI_STATUS (status); 570 return_ACPI_STATUS(status);
616 } 571 }
617 572
618 /* 573 /*
@@ -620,16 +575,15 @@ acpi_ut_get_package_object_size (
620 * just add the length of the package objects themselves. 575 * just add the length of the package objects themselves.
621 * Round up to the next machine word. 576 * Round up to the next machine word.
622 */ 577 */
623 info.length += ACPI_ROUND_UP_TO_NATIVE_WORD (sizeof (union acpi_object)) * 578 info.length += ACPI_ROUND_UP_TO_NATIVE_WORD(sizeof(union acpi_object)) *
624 (acpi_size) info.num_packages; 579 (acpi_size) info.num_packages;
625 580
626 /* Return the total package length */ 581 /* Return the total package length */
627 582
628 *obj_length = info.length; 583 *obj_length = info.length;
629 return_ACPI_STATUS (status); 584 return_ACPI_STATUS(status);
630} 585}
631 586
632
633/******************************************************************************* 587/*******************************************************************************
634 * 588 *
635 * FUNCTION: acpi_ut_get_object_size 589 * FUNCTION: acpi_ut_get_object_size
@@ -645,25 +599,23 @@ acpi_ut_get_package_object_size (
645 ******************************************************************************/ 599 ******************************************************************************/
646 600
647acpi_status 601acpi_status
648acpi_ut_get_object_size ( 602acpi_ut_get_object_size(union acpi_operand_object *internal_object,
649 union acpi_operand_object *internal_object, 603 acpi_size * obj_length)
650 acpi_size *obj_length)
651{ 604{
652 acpi_status status; 605 acpi_status status;
653 606
654 607 ACPI_FUNCTION_ENTRY();
655 ACPI_FUNCTION_ENTRY (); 608
656 609 if ((ACPI_GET_DESCRIPTOR_TYPE(internal_object) ==
657 610 ACPI_DESC_TYPE_OPERAND)
658 if ((ACPI_GET_DESCRIPTOR_TYPE (internal_object) == ACPI_DESC_TYPE_OPERAND) && 611 && (ACPI_GET_OBJECT_TYPE(internal_object) == ACPI_TYPE_PACKAGE)) {
659 (ACPI_GET_OBJECT_TYPE (internal_object) == ACPI_TYPE_PACKAGE)) { 612 status =
660 status = acpi_ut_get_package_object_size (internal_object, obj_length); 613 acpi_ut_get_package_object_size(internal_object,
661 } 614 obj_length);
662 else { 615 } else {
663 status = acpi_ut_get_simple_object_size (internal_object, obj_length); 616 status =
617 acpi_ut_get_simple_object_size(internal_object, obj_length);
664 } 618 }
665 619
666 return (status); 620 return (status);
667} 621}
668
669
diff --git a/drivers/acpi/utilities/utstate.c b/drivers/acpi/utilities/utstate.c
index 192e7ac95690..c1cb27583be8 100644
--- a/drivers/acpi/utilities/utstate.c
+++ b/drivers/acpi/utilities/utstate.c
@@ -41,12 +41,10 @@
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#define _COMPONENT ACPI_UTILITIES 46#define _COMPONENT ACPI_UTILITIES
48 ACPI_MODULE_NAME ("utstate") 47ACPI_MODULE_NAME("utstate")
49
50 48
51/******************************************************************************* 49/*******************************************************************************
52 * 50 *
@@ -61,30 +59,26 @@
61 * DESCRIPTION: Create a new state and push it 59 * DESCRIPTION: Create a new state and push it
62 * 60 *
63 ******************************************************************************/ 61 ******************************************************************************/
64
65acpi_status 62acpi_status
66acpi_ut_create_pkg_state_and_push ( 63acpi_ut_create_pkg_state_and_push(void *internal_object,
67 void *internal_object, 64 void *external_object,
68 void *external_object, 65 u16 index,
69 u16 index, 66 union acpi_generic_state ** state_list)
70 union acpi_generic_state **state_list)
71{ 67{
72 union acpi_generic_state *state; 68 union acpi_generic_state *state;
73
74 69
75 ACPI_FUNCTION_ENTRY (); 70 ACPI_FUNCTION_ENTRY();
76 71
77 72 state =
78 state = acpi_ut_create_pkg_state (internal_object, external_object, index); 73 acpi_ut_create_pkg_state(internal_object, external_object, index);
79 if (!state) { 74 if (!state) {
80 return (AE_NO_MEMORY); 75 return (AE_NO_MEMORY);
81 } 76 }
82 77
83 acpi_ut_push_generic_state (state_list, state); 78 acpi_ut_push_generic_state(state_list, state);
84 return (AE_OK); 79 return (AE_OK);
85} 80}
86 81
87
88/******************************************************************************* 82/*******************************************************************************
89 * 83 *
90 * FUNCTION: acpi_ut_push_generic_state 84 * FUNCTION: acpi_ut_push_generic_state
@@ -99,12 +93,10 @@ acpi_ut_create_pkg_state_and_push (
99 ******************************************************************************/ 93 ******************************************************************************/
100 94
101void 95void
102acpi_ut_push_generic_state ( 96acpi_ut_push_generic_state(union acpi_generic_state **list_head,
103 union acpi_generic_state **list_head, 97 union acpi_generic_state *state)
104 union acpi_generic_state *state)
105{ 98{
106 ACPI_FUNCTION_TRACE ("ut_push_generic_state"); 99 ACPI_FUNCTION_TRACE("ut_push_generic_state");
107
108 100
109 /* Push the state object onto the front of the list (stack) */ 101 /* Push the state object onto the front of the list (stack) */
110 102
@@ -114,7 +106,6 @@ acpi_ut_push_generic_state (
114 return_VOID; 106 return_VOID;
115} 107}
116 108
117
118/******************************************************************************* 109/*******************************************************************************
119 * 110 *
120 * FUNCTION: acpi_ut_pop_generic_state 111 * FUNCTION: acpi_ut_pop_generic_state
@@ -127,15 +118,12 @@ acpi_ut_push_generic_state (
127 * 118 *
128 ******************************************************************************/ 119 ******************************************************************************/
129 120
130union acpi_generic_state * 121union acpi_generic_state *acpi_ut_pop_generic_state(union acpi_generic_state
131acpi_ut_pop_generic_state ( 122 **list_head)
132 union acpi_generic_state **list_head)
133{ 123{
134 union acpi_generic_state *state; 124 union acpi_generic_state *state;
135
136
137 ACPI_FUNCTION_TRACE ("ut_pop_generic_state");
138 125
126 ACPI_FUNCTION_TRACE("ut_pop_generic_state");
139 127
140 /* Remove the state object at the head of the list (stack) */ 128 /* Remove the state object at the head of the list (stack) */
141 129
@@ -146,10 +134,9 @@ acpi_ut_pop_generic_state (
146 *list_head = state->common.next; 134 *list_head = state->common.next;
147 } 135 }
148 136
149 return_PTR (state); 137 return_PTR(state);
150} 138}
151 139
152
153/******************************************************************************* 140/*******************************************************************************
154 * 141 *
155 * FUNCTION: acpi_ut_create_generic_state 142 * FUNCTION: acpi_ut_create_generic_state
@@ -163,17 +150,13 @@ acpi_ut_pop_generic_state (
163 * 150 *
164 ******************************************************************************/ 151 ******************************************************************************/
165 152
166union acpi_generic_state * 153union acpi_generic_state *acpi_ut_create_generic_state(void)
167acpi_ut_create_generic_state (
168 void)
169{ 154{
170 union acpi_generic_state *state; 155 union acpi_generic_state *state;
171
172 156
173 ACPI_FUNCTION_ENTRY (); 157 ACPI_FUNCTION_ENTRY();
174 158
175 159 state = acpi_os_acquire_object(acpi_gbl_state_cache);
176 state = acpi_os_acquire_object (acpi_gbl_state_cache);
177 if (state) { 160 if (state) {
178 /* Initialize */ 161 /* Initialize */
179 memset(state, 0, sizeof(union acpi_generic_state)); 162 memset(state, 0, sizeof(union acpi_generic_state));
@@ -183,7 +166,6 @@ acpi_ut_create_generic_state (
183 return (state); 166 return (state);
184} 167}
185 168
186
187/******************************************************************************* 169/*******************************************************************************
188 * 170 *
189 * FUNCTION: acpi_ut_create_thread_state 171 * FUNCTION: acpi_ut_create_thread_state
@@ -197,32 +179,27 @@ acpi_ut_create_generic_state (
197 * 179 *
198 ******************************************************************************/ 180 ******************************************************************************/
199 181
200struct acpi_thread_state * 182struct acpi_thread_state *acpi_ut_create_thread_state(void)
201acpi_ut_create_thread_state (
202 void)
203{ 183{
204 union acpi_generic_state *state; 184 union acpi_generic_state *state;
205
206
207 ACPI_FUNCTION_TRACE ("ut_create_thread_state");
208 185
186 ACPI_FUNCTION_TRACE("ut_create_thread_state");
209 187
210 /* Create the generic state object */ 188 /* Create the generic state object */
211 189
212 state = acpi_ut_create_generic_state (); 190 state = acpi_ut_create_generic_state();
213 if (!state) { 191 if (!state) {
214 return_PTR (NULL); 192 return_PTR(NULL);
215 } 193 }
216 194
217 /* Init fields specific to the update struct */ 195 /* Init fields specific to the update struct */
218 196
219 state->common.data_type = ACPI_DESC_TYPE_STATE_THREAD; 197 state->common.data_type = ACPI_DESC_TYPE_STATE_THREAD;
220 state->thread.thread_id = acpi_os_get_thread_id (); 198 state->thread.thread_id = acpi_os_get_thread_id();
221 199
222 return_PTR ((struct acpi_thread_state *) state); 200 return_PTR((struct acpi_thread_state *)state);
223} 201}
224 202
225
226/******************************************************************************* 203/*******************************************************************************
227 * 204 *
228 * FUNCTION: acpi_ut_create_update_state 205 * FUNCTION: acpi_ut_create_update_state
@@ -238,34 +215,29 @@ acpi_ut_create_thread_state (
238 * 215 *
239 ******************************************************************************/ 216 ******************************************************************************/
240 217
241union acpi_generic_state * 218union acpi_generic_state *acpi_ut_create_update_state(union acpi_operand_object
242acpi_ut_create_update_state ( 219 *object, u16 action)
243 union acpi_operand_object *object,
244 u16 action)
245{ 220{
246 union acpi_generic_state *state; 221 union acpi_generic_state *state;
247
248
249 ACPI_FUNCTION_TRACE_PTR ("ut_create_update_state", object);
250 222
223 ACPI_FUNCTION_TRACE_PTR("ut_create_update_state", object);
251 224
252 /* Create the generic state object */ 225 /* Create the generic state object */
253 226
254 state = acpi_ut_create_generic_state (); 227 state = acpi_ut_create_generic_state();
255 if (!state) { 228 if (!state) {
256 return_PTR (NULL); 229 return_PTR(NULL);
257 } 230 }
258 231
259 /* Init fields specific to the update struct */ 232 /* Init fields specific to the update struct */
260 233
261 state->common.data_type = ACPI_DESC_TYPE_STATE_UPDATE; 234 state->common.data_type = ACPI_DESC_TYPE_STATE_UPDATE;
262 state->update.object = object; 235 state->update.object = object;
263 state->update.value = action; 236 state->update.value = action;
264 237
265 return_PTR (state); 238 return_PTR(state);
266} 239}
267 240
268
269/******************************************************************************* 241/*******************************************************************************
270 * 242 *
271 * FUNCTION: acpi_ut_create_pkg_state 243 * FUNCTION: acpi_ut_create_pkg_state
@@ -279,37 +251,32 @@ acpi_ut_create_update_state (
279 * 251 *
280 ******************************************************************************/ 252 ******************************************************************************/
281 253
282union acpi_generic_state * 254union acpi_generic_state *acpi_ut_create_pkg_state(void *internal_object,
283acpi_ut_create_pkg_state ( 255 void *external_object,
284 void *internal_object, 256 u16 index)
285 void *external_object,
286 u16 index)
287{ 257{
288 union acpi_generic_state *state; 258 union acpi_generic_state *state;
289
290
291 ACPI_FUNCTION_TRACE_PTR ("ut_create_pkg_state", internal_object);
292 259
260 ACPI_FUNCTION_TRACE_PTR("ut_create_pkg_state", internal_object);
293 261
294 /* Create the generic state object */ 262 /* Create the generic state object */
295 263
296 state = acpi_ut_create_generic_state (); 264 state = acpi_ut_create_generic_state();
297 if (!state) { 265 if (!state) {
298 return_PTR (NULL); 266 return_PTR(NULL);
299 } 267 }
300 268
301 /* Init fields specific to the update struct */ 269 /* Init fields specific to the update struct */
302 270
303 state->common.data_type = ACPI_DESC_TYPE_STATE_PACKAGE; 271 state->common.data_type = ACPI_DESC_TYPE_STATE_PACKAGE;
304 state->pkg.source_object = (union acpi_operand_object *) internal_object; 272 state->pkg.source_object = (union acpi_operand_object *)internal_object;
305 state->pkg.dest_object = external_object; 273 state->pkg.dest_object = external_object;
306 state->pkg.index = index; 274 state->pkg.index = index;
307 state->pkg.num_packages = 1; 275 state->pkg.num_packages = 1;
308 276
309 return_PTR (state); 277 return_PTR(state);
310} 278}
311 279
312
313/******************************************************************************* 280/*******************************************************************************
314 * 281 *
315 * FUNCTION: acpi_ut_create_control_state 282 * FUNCTION: acpi_ut_create_control_state
@@ -323,32 +290,27 @@ acpi_ut_create_pkg_state (
323 * 290 *
324 ******************************************************************************/ 291 ******************************************************************************/
325 292
326union acpi_generic_state * 293union acpi_generic_state *acpi_ut_create_control_state(void)
327acpi_ut_create_control_state (
328 void)
329{ 294{
330 union acpi_generic_state *state; 295 union acpi_generic_state *state;
331
332
333 ACPI_FUNCTION_TRACE ("ut_create_control_state");
334 296
297 ACPI_FUNCTION_TRACE("ut_create_control_state");
335 298
336 /* Create the generic state object */ 299 /* Create the generic state object */
337 300
338 state = acpi_ut_create_generic_state (); 301 state = acpi_ut_create_generic_state();
339 if (!state) { 302 if (!state) {
340 return_PTR (NULL); 303 return_PTR(NULL);
341 } 304 }
342 305
343 /* Init fields specific to the control struct */ 306 /* Init fields specific to the control struct */
344 307
345 state->common.data_type = ACPI_DESC_TYPE_STATE_CONTROL; 308 state->common.data_type = ACPI_DESC_TYPE_STATE_CONTROL;
346 state->common.state = ACPI_CONTROL_CONDITIONAL_EXECUTING; 309 state->common.state = ACPI_CONTROL_CONDITIONAL_EXECUTING;
347 310
348 return_PTR (state); 311 return_PTR(state);
349} 312}
350 313
351
352/******************************************************************************* 314/*******************************************************************************
353 * 315 *
354 * FUNCTION: acpi_ut_delete_generic_state 316 * FUNCTION: acpi_ut_delete_generic_state
@@ -362,15 +324,10 @@ acpi_ut_create_control_state (
362 * 324 *
363 ******************************************************************************/ 325 ******************************************************************************/
364 326
365void 327void acpi_ut_delete_generic_state(union acpi_generic_state *state)
366acpi_ut_delete_generic_state (
367 union acpi_generic_state *state)
368{ 328{
369 ACPI_FUNCTION_TRACE ("ut_delete_generic_state"); 329 ACPI_FUNCTION_TRACE("ut_delete_generic_state");
370 330
371 331 (void)acpi_os_release_object(acpi_gbl_state_cache, state);
372 (void) acpi_os_release_object (acpi_gbl_state_cache, state);
373 return_VOID; 332 return_VOID;
374} 333}
375
376
diff --git a/drivers/acpi/utilities/utxface.c b/drivers/acpi/utilities/utxface.c
index 850da6817423..f06bd5e5e9d1 100644
--- a/drivers/acpi/utilities/utxface.c
+++ b/drivers/acpi/utilities/utxface.c
@@ -49,8 +49,7 @@
49#include <acpi/acdebug.h> 49#include <acpi/acdebug.h>
50 50
51#define _COMPONENT ACPI_UTILITIES 51#define _COMPONENT ACPI_UTILITIES
52 ACPI_MODULE_NAME ("utxface") 52ACPI_MODULE_NAME("utxface")
53
54 53
55/******************************************************************************* 54/*******************************************************************************
56 * 55 *
@@ -64,60 +63,54 @@
64 * called, so any early initialization belongs here. 63 * called, so any early initialization belongs here.
65 * 64 *
66 ******************************************************************************/ 65 ******************************************************************************/
67 66acpi_status acpi_initialize_subsystem(void)
68acpi_status
69acpi_initialize_subsystem (
70 void)
71{ 67{
72 acpi_status status; 68 acpi_status status;
73
74 69
75 ACPI_FUNCTION_TRACE ("acpi_initialize_subsystem"); 70 ACPI_FUNCTION_TRACE("acpi_initialize_subsystem");
76 71
77 72 ACPI_DEBUG_EXEC(acpi_ut_init_stack_ptr_trace());
78 ACPI_DEBUG_EXEC (acpi_ut_init_stack_ptr_trace ());
79 73
80 /* Initialize the OS-Dependent layer */ 74 /* Initialize the OS-Dependent layer */
81 75
82 status = acpi_os_initialize (); 76 status = acpi_os_initialize();
83 if (ACPI_FAILURE (status)) { 77 if (ACPI_FAILURE(status)) {
84 ACPI_REPORT_ERROR (("OSD failed to initialize, %s\n", 78 ACPI_REPORT_ERROR(("OSD failed to initialize, %s\n",
85 acpi_format_exception (status))); 79 acpi_format_exception(status)));
86 return_ACPI_STATUS (status); 80 return_ACPI_STATUS(status);
87 } 81 }
88 82
89 /* Initialize all globals used by the subsystem */ 83 /* Initialize all globals used by the subsystem */
90 84
91 acpi_ut_init_globals (); 85 acpi_ut_init_globals();
92 86
93 /* Create the default mutex objects */ 87 /* Create the default mutex objects */
94 88
95 status = acpi_ut_mutex_initialize (); 89 status = acpi_ut_mutex_initialize();
96 if (ACPI_FAILURE (status)) { 90 if (ACPI_FAILURE(status)) {
97 ACPI_REPORT_ERROR (("Global mutex creation failure, %s\n", 91 ACPI_REPORT_ERROR(("Global mutex creation failure, %s\n",
98 acpi_format_exception (status))); 92 acpi_format_exception(status)));
99 return_ACPI_STATUS (status); 93 return_ACPI_STATUS(status);
100 } 94 }
101 95
102 /* 96 /*
103 * Initialize the namespace manager and 97 * Initialize the namespace manager and
104 * the root of the namespace tree 98 * the root of the namespace tree
105 */ 99 */
106 status = acpi_ns_root_initialize (); 100 status = acpi_ns_root_initialize();
107 if (ACPI_FAILURE (status)) { 101 if (ACPI_FAILURE(status)) {
108 ACPI_REPORT_ERROR (("Namespace initialization failure, %s\n", 102 ACPI_REPORT_ERROR(("Namespace initialization failure, %s\n",
109 acpi_format_exception (status))); 103 acpi_format_exception(status)));
110 return_ACPI_STATUS (status); 104 return_ACPI_STATUS(status);
111 } 105 }
112 106
113 /* If configured, initialize the AML debugger */ 107 /* If configured, initialize the AML debugger */
114 108
115 ACPI_DEBUGGER_EXEC (status = acpi_db_initialize ()); 109 ACPI_DEBUGGER_EXEC(status = acpi_db_initialize());
116 110
117 return_ACPI_STATUS (status); 111 return_ACPI_STATUS(status);
118} 112}
119 113
120
121/******************************************************************************* 114/*******************************************************************************
122 * 115 *
123 * FUNCTION: acpi_enable_subsystem 116 * FUNCTION: acpi_enable_subsystem
@@ -131,41 +124,39 @@ acpi_initialize_subsystem (
131 * 124 *
132 ******************************************************************************/ 125 ******************************************************************************/
133 126
134acpi_status 127acpi_status acpi_enable_subsystem(u32 flags)
135acpi_enable_subsystem (
136 u32 flags)
137{ 128{
138 acpi_status status = AE_OK; 129 acpi_status status = AE_OK;
139
140
141 ACPI_FUNCTION_TRACE ("acpi_enable_subsystem");
142 130
131 ACPI_FUNCTION_TRACE("acpi_enable_subsystem");
143 132
144 /* 133 /*
145 * We must initialize the hardware before we can enable ACPI. 134 * We must initialize the hardware before we can enable ACPI.
146 * The values from the FADT are validated here. 135 * The values from the FADT are validated here.
147 */ 136 */
148 if (!(flags & ACPI_NO_HARDWARE_INIT)) { 137 if (!(flags & ACPI_NO_HARDWARE_INIT)) {
149 ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, 138 ACPI_DEBUG_PRINT((ACPI_DB_EXEC,
150 "[Init] Initializing ACPI hardware\n")); 139 "[Init] Initializing ACPI hardware\n"));
151 140
152 status = acpi_hw_initialize (); 141 status = acpi_hw_initialize();
153 if (ACPI_FAILURE (status)) { 142 if (ACPI_FAILURE(status)) {
154 return_ACPI_STATUS (status); 143 return_ACPI_STATUS(status);
155 } 144 }
156 } 145 }
157 146
158 /* Enable ACPI mode */ 147 /* Enable ACPI mode */
159 148
160 if (!(flags & ACPI_NO_ACPI_ENABLE)) { 149 if (!(flags & ACPI_NO_ACPI_ENABLE)) {
161 ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "[Init] Going into ACPI mode\n")); 150 ACPI_DEBUG_PRINT((ACPI_DB_EXEC,
151 "[Init] Going into ACPI mode\n"));
162 152
163 acpi_gbl_original_mode = acpi_hw_get_mode(); 153 acpi_gbl_original_mode = acpi_hw_get_mode();
164 154
165 status = acpi_enable (); 155 status = acpi_enable();
166 if (ACPI_FAILURE (status)) { 156 if (ACPI_FAILURE(status)) {
167 ACPI_DEBUG_PRINT ((ACPI_DB_WARN, "acpi_enable failed.\n")); 157 ACPI_DEBUG_PRINT((ACPI_DB_WARN,
168 return_ACPI_STATUS (status); 158 "acpi_enable failed.\n"));
159 return_ACPI_STATUS(status);
169 } 160 }
170 } 161 }
171 162
@@ -175,12 +166,12 @@ acpi_enable_subsystem (
175 * install_address_space_handler interface. 166 * install_address_space_handler interface.
176 */ 167 */
177 if (!(flags & ACPI_NO_ADDRESS_SPACE_INIT)) { 168 if (!(flags & ACPI_NO_ADDRESS_SPACE_INIT)) {
178 ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, 169 ACPI_DEBUG_PRINT((ACPI_DB_EXEC,
179 "[Init] Installing default address space handlers\n")); 170 "[Init] Installing default address space handlers\n"));
180 171
181 status = acpi_ev_install_region_handlers (); 172 status = acpi_ev_install_region_handlers();
182 if (ACPI_FAILURE (status)) { 173 if (ACPI_FAILURE(status)) {
183 return_ACPI_STATUS (status); 174 return_ACPI_STATUS(status);
184 } 175 }
185 } 176 }
186 177
@@ -193,28 +184,28 @@ acpi_enable_subsystem (
193 * execution! 184 * execution!
194 */ 185 */
195 if (!(flags & ACPI_NO_EVENT_INIT)) { 186 if (!(flags & ACPI_NO_EVENT_INIT)) {
196 ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, 187 ACPI_DEBUG_PRINT((ACPI_DB_EXEC,
197 "[Init] Initializing ACPI events\n")); 188 "[Init] Initializing ACPI events\n"));
198 189
199 status = acpi_ev_initialize_events (); 190 status = acpi_ev_initialize_events();
200 if (ACPI_FAILURE (status)) { 191 if (ACPI_FAILURE(status)) {
201 return_ACPI_STATUS (status); 192 return_ACPI_STATUS(status);
202 } 193 }
203 } 194 }
204 195
205 /* Install the SCI handler and Global Lock handler */ 196 /* Install the SCI handler and Global Lock handler */
206 197
207 if (!(flags & ACPI_NO_HANDLER_INIT)) { 198 if (!(flags & ACPI_NO_HANDLER_INIT)) {
208 ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, 199 ACPI_DEBUG_PRINT((ACPI_DB_EXEC,
209 "[Init] Installing SCI/GL handlers\n")); 200 "[Init] Installing SCI/GL handlers\n"));
210 201
211 status = acpi_ev_install_xrupt_handlers (); 202 status = acpi_ev_install_xrupt_handlers();
212 if (ACPI_FAILURE (status)) { 203 if (ACPI_FAILURE(status)) {
213 return_ACPI_STATUS (status); 204 return_ACPI_STATUS(status);
214 } 205 }
215 } 206 }
216 207
217 return_ACPI_STATUS (status); 208 return_ACPI_STATUS(status);
218} 209}
219 210
220/******************************************************************************* 211/*******************************************************************************
@@ -230,15 +221,11 @@ acpi_enable_subsystem (
230 * 221 *
231 ******************************************************************************/ 222 ******************************************************************************/
232 223
233acpi_status 224acpi_status acpi_initialize_objects(u32 flags)
234acpi_initialize_objects (
235 u32 flags)
236{ 225{
237 acpi_status status = AE_OK; 226 acpi_status status = AE_OK;
238
239
240 ACPI_FUNCTION_TRACE ("acpi_initialize_objects");
241 227
228 ACPI_FUNCTION_TRACE("acpi_initialize_objects");
242 229
243 /* 230 /*
244 * Run all _REG methods 231 * Run all _REG methods
@@ -248,12 +235,12 @@ acpi_initialize_objects (
248 * contain executable AML (see call to acpi_ns_initialize_objects below). 235 * contain executable AML (see call to acpi_ns_initialize_objects below).
249 */ 236 */
250 if (!(flags & ACPI_NO_ADDRESS_SPACE_INIT)) { 237 if (!(flags & ACPI_NO_ADDRESS_SPACE_INIT)) {
251 ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, 238 ACPI_DEBUG_PRINT((ACPI_DB_EXEC,
252 "[Init] Executing _REG op_region methods\n")); 239 "[Init] Executing _REG op_region methods\n"));
253 240
254 status = acpi_ev_initialize_op_regions (); 241 status = acpi_ev_initialize_op_regions();
255 if (ACPI_FAILURE (status)) { 242 if (ACPI_FAILURE(status)) {
256 return_ACPI_STATUS (status); 243 return_ACPI_STATUS(status);
257 } 244 }
258 } 245 }
259 246
@@ -263,12 +250,12 @@ acpi_initialize_objects (
263 * objects: operation_regions, buffer_fields, Buffers, and Packages. 250 * objects: operation_regions, buffer_fields, Buffers, and Packages.
264 */ 251 */
265 if (!(flags & ACPI_NO_OBJECT_INIT)) { 252 if (!(flags & ACPI_NO_OBJECT_INIT)) {
266 ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, 253 ACPI_DEBUG_PRINT((ACPI_DB_EXEC,
267 "[Init] Completing Initialization of ACPI Objects\n")); 254 "[Init] Completing Initialization of ACPI Objects\n"));
268 255
269 status = acpi_ns_initialize_objects (); 256 status = acpi_ns_initialize_objects();
270 if (ACPI_FAILURE (status)) { 257 if (ACPI_FAILURE(status)) {
271 return_ACPI_STATUS (status); 258 return_ACPI_STATUS(status);
272 } 259 }
273 } 260 }
274 261
@@ -277,12 +264,12 @@ acpi_initialize_objects (
277 * This runs the _STA and _INI methods. 264 * This runs the _STA and _INI methods.
278 */ 265 */
279 if (!(flags & ACPI_NO_DEVICE_INIT)) { 266 if (!(flags & ACPI_NO_DEVICE_INIT)) {
280 ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, 267 ACPI_DEBUG_PRINT((ACPI_DB_EXEC,
281 "[Init] Initializing ACPI Devices\n")); 268 "[Init] Initializing ACPI Devices\n"));
282 269
283 status = acpi_ns_initialize_devices (); 270 status = acpi_ns_initialize_devices();
284 if (ACPI_FAILURE (status)) { 271 if (ACPI_FAILURE(status)) {
285 return_ACPI_STATUS (status); 272 return_ACPI_STATUS(status);
286 } 273 }
287 } 274 }
288 275
@@ -291,13 +278,12 @@ acpi_initialize_objects (
291 * the table load filled them up more than they will be at runtime -- 278 * the table load filled them up more than they will be at runtime --
292 * thus wasting non-paged memory. 279 * thus wasting non-paged memory.
293 */ 280 */
294 status = acpi_purge_cached_objects (); 281 status = acpi_purge_cached_objects();
295 282
296 acpi_gbl_startup_flags |= ACPI_INITIALIZED_OK; 283 acpi_gbl_startup_flags |= ACPI_INITIALIZED_OK;
297 return_ACPI_STATUS (status); 284 return_ACPI_STATUS(status);
298} 285}
299 286
300
301/******************************************************************************* 287/*******************************************************************************
302 * 288 *
303 * FUNCTION: acpi_terminate 289 * FUNCTION: acpi_terminate
@@ -310,15 +296,11 @@ acpi_initialize_objects (
310 * 296 *
311 ******************************************************************************/ 297 ******************************************************************************/
312 298
313acpi_status 299acpi_status acpi_terminate(void)
314acpi_terminate (
315 void)
316{ 300{
317 acpi_status status; 301 acpi_status status;
318
319
320 ACPI_FUNCTION_TRACE ("acpi_terminate");
321 302
303 ACPI_FUNCTION_TRACE("acpi_terminate");
322 304
323 /* Terminate the AML Debugger if present */ 305 /* Terminate the AML Debugger if present */
324 306
@@ -326,28 +308,25 @@ acpi_terminate (
326 308
327 /* Shutdown and free all resources */ 309 /* Shutdown and free all resources */
328 310
329 acpi_ut_subsystem_shutdown (); 311 acpi_ut_subsystem_shutdown();
330
331 312
332 /* Free the mutex objects */ 313 /* Free the mutex objects */
333 314
334 acpi_ut_mutex_terminate (); 315 acpi_ut_mutex_terminate();
335
336 316
337#ifdef ACPI_DEBUGGER 317#ifdef ACPI_DEBUGGER
338 318
339 /* Shut down the debugger */ 319 /* Shut down the debugger */
340 320
341 acpi_db_terminate (); 321 acpi_db_terminate();
342#endif 322#endif
343 323
344 /* Now we can shutdown the OS-dependent layer */ 324 /* Now we can shutdown the OS-dependent layer */
345 325
346 status = acpi_os_terminate (); 326 status = acpi_os_terminate();
347 return_ACPI_STATUS (status); 327 return_ACPI_STATUS(status);
348} 328}
349 329
350
351#ifdef ACPI_FUTURE_USAGE 330#ifdef ACPI_FUTURE_USAGE
352/******************************************************************************* 331/*******************************************************************************
353 * 332 *
@@ -363,20 +342,16 @@ acpi_terminate (
363 * 342 *
364 ******************************************************************************/ 343 ******************************************************************************/
365 344
366acpi_status 345acpi_status acpi_subsystem_status(void)
367acpi_subsystem_status (
368 void)
369{ 346{
370 347
371 if (acpi_gbl_startup_flags & ACPI_INITIALIZED_OK) { 348 if (acpi_gbl_startup_flags & ACPI_INITIALIZED_OK) {
372 return (AE_OK); 349 return (AE_OK);
373 } 350 } else {
374 else {
375 return (AE_ERROR); 351 return (AE_ERROR);
376 } 352 }
377} 353}
378 354
379
380/******************************************************************************* 355/*******************************************************************************
381 * 356 *
382 * FUNCTION: acpi_get_system_info 357 * FUNCTION: acpi_get_system_info
@@ -395,64 +370,60 @@ acpi_subsystem_status (
395 * 370 *
396 ******************************************************************************/ 371 ******************************************************************************/
397 372
398acpi_status 373acpi_status acpi_get_system_info(struct acpi_buffer * out_buffer)
399acpi_get_system_info (
400 struct acpi_buffer *out_buffer)
401{ 374{
402 struct acpi_system_info *info_ptr; 375 struct acpi_system_info *info_ptr;
403 acpi_status status; 376 acpi_status status;
404 u32 i; 377 u32 i;
405
406
407 ACPI_FUNCTION_TRACE ("acpi_get_system_info");
408 378
379 ACPI_FUNCTION_TRACE("acpi_get_system_info");
409 380
410 /* Parameter validation */ 381 /* Parameter validation */
411 382
412 status = acpi_ut_validate_buffer (out_buffer); 383 status = acpi_ut_validate_buffer(out_buffer);
413 if (ACPI_FAILURE (status)) { 384 if (ACPI_FAILURE(status)) {
414 return_ACPI_STATUS (status); 385 return_ACPI_STATUS(status);
415 } 386 }
416 387
417 /* Validate/Allocate/Clear caller buffer */ 388 /* Validate/Allocate/Clear caller buffer */
418 389
419 status = acpi_ut_initialize_buffer (out_buffer, sizeof (struct acpi_system_info)); 390 status =
420 if (ACPI_FAILURE (status)) { 391 acpi_ut_initialize_buffer(out_buffer,
421 return_ACPI_STATUS (status); 392 sizeof(struct acpi_system_info));
393 if (ACPI_FAILURE(status)) {
394 return_ACPI_STATUS(status);
422 } 395 }
423 396
424 /* 397 /*
425 * Populate the return buffer 398 * Populate the return buffer
426 */ 399 */
427 info_ptr = (struct acpi_system_info *) out_buffer->pointer; 400 info_ptr = (struct acpi_system_info *)out_buffer->pointer;
428 401
429 info_ptr->acpi_ca_version = ACPI_CA_VERSION; 402 info_ptr->acpi_ca_version = ACPI_CA_VERSION;
430 403
431 /* System flags (ACPI capabilities) */ 404 /* System flags (ACPI capabilities) */
432 405
433 info_ptr->flags = ACPI_SYS_MODE_ACPI; 406 info_ptr->flags = ACPI_SYS_MODE_ACPI;
434 407
435 /* Timer resolution - 24 or 32 bits */ 408 /* Timer resolution - 24 or 32 bits */
436 409
437 if (!acpi_gbl_FADT) { 410 if (!acpi_gbl_FADT) {
438 info_ptr->timer_resolution = 0; 411 info_ptr->timer_resolution = 0;
439 } 412 } else if (acpi_gbl_FADT->tmr_val_ext == 0) {
440 else if (acpi_gbl_FADT->tmr_val_ext == 0) {
441 info_ptr->timer_resolution = 24; 413 info_ptr->timer_resolution = 24;
442 } 414 } else {
443 else {
444 info_ptr->timer_resolution = 32; 415 info_ptr->timer_resolution = 32;
445 } 416 }
446 417
447 /* Clear the reserved fields */ 418 /* Clear the reserved fields */
448 419
449 info_ptr->reserved1 = 0; 420 info_ptr->reserved1 = 0;
450 info_ptr->reserved2 = 0; 421 info_ptr->reserved2 = 0;
451 422
452 /* Current debug levels */ 423 /* Current debug levels */
453 424
454 info_ptr->debug_layer = acpi_dbg_layer; 425 info_ptr->debug_layer = acpi_dbg_layer;
455 info_ptr->debug_level = acpi_dbg_level; 426 info_ptr->debug_level = acpi_dbg_level;
456 427
457 /* Current status of the ACPI tables, per table type */ 428 /* Current status of the ACPI tables, per table type */
458 429
@@ -461,10 +432,10 @@ acpi_get_system_info (
461 info_ptr->table_info[i].count = acpi_gbl_table_lists[i].count; 432 info_ptr->table_info[i].count = acpi_gbl_table_lists[i].count;
462 } 433 }
463 434
464 return_ACPI_STATUS (AE_OK); 435 return_ACPI_STATUS(AE_OK);
465} 436}
466EXPORT_SYMBOL(acpi_get_system_info);
467 437
438EXPORT_SYMBOL(acpi_get_system_info);
468 439
469/***************************************************************************** 440/*****************************************************************************
470 * 441 *
@@ -482,9 +453,7 @@ EXPORT_SYMBOL(acpi_get_system_info);
482 ****************************************************************************/ 453 ****************************************************************************/
483 454
484acpi_status 455acpi_status
485acpi_install_initialization_handler ( 456acpi_install_initialization_handler(acpi_init_handler handler, u32 function)
486 acpi_init_handler handler,
487 u32 function)
488{ 457{
489 458
490 if (!handler) { 459 if (!handler) {
@@ -499,7 +468,7 @@ acpi_install_initialization_handler (
499 return AE_OK; 468 return AE_OK;
500} 469}
501 470
502#endif /* ACPI_FUTURE_USAGE */ 471#endif /* ACPI_FUTURE_USAGE */
503 472
504/***************************************************************************** 473/*****************************************************************************
505 * 474 *
@@ -513,15 +482,13 @@ acpi_install_initialization_handler (
513 * 482 *
514 ****************************************************************************/ 483 ****************************************************************************/
515 484
516acpi_status 485acpi_status acpi_purge_cached_objects(void)
517acpi_purge_cached_objects (
518 void)
519{ 486{
520 ACPI_FUNCTION_TRACE ("acpi_purge_cached_objects"); 487 ACPI_FUNCTION_TRACE("acpi_purge_cached_objects");
521 488
522 (void) acpi_os_purge_cache (acpi_gbl_state_cache); 489 (void)acpi_os_purge_cache(acpi_gbl_state_cache);
523 (void) acpi_os_purge_cache (acpi_gbl_operand_cache); 490 (void)acpi_os_purge_cache(acpi_gbl_operand_cache);
524 (void) acpi_os_purge_cache (acpi_gbl_ps_node_cache); 491 (void)acpi_os_purge_cache(acpi_gbl_ps_node_cache);
525 (void) acpi_os_purge_cache (acpi_gbl_ps_node_ext_cache); 492 (void)acpi_os_purge_cache(acpi_gbl_ps_node_ext_cache);
526 return_ACPI_STATUS (AE_OK); 493 return_ACPI_STATUS(AE_OK);
527} 494}