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