diff options
Diffstat (limited to 'drivers/acpi/namespace/nsxfeval.c')
-rw-r--r-- | drivers/acpi/namespace/nsxfeval.c | 78 |
1 files changed, 78 insertions, 0 deletions
diff --git a/drivers/acpi/namespace/nsxfeval.c b/drivers/acpi/namespace/nsxfeval.c index 38be5865d95d..a085cc39c055 100644 --- a/drivers/acpi/namespace/nsxfeval.c +++ b/drivers/acpi/namespace/nsxfeval.c | |||
@@ -48,6 +48,10 @@ | |||
48 | 48 | ||
49 | #define _COMPONENT ACPI_NAMESPACE | 49 | #define _COMPONENT ACPI_NAMESPACE |
50 | ACPI_MODULE_NAME("nsxfeval") | 50 | ACPI_MODULE_NAME("nsxfeval") |
51 | |||
52 | /* Local prototypes */ | ||
53 | static void acpi_ns_resolve_references(struct acpi_evaluate_info *info); | ||
54 | |||
51 | #ifdef ACPI_FUTURE_USAGE | 55 | #ifdef ACPI_FUTURE_USAGE |
52 | /******************************************************************************* | 56 | /******************************************************************************* |
53 | * | 57 | * |
@@ -69,6 +73,7 @@ ACPI_MODULE_NAME("nsxfeval") | |||
69 | * be valid (non-null) | 73 | * be valid (non-null) |
70 | * | 74 | * |
71 | ******************************************************************************/ | 75 | ******************************************************************************/ |
76 | |||
72 | acpi_status | 77 | acpi_status |
73 | acpi_evaluate_object_typed(acpi_handle handle, | 78 | acpi_evaluate_object_typed(acpi_handle handle, |
74 | acpi_string pathname, | 79 | acpi_string pathname, |
@@ -283,6 +288,10 @@ acpi_evaluate_object(acpi_handle handle, | |||
283 | 288 | ||
284 | if (ACPI_SUCCESS(status)) { | 289 | if (ACPI_SUCCESS(status)) { |
285 | 290 | ||
291 | /* Dereference Index and ref_of references */ | ||
292 | |||
293 | acpi_ns_resolve_references(info); | ||
294 | |||
286 | /* Get the size of the returned object */ | 295 | /* Get the size of the returned object */ |
287 | 296 | ||
288 | status = | 297 | status = |
@@ -352,6 +361,74 @@ ACPI_EXPORT_SYMBOL(acpi_evaluate_object) | |||
352 | 361 | ||
353 | /******************************************************************************* | 362 | /******************************************************************************* |
354 | * | 363 | * |
364 | * FUNCTION: acpi_ns_resolve_references | ||
365 | * | ||
366 | * PARAMETERS: Info - Evaluation info block | ||
367 | * | ||
368 | * RETURN: Info->return_object is replaced with the dereferenced object | ||
369 | * | ||
370 | * DESCRIPTION: Dereference certain reference objects. Called before an | ||
371 | * internal return object is converted to an external union acpi_object. | ||
372 | * | ||
373 | * Performs an automatic dereference of Index and ref_of reference objects. | ||
374 | * These reference objects are not supported by the union acpi_object, so this is a | ||
375 | * last resort effort to return something useful. Also, provides compatibility | ||
376 | * with other ACPI implementations. | ||
377 | * | ||
378 | * NOTE: does not handle references within returned package objects or nested | ||
379 | * references, but this support could be added later if found to be necessary. | ||
380 | * | ||
381 | ******************************************************************************/ | ||
382 | static void acpi_ns_resolve_references(struct acpi_evaluate_info *info) | ||
383 | { | ||
384 | union acpi_operand_object *obj_desc = NULL; | ||
385 | struct acpi_namespace_node *node; | ||
386 | |||
387 | /* We are interested in reference objects only */ | ||
388 | |||
389 | if (ACPI_GET_OBJECT_TYPE(info->return_object) != | ||
390 | ACPI_TYPE_LOCAL_REFERENCE) { | ||
391 | return; | ||
392 | } | ||
393 | |||
394 | /* | ||
395 | * Two types of references are supported - those created by Index and | ||
396 | * ref_of operators. A name reference (AML_NAMEPATH_OP) can be converted | ||
397 | * to an union acpi_object, so it is not dereferenced here. A ddb_handle | ||
398 | * (AML_LOAD_OP) cannot be dereferenced, nor can it be converted to | ||
399 | * an union acpi_object. | ||
400 | */ | ||
401 | switch (info->return_object->reference.class) { | ||
402 | case ACPI_REFCLASS_INDEX: | ||
403 | |||
404 | obj_desc = *(info->return_object->reference.where); | ||
405 | break; | ||
406 | |||
407 | case ACPI_REFCLASS_REFOF: | ||
408 | |||
409 | node = info->return_object->reference.object; | ||
410 | if (node) { | ||
411 | obj_desc = node->object; | ||
412 | } | ||
413 | break; | ||
414 | |||
415 | default: | ||
416 | return; | ||
417 | } | ||
418 | |||
419 | /* Replace the existing reference object */ | ||
420 | |||
421 | if (obj_desc) { | ||
422 | acpi_ut_add_reference(obj_desc); | ||
423 | acpi_ut_remove_reference(info->return_object); | ||
424 | info->return_object = obj_desc; | ||
425 | } | ||
426 | |||
427 | return; | ||
428 | } | ||
429 | |||
430 | /******************************************************************************* | ||
431 | * | ||
355 | * FUNCTION: acpi_walk_namespace | 432 | * FUNCTION: acpi_walk_namespace |
356 | * | 433 | * |
357 | * PARAMETERS: Type - acpi_object_type to search for | 434 | * PARAMETERS: Type - acpi_object_type to search for |
@@ -379,6 +456,7 @@ ACPI_EXPORT_SYMBOL(acpi_evaluate_object) | |||
379 | * function, etc. | 456 | * function, etc. |
380 | * | 457 | * |
381 | ******************************************************************************/ | 458 | ******************************************************************************/ |
459 | |||
382 | acpi_status | 460 | acpi_status |
383 | acpi_walk_namespace(acpi_object_type type, | 461 | acpi_walk_namespace(acpi_object_type type, |
384 | acpi_handle start_object, | 462 | acpi_handle start_object, |