aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/acpi/namespace/nseval.c
diff options
context:
space:
mode:
authorLen Brown <len.brown@intel.com>2005-08-05 00:44:28 -0400
committerLen Brown <len.brown@intel.com>2005-08-05 00:45:14 -0400
commit4be44fcd3bf648b782f4460fd06dfae6c42ded4b (patch)
tree5b5b7d296ea58786f53b95e5eac9565ff66890b0 /drivers/acpi/namespace/nseval.c
parentc65ade4dc8b486e8c8b9b0a6399789a5428e2039 (diff)
[ACPI] Lindent all ACPI files
Signed-off-by: Len Brown <len.brown@intel.com>
Diffstat (limited to 'drivers/acpi/namespace/nseval.c')
-rw-r--r--drivers/acpi/namespace/nseval.c270
1 files changed, 122 insertions, 148 deletions
diff --git a/drivers/acpi/namespace/nseval.c b/drivers/acpi/namespace/nseval.c
index 908cffd5e720..0191c7d92824 100644
--- a/drivers/acpi/namespace/nseval.c
+++ b/drivers/acpi/namespace/nseval.c
@@ -42,26 +42,19 @@
42 * POSSIBILITY OF SUCH DAMAGES. 42 * POSSIBILITY OF SUCH DAMAGES.
43 */ 43 */
44 44
45
46#include <acpi/acpi.h> 45#include <acpi/acpi.h>
47#include <acpi/acparser.h> 46#include <acpi/acparser.h>
48#include <acpi/acinterp.h> 47#include <acpi/acinterp.h>
49#include <acpi/acnamesp.h> 48#include <acpi/acnamesp.h>
50 49
51
52#define _COMPONENT ACPI_NAMESPACE 50#define _COMPONENT ACPI_NAMESPACE
53 ACPI_MODULE_NAME ("nseval") 51ACPI_MODULE_NAME("nseval")
54 52
55/* Local prototypes */ 53/* Local prototypes */
56
57static acpi_status 54static acpi_status
58acpi_ns_execute_control_method ( 55acpi_ns_execute_control_method(struct acpi_parameter_info *info);
59 struct acpi_parameter_info *info);
60
61static acpi_status
62acpi_ns_get_object_value (
63 struct acpi_parameter_info *info);
64 56
57static acpi_status acpi_ns_get_object_value(struct acpi_parameter_info *info);
65 58
66/******************************************************************************* 59/*******************************************************************************
67 * 60 *
@@ -85,48 +78,44 @@ acpi_ns_get_object_value (
85 ******************************************************************************/ 78 ******************************************************************************/
86 79
87acpi_status 80acpi_status
88acpi_ns_evaluate_relative ( 81acpi_ns_evaluate_relative(char *pathname, struct acpi_parameter_info *info)
89 char *pathname,
90 struct acpi_parameter_info *info)
91{ 82{
92 acpi_status status; 83 acpi_status status;
93 struct acpi_namespace_node *node = NULL; 84 struct acpi_namespace_node *node = NULL;
94 union acpi_generic_state *scope_info; 85 union acpi_generic_state *scope_info;
95 char *internal_path = NULL; 86 char *internal_path = NULL;
96
97
98 ACPI_FUNCTION_TRACE ("ns_evaluate_relative");
99 87
88 ACPI_FUNCTION_TRACE("ns_evaluate_relative");
100 89
101 /* 90 /*
102 * Must have a valid object handle 91 * Must have a valid object handle
103 */ 92 */
104 if (!info || !info->node) { 93 if (!info || !info->node) {
105 return_ACPI_STATUS (AE_BAD_PARAMETER); 94 return_ACPI_STATUS(AE_BAD_PARAMETER);
106 } 95 }
107 96
108 /* Build an internal name string for the method */ 97 /* Build an internal name string for the method */
109 98
110 status = acpi_ns_internalize_name (pathname, &internal_path); 99 status = acpi_ns_internalize_name(pathname, &internal_path);
111 if (ACPI_FAILURE (status)) { 100 if (ACPI_FAILURE(status)) {
112 return_ACPI_STATUS (status); 101 return_ACPI_STATUS(status);
113 } 102 }
114 103
115 scope_info = acpi_ut_create_generic_state (); 104 scope_info = acpi_ut_create_generic_state();
116 if (!scope_info) { 105 if (!scope_info) {
117 goto cleanup1; 106 goto cleanup1;
118 } 107 }
119 108
120 /* Get the prefix handle and Node */ 109 /* Get the prefix handle and Node */
121 110
122 status = acpi_ut_acquire_mutex (ACPI_MTX_NAMESPACE); 111 status = acpi_ut_acquire_mutex(ACPI_MTX_NAMESPACE);
123 if (ACPI_FAILURE (status)) { 112 if (ACPI_FAILURE(status)) {
124 goto cleanup; 113 goto cleanup;
125 } 114 }
126 115
127 info->node = acpi_ns_map_handle_to_node (info->node); 116 info->node = acpi_ns_map_handle_to_node(info->node);
128 if (!info->node) { 117 if (!info->node) {
129 (void) acpi_ut_release_mutex (ACPI_MTX_NAMESPACE); 118 (void)acpi_ut_release_mutex(ACPI_MTX_NAMESPACE);
130 status = AE_BAD_PARAMETER; 119 status = AE_BAD_PARAMETER;
131 goto cleanup; 120 goto cleanup;
132 } 121 }
@@ -134,39 +123,38 @@ acpi_ns_evaluate_relative (
134 /* Lookup the name in the namespace */ 123 /* Lookup the name in the namespace */
135 124
136 scope_info->scope.node = info->node; 125 scope_info->scope.node = info->node;
137 status = acpi_ns_lookup (scope_info, internal_path, ACPI_TYPE_ANY, 126 status = acpi_ns_lookup(scope_info, internal_path, ACPI_TYPE_ANY,
138 ACPI_IMODE_EXECUTE, ACPI_NS_NO_UPSEARCH, NULL, 127 ACPI_IMODE_EXECUTE, ACPI_NS_NO_UPSEARCH, NULL,
139 &node); 128 &node);
140 129
141 (void) acpi_ut_release_mutex (ACPI_MTX_NAMESPACE); 130 (void)acpi_ut_release_mutex(ACPI_MTX_NAMESPACE);
142 131
143 if (ACPI_FAILURE (status)) { 132 if (ACPI_FAILURE(status)) {
144 ACPI_DEBUG_PRINT ((ACPI_DB_NAMES, "Object [%s] not found [%s]\n", 133 ACPI_DEBUG_PRINT((ACPI_DB_NAMES, "Object [%s] not found [%s]\n",
145 pathname, acpi_format_exception (status))); 134 pathname, acpi_format_exception(status)));
146 goto cleanup; 135 goto cleanup;
147 } 136 }
148 137
149 /* 138 /*
150 * Now that we have a handle to the object, we can attempt to evaluate it. 139 * Now that we have a handle to the object, we can attempt to evaluate it.
151 */ 140 */
152 ACPI_DEBUG_PRINT ((ACPI_DB_NAMES, "%s [%p] Value %p\n", 141 ACPI_DEBUG_PRINT((ACPI_DB_NAMES, "%s [%p] Value %p\n",
153 pathname, node, acpi_ns_get_attached_object (node))); 142 pathname, node, acpi_ns_get_attached_object(node)));
154 143
155 info->node = node; 144 info->node = node;
156 status = acpi_ns_evaluate_by_handle (info); 145 status = acpi_ns_evaluate_by_handle(info);
157 146
158 ACPI_DEBUG_PRINT ((ACPI_DB_NAMES, "*** Completed eval of object %s ***\n", 147 ACPI_DEBUG_PRINT((ACPI_DB_NAMES,
159 pathname)); 148 "*** Completed eval of object %s ***\n", pathname));
160 149
161cleanup: 150 cleanup:
162 acpi_ut_delete_generic_state (scope_info); 151 acpi_ut_delete_generic_state(scope_info);
163 152
164cleanup1: 153 cleanup1:
165 ACPI_MEM_FREE (internal_path); 154 ACPI_MEM_FREE(internal_path);
166 return_ACPI_STATUS (status); 155 return_ACPI_STATUS(status);
167} 156}
168 157
169
170/******************************************************************************* 158/*******************************************************************************
171 * 159 *
172 * FUNCTION: acpi_ns_evaluate_by_name 160 * FUNCTION: acpi_ns_evaluate_by_name
@@ -189,68 +177,63 @@ cleanup1:
189 ******************************************************************************/ 177 ******************************************************************************/
190 178
191acpi_status 179acpi_status
192acpi_ns_evaluate_by_name ( 180acpi_ns_evaluate_by_name(char *pathname, struct acpi_parameter_info *info)
193 char *pathname,
194 struct acpi_parameter_info *info)
195{ 181{
196 acpi_status status; 182 acpi_status status;
197 char *internal_path = NULL; 183 char *internal_path = NULL;
198
199
200 ACPI_FUNCTION_TRACE ("ns_evaluate_by_name");
201 184
185 ACPI_FUNCTION_TRACE("ns_evaluate_by_name");
202 186
203 /* Build an internal name string for the method */ 187 /* Build an internal name string for the method */
204 188
205 status = acpi_ns_internalize_name (pathname, &internal_path); 189 status = acpi_ns_internalize_name(pathname, &internal_path);
206 if (ACPI_FAILURE (status)) { 190 if (ACPI_FAILURE(status)) {
207 return_ACPI_STATUS (status); 191 return_ACPI_STATUS(status);
208 } 192 }
209 193
210 status = acpi_ut_acquire_mutex (ACPI_MTX_NAMESPACE); 194 status = acpi_ut_acquire_mutex(ACPI_MTX_NAMESPACE);
211 if (ACPI_FAILURE (status)) { 195 if (ACPI_FAILURE(status)) {
212 goto cleanup; 196 goto cleanup;
213 } 197 }
214 198
215 /* Lookup the name in the namespace */ 199 /* Lookup the name in the namespace */
216 200
217 status = acpi_ns_lookup (NULL, internal_path, ACPI_TYPE_ANY, 201 status = acpi_ns_lookup(NULL, internal_path, ACPI_TYPE_ANY,
218 ACPI_IMODE_EXECUTE, ACPI_NS_NO_UPSEARCH, NULL, 202 ACPI_IMODE_EXECUTE, ACPI_NS_NO_UPSEARCH, NULL,
219 &info->node); 203 &info->node);
220 204
221 (void) acpi_ut_release_mutex (ACPI_MTX_NAMESPACE); 205 (void)acpi_ut_release_mutex(ACPI_MTX_NAMESPACE);
222 206
223 if (ACPI_FAILURE (status)) { 207 if (ACPI_FAILURE(status)) {
224 ACPI_DEBUG_PRINT ((ACPI_DB_NAMES, 208 ACPI_DEBUG_PRINT((ACPI_DB_NAMES,
225 "Object at [%s] was not found, status=%.4X\n", 209 "Object at [%s] was not found, status=%.4X\n",
226 pathname, status)); 210 pathname, status));
227 goto cleanup; 211 goto cleanup;
228 } 212 }
229 213
230 /* 214 /*
231 * Now that we have a handle to the object, we can attempt to evaluate it. 215 * Now that we have a handle to the object, we can attempt to evaluate it.
232 */ 216 */
233 ACPI_DEBUG_PRINT ((ACPI_DB_NAMES, "%s [%p] Value %p\n", 217 ACPI_DEBUG_PRINT((ACPI_DB_NAMES, "%s [%p] Value %p\n",
234 pathname, info->node, acpi_ns_get_attached_object (info->node))); 218 pathname, info->node,
235 219 acpi_ns_get_attached_object(info->node)));
236 status = acpi_ns_evaluate_by_handle (info);
237 220
238 ACPI_DEBUG_PRINT ((ACPI_DB_NAMES, "*** Completed eval of object %s ***\n", 221 status = acpi_ns_evaluate_by_handle(info);
239 pathname));
240 222
223 ACPI_DEBUG_PRINT((ACPI_DB_NAMES,
224 "*** Completed eval of object %s ***\n", pathname));
241 225
242cleanup: 226 cleanup:
243 227
244 /* Cleanup */ 228 /* Cleanup */
245 229
246 if (internal_path) { 230 if (internal_path) {
247 ACPI_MEM_FREE (internal_path); 231 ACPI_MEM_FREE(internal_path);
248 } 232 }
249 233
250 return_ACPI_STATUS (status); 234 return_ACPI_STATUS(status);
251} 235}
252 236
253
254/******************************************************************************* 237/*******************************************************************************
255 * 238 *
256 * FUNCTION: acpi_ns_evaluate_by_handle 239 * FUNCTION: acpi_ns_evaluate_by_handle
@@ -275,26 +258,22 @@ cleanup:
275 * 258 *
276 ******************************************************************************/ 259 ******************************************************************************/
277 260
278acpi_status 261acpi_status acpi_ns_evaluate_by_handle(struct acpi_parameter_info *info)
279acpi_ns_evaluate_by_handle (
280 struct acpi_parameter_info *info)
281{ 262{
282 acpi_status status; 263 acpi_status status;
283
284
285 ACPI_FUNCTION_TRACE ("ns_evaluate_by_handle");
286 264
265 ACPI_FUNCTION_TRACE("ns_evaluate_by_handle");
287 266
288 /* Check if namespace has been initialized */ 267 /* Check if namespace has been initialized */
289 268
290 if (!acpi_gbl_root_node) { 269 if (!acpi_gbl_root_node) {
291 return_ACPI_STATUS (AE_NO_NAMESPACE); 270 return_ACPI_STATUS(AE_NO_NAMESPACE);
292 } 271 }
293 272
294 /* Parameter Validation */ 273 /* Parameter Validation */
295 274
296 if (!info) { 275 if (!info) {
297 return_ACPI_STATUS (AE_BAD_PARAMETER); 276 return_ACPI_STATUS(AE_BAD_PARAMETER);
298 } 277 }
299 278
300 /* Initialize the return value to an invalid object */ 279 /* Initialize the return value to an invalid object */
@@ -303,23 +282,25 @@ acpi_ns_evaluate_by_handle (
303 282
304 /* Get the prefix handle and Node */ 283 /* Get the prefix handle and Node */
305 284
306 status = acpi_ut_acquire_mutex (ACPI_MTX_NAMESPACE); 285 status = acpi_ut_acquire_mutex(ACPI_MTX_NAMESPACE);
307 if (ACPI_FAILURE (status)) { 286 if (ACPI_FAILURE(status)) {
308 return_ACPI_STATUS (status); 287 return_ACPI_STATUS(status);
309 } 288 }
310 289
311 info->node = acpi_ns_map_handle_to_node (info->node); 290 info->node = acpi_ns_map_handle_to_node(info->node);
312 if (!info->node) { 291 if (!info->node) {
313 (void) acpi_ut_release_mutex (ACPI_MTX_NAMESPACE); 292 (void)acpi_ut_release_mutex(ACPI_MTX_NAMESPACE);
314 return_ACPI_STATUS (AE_BAD_PARAMETER); 293 return_ACPI_STATUS(AE_BAD_PARAMETER);
315 } 294 }
316 295
317 /* 296 /*
318 * For a method alias, we must grab the actual method node so that proper 297 * For a method alias, we must grab the actual method node so that proper
319 * scoping context will be established before execution. 298 * scoping context will be established before execution.
320 */ 299 */
321 if (acpi_ns_get_type (info->node) == ACPI_TYPE_LOCAL_METHOD_ALIAS) { 300 if (acpi_ns_get_type(info->node) == ACPI_TYPE_LOCAL_METHOD_ALIAS) {
322 info->node = ACPI_CAST_PTR (struct acpi_namespace_node, info->node->object); 301 info->node =
302 ACPI_CAST_PTR(struct acpi_namespace_node,
303 info->node->object);
323 } 304 }
324 305
325 /* 306 /*
@@ -329,17 +310,16 @@ acpi_ns_evaluate_by_handle (
329 * 310 *
330 * In both cases, the namespace is unlocked by the acpi_ns* procedure 311 * In both cases, the namespace is unlocked by the acpi_ns* procedure
331 */ 312 */
332 if (acpi_ns_get_type (info->node) == ACPI_TYPE_METHOD) { 313 if (acpi_ns_get_type(info->node) == ACPI_TYPE_METHOD) {
333 /* 314 /*
334 * Case 1) We have an actual control method to execute 315 * Case 1) We have an actual control method to execute
335 */ 316 */
336 status = acpi_ns_execute_control_method (info); 317 status = acpi_ns_execute_control_method(info);
337 } 318 } else {
338 else {
339 /* 319 /*
340 * Case 2) Object is NOT a method, just return its current value 320 * Case 2) Object is NOT a method, just return its current value
341 */ 321 */
342 status = acpi_ns_get_object_value (info); 322 status = acpi_ns_get_object_value(info);
343 } 323 }
344 324
345 /* 325 /*
@@ -355,10 +335,9 @@ acpi_ns_evaluate_by_handle (
355 * Namespace was unlocked by the handling acpi_ns* function, so we 335 * Namespace was unlocked by the handling acpi_ns* function, so we
356 * just return 336 * just return
357 */ 337 */
358 return_ACPI_STATUS (status); 338 return_ACPI_STATUS(status);
359} 339}
360 340
361
362/******************************************************************************* 341/*******************************************************************************
363 * 342 *
364 * FUNCTION: acpi_ns_execute_control_method 343 * FUNCTION: acpi_ns_execute_control_method
@@ -384,30 +363,29 @@ acpi_ns_evaluate_by_handle (
384 ******************************************************************************/ 363 ******************************************************************************/
385 364
386static acpi_status 365static acpi_status
387acpi_ns_execute_control_method ( 366acpi_ns_execute_control_method(struct acpi_parameter_info *info)
388 struct acpi_parameter_info *info)
389{ 367{
390 acpi_status status; 368 acpi_status status;
391
392
393 ACPI_FUNCTION_TRACE ("ns_execute_control_method");
394 369
370 ACPI_FUNCTION_TRACE("ns_execute_control_method");
395 371
396 /* Verify that there is a method associated with this object */ 372 /* Verify that there is a method associated with this object */
397 373
398 info->obj_desc = acpi_ns_get_attached_object (info->node); 374 info->obj_desc = acpi_ns_get_attached_object(info->node);
399 if (!info->obj_desc) { 375 if (!info->obj_desc) {
400 ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "No attached method object\n")); 376 ACPI_DEBUG_PRINT((ACPI_DB_ERROR,
377 "No attached method object\n"));
401 378
402 (void) acpi_ut_release_mutex (ACPI_MTX_NAMESPACE); 379 (void)acpi_ut_release_mutex(ACPI_MTX_NAMESPACE);
403 return_ACPI_STATUS (AE_NULL_OBJECT); 380 return_ACPI_STATUS(AE_NULL_OBJECT);
404 } 381 }
405 382
406 ACPI_DUMP_PATHNAME (info->node, "Execute Method:", 383 ACPI_DUMP_PATHNAME(info->node, "Execute Method:",
407 ACPI_LV_INFO, _COMPONENT); 384 ACPI_LV_INFO, _COMPONENT);
408 385
409 ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "Method at AML address %p Length %X\n", 386 ACPI_DEBUG_PRINT((ACPI_DB_EXEC, "Method at AML address %p Length %X\n",
410 info->obj_desc->method.aml_start + 1, info->obj_desc->method.aml_length - 1)); 387 info->obj_desc->method.aml_start + 1,
388 info->obj_desc->method.aml_length - 1));
411 389
412 /* 390 /*
413 * Unlock the namespace before execution. This allows namespace access 391 * Unlock the namespace before execution. This allows namespace access
@@ -416,27 +394,26 @@ acpi_ns_execute_control_method (
416 * interpreter locks to ensure that no thread is using the portion of the 394 * interpreter locks to ensure that no thread is using the portion of the
417 * namespace that is being deleted. 395 * namespace that is being deleted.
418 */ 396 */
419 status = acpi_ut_release_mutex (ACPI_MTX_NAMESPACE); 397 status = acpi_ut_release_mutex(ACPI_MTX_NAMESPACE);
420 if (ACPI_FAILURE (status)) { 398 if (ACPI_FAILURE(status)) {
421 return_ACPI_STATUS (status); 399 return_ACPI_STATUS(status);
422 } 400 }
423 401
424 /* 402 /*
425 * Execute the method via the interpreter. The interpreter is locked 403 * Execute the method via the interpreter. The interpreter is locked
426 * here before calling into the AML parser 404 * here before calling into the AML parser
427 */ 405 */
428 status = acpi_ex_enter_interpreter (); 406 status = acpi_ex_enter_interpreter();
429 if (ACPI_FAILURE (status)) { 407 if (ACPI_FAILURE(status)) {
430 return_ACPI_STATUS (status); 408 return_ACPI_STATUS(status);
431 } 409 }
432 410
433 status = acpi_ps_execute_method (info); 411 status = acpi_ps_execute_method(info);
434 acpi_ex_exit_interpreter (); 412 acpi_ex_exit_interpreter();
435 413
436 return_ACPI_STATUS (status); 414 return_ACPI_STATUS(status);
437} 415}
438 416
439
440/******************************************************************************* 417/*******************************************************************************
441 * 418 *
442 * FUNCTION: acpi_ns_get_object_value 419 * FUNCTION: acpi_ns_get_object_value
@@ -454,16 +431,12 @@ acpi_ns_execute_control_method (
454 * 431 *
455 ******************************************************************************/ 432 ******************************************************************************/
456 433
457static acpi_status 434static acpi_status acpi_ns_get_object_value(struct acpi_parameter_info *info)
458acpi_ns_get_object_value (
459 struct acpi_parameter_info *info)
460{ 435{
461 acpi_status status = AE_OK; 436 acpi_status status = AE_OK;
462 struct acpi_namespace_node *resolved_node = info->node; 437 struct acpi_namespace_node *resolved_node = info->node;
463
464
465 ACPI_FUNCTION_TRACE ("ns_get_object_value");
466 438
439 ACPI_FUNCTION_TRACE("ns_get_object_value");
467 440
468 /* 441 /*
469 * Objects require additional resolution steps (e.g., the Node may be a 442 * Objects require additional resolution steps (e.g., the Node may be a
@@ -486,32 +459,33 @@ acpi_ns_get_object_value (
486 * 459 *
487 * We must release the namespace lock before entering the intepreter. 460 * We must release the namespace lock before entering the intepreter.
488 */ 461 */
489 status = acpi_ut_release_mutex (ACPI_MTX_NAMESPACE); 462 status = acpi_ut_release_mutex(ACPI_MTX_NAMESPACE);
490 if (ACPI_FAILURE (status)) { 463 if (ACPI_FAILURE(status)) {
491 return_ACPI_STATUS (status); 464 return_ACPI_STATUS(status);
492 } 465 }
493 466
494 status = acpi_ex_enter_interpreter (); 467 status = acpi_ex_enter_interpreter();
495 if (ACPI_SUCCESS (status)) { 468 if (ACPI_SUCCESS(status)) {
496 status = acpi_ex_resolve_node_to_value (&resolved_node, NULL); 469 status = acpi_ex_resolve_node_to_value(&resolved_node, NULL);
497 /* 470 /*
498 * If acpi_ex_resolve_node_to_value() succeeded, the return value was placed 471 * If acpi_ex_resolve_node_to_value() succeeded, the return value was placed
499 * in resolved_node. 472 * in resolved_node.
500 */ 473 */
501 acpi_ex_exit_interpreter (); 474 acpi_ex_exit_interpreter();
502 475
503 if (ACPI_SUCCESS (status)) { 476 if (ACPI_SUCCESS(status)) {
504 status = AE_CTRL_RETURN_VALUE; 477 status = AE_CTRL_RETURN_VALUE;
505 info->return_object = ACPI_CAST_PTR 478 info->return_object = ACPI_CAST_PTR
506 (union acpi_operand_object, resolved_node); 479 (union acpi_operand_object, resolved_node);
507 ACPI_DEBUG_PRINT ((ACPI_DB_NAMES, "Returning object %p [%s]\n", 480 ACPI_DEBUG_PRINT((ACPI_DB_NAMES,
508 info->return_object, 481 "Returning object %p [%s]\n",
509 acpi_ut_get_object_type_name (info->return_object))); 482 info->return_object,
483 acpi_ut_get_object_type_name(info->
484 return_object)));
510 } 485 }
511 } 486 }
512 487
513 /* Namespace is unlocked */ 488 /* Namespace is unlocked */
514 489
515 return_ACPI_STATUS (status); 490 return_ACPI_STATUS(status);
516} 491}
517