aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/acpi/dispatcher/dsmethod.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/acpi/dispatcher/dsmethod.c')
-rw-r--r--drivers/acpi/dispatcher/dsmethod.c354
1 files changed, 171 insertions, 183 deletions
diff --git a/drivers/acpi/dispatcher/dsmethod.c b/drivers/acpi/dispatcher/dsmethod.c
index e344c06ed33..77fcfc3070d 100644
--- a/drivers/acpi/dispatcher/dsmethod.c
+++ b/drivers/acpi/dispatcher/dsmethod.c
@@ -41,7 +41,6 @@
41 * POSSIBILITY OF SUCH DAMAGES. 41 * POSSIBILITY OF SUCH DAMAGES.
42 */ 42 */
43 43
44
45#include <acpi/acpi.h> 44#include <acpi/acpi.h>
46#include <acpi/acparser.h> 45#include <acpi/acparser.h>
47#include <acpi/amlcode.h> 46#include <acpi/amlcode.h>
@@ -49,10 +48,8 @@
49#include <acpi/acinterp.h> 48#include <acpi/acinterp.h>
50#include <acpi/acnamesp.h> 49#include <acpi/acnamesp.h>
51 50
52
53#define _COMPONENT ACPI_DISPATCHER 51#define _COMPONENT ACPI_DISPATCHER
54 ACPI_MODULE_NAME ("dsmethod") 52ACPI_MODULE_NAME("dsmethod")
55
56 53
57/******************************************************************************* 54/*******************************************************************************
58 * 55 *
@@ -67,45 +64,41 @@
67 * MUTEX: Assumes parser is locked 64 * MUTEX: Assumes parser is locked
68 * 65 *
69 ******************************************************************************/ 66 ******************************************************************************/
70 67acpi_status acpi_ds_parse_method(struct acpi_namespace_node *node)
71acpi_status
72acpi_ds_parse_method (
73 struct acpi_namespace_node *node)
74{ 68{
75 acpi_status status; 69 acpi_status status;
76 union acpi_operand_object *obj_desc; 70 union acpi_operand_object *obj_desc;
77 union acpi_parse_object *op; 71 union acpi_parse_object *op;
78 struct acpi_walk_state *walk_state; 72 struct acpi_walk_state *walk_state;
79
80
81 ACPI_FUNCTION_TRACE_PTR ("ds_parse_method", node);
82 73
74 ACPI_FUNCTION_TRACE_PTR("ds_parse_method", node);
83 75
84 /* Parameter Validation */ 76 /* Parameter Validation */
85 77
86 if (!node) { 78 if (!node) {
87 return_ACPI_STATUS (AE_NULL_ENTRY); 79 return_ACPI_STATUS(AE_NULL_ENTRY);
88 } 80 }
89 81
90 ACPI_DEBUG_PRINT ((ACPI_DB_PARSE, "**** Parsing [%4.4s] **** named_obj=%p\n", 82 ACPI_DEBUG_PRINT((ACPI_DB_PARSE,
91 acpi_ut_get_node_name (node), node)); 83 "**** Parsing [%4.4s] **** named_obj=%p\n",
84 acpi_ut_get_node_name(node), node));
92 85
93 /* Extract the method object from the method Node */ 86 /* Extract the method object from the method Node */
94 87
95 obj_desc = acpi_ns_get_attached_object (node); 88 obj_desc = acpi_ns_get_attached_object(node);
96 if (!obj_desc) { 89 if (!obj_desc) {
97 return_ACPI_STATUS (AE_NULL_OBJECT); 90 return_ACPI_STATUS(AE_NULL_OBJECT);
98 } 91 }
99 92
100 /* Create a mutex for the method if there is a concurrency limit */ 93 /* Create a mutex for the method if there is a concurrency limit */
101 94
102 if ((obj_desc->method.concurrency != ACPI_INFINITE_CONCURRENCY) && 95 if ((obj_desc->method.concurrency != ACPI_INFINITE_CONCURRENCY) &&
103 (!obj_desc->method.semaphore)) { 96 (!obj_desc->method.semaphore)) {
104 status = acpi_os_create_semaphore (obj_desc->method.concurrency, 97 status = acpi_os_create_semaphore(obj_desc->method.concurrency,
105 obj_desc->method.concurrency, 98 obj_desc->method.concurrency,
106 &obj_desc->method.semaphore); 99 &obj_desc->method.semaphore);
107 if (ACPI_FAILURE (status)) { 100 if (ACPI_FAILURE(status)) {
108 return_ACPI_STATUS (status); 101 return_ACPI_STATUS(status);
109 } 102 }
110 } 103 }
111 104
@@ -113,14 +106,14 @@ acpi_ds_parse_method (
113 * Allocate a new parser op to be the root of the parsed 106 * Allocate a new parser op to be the root of the parsed
114 * method tree 107 * method tree
115 */ 108 */
116 op = acpi_ps_alloc_op (AML_METHOD_OP); 109 op = acpi_ps_alloc_op(AML_METHOD_OP);
117 if (!op) { 110 if (!op) {
118 return_ACPI_STATUS (AE_NO_MEMORY); 111 return_ACPI_STATUS(AE_NO_MEMORY);
119 } 112 }
120 113
121 /* Init new op with the method name and pointer back to the Node */ 114 /* Init new op with the method name and pointer back to the Node */
122 115
123 acpi_ps_set_name (op, node->name.integer); 116 acpi_ps_set_name(op, node->name.integer);
124 op->common.node = node; 117 op->common.node = node;
125 118
126 /* 119 /*
@@ -128,25 +121,26 @@ acpi_ds_parse_method (
128 * objects (such as Operation Regions) can be created during the 121 * objects (such as Operation Regions) can be created during the
129 * first pass parse. 122 * first pass parse.
130 */ 123 */
131 status = acpi_ut_allocate_owner_id (&obj_desc->method.owner_id); 124 status = acpi_ut_allocate_owner_id(&obj_desc->method.owner_id);
132 if (ACPI_FAILURE (status)) { 125 if (ACPI_FAILURE(status)) {
133 goto cleanup; 126 goto cleanup;
134 } 127 }
135 128
136 /* Create and initialize a new walk state */ 129 /* Create and initialize a new walk state */
137 130
138 walk_state = acpi_ds_create_walk_state ( 131 walk_state =
139 obj_desc->method.owner_id, NULL, NULL, NULL); 132 acpi_ds_create_walk_state(obj_desc->method.owner_id, NULL, NULL,
133 NULL);
140 if (!walk_state) { 134 if (!walk_state) {
141 status = AE_NO_MEMORY; 135 status = AE_NO_MEMORY;
142 goto cleanup2; 136 goto cleanup2;
143 } 137 }
144 138
145 status = acpi_ds_init_aml_walk (walk_state, op, node, 139 status = acpi_ds_init_aml_walk(walk_state, op, node,
146 obj_desc->method.aml_start, 140 obj_desc->method.aml_start,
147 obj_desc->method.aml_length, NULL, 1); 141 obj_desc->method.aml_length, NULL, 1);
148 if (ACPI_FAILURE (status)) { 142 if (ACPI_FAILURE(status)) {
149 acpi_ds_delete_walk_state (walk_state); 143 acpi_ds_delete_walk_state(walk_state);
150 goto cleanup2; 144 goto cleanup2;
151 } 145 }
152 146
@@ -159,32 +153,31 @@ acpi_ds_parse_method (
159 * method so that operands to the named objects can take on dynamic 153 * method so that operands to the named objects can take on dynamic
160 * run-time values. 154 * run-time values.
161 */ 155 */
162 status = acpi_ps_parse_aml (walk_state); 156 status = acpi_ps_parse_aml(walk_state);
163 if (ACPI_FAILURE (status)) { 157 if (ACPI_FAILURE(status)) {
164 goto cleanup2; 158 goto cleanup2;
165 } 159 }
166 160
167 ACPI_DEBUG_PRINT ((ACPI_DB_PARSE, 161 ACPI_DEBUG_PRINT((ACPI_DB_PARSE,
168 "**** [%4.4s] Parsed **** named_obj=%p Op=%p\n", 162 "**** [%4.4s] Parsed **** named_obj=%p Op=%p\n",
169 acpi_ut_get_node_name (node), node, op)); 163 acpi_ut_get_node_name(node), node, op));
170 164
171 /* 165 /*
172 * Delete the parse tree. We simply re-parse the method for every 166 * Delete the parse tree. We simply re-parse the method for every
173 * execution since there isn't much overhead (compared to keeping lots 167 * execution since there isn't much overhead (compared to keeping lots
174 * of parse trees around) 168 * of parse trees around)
175 */ 169 */
176 acpi_ns_delete_namespace_subtree (node); 170 acpi_ns_delete_namespace_subtree(node);
177 acpi_ns_delete_namespace_by_owner (obj_desc->method.owner_id); 171 acpi_ns_delete_namespace_by_owner(obj_desc->method.owner_id);
178 172
179cleanup2: 173 cleanup2:
180 acpi_ut_release_owner_id (&obj_desc->method.owner_id); 174 acpi_ut_release_owner_id(&obj_desc->method.owner_id);
181 175
182cleanup: 176 cleanup:
183 acpi_ps_delete_parse_tree (op); 177 acpi_ps_delete_parse_tree(op);
184 return_ACPI_STATUS (status); 178 return_ACPI_STATUS(status);
185} 179}
186 180
187
188/******************************************************************************* 181/*******************************************************************************
189 * 182 *
190 * FUNCTION: acpi_ds_begin_method_execution 183 * FUNCTION: acpi_ds_begin_method_execution
@@ -202,19 +195,16 @@ cleanup:
202 ******************************************************************************/ 195 ******************************************************************************/
203 196
204acpi_status 197acpi_status
205acpi_ds_begin_method_execution ( 198acpi_ds_begin_method_execution(struct acpi_namespace_node *method_node,
206 struct acpi_namespace_node *method_node, 199 union acpi_operand_object *obj_desc,
207 union acpi_operand_object *obj_desc, 200 struct acpi_namespace_node *calling_method_node)
208 struct acpi_namespace_node *calling_method_node)
209{ 201{
210 acpi_status status = AE_OK; 202 acpi_status status = AE_OK;
211
212
213 ACPI_FUNCTION_TRACE_PTR ("ds_begin_method_execution", method_node);
214 203
204 ACPI_FUNCTION_TRACE_PTR("ds_begin_method_execution", method_node);
215 205
216 if (!method_node) { 206 if (!method_node) {
217 return_ACPI_STATUS (AE_NULL_ENTRY); 207 return_ACPI_STATUS(AE_NULL_ENTRY);
218 } 208 }
219 209
220 /* 210 /*
@@ -231,8 +221,9 @@ acpi_ds_begin_method_execution (
231 * thread that is making recursive method calls. 221 * thread that is making recursive method calls.
232 */ 222 */
233 if (method_node == calling_method_node) { 223 if (method_node == calling_method_node) {
234 if (obj_desc->method.thread_count >= obj_desc->method.concurrency) { 224 if (obj_desc->method.thread_count >=
235 return_ACPI_STATUS (AE_AML_METHOD_LIMIT); 225 obj_desc->method.concurrency) {
226 return_ACPI_STATUS(AE_AML_METHOD_LIMIT);
236 } 227 }
237 } 228 }
238 229
@@ -240,8 +231,9 @@ acpi_ds_begin_method_execution (
240 * Get a unit from the method semaphore. This releases the 231 * Get a unit from the method semaphore. This releases the
241 * interpreter if we block 232 * interpreter if we block
242 */ 233 */
243 status = acpi_ex_system_wait_semaphore (obj_desc->method.semaphore, 234 status =
244 ACPI_WAIT_FOREVER); 235 acpi_ex_system_wait_semaphore(obj_desc->method.semaphore,
236 ACPI_WAIT_FOREVER);
245 } 237 }
246 238
247 /* 239 /*
@@ -249,10 +241,9 @@ acpi_ds_begin_method_execution (
249 * reentered one more time (even if it is the same thread) 241 * reentered one more time (even if it is the same thread)
250 */ 242 */
251 obj_desc->method.thread_count++; 243 obj_desc->method.thread_count++;
252 return_ACPI_STATUS (status); 244 return_ACPI_STATUS(status);
253} 245}
254 246
255
256/******************************************************************************* 247/*******************************************************************************
257 * 248 *
258 * FUNCTION: acpi_ds_call_control_method 249 * FUNCTION: acpi_ds_call_control_method
@@ -268,85 +259,86 @@ acpi_ds_begin_method_execution (
268 ******************************************************************************/ 259 ******************************************************************************/
269 260
270acpi_status 261acpi_status
271acpi_ds_call_control_method ( 262acpi_ds_call_control_method(struct acpi_thread_state *thread,
272 struct acpi_thread_state *thread, 263 struct acpi_walk_state *this_walk_state,
273 struct acpi_walk_state *this_walk_state, 264 union acpi_parse_object *op)
274 union acpi_parse_object *op)
275{ 265{
276 acpi_status status; 266 acpi_status status;
277 struct acpi_namespace_node *method_node; 267 struct acpi_namespace_node *method_node;
278 struct acpi_walk_state *next_walk_state = NULL; 268 struct acpi_walk_state *next_walk_state = NULL;
279 union acpi_operand_object *obj_desc; 269 union acpi_operand_object *obj_desc;
280 struct acpi_parameter_info info; 270 struct acpi_parameter_info info;
281 u32 i; 271 u32 i;
282
283 272
284 ACPI_FUNCTION_TRACE_PTR ("ds_call_control_method", this_walk_state); 273 ACPI_FUNCTION_TRACE_PTR("ds_call_control_method", this_walk_state);
285 274
286 ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH, "Execute method %p, currentstate=%p\n", 275 ACPI_DEBUG_PRINT((ACPI_DB_DISPATCH,
287 this_walk_state->prev_op, this_walk_state)); 276 "Execute method %p, currentstate=%p\n",
277 this_walk_state->prev_op, this_walk_state));
288 278
289 /* 279 /*
290 * Get the namespace entry for the control method we are about to call 280 * Get the namespace entry for the control method we are about to call
291 */ 281 */
292 method_node = this_walk_state->method_call_node; 282 method_node = this_walk_state->method_call_node;
293 if (!method_node) { 283 if (!method_node) {
294 return_ACPI_STATUS (AE_NULL_ENTRY); 284 return_ACPI_STATUS(AE_NULL_ENTRY);
295 } 285 }
296 286
297 obj_desc = acpi_ns_get_attached_object (method_node); 287 obj_desc = acpi_ns_get_attached_object(method_node);
298 if (!obj_desc) { 288 if (!obj_desc) {
299 return_ACPI_STATUS (AE_NULL_OBJECT); 289 return_ACPI_STATUS(AE_NULL_OBJECT);
300 } 290 }
301 291
302 status = acpi_ut_allocate_owner_id (&obj_desc->method.owner_id); 292 status = acpi_ut_allocate_owner_id(&obj_desc->method.owner_id);
303 if (ACPI_FAILURE (status)) { 293 if (ACPI_FAILURE(status)) {
304 return_ACPI_STATUS (status); 294 return_ACPI_STATUS(status);
305 } 295 }
306 296
307 /* Init for new method, wait on concurrency semaphore */ 297 /* Init for new method, wait on concurrency semaphore */
308 298
309 status = acpi_ds_begin_method_execution (method_node, obj_desc, 299 status = acpi_ds_begin_method_execution(method_node, obj_desc,
310 this_walk_state->method_node); 300 this_walk_state->method_node);
311 if (ACPI_FAILURE (status)) { 301 if (ACPI_FAILURE(status)) {
312 goto cleanup; 302 goto cleanup;
313 } 303 }
314 304
315 if (!(obj_desc->method.method_flags & AML_METHOD_INTERNAL_ONLY)) { 305 if (!(obj_desc->method.method_flags & AML_METHOD_INTERNAL_ONLY)) {
316 /* 1) Parse: Create a new walk state for the preempting walk */ 306 /* 1) Parse: Create a new walk state for the preempting walk */
317 307
318 next_walk_state = acpi_ds_create_walk_state (obj_desc->method.owner_id, 308 next_walk_state =
319 op, obj_desc, NULL); 309 acpi_ds_create_walk_state(obj_desc->method.owner_id, op,
310 obj_desc, NULL);
320 if (!next_walk_state) { 311 if (!next_walk_state) {
321 return_ACPI_STATUS (AE_NO_MEMORY); 312 return_ACPI_STATUS(AE_NO_MEMORY);
322 } 313 }
323 314
324 /* Create and init a Root Node */ 315 /* Create and init a Root Node */
325 316
326 op = acpi_ps_create_scope_op (); 317 op = acpi_ps_create_scope_op();
327 if (!op) { 318 if (!op) {
328 status = AE_NO_MEMORY; 319 status = AE_NO_MEMORY;
329 goto cleanup; 320 goto cleanup;
330 } 321 }
331 322
332 status = acpi_ds_init_aml_walk (next_walk_state, op, method_node, 323 status = acpi_ds_init_aml_walk(next_walk_state, op, method_node,
333 obj_desc->method.aml_start, obj_desc->method.aml_length, 324 obj_desc->method.aml_start,
334 NULL, 1); 325 obj_desc->method.aml_length,
335 if (ACPI_FAILURE (status)) { 326 NULL, 1);
336 acpi_ds_delete_walk_state (next_walk_state); 327 if (ACPI_FAILURE(status)) {
328 acpi_ds_delete_walk_state(next_walk_state);
337 goto cleanup; 329 goto cleanup;
338 } 330 }
339 331
340 /* Begin AML parse */ 332 /* Begin AML parse */
341 333
342 status = acpi_ps_parse_aml (next_walk_state); 334 status = acpi_ps_parse_aml(next_walk_state);
343 acpi_ps_delete_parse_tree (op); 335 acpi_ps_delete_parse_tree(op);
344 } 336 }
345 337
346 /* 2) Execute: Create a new state for the preempting walk */ 338 /* 2) Execute: Create a new state for the preempting walk */
347 339
348 next_walk_state = acpi_ds_create_walk_state (obj_desc->method.owner_id, 340 next_walk_state = acpi_ds_create_walk_state(obj_desc->method.owner_id,
349 NULL, obj_desc, thread); 341 NULL, obj_desc, thread);
350 if (!next_walk_state) { 342 if (!next_walk_state) {
351 status = AE_NO_MEMORY; 343 status = AE_NO_MEMORY;
352 goto cleanup; 344 goto cleanup;
@@ -357,15 +349,15 @@ acpi_ds_call_control_method (
357 * start at index 0. 349 * start at index 0.
358 * Null terminate the list of arguments 350 * Null terminate the list of arguments
359 */ 351 */
360 this_walk_state->operands [this_walk_state->num_operands] = NULL; 352 this_walk_state->operands[this_walk_state->num_operands] = NULL;
361 353
362 info.parameters = &this_walk_state->operands[0]; 354 info.parameters = &this_walk_state->operands[0];
363 info.parameter_type = ACPI_PARAM_ARGS; 355 info.parameter_type = ACPI_PARAM_ARGS;
364 356
365 status = acpi_ds_init_aml_walk (next_walk_state, NULL, method_node, 357 status = acpi_ds_init_aml_walk(next_walk_state, NULL, method_node,
366 obj_desc->method.aml_start, obj_desc->method.aml_length, 358 obj_desc->method.aml_start,
367 &info, 3); 359 obj_desc->method.aml_length, &info, 3);
368 if (ACPI_FAILURE (status)) { 360 if (ACPI_FAILURE(status)) {
369 goto cleanup; 361 goto cleanup;
370 } 362 }
371 363
@@ -374,40 +366,39 @@ acpi_ds_call_control_method (
374 * (they were copied to new objects) 366 * (they were copied to new objects)
375 */ 367 */
376 for (i = 0; i < obj_desc->method.param_count; i++) { 368 for (i = 0; i < obj_desc->method.param_count; i++) {
377 acpi_ut_remove_reference (this_walk_state->operands [i]); 369 acpi_ut_remove_reference(this_walk_state->operands[i]);
378 this_walk_state->operands [i] = NULL; 370 this_walk_state->operands[i] = NULL;
379 } 371 }
380 372
381 /* Clear the operand stack */ 373 /* Clear the operand stack */
382 374
383 this_walk_state->num_operands = 0; 375 this_walk_state->num_operands = 0;
384 376
385 ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH, 377 ACPI_DEBUG_PRINT((ACPI_DB_DISPATCH,
386 "Starting nested execution, newstate=%p\n", next_walk_state)); 378 "Starting nested execution, newstate=%p\n",
379 next_walk_state));
387 380
388 if (obj_desc->method.method_flags & AML_METHOD_INTERNAL_ONLY) { 381 if (obj_desc->method.method_flags & AML_METHOD_INTERNAL_ONLY) {
389 status = obj_desc->method.implementation (next_walk_state); 382 status = obj_desc->method.implementation(next_walk_state);
390 return_ACPI_STATUS (status); 383 return_ACPI_STATUS(status);
391 } 384 }
392 385
393 return_ACPI_STATUS (AE_OK); 386 return_ACPI_STATUS(AE_OK);
394
395 387
396 /* On error, we must delete the new walk state */ 388 /* On error, we must delete the new walk state */
397 389
398cleanup: 390 cleanup:
399 acpi_ut_release_owner_id (&obj_desc->method.owner_id); 391 acpi_ut_release_owner_id(&obj_desc->method.owner_id);
400 if (next_walk_state && (next_walk_state->method_desc)) { 392 if (next_walk_state && (next_walk_state->method_desc)) {
401 /* Decrement the thread count on the method parse tree */ 393 /* Decrement the thread count on the method parse tree */
402 394
403 next_walk_state->method_desc->method.thread_count--; 395 next_walk_state->method_desc->method.thread_count--;
404 } 396 }
405 (void) acpi_ds_terminate_control_method (next_walk_state); 397 (void)acpi_ds_terminate_control_method(next_walk_state);
406 acpi_ds_delete_walk_state (next_walk_state); 398 acpi_ds_delete_walk_state(next_walk_state);
407 return_ACPI_STATUS (status); 399 return_ACPI_STATUS(status);
408} 400}
409 401
410
411/******************************************************************************* 402/*******************************************************************************
412 * 403 *
413 * FUNCTION: acpi_ds_restart_control_method 404 * FUNCTION: acpi_ds_restart_control_method
@@ -423,25 +414,22 @@ cleanup:
423 ******************************************************************************/ 414 ******************************************************************************/
424 415
425acpi_status 416acpi_status
426acpi_ds_restart_control_method ( 417acpi_ds_restart_control_method(struct acpi_walk_state *walk_state,
427 struct acpi_walk_state *walk_state, 418 union acpi_operand_object *return_desc)
428 union acpi_operand_object *return_desc)
429{ 419{
430 acpi_status status; 420 acpi_status status;
431
432 421
433 ACPI_FUNCTION_TRACE_PTR ("ds_restart_control_method", walk_state); 422 ACPI_FUNCTION_TRACE_PTR("ds_restart_control_method", walk_state);
434 423
424 ACPI_DEBUG_PRINT((ACPI_DB_DISPATCH,
425 "****Restart [%4.4s] Op %p return_value_from_callee %p\n",
426 (char *)&walk_state->method_node->name,
427 walk_state->method_call_op, return_desc));
435 428
436 ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH, 429 ACPI_DEBUG_PRINT((ACPI_DB_DISPATCH,
437 "****Restart [%4.4s] Op %p return_value_from_callee %p\n", 430 " return_from_this_method_used?=%X res_stack %p Walk %p\n",
438 (char *) &walk_state->method_node->name, walk_state->method_call_op, 431 walk_state->return_used,
439 return_desc)); 432 walk_state->results, walk_state));
440
441 ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH,
442 " return_from_this_method_used?=%X res_stack %p Walk %p\n",
443 walk_state->return_used,
444 walk_state->results, walk_state));
445 433
446 /* Did the called method return a value? */ 434 /* Did the called method return a value? */
447 435
@@ -451,10 +439,10 @@ acpi_ds_restart_control_method (
451 if (walk_state->return_used) { 439 if (walk_state->return_used) {
452 /* Save the return value from the previous method */ 440 /* Save the return value from the previous method */
453 441
454 status = acpi_ds_result_push (return_desc, walk_state); 442 status = acpi_ds_result_push(return_desc, walk_state);
455 if (ACPI_FAILURE (status)) { 443 if (ACPI_FAILURE(status)) {
456 acpi_ut_remove_reference (return_desc); 444 acpi_ut_remove_reference(return_desc);
457 return_ACPI_STATUS (status); 445 return_ACPI_STATUS(status);
458 } 446 }
459 447
460 /* 448 /*
@@ -472,19 +460,19 @@ acpi_ds_restart_control_method (
472 * NOTE: this is optional because the ASL language does not actually 460 * NOTE: this is optional because the ASL language does not actually
473 * support this behavior. 461 * support this behavior.
474 */ 462 */
475 else if (!acpi_ds_do_implicit_return (return_desc, walk_state, FALSE)) { 463 else if (!acpi_ds_do_implicit_return
464 (return_desc, walk_state, FALSE)) {
476 /* 465 /*
477 * Delete the return value if it will not be used by the 466 * Delete the return value if it will not be used by the
478 * calling method 467 * calling method
479 */ 468 */
480 acpi_ut_remove_reference (return_desc); 469 acpi_ut_remove_reference(return_desc);
481 } 470 }
482 } 471 }
483 472
484 return_ACPI_STATUS (AE_OK); 473 return_ACPI_STATUS(AE_OK);
485} 474}
486 475
487
488/******************************************************************************* 476/*******************************************************************************
489 * 477 *
490 * FUNCTION: acpi_ds_terminate_control_method 478 * FUNCTION: acpi_ds_terminate_control_method
@@ -499,17 +487,13 @@ acpi_ds_restart_control_method (
499 * 487 *
500 ******************************************************************************/ 488 ******************************************************************************/
501 489
502acpi_status 490acpi_status acpi_ds_terminate_control_method(struct acpi_walk_state *walk_state)
503acpi_ds_terminate_control_method (
504 struct acpi_walk_state *walk_state)
505{ 491{
506 union acpi_operand_object *obj_desc; 492 union acpi_operand_object *obj_desc;
507 struct acpi_namespace_node *method_node; 493 struct acpi_namespace_node *method_node;
508 acpi_status status; 494 acpi_status status;
509
510
511 ACPI_FUNCTION_TRACE_PTR ("ds_terminate_control_method", walk_state);
512 495
496 ACPI_FUNCTION_TRACE_PTR("ds_terminate_control_method", walk_state);
513 497
514 if (!walk_state) { 498 if (!walk_state) {
515 return (AE_BAD_PARAMETER); 499 return (AE_BAD_PARAMETER);
@@ -519,30 +503,31 @@ acpi_ds_terminate_control_method (
519 503
520 obj_desc = walk_state->method_desc; 504 obj_desc = walk_state->method_desc;
521 if (!obj_desc) { 505 if (!obj_desc) {
522 return_ACPI_STATUS (AE_OK); 506 return_ACPI_STATUS(AE_OK);
523 } 507 }
524 508
525 /* Delete all arguments and locals */ 509 /* Delete all arguments and locals */
526 510
527 acpi_ds_method_data_delete_all (walk_state); 511 acpi_ds_method_data_delete_all(walk_state);
528 512
529 /* 513 /*
530 * Lock the parser while we terminate this method. 514 * Lock the parser while we terminate this method.
531 * If this is the last thread executing the method, 515 * If this is the last thread executing the method,
532 * we have additional cleanup to perform 516 * we have additional cleanup to perform
533 */ 517 */
534 status = acpi_ut_acquire_mutex (ACPI_MTX_PARSER); 518 status = acpi_ut_acquire_mutex(ACPI_MTX_PARSER);
535 if (ACPI_FAILURE (status)) { 519 if (ACPI_FAILURE(status)) {
536 return_ACPI_STATUS (status); 520 return_ACPI_STATUS(status);
537 } 521 }
538 522
539 /* Signal completion of the execution of this method if necessary */ 523 /* Signal completion of the execution of this method if necessary */
540 524
541 if (walk_state->method_desc->method.semaphore) { 525 if (walk_state->method_desc->method.semaphore) {
542 status = acpi_os_signal_semaphore ( 526 status =
543 walk_state->method_desc->method.semaphore, 1); 527 acpi_os_signal_semaphore(walk_state->method_desc->method.
544 if (ACPI_FAILURE (status)) { 528 semaphore, 1);
545 ACPI_REPORT_ERROR (("Could not signal method semaphore\n")); 529 if (ACPI_FAILURE(status)) {
530 ACPI_REPORT_ERROR(("Could not signal method semaphore\n"));
546 status = AE_OK; 531 status = AE_OK;
547 532
548 /* Ignore error and continue cleanup */ 533 /* Ignore error and continue cleanup */
@@ -550,9 +535,10 @@ acpi_ds_terminate_control_method (
550 } 535 }
551 536
552 if (walk_state->method_desc->method.thread_count) { 537 if (walk_state->method_desc->method.thread_count) {
553 ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH, 538 ACPI_DEBUG_PRINT((ACPI_DB_DISPATCH,
554 "*** Not deleting method namespace, there are still %d threads\n", 539 "*** Not deleting method namespace, there are still %d threads\n",
555 walk_state->method_desc->method.thread_count)); 540 walk_state->method_desc->method.
541 thread_count));
556 } 542 }
557 543
558 if (!walk_state->method_desc->method.thread_count) { 544 if (!walk_state->method_desc->method.thread_count) {
@@ -567,9 +553,11 @@ acpi_ds_terminate_control_method (
567 * before creating the synchronization semaphore. 553 * before creating the synchronization semaphore.
568 */ 554 */
569 if ((walk_state->method_desc->method.concurrency == 1) && 555 if ((walk_state->method_desc->method.concurrency == 1) &&
570 (!walk_state->method_desc->method.semaphore)) { 556 (!walk_state->method_desc->method.semaphore)) {
571 status = acpi_os_create_semaphore (1, 1, 557 status = acpi_os_create_semaphore(1, 1,
572 &walk_state->method_desc->method.semaphore); 558 &walk_state->
559 method_desc->method.
560 semaphore);
573 } 561 }
574 562
575 /* 563 /*
@@ -584,30 +572,30 @@ acpi_ds_terminate_control_method (
584 * Delete any namespace entries created immediately underneath 572 * Delete any namespace entries created immediately underneath
585 * the method 573 * the method
586 */ 574 */
587 status = acpi_ut_acquire_mutex (ACPI_MTX_NAMESPACE); 575 status = acpi_ut_acquire_mutex(ACPI_MTX_NAMESPACE);
588 if (ACPI_FAILURE (status)) { 576 if (ACPI_FAILURE(status)) {
589 return_ACPI_STATUS (status); 577 return_ACPI_STATUS(status);
590 } 578 }
591 579
592 if (method_node->child) { 580 if (method_node->child) {
593 acpi_ns_delete_namespace_subtree (method_node); 581 acpi_ns_delete_namespace_subtree(method_node);
594 } 582 }
595 583
596 /* 584 /*
597 * Delete any namespace entries created anywhere else within 585 * Delete any namespace entries created anywhere else within
598 * the namespace 586 * the namespace
599 */ 587 */
600 acpi_ns_delete_namespace_by_owner (walk_state->method_desc->method.owner_id); 588 acpi_ns_delete_namespace_by_owner(walk_state->method_desc->
601 status = acpi_ut_release_mutex (ACPI_MTX_NAMESPACE); 589 method.owner_id);
602 acpi_ut_release_owner_id (&walk_state->method_desc->method.owner_id); 590 status = acpi_ut_release_mutex(ACPI_MTX_NAMESPACE);
603 591 acpi_ut_release_owner_id(&walk_state->method_desc->method.
604 if (ACPI_FAILURE (status)) { 592 owner_id);
605 return_ACPI_STATUS (status); 593
594 if (ACPI_FAILURE(status)) {
595 return_ACPI_STATUS(status);
606 } 596 }
607 } 597 }
608 598
609 status = acpi_ut_release_mutex (ACPI_MTX_PARSER); 599 status = acpi_ut_release_mutex(ACPI_MTX_PARSER);
610 return_ACPI_STATUS (status); 600 return_ACPI_STATUS(status);
611} 601}
612
613