aboutsummaryrefslogtreecommitdiffstats
path: root/drivers
diff options
context:
space:
mode:
authorBob Moore <robert.moore@intel.com>2006-03-17 16:44:00 -0500
committerLen Brown <len.brown@intel.com>2006-06-14 01:22:20 -0400
commit61686124f47d7c4b78610346c5f8f9d8a6d46bb5 (patch)
tree6fd91b2c1749907e58ef136107e53d634d7978c4 /drivers
parent144c87b4e03759214c362d267e01c2905f1ab095 (diff)
[ACPI] ACPICA 20060317
Implemented the use of a cache object for all internal namespace nodes. Since there are about 1000 static nodes in a typical system, this will decrease memory use for cache implementations that minimize per-allocation overhead (such as a slab allocator.) Removed the reference count mechanism for internal namespace nodes, since it was deemed unnecessary. This reduces the size of each namespace node by about 5%-10% on all platforms. Nodes are now 20 bytes for the 32-bit case, and 32 bytes for the 64-bit case. Optimized several internal data structures to reduce object size on 64-bit platforms by packing data within the 64-bit alignment. This includes the frequently used ACPI_OPERAND_OBJECT, of which there can be ~1000 static instances corresponding to the namespace objects. Added two new strings for the predefined _OSI method: "Windows 2001.1 SP1" and "Windows 2006". Split the allocation tracking mechanism out to a separate file, from utalloc.c to uttrack.c. This mechanism appears to be only useful for application-level code. Kernels may wish to not include uttrack.c in distributions. Removed all remnants of the obsolete ACPI_REPORT_* macros and the associated code. (These macros have been replaced by the ACPI_ERROR and ACPI_WARNING macros.) Signed-off-by: Bob Moore <robert.moore@intel.com> Signed-off-by: Len Brown <len.brown@intel.com>
Diffstat (limited to 'drivers')
-rw-r--r--drivers/acpi/bus.c4
-rw-r--r--drivers/acpi/dispatcher/dsmthdat.c12
-rw-r--r--drivers/acpi/dispatcher/dswscope.c2
-rw-r--r--drivers/acpi/dispatcher/dswstate.c12
-rw-r--r--drivers/acpi/events/evgpeblk.c2
-rw-r--r--drivers/acpi/events/evmisc.c3
-rw-r--r--drivers/acpi/events/evregion.c15
-rw-r--r--drivers/acpi/executer/excreate.c7
-rw-r--r--drivers/acpi/executer/exdump.c2
-rw-r--r--drivers/acpi/namespace/nsalloc.c104
-rw-r--r--drivers/acpi/namespace/nsutils.c4
-rw-r--r--drivers/acpi/osl.c5
-rw-r--r--drivers/acpi/parser/psscope.c12
-rw-r--r--drivers/acpi/parser/psutils.c2
-rw-r--r--drivers/acpi/resources/rscalc.c2
-rw-r--r--drivers/acpi/resources/rscreate.c7
-rw-r--r--drivers/acpi/resources/rslist.c110
-rw-r--r--drivers/acpi/resources/rsxface.c4
-rw-r--r--drivers/acpi/utilities/utalloc.c590
-rw-r--r--drivers/acpi/utilities/utcache.c6
-rw-r--r--drivers/acpi/utilities/utdelete.c3
-rw-r--r--drivers/acpi/utilities/utglobal.c8
-rw-r--r--drivers/acpi/utilities/utmisc.c33
-rw-r--r--drivers/acpi/utilities/utresrc.c150
-rw-r--r--drivers/acpi/utilities/utstate.c10
25 files changed, 245 insertions, 864 deletions
diff --git a/drivers/acpi/bus.c b/drivers/acpi/bus.c
index 606f8733a776..9c4ac0191f64 100644
--- a/drivers/acpi/bus.c
+++ b/drivers/acpi/bus.c
@@ -596,6 +596,8 @@ void __init acpi_early_init(void)
596 if (acpi_disabled) 596 if (acpi_disabled)
597 return_VOID; 597 return_VOID;
598 598
599 printk(KERN_INFO PREFIX "Core revision %08x\n", ACPI_CA_VERSION);
600
599 /* enable workarounds, unless strict ACPI spec. compliance */ 601 /* enable workarounds, unless strict ACPI spec. compliance */
600 if (!acpi_strict) 602 if (!acpi_strict)
601 acpi_gbl_enable_interpreter_slack = TRUE; 603 acpi_gbl_enable_interpreter_slack = TRUE;
@@ -743,8 +745,6 @@ static int __init acpi_init(void)
743 745
744 ACPI_FUNCTION_TRACE("acpi_init"); 746 ACPI_FUNCTION_TRACE("acpi_init");
745 747
746 printk(KERN_INFO PREFIX "Subsystem revision %08x\n", ACPI_CA_VERSION);
747
748 if (acpi_disabled) { 748 if (acpi_disabled) {
749 printk(KERN_INFO PREFIX "Interpreter disabled.\n"); 749 printk(KERN_INFO PREFIX "Interpreter disabled.\n");
750 return_VALUE(-ENODEV); 750 return_VALUE(-ENODEV);
diff --git a/drivers/acpi/dispatcher/dsmthdat.c b/drivers/acpi/dispatcher/dsmthdat.c
index 2ed48439835d..ce4de18f1229 100644
--- a/drivers/acpi/dispatcher/dsmthdat.c
+++ b/drivers/acpi/dispatcher/dsmthdat.c
@@ -100,10 +100,10 @@ void acpi_ds_method_data_init(struct acpi_walk_state *walk_state)
100 ACPI_MOVE_32_TO_32(&walk_state->arguments[i].name, 100 ACPI_MOVE_32_TO_32(&walk_state->arguments[i].name,
101 NAMEOF_ARG_NTE); 101 NAMEOF_ARG_NTE);
102 walk_state->arguments[i].name.integer |= (i << 24); 102 walk_state->arguments[i].name.integer |= (i << 24);
103 walk_state->arguments[i].descriptor = ACPI_DESC_TYPE_NAMED; 103 walk_state->arguments[i].descriptor_type = ACPI_DESC_TYPE_NAMED;
104 walk_state->arguments[i].type = ACPI_TYPE_ANY; 104 walk_state->arguments[i].type = ACPI_TYPE_ANY;
105 walk_state->arguments[i].flags = ANOBJ_END_OF_PEER_LIST | 105 walk_state->arguments[i].flags =
106 ANOBJ_METHOD_ARG; 106 ANOBJ_END_OF_PEER_LIST | ANOBJ_METHOD_ARG;
107 } 107 }
108 108
109 /* Init the method locals */ 109 /* Init the method locals */
@@ -113,11 +113,11 @@ void acpi_ds_method_data_init(struct acpi_walk_state *walk_state)
113 NAMEOF_LOCAL_NTE); 113 NAMEOF_LOCAL_NTE);
114 114
115 walk_state->local_variables[i].name.integer |= (i << 24); 115 walk_state->local_variables[i].name.integer |= (i << 24);
116 walk_state->local_variables[i].descriptor = 116 walk_state->local_variables[i].descriptor_type =
117 ACPI_DESC_TYPE_NAMED; 117 ACPI_DESC_TYPE_NAMED;
118 walk_state->local_variables[i].type = ACPI_TYPE_ANY; 118 walk_state->local_variables[i].type = ACPI_TYPE_ANY;
119 walk_state->local_variables[i].flags = ANOBJ_END_OF_PEER_LIST | 119 walk_state->local_variables[i].flags =
120 ANOBJ_METHOD_LOCAL; 120 ANOBJ_END_OF_PEER_LIST | ANOBJ_METHOD_LOCAL;
121 } 121 }
122 122
123 return_VOID; 123 return_VOID;
diff --git a/drivers/acpi/dispatcher/dswscope.c b/drivers/acpi/dispatcher/dswscope.c
index e2954fff8c5e..3cd6895ed2c3 100644
--- a/drivers/acpi/dispatcher/dswscope.c
+++ b/drivers/acpi/dispatcher/dswscope.c
@@ -128,7 +128,7 @@ acpi_ds_scope_stack_push(struct acpi_namespace_node *node,
128 128
129 /* Init new scope object */ 129 /* Init new scope object */
130 130
131 scope_info->common.data_type = ACPI_DESC_TYPE_STATE_WSCOPE; 131 scope_info->common.descriptor_type = ACPI_DESC_TYPE_STATE_WSCOPE;
132 scope_info->scope.node = node; 132 scope_info->scope.node = node;
133 scope_info->common.value = (u16) type; 133 scope_info->common.value = (u16) type;
134 134
diff --git a/drivers/acpi/dispatcher/dswstate.c b/drivers/acpi/dispatcher/dswstate.c
index d2846ffc9773..4840eae47d34 100644
--- a/drivers/acpi/dispatcher/dswstate.c
+++ b/drivers/acpi/dispatcher/dswstate.c
@@ -337,7 +337,7 @@ acpi_status acpi_ds_result_stack_push(struct acpi_walk_state * walk_state)
337 return (AE_NO_MEMORY); 337 return (AE_NO_MEMORY);
338 } 338 }
339 339
340 state->common.data_type = ACPI_DESC_TYPE_STATE_RESULT; 340 state->common.descriptor_type = ACPI_DESC_TYPE_STATE_RESULT;
341 acpi_ut_push_generic_state(&walk_state->results, state); 341 acpi_ut_push_generic_state(&walk_state->results, state);
342 342
343 ACPI_DEBUG_PRINT((ACPI_DB_EXEC, "Results=%p State=%p\n", 343 ACPI_DEBUG_PRINT((ACPI_DB_EXEC, "Results=%p State=%p\n",
@@ -620,7 +620,7 @@ struct acpi_walk_state *acpi_ds_pop_walk_state(struct acpi_thread_state *thread)
620 * 620 *
621 * PARAMETERS: owner_id - ID for object creation 621 * PARAMETERS: owner_id - ID for object creation
622 * Origin - Starting point for this walk 622 * Origin - Starting point for this walk
623 * mth_desc - Method object 623 * method_desc - Method object
624 * Thread - Current thread state 624 * Thread - Current thread state
625 * 625 *
626 * RETURN: Pointer to the new walk state. 626 * RETURN: Pointer to the new walk state.
@@ -634,7 +634,7 @@ struct acpi_walk_state *acpi_ds_create_walk_state(acpi_owner_id owner_id,
634 union acpi_parse_object 634 union acpi_parse_object
635 *origin, 635 *origin,
636 union acpi_operand_object 636 union acpi_operand_object
637 *mth_desc, 637 *method_desc,
638 struct acpi_thread_state 638 struct acpi_thread_state
639 *thread) 639 *thread)
640{ 640{
@@ -648,10 +648,10 @@ struct acpi_walk_state *acpi_ds_create_walk_state(acpi_owner_id owner_id,
648 return_PTR(NULL); 648 return_PTR(NULL);
649 } 649 }
650 650
651 walk_state->data_type = ACPI_DESC_TYPE_WALK; 651 walk_state->descriptor_type = ACPI_DESC_TYPE_WALK;
652 walk_state->method_desc = method_desc;
652 walk_state->owner_id = owner_id; 653 walk_state->owner_id = owner_id;
653 walk_state->origin = origin; 654 walk_state->origin = origin;
654 walk_state->method_desc = mth_desc;
655 walk_state->thread = thread; 655 walk_state->thread = thread;
656 656
657 walk_state->parser_state.start_op = origin; 657 walk_state->parser_state.start_op = origin;
@@ -819,7 +819,7 @@ void acpi_ds_delete_walk_state(struct acpi_walk_state *walk_state)
819 return; 819 return;
820 } 820 }
821 821
822 if (walk_state->data_type != ACPI_DESC_TYPE_WALK) { 822 if (walk_state->descriptor_type != ACPI_DESC_TYPE_WALK) {
823 ACPI_ERROR((AE_INFO, "%p is not a valid walk state", 823 ACPI_ERROR((AE_INFO, "%p is not a valid walk state",
824 walk_state)); 824 walk_state));
825 return; 825 return;
diff --git a/drivers/acpi/events/evgpeblk.c b/drivers/acpi/events/evgpeblk.c
index e8e72986f0d6..4e90c1f837c3 100644
--- a/drivers/acpi/events/evgpeblk.c
+++ b/drivers/acpi/events/evgpeblk.c
@@ -131,7 +131,7 @@ u8 acpi_ev_valid_gpe_event(struct acpi_gpe_event_info *gpe_event_info)
131 * 131 *
132 ******************************************************************************/ 132 ******************************************************************************/
133 133
134acpi_status acpi_ev_walk_gpe_list(ACPI_GPE_CALLBACK gpe_walk_callback) 134acpi_status acpi_ev_walk_gpe_list(acpi_gpe_callback gpe_walk_callback)
135{ 135{
136 struct acpi_gpe_block_info *gpe_block; 136 struct acpi_gpe_block_info *gpe_block;
137 struct acpi_gpe_xrupt_info *gpe_xrupt_info; 137 struct acpi_gpe_xrupt_info *gpe_xrupt_info;
diff --git a/drivers/acpi/events/evmisc.c b/drivers/acpi/events/evmisc.c
index 334407239f2f..b216b3229e27 100644
--- a/drivers/acpi/events/evmisc.c
+++ b/drivers/acpi/events/evmisc.c
@@ -185,7 +185,8 @@ acpi_ev_queue_notify_request(struct acpi_namespace_node * node,
185 return (AE_NO_MEMORY); 185 return (AE_NO_MEMORY);
186 } 186 }
187 187
188 notify_info->common.data_type = ACPI_DESC_TYPE_STATE_NOTIFY; 188 notify_info->common.descriptor_type =
189 ACPI_DESC_TYPE_STATE_NOTIFY;
189 notify_info->notify.node = node; 190 notify_info->notify.node = node;
190 notify_info->notify.value = (u16) notify_value; 191 notify_info->notify.value = (u16) notify_value;
191 notify_info->notify.handler_obj = handler_obj; 192 notify_info->notify.handler_obj = handler_obj;
diff --git a/drivers/acpi/events/evregion.c b/drivers/acpi/events/evregion.c
index 2b900ef05fa9..0337ad222b26 100644
--- a/drivers/acpi/events/evregion.c
+++ b/drivers/acpi/events/evregion.c
@@ -250,7 +250,6 @@ acpi_ev_execute_reg_method(union acpi_operand_object *region_obj, u32 function)
250 250
251 cleanup: 251 cleanup:
252 acpi_ut_remove_reference(params[0]); 252 acpi_ut_remove_reference(params[0]);
253
254 return_ACPI_STATUS(status); 253 return_ACPI_STATUS(status);
255} 254}
256 255
@@ -389,9 +388,8 @@ acpi_ev_address_space_dispatch(union acpi_operand_object *region_obj,
389 acpi_ut_get_region_name(region_obj->region. 388 acpi_ut_get_region_name(region_obj->region.
390 space_id))); 389 space_id)));
391 390
392 if (! 391 if (!(handler_desc->address_space.handler_flags &
393 (handler_desc->address_space. 392 ACPI_ADDR_HANDLER_DEFAULT_INSTALLED)) {
394 hflags & ACPI_ADDR_HANDLER_DEFAULT_INSTALLED)) {
395 /* 393 /*
396 * For handlers other than the default (supplied) handlers, we must 394 * For handlers other than the default (supplied) handlers, we must
397 * exit the interpreter because the handler *might* block -- we don't 395 * exit the interpreter because the handler *might* block -- we don't
@@ -412,9 +410,8 @@ acpi_ev_address_space_dispatch(union acpi_operand_object *region_obj,
412 space_id))); 410 space_id)));
413 } 411 }
414 412
415 if (! 413 if (!(handler_desc->address_space.handler_flags &
416 (handler_desc->address_space. 414 ACPI_ADDR_HANDLER_DEFAULT_INSTALLED)) {
417 hflags & ACPI_ADDR_HANDLER_DEFAULT_INSTALLED)) {
418 /* 415 /*
419 * We just returned from a non-default handler, we must re-enter the 416 * We just returned from a non-default handler, we must re-enter the
420 * interpreter 417 * interpreter
@@ -772,7 +769,7 @@ acpi_ev_install_space_handler(struct acpi_namespace_node * node,
772 union acpi_operand_object *handler_obj; 769 union acpi_operand_object *handler_obj;
773 acpi_status status; 770 acpi_status status;
774 acpi_object_type type; 771 acpi_object_type type;
775 u16 flags = 0; 772 u8 flags = 0;
776 773
777 ACPI_FUNCTION_TRACE("ev_install_space_handler"); 774 ACPI_FUNCTION_TRACE("ev_install_space_handler");
778 775
@@ -930,7 +927,7 @@ acpi_ev_install_space_handler(struct acpi_namespace_node * node,
930 /* Init handler obj */ 927 /* Init handler obj */
931 928
932 handler_obj->address_space.space_id = (u8) space_id; 929 handler_obj->address_space.space_id = (u8) space_id;
933 handler_obj->address_space.hflags = flags; 930 handler_obj->address_space.handler_flags = flags;
934 handler_obj->address_space.region_list = NULL; 931 handler_obj->address_space.region_list = NULL;
935 handler_obj->address_space.node = node; 932 handler_obj->address_space.node = node;
936 handler_obj->address_space.handler = handler; 933 handler_obj->address_space.handler = handler;
diff --git a/drivers/acpi/executer/excreate.c b/drivers/acpi/executer/excreate.c
index 680575402835..763e132da4c6 100644
--- a/drivers/acpi/executer/excreate.c
+++ b/drivers/acpi/executer/excreate.c
@@ -243,8 +243,9 @@ acpi_status acpi_ex_create_mutex(struct acpi_walk_state *walk_state)
243 obj_desc->mutex.node = 243 obj_desc->mutex.node =
244 (struct acpi_namespace_node *)walk_state->operands[0]; 244 (struct acpi_namespace_node *)walk_state->operands[0];
245 245
246 status = acpi_ns_attach_object(obj_desc->mutex.node, 246 status =
247 obj_desc, ACPI_TYPE_MUTEX); 247 acpi_ns_attach_object(obj_desc->mutex.node, obj_desc,
248 ACPI_TYPE_MUTEX);
248 249
249 cleanup: 250 cleanup:
250 /* 251 /*
@@ -464,9 +465,9 @@ acpi_status acpi_ex_create_processor(struct acpi_walk_state *walk_state)
464 /* Initialize the processor object from the operands */ 465 /* Initialize the processor object from the operands */
465 466
466 obj_desc->processor.proc_id = (u8) operand[1]->integer.value; 467 obj_desc->processor.proc_id = (u8) operand[1]->integer.value;
468 obj_desc->processor.length = (u8) operand[3]->integer.value;
467 obj_desc->processor.address = 469 obj_desc->processor.address =
468 (acpi_io_address) operand[2]->integer.value; 470 (acpi_io_address) operand[2]->integer.value;
469 obj_desc->processor.length = (u8) operand[3]->integer.value;
470 471
471 /* Install the processor object in the parent Node */ 472 /* Install the processor object in the parent Node */
472 473
diff --git a/drivers/acpi/executer/exdump.c b/drivers/acpi/executer/exdump.c
index 502293c35afa..56db58b8e23a 100644
--- a/drivers/acpi/executer/exdump.c
+++ b/drivers/acpi/executer/exdump.c
@@ -267,8 +267,6 @@ static struct acpi_exdump_info acpi_ex_dump_node[6] = {
267 {ACPI_EXD_INIT, ACPI_EXD_TABLE_SIZE(acpi_ex_dump_node), NULL}, 267 {ACPI_EXD_INIT, ACPI_EXD_TABLE_SIZE(acpi_ex_dump_node), NULL},
268 {ACPI_EXD_UINT8, ACPI_EXD_NSOFFSET(flags), "Flags"}, 268 {ACPI_EXD_UINT8, ACPI_EXD_NSOFFSET(flags), "Flags"},
269 {ACPI_EXD_UINT8, ACPI_EXD_NSOFFSET(owner_id), "Owner Id"}, 269 {ACPI_EXD_UINT8, ACPI_EXD_NSOFFSET(owner_id), "Owner Id"},
270 {ACPI_EXD_UINT16, ACPI_EXD_NSOFFSET(reference_count),
271 "Reference Count"},
272 {ACPI_EXD_POINTER, ACPI_EXD_NSOFFSET(child), "Child List"}, 270 {ACPI_EXD_POINTER, ACPI_EXD_NSOFFSET(child), "Child List"},
273 {ACPI_EXD_POINTER, ACPI_EXD_NSOFFSET(peer), "Next Peer"} 271 {ACPI_EXD_POINTER, ACPI_EXD_NSOFFSET(peer), "Next Peer"}
274}; 272};
diff --git a/drivers/acpi/namespace/nsalloc.c b/drivers/acpi/namespace/nsalloc.c
index acd4b6732ac4..8b921c96d6a5 100644
--- a/drivers/acpi/namespace/nsalloc.c
+++ b/drivers/acpi/namespace/nsalloc.c
@@ -47,9 +47,6 @@
47#define _COMPONENT ACPI_NAMESPACE 47#define _COMPONENT ACPI_NAMESPACE
48ACPI_MODULE_NAME("nsalloc") 48ACPI_MODULE_NAME("nsalloc")
49 49
50/* Local prototypes */
51static void acpi_ns_remove_reference(struct acpi_namespace_node *node);
52
53/******************************************************************************* 50/*******************************************************************************
54 * 51 *
55 * FUNCTION: acpi_ns_create_node 52 * FUNCTION: acpi_ns_create_node
@@ -61,14 +58,13 @@ static void acpi_ns_remove_reference(struct acpi_namespace_node *node);
61 * DESCRIPTION: Create a namespace node 58 * DESCRIPTION: Create a namespace node
62 * 59 *
63 ******************************************************************************/ 60 ******************************************************************************/
64
65struct acpi_namespace_node *acpi_ns_create_node(u32 name) 61struct acpi_namespace_node *acpi_ns_create_node(u32 name)
66{ 62{
67 struct acpi_namespace_node *node; 63 struct acpi_namespace_node *node;
68 64
69 ACPI_FUNCTION_TRACE("ns_create_node"); 65 ACPI_FUNCTION_TRACE("ns_create_node");
70 66
71 node = ACPI_ALLOCATE_ZEROED(sizeof(struct acpi_namespace_node)); 67 node = acpi_os_acquire_object(acpi_gbl_namespace_cache);
72 if (!node) { 68 if (!node) {
73 return_PTR(NULL); 69 return_PTR(NULL);
74 } 70 }
@@ -76,9 +72,7 @@ struct acpi_namespace_node *acpi_ns_create_node(u32 name)
76 ACPI_MEM_TRACKING(acpi_gbl_ns_node_list->total_allocated++); 72 ACPI_MEM_TRACKING(acpi_gbl_ns_node_list->total_allocated++);
77 73
78 node->name.integer = name; 74 node->name.integer = name;
79 node->reference_count = 1;
80 ACPI_SET_DESCRIPTOR_TYPE(node, ACPI_DESC_TYPE_NAMED); 75 ACPI_SET_DESCRIPTOR_TYPE(node, ACPI_DESC_TYPE_NAMED);
81
82 return_PTR(node); 76 return_PTR(node);
83} 77}
84 78
@@ -139,10 +133,10 @@ void acpi_ns_delete_node(struct acpi_namespace_node *node)
139 ACPI_MEM_TRACKING(acpi_gbl_ns_node_list->total_freed++); 133 ACPI_MEM_TRACKING(acpi_gbl_ns_node_list->total_freed++);
140 134
141 /* 135 /*
142 * Detach an object if there is one then delete the node 136 * Detach an object if there is one, then delete the node
143 */ 137 */
144 acpi_ns_detach_object(node); 138 acpi_ns_detach_object(node);
145 ACPI_FREE(node); 139 (void)acpi_os_release_object(acpi_gbl_namespace_cache, node);
146 return_VOID; 140 return_VOID;
147} 141}
148 142
@@ -217,16 +211,6 @@ void acpi_ns_install_node(struct acpi_walk_state *walk_state, struct acpi_namesp
217 acpi_ut_get_node_name(parent_node), 211 acpi_ut_get_node_name(parent_node),
218 acpi_ut_get_type_name(parent_node->type), 212 acpi_ut_get_type_name(parent_node->type),
219 parent_node)); 213 parent_node));
220
221 /*
222 * Increment the reference count(s) of all parents up to
223 * the root!
224 */
225 while ((node = acpi_ns_get_parent_node(node)) != NULL) {
226 node->reference_count++;
227 }
228
229 return_VOID;
230} 214}
231 215
232/******************************************************************************* 216/*******************************************************************************
@@ -246,7 +230,6 @@ void acpi_ns_delete_children(struct acpi_namespace_node *parent_node)
246{ 230{
247 struct acpi_namespace_node *child_node; 231 struct acpi_namespace_node *child_node;
248 struct acpi_namespace_node *next_node; 232 struct acpi_namespace_node *next_node;
249 struct acpi_namespace_node *node;
250 u8 flags; 233 u8 flags;
251 234
252 ACPI_FUNCTION_TRACE_PTR("ns_delete_children", parent_node); 235 ACPI_FUNCTION_TRACE_PTR("ns_delete_children", parent_node);
@@ -292,26 +275,10 @@ void acpi_ns_delete_children(struct acpi_namespace_node *parent_node)
292 */ 275 */
293 acpi_ns_detach_object(child_node); 276 acpi_ns_detach_object(child_node);
294 277
295 /*
296 * Decrement the reference count(s) of all parents up to
297 * the root! (counts were incremented when the node was created)
298 */
299 node = child_node;
300 while ((node = acpi_ns_get_parent_node(node)) != NULL) {
301 node->reference_count--;
302 }
303
304 /* There should be only one reference remaining on this node */
305
306 if (child_node->reference_count != 1) {
307 ACPI_WARNING((AE_INFO,
308 "Existing references (%d) on node being deleted (%p)",
309 child_node->reference_count, child_node));
310 }
311
312 /* Now we can delete the node */ 278 /* Now we can delete the node */
313 279
314 ACPI_FREE(child_node); 280 (void)acpi_os_release_object(acpi_gbl_namespace_cache,
281 child_node);
315 282
316 /* And move on to the next child in the list */ 283 /* And move on to the next child in the list */
317 284
@@ -358,8 +325,9 @@ void acpi_ns_delete_namespace_subtree(struct acpi_namespace_node *parent_node)
358 325
359 /* Get the next node in this scope (NULL if none) */ 326 /* Get the next node in this scope (NULL if none) */
360 327
361 child_node = acpi_ns_get_next_node(ACPI_TYPE_ANY, parent_node, 328 child_node =
362 child_node); 329 acpi_ns_get_next_node(ACPI_TYPE_ANY, parent_node,
330 child_node);
363 if (child_node) { 331 if (child_node) {
364 332
365 /* Found a child node - detach any attached object */ 333 /* Found a child node - detach any attached object */
@@ -406,57 +374,6 @@ void acpi_ns_delete_namespace_subtree(struct acpi_namespace_node *parent_node)
406 374
407/******************************************************************************* 375/*******************************************************************************
408 * 376 *
409 * FUNCTION: acpi_ns_remove_reference
410 *
411 * PARAMETERS: Node - Named node whose reference count is to be
412 * decremented
413 *
414 * RETURN: None.
415 *
416 * DESCRIPTION: Remove a Node reference. Decrements the reference count
417 * of all parent Nodes up to the root. Any node along
418 * the way that reaches zero references is freed.
419 *
420 ******************************************************************************/
421
422static void acpi_ns_remove_reference(struct acpi_namespace_node *node)
423{
424 struct acpi_namespace_node *parent_node;
425 struct acpi_namespace_node *this_node;
426
427 ACPI_FUNCTION_ENTRY();
428
429 /*
430 * Decrement the reference count(s) of this node and all
431 * nodes up to the root, Delete anything with zero remaining references.
432 */
433 this_node = node;
434 while (this_node) {
435
436 /* Prepare to move up to parent */
437
438 parent_node = acpi_ns_get_parent_node(this_node);
439
440 /* Decrement the reference count on this node */
441
442 this_node->reference_count--;
443
444 /* Delete the node if no more references */
445
446 if (!this_node->reference_count) {
447
448 /* Delete all children and delete the node */
449
450 acpi_ns_delete_children(this_node);
451 acpi_ns_delete_node(this_node);
452 }
453
454 this_node = parent_node;
455 }
456}
457
458/*******************************************************************************
459 *
460 * FUNCTION: acpi_ns_delete_namespace_by_owner 377 * FUNCTION: acpi_ns_delete_namespace_by_owner
461 * 378 *
462 * PARAMETERS: owner_id - All nodes with this owner will be deleted 379 * PARAMETERS: owner_id - All nodes with this owner will be deleted
@@ -482,9 +399,9 @@ void acpi_ns_delete_namespace_by_owner(acpi_owner_id owner_id)
482 return_VOID; 399 return_VOID;
483 } 400 }
484 401
402 deletion_node = NULL;
485 parent_node = acpi_gbl_root_node; 403 parent_node = acpi_gbl_root_node;
486 child_node = NULL; 404 child_node = NULL;
487 deletion_node = NULL;
488 level = 1; 405 level = 1;
489 406
490 /* 407 /*
@@ -501,7 +418,8 @@ void acpi_ns_delete_namespace_by_owner(acpi_owner_id owner_id)
501 child_node); 418 child_node);
502 419
503 if (deletion_node) { 420 if (deletion_node) {
504 acpi_ns_remove_reference(deletion_node); 421 acpi_ns_delete_children(deletion_node);
422 acpi_ns_delete_node(deletion_node);
505 deletion_node = NULL; 423 deletion_node = NULL;
506 } 424 }
507 425
diff --git a/drivers/acpi/namespace/nsutils.c b/drivers/acpi/namespace/nsutils.c
index 586014ecf24b..9fa38ffc2e6e 100644
--- a/drivers/acpi/namespace/nsutils.c
+++ b/drivers/acpi/namespace/nsutils.c
@@ -81,7 +81,7 @@ acpi_ns_report_error(char *module_name,
81 u32 bad_name; 81 u32 bad_name;
82 char *name = NULL; 82 char *name = NULL;
83 83
84 acpi_ut_report_error(module_name, line_number); 84 acpi_os_printf("ACPI Error (%s-%04d): ", module_name, line_number);
85 85
86 if (lookup_status == AE_BAD_CHARACTER) { 86 if (lookup_status == AE_BAD_CHARACTER) {
87 87
@@ -139,7 +139,7 @@ acpi_ns_report_method_error(char *module_name,
139 acpi_status status; 139 acpi_status status;
140 struct acpi_namespace_node *node = prefix_node; 140 struct acpi_namespace_node *node = prefix_node;
141 141
142 acpi_ut_report_error(module_name, line_number); 142 acpi_os_printf("ACPI Error (%s-%04d): ", module_name, line_number);
143 143
144 if (path) { 144 if (path) {
145 status = acpi_ns_get_node_by_path(path, prefix_node, 145 status = acpi_ns_get_node_by_path(path, prefix_node,
diff --git a/drivers/acpi/osl.c b/drivers/acpi/osl.c
index 56d97f1d108f..006b31a56559 100644
--- a/drivers/acpi/osl.c
+++ b/drivers/acpi/osl.c
@@ -1126,14 +1126,13 @@ acpi_status acpi_os_release_object(acpi_cache_t * cache, void *object)
1126 * 1126 *
1127 * RETURN: Status 1127 * RETURN: Status
1128 * 1128 *
1129 * DESCRIPTION: Get an object from the specified cache. If cache is empty, 1129 * DESCRIPTION: Return a zero-filled object.
1130 * the object is allocated.
1131 * 1130 *
1132 ******************************************************************************/ 1131 ******************************************************************************/
1133 1132
1134void *acpi_os_acquire_object(acpi_cache_t * cache) 1133void *acpi_os_acquire_object(acpi_cache_t * cache)
1135{ 1134{
1136 void *object = kmem_cache_alloc(cache, GFP_KERNEL); 1135 void *object = kmem_cache_zalloc(cache, GFP_KERNEL);
1137 WARN_ON(!object); 1136 WARN_ON(!object);
1138 return object; 1137 return object;
1139} 1138}
diff --git a/drivers/acpi/parser/psscope.c b/drivers/acpi/parser/psscope.c
index edb7c9ba6ec2..9233a4044d6b 100644
--- a/drivers/acpi/parser/psscope.c
+++ b/drivers/acpi/parser/psscope.c
@@ -113,7 +113,7 @@ acpi_ps_init_scope(struct acpi_parse_state * parser_state,
113 return_ACPI_STATUS(AE_NO_MEMORY); 113 return_ACPI_STATUS(AE_NO_MEMORY);
114 } 114 }
115 115
116 scope->common.data_type = ACPI_DESC_TYPE_STATE_RPSCOPE; 116 scope->common.descriptor_type = ACPI_DESC_TYPE_STATE_RPSCOPE;
117 scope->parse_scope.op = root_op; 117 scope->parse_scope.op = root_op;
118 scope->parse_scope.arg_count = ACPI_VAR_ARGS; 118 scope->parse_scope.arg_count = ACPI_VAR_ARGS;
119 scope->parse_scope.arg_end = parser_state->aml_end; 119 scope->parse_scope.arg_end = parser_state->aml_end;
@@ -143,7 +143,7 @@ acpi_ps_init_scope(struct acpi_parse_state * parser_state,
143acpi_status 143acpi_status
144acpi_ps_push_scope(struct acpi_parse_state *parser_state, 144acpi_ps_push_scope(struct acpi_parse_state *parser_state,
145 union acpi_parse_object *op, 145 union acpi_parse_object *op,
146 u32 remaining_args, u32 arg_count) 146 u32 remaining_args, u8 arg_count)
147{ 147{
148 union acpi_generic_state *scope; 148 union acpi_generic_state *scope;
149 149
@@ -154,7 +154,7 @@ acpi_ps_push_scope(struct acpi_parse_state *parser_state,
154 return_ACPI_STATUS(AE_NO_MEMORY); 154 return_ACPI_STATUS(AE_NO_MEMORY);
155 } 155 }
156 156
157 scope->common.data_type = ACPI_DESC_TYPE_STATE_PSCOPE; 157 scope->common.descriptor_type = ACPI_DESC_TYPE_STATE_PSCOPE;
158 scope->parse_scope.op = op; 158 scope->parse_scope.op = op;
159 scope->parse_scope.arg_list = remaining_args; 159 scope->parse_scope.arg_list = remaining_args;
160 scope->parse_scope.arg_count = arg_count; 160 scope->parse_scope.arg_count = arg_count;
@@ -196,7 +196,7 @@ acpi_ps_push_scope(struct acpi_parse_state *parser_state,
196 196
197void 197void
198acpi_ps_pop_scope(struct acpi_parse_state *parser_state, 198acpi_ps_pop_scope(struct acpi_parse_state *parser_state,
199 union acpi_parse_object **op, u32 * arg_list, u32 * arg_count) 199 union acpi_parse_object **op, u32 * arg_list, u8 * arg_count)
200{ 200{
201 union acpi_generic_state *scope = parser_state->scope; 201 union acpi_generic_state *scope = parser_state->scope;
202 202
@@ -207,7 +207,7 @@ acpi_ps_pop_scope(struct acpi_parse_state *parser_state,
207 if (scope->common.next) { 207 if (scope->common.next) {
208 scope = acpi_ut_pop_generic_state(&parser_state->scope); 208 scope = acpi_ut_pop_generic_state(&parser_state->scope);
209 209
210 /* return to parsing previous op */ 210 /* Return to parsing previous op */
211 211
212 *op = scope->parse_scope.op; 212 *op = scope->parse_scope.op;
213 *arg_list = scope->parse_scope.arg_list; 213 *arg_list = scope->parse_scope.arg_list;
@@ -218,7 +218,7 @@ acpi_ps_pop_scope(struct acpi_parse_state *parser_state,
218 218
219 acpi_ut_delete_generic_state(scope); 219 acpi_ut_delete_generic_state(scope);
220 } else { 220 } else {
221 /* empty parse stack, prepare to fetch next opcode */ 221 /* Empty parse stack, prepare to fetch next opcode */
222 222
223 *op = NULL; 223 *op = NULL;
224 *arg_list = 0; 224 *arg_list = 0;
diff --git a/drivers/acpi/parser/psutils.c b/drivers/acpi/parser/psutils.c
index a4c33a4bfe35..43e3190583e3 100644
--- a/drivers/acpi/parser/psutils.c
+++ b/drivers/acpi/parser/psutils.c
@@ -89,7 +89,7 @@ void acpi_ps_init_op(union acpi_parse_object *op, u16 opcode)
89{ 89{
90 ACPI_FUNCTION_ENTRY(); 90 ACPI_FUNCTION_ENTRY();
91 91
92 op->common.data_type = ACPI_DESC_TYPE_PARSER; 92 op->common.descriptor_type = ACPI_DESC_TYPE_PARSER;
93 op->common.aml_opcode = opcode; 93 op->common.aml_opcode = opcode;
94 94
95 ACPI_DISASM_ONLY_MEMBERS(ACPI_STRNCPY(op->common.aml_op_name, 95 ACPI_DISASM_ONLY_MEMBERS(ACPI_STRNCPY(op->common.aml_op_name,
diff --git a/drivers/acpi/resources/rscalc.c b/drivers/acpi/resources/rscalc.c
index 8e406d992f3b..dd5caa2c8fdd 100644
--- a/drivers/acpi/resources/rscalc.c
+++ b/drivers/acpi/resources/rscalc.c
@@ -456,7 +456,7 @@ acpi_rs_get_list_length(u8 * aml_buffer,
456 *size_needed += buffer_size; 456 *size_needed += buffer_size;
457 457
458 ACPI_DEBUG_PRINT((ACPI_DB_RESOURCES, 458 ACPI_DEBUG_PRINT((ACPI_DB_RESOURCES,
459 "Type %.2X, Aml %.2X internal %.2X\n", 459 "Type %.2X, aml_length %.2X internal_length %.2X\n",
460 acpi_ut_get_resource_type(aml_buffer), 460 acpi_ut_get_resource_type(aml_buffer),
461 acpi_ut_get_descriptor_length(aml_buffer), 461 acpi_ut_get_descriptor_length(aml_buffer),
462 buffer_size)); 462 buffer_size));
diff --git a/drivers/acpi/resources/rscreate.c b/drivers/acpi/resources/rscreate.c
index 67c052af7bbe..01488cfc9bae 100644
--- a/drivers/acpi/resources/rscreate.c
+++ b/drivers/acpi/resources/rscreate.c
@@ -75,6 +75,7 @@ acpi_rs_create_resource_list(union acpi_operand_object *aml_buffer,
75 u8 *aml_start; 75 u8 *aml_start;
76 acpi_size list_size_needed = 0; 76 acpi_size list_size_needed = 0;
77 u32 aml_buffer_length; 77 u32 aml_buffer_length;
78 void *resource;
78 79
79 ACPI_FUNCTION_TRACE("rs_create_resource_list"); 80 ACPI_FUNCTION_TRACE("rs_create_resource_list");
80 81
@@ -107,8 +108,10 @@ acpi_rs_create_resource_list(union acpi_operand_object *aml_buffer,
107 108
108 /* Do the conversion */ 109 /* Do the conversion */
109 110
110 status = acpi_rs_convert_aml_to_resources(aml_start, aml_buffer_length, 111 resource = output_buffer->pointer;
111 output_buffer->pointer); 112 status = acpi_ut_walk_aml_resources(aml_start, aml_buffer_length,
113 acpi_rs_convert_aml_to_resources,
114 &resource);
112 if (ACPI_FAILURE(status)) { 115 if (ACPI_FAILURE(status)) {
113 return_ACPI_STATUS(status); 116 return_ACPI_STATUS(status);
114 } 117 }
diff --git a/drivers/acpi/resources/rslist.c b/drivers/acpi/resources/rslist.c
index 6f2d8de39523..50bbb19bf4ae 100644
--- a/drivers/acpi/resources/rslist.c
+++ b/drivers/acpi/resources/rslist.c
@@ -51,92 +51,60 @@ ACPI_MODULE_NAME("rslist")
51 * 51 *
52 * FUNCTION: acpi_rs_convert_aml_to_resources 52 * FUNCTION: acpi_rs_convert_aml_to_resources
53 * 53 *
54 * PARAMETERS: Aml - Pointer to the resource byte stream 54 * PARAMETERS: acpi_walk_aml_callback
55 * aml_length - Length of Aml 55 * resource_ptr - Pointer to the buffer that will
56 * output_buffer - Pointer to the buffer that will 56 * contain the output structures
57 * contain the output structures
58 * 57 *
59 * RETURN: Status 58 * RETURN: Status
60 * 59 *
61 * DESCRIPTION: Takes the resource byte stream and parses it, creating a 60 * DESCRIPTION: Convert an AML resource to an internal representation of the
62 * linked list of resources in the caller's output buffer 61 * resource that is aligned and easier to access.
63 * 62 *
64 ******************************************************************************/ 63 ******************************************************************************/
65acpi_status 64acpi_status
66acpi_rs_convert_aml_to_resources(u8 * aml, u32 aml_length, u8 * output_buffer) 65acpi_rs_convert_aml_to_resources(u8 * aml,
66 u32 length,
67 u32 offset,
68 u8 resource_index, void **resource_ptr)
67{ 69{
68 struct acpi_resource *resource = (void *)output_buffer; 70 struct acpi_resource *resource = *resource_ptr;
69 acpi_status status; 71 acpi_status status;
70 u8 resource_index;
71 u8 *end_aml;
72 72
73 ACPI_FUNCTION_TRACE("rs_convert_aml_to_resources"); 73 ACPI_FUNCTION_TRACE("rs_convert_aml_to_resources");
74 74
75 end_aml = aml + aml_length; 75 /*
76 76 * Check that the input buffer and all subsequent pointers into it
77 /* Loop until end-of-buffer or an end_tag is found */ 77 * are aligned on a native word boundary. Most important on IA64
78 78 */
79 while (aml < end_aml) { 79 if (ACPI_IS_MISALIGNED(resource)) {
80 /* 80 ACPI_WARNING((AE_INFO,
81 * Check that the input buffer and all subsequent pointers into it 81 "Misaligned resource pointer %p", resource));
82 * are aligned on a native word boundary. Most important on IA64 82 }
83 */
84 if (ACPI_IS_MISALIGNED(resource)) {
85 ACPI_WARNING((AE_INFO,
86 "Misaligned resource pointer %p",
87 resource));
88 }
89
90 /* Validate the Resource Type and Resource Length */
91
92 status = acpi_ut_validate_resource(aml, &resource_index);
93 if (ACPI_FAILURE(status)) {
94 return_ACPI_STATUS(status);
95 }
96
97 /* Convert the AML byte stream resource to a local resource struct */
98
99 status =
100 acpi_rs_convert_aml_to_resource(resource,
101 ACPI_CAST_PTR(union
102 aml_resource,
103 aml),
104 acpi_gbl_get_resource_dispatch
105 [resource_index]);
106 if (ACPI_FAILURE(status)) {
107 ACPI_EXCEPTION((AE_INFO, status,
108 "Could not convert AML resource (Type %X)",
109 *aml));
110 return_ACPI_STATUS(status);
111 }
112
113 ACPI_DEBUG_PRINT((ACPI_DB_RESOURCES,
114 "Type %.2X, Aml %.2X internal %.2X\n",
115 acpi_ut_get_resource_type(aml),
116 acpi_ut_get_descriptor_length(aml),
117 resource->length));
118
119 /* Normal exit on completion of an end_tag resource descriptor */
120
121 if (acpi_ut_get_resource_type(aml) ==
122 ACPI_RESOURCE_NAME_END_TAG) {
123 return_ACPI_STATUS(AE_OK);
124 }
125
126 /* Point to the next input AML resource */
127
128 aml += acpi_ut_get_descriptor_length(aml);
129
130 /* Point to the next structure in the output buffer */
131 83
132 resource = 84 /* Convert the AML byte stream resource to a local resource struct */
133 ACPI_ADD_PTR(struct acpi_resource, resource, 85
134 resource->length); 86 status =
87 acpi_rs_convert_aml_to_resource(resource,
88 ACPI_CAST_PTR(union aml_resource,
89 aml),
90 acpi_gbl_get_resource_dispatch
91 [resource_index]);
92 if (ACPI_FAILURE(status)) {
93 ACPI_EXCEPTION((AE_INFO, status,
94 "Could not convert AML resource (Type %X)",
95 *aml));
96 return_ACPI_STATUS(status);
135 } 97 }
136 98
137 /* Did not find an end_tag resource descriptor */ 99 ACPI_DEBUG_PRINT((ACPI_DB_RESOURCES,
100 "Type %.2X, aml_length %.2X internal_length %.2X\n",
101 acpi_ut_get_resource_type(aml), length,
102 resource->length));
138 103
139 return_ACPI_STATUS(AE_AML_NO_RESOURCE_END_TAG); 104 /* Point to the next structure in the output buffer */
105
106 *resource_ptr = ACPI_ADD_PTR(void, resource, resource->length);
107 return_ACPI_STATUS(AE_OK);
140} 108}
141 109
142/******************************************************************************* 110/*******************************************************************************
diff --git a/drivers/acpi/resources/rsxface.c b/drivers/acpi/resources/rsxface.c
index b3feebbd8ca2..1d00d285a5a3 100644
--- a/drivers/acpi/resources/rsxface.c
+++ b/drivers/acpi/resources/rsxface.c
@@ -242,7 +242,7 @@ ACPI_EXPORT_SYMBOL(acpi_get_possible_resources)
242acpi_status 242acpi_status
243acpi_walk_resources(acpi_handle device_handle, 243acpi_walk_resources(acpi_handle device_handle,
244 char *name, 244 char *name,
245 ACPI_WALK_RESOURCE_CALLBACK user_function, void *context) 245 acpi_walk_resource_callback user_function, void *context)
246{ 246{
247 acpi_status status; 247 acpi_status status;
248 struct acpi_buffer buffer; 248 struct acpi_buffer buffer;
@@ -469,7 +469,7 @@ ACPI_EXPORT_SYMBOL(acpi_get_vendor_resource)
469 * 469 *
470 * FUNCTION: acpi_rs_match_vendor_resource 470 * FUNCTION: acpi_rs_match_vendor_resource
471 * 471 *
472 * PARAMETERS: ACPI_WALK_RESOURCE_CALLBACK 472 * PARAMETERS: acpi_walk_resource_callback
473 * 473 *
474 * RETURN: Status 474 * RETURN: Status
475 * 475 *
diff --git a/drivers/acpi/utilities/utalloc.c b/drivers/acpi/utilities/utalloc.c
index 7b35eb84d058..3b29aecaaca5 100644
--- a/drivers/acpi/utilities/utalloc.c
+++ b/drivers/acpi/utilities/utalloc.c
@@ -46,24 +46,6 @@
46#define _COMPONENT ACPI_UTILITIES 46#define _COMPONENT ACPI_UTILITIES
47ACPI_MODULE_NAME("utalloc") 47ACPI_MODULE_NAME("utalloc")
48 48
49/* Local prototypes */
50#ifdef ACPI_DBG_TRACK_ALLOCATIONS
51static struct acpi_debug_mem_block *acpi_ut_find_allocation(void *allocation);
52
53static acpi_status
54acpi_ut_track_allocation(struct acpi_debug_mem_block *address,
55 acpi_size size,
56 u8 alloc_type, u32 component, char *module, u32 line);
57
58static acpi_status
59acpi_ut_remove_allocation(struct acpi_debug_mem_block *address,
60 u32 component, char *module, u32 line);
61
62static acpi_status
63acpi_ut_create_list(char *list_name,
64 u16 object_size, struct acpi_memory_list **return_cache);
65#endif
66
67/******************************************************************************* 49/*******************************************************************************
68 * 50 *
69 * FUNCTION: acpi_ut_create_caches 51 * FUNCTION: acpi_ut_create_caches
@@ -75,7 +57,6 @@ acpi_ut_create_list(char *list_name,
75 * DESCRIPTION: Create all local caches 57 * DESCRIPTION: Create all local caches
76 * 58 *
77 ******************************************************************************/ 59 ******************************************************************************/
78
79acpi_status acpi_ut_create_caches(void) 60acpi_status acpi_ut_create_caches(void)
80{ 61{
81 acpi_status status; 62 acpi_status status;
@@ -101,7 +82,16 @@ acpi_status acpi_ut_create_caches(void)
101 /* Object Caches, for frequently used objects */ 82 /* Object Caches, for frequently used objects */
102 83
103 status = 84 status =
104 acpi_os_create_cache("acpi_state", sizeof(union acpi_generic_state), 85 acpi_os_create_cache("Acpi-Namespace",
86 sizeof(struct acpi_namespace_node),
87 ACPI_MAX_NAMESPACE_CACHE_DEPTH,
88 &acpi_gbl_namespace_cache);
89 if (ACPI_FAILURE(status)) {
90 return (status);
91 }
92
93 status =
94 acpi_os_create_cache("Acpi-State", sizeof(union acpi_generic_state),
105 ACPI_MAX_STATE_CACHE_DEPTH, 95 ACPI_MAX_STATE_CACHE_DEPTH,
106 &acpi_gbl_state_cache); 96 &acpi_gbl_state_cache);
107 if (ACPI_FAILURE(status)) { 97 if (ACPI_FAILURE(status)) {
@@ -109,7 +99,7 @@ acpi_status acpi_ut_create_caches(void)
109 } 99 }
110 100
111 status = 101 status =
112 acpi_os_create_cache("acpi_parse", 102 acpi_os_create_cache("Acpi-Parse",
113 sizeof(struct acpi_parse_obj_common), 103 sizeof(struct acpi_parse_obj_common),
114 ACPI_MAX_PARSE_CACHE_DEPTH, 104 ACPI_MAX_PARSE_CACHE_DEPTH,
115 &acpi_gbl_ps_node_cache); 105 &acpi_gbl_ps_node_cache);
@@ -118,7 +108,7 @@ acpi_status acpi_ut_create_caches(void)
118 } 108 }
119 109
120 status = 110 status =
121 acpi_os_create_cache("acpi_parse_ext", 111 acpi_os_create_cache("Acpi-parse_ext",
122 sizeof(struct acpi_parse_obj_named), 112 sizeof(struct acpi_parse_obj_named),
123 ACPI_MAX_EXTPARSE_CACHE_DEPTH, 113 ACPI_MAX_EXTPARSE_CACHE_DEPTH,
124 &acpi_gbl_ps_node_ext_cache); 114 &acpi_gbl_ps_node_ext_cache);
@@ -127,7 +117,7 @@ acpi_status acpi_ut_create_caches(void)
127 } 117 }
128 118
129 status = 119 status =
130 acpi_os_create_cache("acpi_operand", 120 acpi_os_create_cache("Acpi-Operand",
131 sizeof(union acpi_operand_object), 121 sizeof(union acpi_operand_object),
132 ACPI_MAX_OBJECT_CACHE_DEPTH, 122 ACPI_MAX_OBJECT_CACHE_DEPTH,
133 &acpi_gbl_operand_cache); 123 &acpi_gbl_operand_cache);
@@ -153,6 +143,9 @@ acpi_status acpi_ut_create_caches(void)
153acpi_status acpi_ut_delete_caches(void) 143acpi_status acpi_ut_delete_caches(void)
154{ 144{
155 145
146 (void)acpi_os_delete_cache(acpi_gbl_namespace_cache);
147 acpi_gbl_namespace_cache = NULL;
148
156 (void)acpi_os_delete_cache(acpi_gbl_state_cache); 149 (void)acpi_os_delete_cache(acpi_gbl_state_cache);
157 acpi_gbl_state_cache = NULL; 150 acpi_gbl_state_cache = NULL;
158 151
@@ -288,7 +281,7 @@ acpi_ut_initialize_buffer(struct acpi_buffer * buffer,
288 * 281 *
289 * RETURN: Address of the allocated memory on success, NULL on failure. 282 * RETURN: Address of the allocated memory on success, NULL on failure.
290 * 283 *
291 * DESCRIPTION: The subsystem's equivalent of malloc. 284 * DESCRIPTION: Subsystem equivalent of malloc.
292 * 285 *
293 ******************************************************************************/ 286 ******************************************************************************/
294 287
@@ -301,8 +294,8 @@ void *acpi_ut_allocate(acpi_size size, u32 component, char *module, u32 line)
301 /* Check for an inadvertent size of zero bytes */ 294 /* Check for an inadvertent size of zero bytes */
302 295
303 if (!size) { 296 if (!size) {
304 ACPI_ERROR((module, line, 297 ACPI_WARNING((module, line,
305 "ut_allocate: Attempt to allocate zero bytes, allocating 1 byte")); 298 "Attempt to allocate zero bytes, allocating 1 byte"));
306 size = 1; 299 size = 1;
307 } 300 }
308 301
@@ -311,9 +304,8 @@ void *acpi_ut_allocate(acpi_size size, u32 component, char *module, u32 line)
311 304
312 /* Report allocation error */ 305 /* Report allocation error */
313 306
314 ACPI_ERROR((module, line, 307 ACPI_WARNING((module, line,
315 "ut_allocate: Could not allocate size %X", 308 "Could not allocate size %X", (u32) size));
316 (u32) size));
317 309
318 return_PTR(NULL); 310 return_PTR(NULL);
319 } 311 }
@@ -323,7 +315,7 @@ void *acpi_ut_allocate(acpi_size size, u32 component, char *module, u32 line)
323 315
324/******************************************************************************* 316/*******************************************************************************
325 * 317 *
326 * FUNCTION: acpi_ut_callocate 318 * FUNCTION: acpi_ut_allocate_zeroed
327 * 319 *
328 * PARAMETERS: Size - Size of the allocation 320 * PARAMETERS: Size - Size of the allocation
329 * Component - Component type of caller 321 * Component - Component type of caller
@@ -332,546 +324,24 @@ void *acpi_ut_allocate(acpi_size size, u32 component, char *module, u32 line)
332 * 324 *
333 * RETURN: Address of the allocated memory on success, NULL on failure. 325 * RETURN: Address of the allocated memory on success, NULL on failure.
334 * 326 *
335 * DESCRIPTION: Subsystem equivalent of calloc. 327 * DESCRIPTION: Subsystem equivalent of calloc. Allocate and zero memory.
336 * 328 *
337 ******************************************************************************/ 329 ******************************************************************************/
338 330
339void *acpi_ut_callocate(acpi_size size, u32 component, char *module, u32 line) 331void *acpi_ut_allocate_zeroed(acpi_size size,
332 u32 component, char *module, u32 line)
340{ 333{
341 void *allocation; 334 void *allocation;
342 335
343 ACPI_FUNCTION_TRACE_U32("ut_callocate", size);
344
345 /* Check for an inadvertent size of zero bytes */
346
347 if (!size) {
348 ACPI_ERROR((module, line,
349 "Attempt to allocate zero bytes, allocating 1 byte"));
350 size = 1;
351 }
352
353 allocation = acpi_os_allocate(size);
354 if (!allocation) {
355
356 /* Report allocation error */
357
358 ACPI_ERROR((module, line,
359 "Could not allocate size %X", (u32) size));
360 return_PTR(NULL);
361 }
362
363 /* Clear the memory block */
364
365 ACPI_MEMSET(allocation, 0, size);
366 return_PTR(allocation);
367}
368
369#ifdef ACPI_DBG_TRACK_ALLOCATIONS
370/*
371 * These procedures are used for tracking memory leaks in the subsystem, and
372 * they get compiled out when the ACPI_DBG_TRACK_ALLOCATIONS is not set.
373 *
374 * Each memory allocation is tracked via a doubly linked list. Each
375 * element contains the caller's component, module name, function name, and
376 * line number. acpi_ut_allocate and acpi_ut_callocate call
377 * acpi_ut_track_allocation to add an element to the list; deletion
378 * occurs in the body of acpi_ut_free.
379 */
380
381/*******************************************************************************
382 *
383 * FUNCTION: acpi_ut_create_list
384 *
385 * PARAMETERS: cache_name - Ascii name for the cache
386 * object_size - Size of each cached object
387 * return_cache - Where the new cache object is returned
388 *
389 * RETURN: Status
390 *
391 * DESCRIPTION: Create a local memory list for tracking purposed
392 *
393 ******************************************************************************/
394
395static acpi_status
396acpi_ut_create_list(char *list_name,
397 u16 object_size, struct acpi_memory_list **return_cache)
398{
399 struct acpi_memory_list *cache;
400
401 cache = acpi_os_allocate(sizeof(struct acpi_memory_list));
402 if (!cache) {
403 return (AE_NO_MEMORY);
404 }
405
406 ACPI_MEMSET(cache, 0, sizeof(struct acpi_memory_list));
407
408 cache->list_name = list_name;
409 cache->object_size = object_size;
410
411 *return_cache = cache;
412 return (AE_OK);
413}
414
415/*******************************************************************************
416 *
417 * FUNCTION: acpi_ut_allocate_and_track
418 *
419 * PARAMETERS: Size - Size of the allocation
420 * Component - Component type of caller
421 * Module - Source file name of caller
422 * Line - Line number of caller
423 *
424 * RETURN: Address of the allocated memory on success, NULL on failure.
425 *
426 * DESCRIPTION: The subsystem's equivalent of malloc.
427 *
428 ******************************************************************************/
429
430void *acpi_ut_allocate_and_track(acpi_size size,
431 u32 component, char *module, u32 line)
432{
433 struct acpi_debug_mem_block *allocation;
434 acpi_status status;
435
436 allocation =
437 acpi_ut_allocate(size + sizeof(struct acpi_debug_mem_header),
438 component, module, line);
439 if (!allocation) {
440 return (NULL);
441 }
442
443 status = acpi_ut_track_allocation(allocation, size,
444 ACPI_MEM_MALLOC, component, module,
445 line);
446 if (ACPI_FAILURE(status)) {
447 acpi_os_free(allocation);
448 return (NULL);
449 }
450
451 acpi_gbl_global_list->total_allocated++;
452 acpi_gbl_global_list->current_total_size += (u32) size;
453
454 return ((void *)&allocation->user_space);
455}
456
457/*******************************************************************************
458 *
459 * FUNCTION: acpi_ut_callocate_and_track
460 *
461 * PARAMETERS: Size - Size of the allocation
462 * Component - Component type of caller
463 * Module - Source file name of caller
464 * Line - Line number of caller
465 *
466 * RETURN: Address of the allocated memory on success, NULL on failure.
467 *
468 * DESCRIPTION: Subsystem equivalent of calloc.
469 *
470 ******************************************************************************/
471
472void *acpi_ut_callocate_and_track(acpi_size size,
473 u32 component, char *module, u32 line)
474{
475 struct acpi_debug_mem_block *allocation;
476 acpi_status status;
477
478 allocation =
479 acpi_ut_callocate(size + sizeof(struct acpi_debug_mem_header),
480 component, module, line);
481 if (!allocation) {
482
483 /* Report allocation error */
484
485 ACPI_ERROR((module, line,
486 "Could not allocate size %X", (u32) size));
487 return (NULL);
488 }
489
490 status = acpi_ut_track_allocation(allocation, size,
491 ACPI_MEM_CALLOC, component, module,
492 line);
493 if (ACPI_FAILURE(status)) {
494 acpi_os_free(allocation);
495 return (NULL);
496 }
497
498 acpi_gbl_global_list->total_allocated++;
499 acpi_gbl_global_list->current_total_size += (u32) size;
500
501 return ((void *)&allocation->user_space);
502}
503
504/*******************************************************************************
505 *
506 * FUNCTION: acpi_ut_free_and_track
507 *
508 * PARAMETERS: Allocation - Address of the memory to deallocate
509 * Component - Component type of caller
510 * Module - Source file name of caller
511 * Line - Line number of caller
512 *
513 * RETURN: None
514 *
515 * DESCRIPTION: Frees the memory at Allocation
516 *
517 ******************************************************************************/
518
519void
520acpi_ut_free_and_track(void *allocation, u32 component, char *module, u32 line)
521{
522 struct acpi_debug_mem_block *debug_block;
523 acpi_status status;
524
525 ACPI_FUNCTION_TRACE_PTR("ut_free", allocation);
526
527 if (NULL == allocation) {
528 ACPI_ERROR((module, line, "Attempt to delete a NULL address"));
529
530 return_VOID;
531 }
532
533 debug_block = ACPI_CAST_PTR(struct acpi_debug_mem_block,
534 (((char *)allocation) -
535 sizeof(struct acpi_debug_mem_header)));
536
537 acpi_gbl_global_list->total_freed++;
538 acpi_gbl_global_list->current_total_size -= debug_block->size;
539
540 status = acpi_ut_remove_allocation(debug_block,
541 component, module, line);
542 if (ACPI_FAILURE(status)) {
543 ACPI_EXCEPTION((AE_INFO, status, "Could not free memory"));
544 }
545
546 acpi_os_free(debug_block);
547 ACPI_DEBUG_PRINT((ACPI_DB_ALLOCATIONS, "%p freed\n", allocation));
548 return_VOID;
549}
550
551/*******************************************************************************
552 *
553 * FUNCTION: acpi_ut_find_allocation
554 *
555 * PARAMETERS: Allocation - Address of allocated memory
556 *
557 * RETURN: A list element if found; NULL otherwise.
558 *
559 * DESCRIPTION: Searches for an element in the global allocation tracking list.
560 *
561 ******************************************************************************/
562
563static struct acpi_debug_mem_block *acpi_ut_find_allocation(void *allocation)
564{
565 struct acpi_debug_mem_block *element;
566
567 ACPI_FUNCTION_ENTRY(); 336 ACPI_FUNCTION_ENTRY();
568 337
569 element = acpi_gbl_global_list->list_head; 338 allocation = acpi_ut_allocate(size, component, module, line);
570 339 if (allocation) {
571 /* Search for the address. */
572
573 while (element) {
574 if (element == allocation) {
575 return (element);
576 }
577
578 element = element->next;
579 }
580
581 return (NULL);
582}
583
584/*******************************************************************************
585 *
586 * FUNCTION: acpi_ut_track_allocation
587 *
588 * PARAMETERS: Allocation - Address of allocated memory
589 * Size - Size of the allocation
590 * alloc_type - MEM_MALLOC or MEM_CALLOC
591 * Component - Component type of caller
592 * Module - Source file name of caller
593 * Line - Line number of caller
594 *
595 * RETURN: None.
596 *
597 * DESCRIPTION: Inserts an element into the global allocation tracking list.
598 *
599 ******************************************************************************/
600
601static acpi_status
602acpi_ut_track_allocation(struct acpi_debug_mem_block *allocation,
603 acpi_size size,
604 u8 alloc_type, u32 component, char *module, u32 line)
605{
606 struct acpi_memory_list *mem_list;
607 struct acpi_debug_mem_block *element;
608 acpi_status status = AE_OK;
609
610 ACPI_FUNCTION_TRACE_PTR("ut_track_allocation", allocation);
611
612 mem_list = acpi_gbl_global_list;
613 status = acpi_ut_acquire_mutex(ACPI_MTX_MEMORY);
614 if (ACPI_FAILURE(status)) {
615 return_ACPI_STATUS(status);
616 }
617
618 /*
619 * Search list for this address to make sure it is not already on the list.
620 * This will catch several kinds of problems.
621 */
622 element = acpi_ut_find_allocation(allocation);
623 if (element) {
624 ACPI_ERROR((AE_INFO,
625 "ut_track_allocation: Allocation already present in list! (%p)",
626 allocation));
627 340
628 ACPI_ERROR((AE_INFO, "Element %p Address %p", 341 /* Clear the memory block */
629 element, allocation));
630 342
631 goto unlock_and_exit; 343 ACPI_MEMSET(allocation, 0, size);
632 } 344 }
633 345
634 /* Fill in the instance data. */ 346 return (allocation);
635
636 allocation->size = (u32) size;
637 allocation->alloc_type = alloc_type;
638 allocation->component = component;
639 allocation->line = line;
640
641 ACPI_STRNCPY(allocation->module, module, ACPI_MAX_MODULE_NAME);
642 allocation->module[ACPI_MAX_MODULE_NAME - 1] = 0;
643
644 /* Insert at list head */
645
646 if (mem_list->list_head) {
647 ((struct acpi_debug_mem_block *)(mem_list->list_head))->
648 previous = allocation;
649 }
650
651 allocation->next = mem_list->list_head;
652 allocation->previous = NULL;
653
654 mem_list->list_head = allocation;
655
656 unlock_and_exit:
657 status = acpi_ut_release_mutex(ACPI_MTX_MEMORY);
658 return_ACPI_STATUS(status);
659} 347}
660
661/*******************************************************************************
662 *
663 * FUNCTION: acpi_ut_remove_allocation
664 *
665 * PARAMETERS: Allocation - Address of allocated memory
666 * Component - Component type of caller
667 * Module - Source file name of caller
668 * Line - Line number of caller
669 *
670 * RETURN:
671 *
672 * DESCRIPTION: Deletes an element from the global allocation tracking list.
673 *
674 ******************************************************************************/
675
676static acpi_status
677acpi_ut_remove_allocation(struct acpi_debug_mem_block *allocation,
678 u32 component, char *module, u32 line)
679{
680 struct acpi_memory_list *mem_list;
681 acpi_status status;
682
683 ACPI_FUNCTION_TRACE("ut_remove_allocation");
684
685 mem_list = acpi_gbl_global_list;
686 if (NULL == mem_list->list_head) {
687
688 /* No allocations! */
689
690 ACPI_ERROR((module, line,
691 "Empty allocation list, nothing to free!"));
692
693 return_ACPI_STATUS(AE_OK);
694 }
695
696 status = acpi_ut_acquire_mutex(ACPI_MTX_MEMORY);
697 if (ACPI_FAILURE(status)) {
698 return_ACPI_STATUS(status);
699 }
700
701 /* Unlink */
702
703 if (allocation->previous) {
704 (allocation->previous)->next = allocation->next;
705 } else {
706 mem_list->list_head = allocation->next;
707 }
708
709 if (allocation->next) {
710 (allocation->next)->previous = allocation->previous;
711 }
712
713 /* Mark the segment as deleted */
714
715 ACPI_MEMSET(&allocation->user_space, 0xEA, allocation->size);
716
717 ACPI_DEBUG_PRINT((ACPI_DB_ALLOCATIONS, "Freeing size 0%X\n",
718 allocation->size));
719
720 status = acpi_ut_release_mutex(ACPI_MTX_MEMORY);
721 return_ACPI_STATUS(status);
722}
723
724/*******************************************************************************
725 *
726 * FUNCTION: acpi_ut_dump_allocation_info
727 *
728 * PARAMETERS:
729 *
730 * RETURN: None
731 *
732 * DESCRIPTION: Print some info about the outstanding allocations.
733 *
734 ******************************************************************************/
735
736#ifdef ACPI_FUTURE_USAGE
737void acpi_ut_dump_allocation_info(void)
738{
739/*
740 struct acpi_memory_list *mem_list;
741*/
742
743 ACPI_FUNCTION_TRACE("ut_dump_allocation_info");
744
745/*
746 ACPI_DEBUG_PRINT (TRACE_ALLOCATIONS | TRACE_TABLES,
747 ("%30s: %4d (%3d Kb)\n", "Current allocations",
748 mem_list->current_count,
749 ROUND_UP_TO_1K (mem_list->current_size)));
750
751 ACPI_DEBUG_PRINT (TRACE_ALLOCATIONS | TRACE_TABLES,
752 ("%30s: %4d (%3d Kb)\n", "Max concurrent allocations",
753 mem_list->max_concurrent_count,
754 ROUND_UP_TO_1K (mem_list->max_concurrent_size)));
755
756 ACPI_DEBUG_PRINT (TRACE_ALLOCATIONS | TRACE_TABLES,
757 ("%30s: %4d (%3d Kb)\n", "Total (all) internal objects",
758 running_object_count,
759 ROUND_UP_TO_1K (running_object_size)));
760
761 ACPI_DEBUG_PRINT (TRACE_ALLOCATIONS | TRACE_TABLES,
762 ("%30s: %4d (%3d Kb)\n", "Total (all) allocations",
763 running_alloc_count,
764 ROUND_UP_TO_1K (running_alloc_size)));
765
766 ACPI_DEBUG_PRINT (TRACE_ALLOCATIONS | TRACE_TABLES,
767 ("%30s: %4d (%3d Kb)\n", "Current Nodes",
768 acpi_gbl_current_node_count,
769 ROUND_UP_TO_1K (acpi_gbl_current_node_size)));
770
771 ACPI_DEBUG_PRINT (TRACE_ALLOCATIONS | TRACE_TABLES,
772 ("%30s: %4d (%3d Kb)\n", "Max Nodes",
773 acpi_gbl_max_concurrent_node_count,
774 ROUND_UP_TO_1K ((acpi_gbl_max_concurrent_node_count *
775 sizeof (struct acpi_namespace_node)))));
776*/
777 return_VOID;
778}
779#endif /* ACPI_FUTURE_USAGE */
780
781/*******************************************************************************
782 *
783 * FUNCTION: acpi_ut_dump_allocations
784 *
785 * PARAMETERS: Component - Component(s) to dump info for.
786 * Module - Module to dump info for. NULL means all.
787 *
788 * RETURN: None
789 *
790 * DESCRIPTION: Print a list of all outstanding allocations.
791 *
792 ******************************************************************************/
793
794void acpi_ut_dump_allocations(u32 component, char *module)
795{
796 struct acpi_debug_mem_block *element;
797 union acpi_descriptor *descriptor;
798 u32 num_outstanding = 0;
799
800 ACPI_FUNCTION_TRACE("ut_dump_allocations");
801
802 /*
803 * Walk the allocation list.
804 */
805 if (ACPI_FAILURE(acpi_ut_acquire_mutex(ACPI_MTX_MEMORY))) {
806 return;
807 }
808
809 element = acpi_gbl_global_list->list_head;
810 while (element) {
811 if ((element->component & component) &&
812 ((module == NULL)
813 || (0 == ACPI_STRCMP(module, element->module)))) {
814
815 /* Ignore allocated objects that are in a cache */
816
817 descriptor =
818 ACPI_CAST_PTR(union acpi_descriptor,
819 &element->user_space);
820 if (descriptor->descriptor_id != ACPI_DESC_TYPE_CACHED) {
821 acpi_os_printf("%p Len %04X %9.9s-%d [%s] ",
822 descriptor, element->size,
823 element->module, element->line,
824 acpi_ut_get_descriptor_name
825 (descriptor));
826
827 /* Most of the elements will be Operand objects. */
828
829 switch (ACPI_GET_DESCRIPTOR_TYPE(descriptor)) {
830 case ACPI_DESC_TYPE_OPERAND:
831 acpi_os_printf("%12.12s R%hd",
832 acpi_ut_get_type_name
833 (descriptor->object.
834 common.type),
835 descriptor->object.
836 common.reference_count);
837 break;
838
839 case ACPI_DESC_TYPE_PARSER:
840 acpi_os_printf("aml_opcode %04hX",
841 descriptor->op.asl.
842 aml_opcode);
843 break;
844
845 case ACPI_DESC_TYPE_NAMED:
846 acpi_os_printf("%4.4s",
847 acpi_ut_get_node_name
848 (&descriptor->node));
849 break;
850
851 default:
852 break;
853 }
854
855 acpi_os_printf("\n");
856 num_outstanding++;
857 }
858 }
859 element = element->next;
860 }
861
862 (void)acpi_ut_release_mutex(ACPI_MTX_MEMORY);
863
864 /* Print summary */
865
866 if (!num_outstanding) {
867 ACPI_INFO((AE_INFO, "No outstanding allocations"));
868 } else {
869 ACPI_ERROR((AE_INFO,
870 "%d(%X) Outstanding allocations",
871 num_outstanding, num_outstanding));
872 }
873
874 return_VOID;
875}
876
877#endif /* #ifdef ACPI_DBG_TRACK_ALLOCATIONS */
diff --git a/drivers/acpi/utilities/utcache.c b/drivers/acpi/utilities/utcache.c
index 5d2f4b2802a5..593b08ccd6bf 100644
--- a/drivers/acpi/utilities/utcache.c
+++ b/drivers/acpi/utilities/utcache.c
@@ -272,9 +272,9 @@ void *acpi_os_acquire_object(struct acpi_memory_list *cache)
272 cache->current_depth--; 272 cache->current_depth--;
273 273
274 ACPI_MEM_TRACKING(cache->hits++); 274 ACPI_MEM_TRACKING(cache->hits++);
275 ACPI_MEM_TRACKING(ACPI_DEBUG_PRINT((ACPI_DB_EXEC, 275 ACPI_DEBUG_PRINT((ACPI_DB_EXEC,
276 "Object %p from %s cache\n", 276 "Object %p from %s cache\n", object,
277 object, cache->list_name))); 277 cache->list_name));
278 278
279 status = acpi_ut_release_mutex(ACPI_MTX_CACHES); 279 status = acpi_ut_release_mutex(ACPI_MTX_CACHES);
280 if (ACPI_FAILURE(status)) { 280 if (ACPI_FAILURE(status)) {
diff --git a/drivers/acpi/utilities/utdelete.c b/drivers/acpi/utilities/utdelete.c
index 9c6867fcf009..51356e8eb999 100644
--- a/drivers/acpi/utilities/utdelete.c
+++ b/drivers/acpi/utilities/utdelete.c
@@ -200,8 +200,7 @@ static void acpi_ut_delete_internal_obj(union acpi_operand_object *object)
200 */ 200 */
201 handler_desc = object->region.handler; 201 handler_desc = object->region.handler;
202 if (handler_desc) { 202 if (handler_desc) {
203 if (handler_desc->address_space. 203 if (handler_desc->address_space.handler_flags &
204 hflags &
205 ACPI_ADDR_HANDLER_DEFAULT_INSTALLED) { 204 ACPI_ADDR_HANDLER_DEFAULT_INSTALLED) {
206 obj_pointer = 205 obj_pointer =
207 second_desc->extra.region_context; 206 second_desc->extra.region_context;
diff --git a/drivers/acpi/utilities/utglobal.c b/drivers/acpi/utilities/utglobal.c
index 5bc8da7acc6c..8a05bb5ef4fe 100644
--- a/drivers/acpi/utilities/utglobal.c
+++ b/drivers/acpi/utilities/utglobal.c
@@ -191,12 +191,14 @@ const char *acpi_gbl_valid_osi_strings[ACPI_NUM_OSI_STRINGS] = {
191 "Linux", 191 "Linux",
192 "Windows 2000", 192 "Windows 2000",
193 "Windows 2001", 193 "Windows 2001",
194 "Windows 2001.1",
195 "Windows 2001 SP0", 194 "Windows 2001 SP0",
196 "Windows 2001 SP1", 195 "Windows 2001 SP1",
197 "Windows 2001 SP2", 196 "Windows 2001 SP2",
198 "Windows 2001 SP3", 197 "Windows 2001 SP3",
199 "Windows 2001 SP4", 198 "Windows 2001 SP4",
199 "Windows 2001.1",
200 "Windows 2001.1 SP1", /* Added 03/2006 */
201 "Windows 2006", /* Added 03/2006 */
200 202
201 /* Feature Group Strings */ 203 /* Feature Group Strings */
202 204
@@ -633,7 +635,7 @@ char *acpi_ut_get_node_name(void *object)
633 635
634 /* Descriptor must be a namespace node */ 636 /* Descriptor must be a namespace node */
635 637
636 if (node->descriptor != ACPI_DESC_TYPE_NAMED) { 638 if (ACPI_GET_DESCRIPTOR_TYPE(node) != ACPI_DESC_TYPE_NAMED) {
637 return ("####"); 639 return ("####");
638 } 640 }
639 641
@@ -855,7 +857,7 @@ void acpi_ut_init_globals(void)
855 857
856 acpi_gbl_root_node = NULL; 858 acpi_gbl_root_node = NULL;
857 acpi_gbl_root_node_struct.name.integer = ACPI_ROOT_NAME; 859 acpi_gbl_root_node_struct.name.integer = ACPI_ROOT_NAME;
858 acpi_gbl_root_node_struct.descriptor = ACPI_DESC_TYPE_NAMED; 860 acpi_gbl_root_node_struct.descriptor_type = ACPI_DESC_TYPE_NAMED;
859 acpi_gbl_root_node_struct.type = ACPI_TYPE_DEVICE; 861 acpi_gbl_root_node_struct.type = ACPI_TYPE_DEVICE;
860 acpi_gbl_root_node_struct.child = NULL; 862 acpi_gbl_root_node_struct.child = NULL;
861 acpi_gbl_root_node_struct.peer = NULL; 863 acpi_gbl_root_node_struct.peer = NULL;
diff --git a/drivers/acpi/utilities/utmisc.c b/drivers/acpi/utilities/utmisc.c
index 77268ba86291..017a87ebc40b 100644
--- a/drivers/acpi/utilities/utmisc.c
+++ b/drivers/acpi/utilities/utmisc.c
@@ -881,36 +881,3 @@ acpi_ut_info(char *module_name, u32 line_number, char *format, ...)
881 acpi_os_vprintf(format, args); 881 acpi_os_vprintf(format, args);
882 acpi_os_printf(" [%X]\n", ACPI_CA_VERSION); 882 acpi_os_printf(" [%X]\n", ACPI_CA_VERSION);
883} 883}
884
885/*******************************************************************************
886 *
887 * FUNCTION: acpi_ut_report_error, Warning, Info
888 *
889 * PARAMETERS: module_name - Caller's module name (for error output)
890 * line_number - Caller's line number (for error output)
891 *
892 * RETURN: None
893 *
894 * DESCRIPTION: Print error message
895 *
896 * Note: Legacy only, should be removed when no longer used by drivers.
897 *
898 ******************************************************************************/
899
900void acpi_ut_report_error(char *module_name, u32 line_number)
901{
902
903 acpi_os_printf("ACPI Error (%s-%04d): ", module_name, line_number);
904}
905
906void acpi_ut_report_warning(char *module_name, u32 line_number)
907{
908
909 acpi_os_printf("ACPI Warning (%s-%04d): ", module_name, line_number);
910}
911
912void acpi_ut_report_info(char *module_name, u32 line_number)
913{
914
915 acpi_os_printf("ACPI (%s-%04d): ", module_name, line_number);
916}
diff --git a/drivers/acpi/utilities/utresrc.c b/drivers/acpi/utilities/utresrc.c
index 27158dd0f877..4c24e6d5400a 100644
--- a/drivers/acpi/utilities/utresrc.c
+++ b/drivers/acpi/utilities/utresrc.c
@@ -240,6 +240,104 @@ static const u8 acpi_gbl_resource_types[] = {
240 240
241/******************************************************************************* 241/*******************************************************************************
242 * 242 *
243 * FUNCTION: acpi_ut_walk_aml_resources
244 *
245 * PARAMETERS: Aml - Pointer to the raw AML resource template
246 * aml_length - Length of the entire template
247 * user_function - Called once for each descriptor found. If
248 * NULL, a pointer to the end_tag is returned
249 * Context - Passed to user_function
250 *
251 * RETURN: Status
252 *
253 * DESCRIPTION: Walk a raw AML resource list(buffer). User function called
254 * once for each resource found.
255 *
256 ******************************************************************************/
257
258acpi_status
259acpi_ut_walk_aml_resources(u8 * aml,
260 acpi_size aml_length,
261 acpi_walk_aml_callback user_function, void *context)
262{
263 acpi_status status;
264 u8 *end_aml;
265 u8 resource_index;
266 u32 length;
267 u32 offset = 0;
268
269 ACPI_FUNCTION_TRACE("ut_walk_aml_resources");
270
271 /* The absolute minimum resource template is one end_tag descriptor */
272
273 if (aml_length < sizeof(struct aml_resource_end_tag)) {
274 return_ACPI_STATUS(AE_AML_NO_RESOURCE_END_TAG);
275 }
276
277 /* Point to the end of the resource template buffer */
278
279 end_aml = aml + aml_length;
280
281 /* Walk the byte list, abort on any invalid descriptor type or length */
282
283 while (aml < end_aml) {
284
285 /* Validate the Resource Type and Resource Length */
286
287 status = acpi_ut_validate_resource(aml, &resource_index);
288 if (ACPI_FAILURE(status)) {
289 return_ACPI_STATUS(status);
290 }
291
292 /* Get the length of this descriptor */
293
294 length = acpi_ut_get_descriptor_length(aml);
295
296 /* Invoke the user function */
297
298 if (user_function) {
299 status =
300 user_function(aml, length, offset, resource_index,
301 context);
302 if (ACPI_FAILURE(status)) {
303 return (status);
304 }
305 }
306
307 /* An end_tag descriptor terminates this resource template */
308
309 if (acpi_ut_get_resource_type(aml) ==
310 ACPI_RESOURCE_NAME_END_TAG) {
311 /*
312 * There must be at least one more byte in the buffer for
313 * the 2nd byte of the end_tag
314 */
315 if ((aml + 1) >= end_aml) {
316 return_ACPI_STATUS(AE_AML_NO_RESOURCE_END_TAG);
317 }
318
319 /* Return the pointer to the end_tag if requested */
320
321 if (!user_function) {
322 *(void **)context = aml;
323 }
324
325 /* Normal exit */
326
327 return_ACPI_STATUS(AE_OK);
328 }
329
330 aml += length;
331 offset += length;
332 }
333
334 /* Did not find an end_tag descriptor */
335
336 return (AE_AML_NO_RESOURCE_END_TAG);
337}
338
339/*******************************************************************************
340 *
243 * FUNCTION: acpi_ut_validate_resource 341 * FUNCTION: acpi_ut_validate_resource
244 * 342 *
245 * PARAMETERS: Aml - Pointer to the raw AML resource descriptor 343 * PARAMETERS: Aml - Pointer to the raw AML resource descriptor
@@ -498,61 +596,21 @@ acpi_ut_get_resource_end_tag(union acpi_operand_object * obj_desc,
498 u8 ** end_tag) 596 u8 ** end_tag)
499{ 597{
500 acpi_status status; 598 acpi_status status;
501 u8 *aml;
502 u8 *end_aml;
503 599
504 ACPI_FUNCTION_TRACE("ut_get_resource_end_tag"); 600 ACPI_FUNCTION_TRACE("ut_get_resource_end_tag");
505 601
506 /* Get start and end pointers */
507
508 aml = obj_desc->buffer.pointer;
509 end_aml = aml + obj_desc->buffer.length;
510
511 /* Allow a buffer length of zero */ 602 /* Allow a buffer length of zero */
512 603
513 if (!obj_desc->buffer.length) { 604 if (!obj_desc->buffer.length) {
514 *end_tag = aml; 605 *end_tag = obj_desc->buffer.pointer;
515 return_ACPI_STATUS(AE_OK); 606 return_ACPI_STATUS(AE_OK);
516 } 607 }
517 608
518 /* Walk the resource template, one descriptor per iteration */ 609 /* Validate the template and get a pointer to the end_tag */
519
520 while (aml < end_aml) {
521
522 /* Validate the Resource Type and Resource Length */
523
524 status = acpi_ut_validate_resource(aml, NULL);
525 if (ACPI_FAILURE(status)) {
526 return_ACPI_STATUS(status);
527 }
528
529 /* end_tag resource indicates the end of the resource template */
530
531 if (acpi_ut_get_resource_type(aml) ==
532 ACPI_RESOURCE_NAME_END_TAG) {
533 /*
534 * There must be at least one more byte in the buffer for
535 * the 2nd byte of the end_tag
536 */
537 if ((aml + 1) >= end_aml) {
538 return_ACPI_STATUS(AE_AML_NO_RESOURCE_END_TAG);
539 }
540
541 /* Return the pointer to the end_tag */
542
543 *end_tag = aml;
544 return_ACPI_STATUS(AE_OK);
545 }
546
547 /*
548 * Point to the next resource descriptor in the AML buffer. The
549 * descriptor length is guaranteed to be non-zero by resource
550 * validation above.
551 */
552 aml += acpi_ut_get_descriptor_length(aml);
553 }
554 610
555 /* Did not find an end_tag resource descriptor */ 611 status = acpi_ut_walk_aml_resources(obj_desc->buffer.pointer,
612 obj_desc->buffer.length, NULL,
613 end_tag);
556 614
557 return_ACPI_STATUS(AE_AML_NO_RESOURCE_END_TAG); 615 return_ACPI_STATUS(status);
558} 616}
diff --git a/drivers/acpi/utilities/utstate.c b/drivers/acpi/utilities/utstate.c
index 69f2bfdc26ab..637c5f964879 100644
--- a/drivers/acpi/utilities/utstate.c
+++ b/drivers/acpi/utilities/utstate.c
@@ -162,7 +162,7 @@ union acpi_generic_state *acpi_ut_create_generic_state(void)
162 162
163 /* Initialize */ 163 /* Initialize */
164 memset(state, 0, sizeof(union acpi_generic_state)); 164 memset(state, 0, sizeof(union acpi_generic_state));
165 state->common.data_type = ACPI_DESC_TYPE_STATE; 165 state->common.descriptor_type = ACPI_DESC_TYPE_STATE;
166 } 166 }
167 167
168 return (state); 168 return (state);
@@ -196,7 +196,7 @@ struct acpi_thread_state *acpi_ut_create_thread_state(void)
196 196
197 /* Init fields specific to the update struct */ 197 /* Init fields specific to the update struct */
198 198
199 state->common.data_type = ACPI_DESC_TYPE_STATE_THREAD; 199 state->common.descriptor_type = ACPI_DESC_TYPE_STATE_THREAD;
200 state->thread.thread_id = acpi_os_get_thread_id(); 200 state->thread.thread_id = acpi_os_get_thread_id();
201 201
202 return_PTR((struct acpi_thread_state *)state); 202 return_PTR((struct acpi_thread_state *)state);
@@ -233,7 +233,7 @@ union acpi_generic_state *acpi_ut_create_update_state(union acpi_operand_object
233 233
234 /* Init fields specific to the update struct */ 234 /* Init fields specific to the update struct */
235 235
236 state->common.data_type = ACPI_DESC_TYPE_STATE_UPDATE; 236 state->common.descriptor_type = ACPI_DESC_TYPE_STATE_UPDATE;
237 state->update.object = object; 237 state->update.object = object;
238 state->update.value = action; 238 state->update.value = action;
239 239
@@ -270,7 +270,7 @@ union acpi_generic_state *acpi_ut_create_pkg_state(void *internal_object,
270 270
271 /* Init fields specific to the update struct */ 271 /* Init fields specific to the update struct */
272 272
273 state->common.data_type = ACPI_DESC_TYPE_STATE_PACKAGE; 273 state->common.descriptor_type = ACPI_DESC_TYPE_STATE_PACKAGE;
274 state->pkg.source_object = (union acpi_operand_object *)internal_object; 274 state->pkg.source_object = (union acpi_operand_object *)internal_object;
275 state->pkg.dest_object = external_object; 275 state->pkg.dest_object = external_object;
276 state->pkg.index = index; 276 state->pkg.index = index;
@@ -307,7 +307,7 @@ union acpi_generic_state *acpi_ut_create_control_state(void)
307 307
308 /* Init fields specific to the control struct */ 308 /* Init fields specific to the control struct */
309 309
310 state->common.data_type = ACPI_DESC_TYPE_STATE_CONTROL; 310 state->common.descriptor_type = ACPI_DESC_TYPE_STATE_CONTROL;
311 state->common.state = ACPI_CONTROL_CONDITIONAL_EXECUTING; 311 state->common.state = ACPI_CONTROL_CONDITIONAL_EXECUTING;
312 312
313 return_PTR(state); 313 return_PTR(state);