diff options
Diffstat (limited to 'drivers/acpi/acpica/rsxface.c')
-rw-r--r-- | drivers/acpi/acpica/rsxface.c | 101 |
1 files changed, 70 insertions, 31 deletions
diff --git a/drivers/acpi/acpica/rsxface.c b/drivers/acpi/acpica/rsxface.c index 3a5ace7e5352..a4086aabe865 100644 --- a/drivers/acpi/acpica/rsxface.c +++ b/drivers/acpi/acpica/rsxface.c | |||
@@ -423,7 +423,7 @@ ACPI_EXPORT_SYMBOL(acpi_resource_to_address64) | |||
423 | * | 423 | * |
424 | * RETURN: Status | 424 | * RETURN: Status |
425 | * | 425 | * |
426 | * DESCRIPTION: Walk a resource template for the specified evice to find a | 426 | * DESCRIPTION: Walk a resource template for the specified device to find a |
427 | * vendor-defined resource that matches the supplied UUID and | 427 | * vendor-defined resource that matches the supplied UUID and |
428 | * UUID subtype. Returns a struct acpi_resource of type Vendor. | 428 | * UUID subtype. Returns a struct acpi_resource of type Vendor. |
429 | * | 429 | * |
@@ -522,57 +522,42 @@ acpi_rs_match_vendor_resource(struct acpi_resource *resource, void *context) | |||
522 | 522 | ||
523 | /******************************************************************************* | 523 | /******************************************************************************* |
524 | * | 524 | * |
525 | * FUNCTION: acpi_walk_resources | 525 | * FUNCTION: acpi_walk_resource_buffer |
526 | * | 526 | * |
527 | * PARAMETERS: device_handle - Handle to the device object for the | 527 | * PARAMETERS: buffer - Formatted buffer returned by one of the |
528 | * device we are querying | 528 | * various Get*Resource functions |
529 | * name - Method name of the resources we want. | ||
530 | * (METHOD_NAME__CRS, METHOD_NAME__PRS, or | ||
531 | * METHOD_NAME__AEI) | ||
532 | * user_function - Called for each resource | 529 | * user_function - Called for each resource |
533 | * context - Passed to user_function | 530 | * context - Passed to user_function |
534 | * | 531 | * |
535 | * RETURN: Status | 532 | * RETURN: Status |
536 | * | 533 | * |
537 | * DESCRIPTION: Retrieves the current or possible resource list for the | 534 | * DESCRIPTION: Walks the input resource template. The user_function is called |
538 | * specified device. The user_function is called once for | 535 | * once for each resource in the list. |
539 | * each resource in the list. | ||
540 | * | 536 | * |
541 | ******************************************************************************/ | 537 | ******************************************************************************/ |
538 | |||
542 | acpi_status | 539 | acpi_status |
543 | acpi_walk_resources(acpi_handle device_handle, | 540 | acpi_walk_resource_buffer(struct acpi_buffer * buffer, |
544 | char *name, | 541 | acpi_walk_resource_callback user_function, |
545 | acpi_walk_resource_callback user_function, void *context) | 542 | void *context) |
546 | { | 543 | { |
547 | acpi_status status; | 544 | acpi_status status = AE_OK; |
548 | struct acpi_buffer buffer; | ||
549 | struct acpi_resource *resource; | 545 | struct acpi_resource *resource; |
550 | struct acpi_resource *resource_end; | 546 | struct acpi_resource *resource_end; |
551 | 547 | ||
552 | ACPI_FUNCTION_TRACE(acpi_walk_resources); | 548 | ACPI_FUNCTION_TRACE(acpi_walk_resource_buffer); |
553 | 549 | ||
554 | /* Parameter validation */ | 550 | /* Parameter validation */ |
555 | 551 | ||
556 | if (!device_handle || !user_function || !name || | 552 | if (!buffer || !buffer->pointer || !user_function) { |
557 | (!ACPI_COMPARE_NAME(name, METHOD_NAME__CRS) && | ||
558 | !ACPI_COMPARE_NAME(name, METHOD_NAME__PRS) && | ||
559 | !ACPI_COMPARE_NAME(name, METHOD_NAME__AEI))) { | ||
560 | return_ACPI_STATUS(AE_BAD_PARAMETER); | 553 | return_ACPI_STATUS(AE_BAD_PARAMETER); |
561 | } | 554 | } |
562 | 555 | ||
563 | /* Get the _CRS/_PRS/_AEI resource list */ | 556 | /* Buffer contains the resource list and length */ |
564 | |||
565 | buffer.length = ACPI_ALLOCATE_LOCAL_BUFFER; | ||
566 | status = acpi_rs_get_method_data(device_handle, name, &buffer); | ||
567 | if (ACPI_FAILURE(status)) { | ||
568 | return_ACPI_STATUS(status); | ||
569 | } | ||
570 | |||
571 | /* Buffer now contains the resource list */ | ||
572 | 557 | ||
573 | resource = ACPI_CAST_PTR(struct acpi_resource, buffer.pointer); | 558 | resource = ACPI_CAST_PTR(struct acpi_resource, buffer->pointer); |
574 | resource_end = | 559 | resource_end = |
575 | ACPI_ADD_PTR(struct acpi_resource, buffer.pointer, buffer.length); | 560 | ACPI_ADD_PTR(struct acpi_resource, buffer->pointer, buffer->length); |
576 | 561 | ||
577 | /* Walk the resource list until the end_tag is found (or buffer end) */ | 562 | /* Walk the resource list until the end_tag is found (or buffer end) */ |
578 | 563 | ||
@@ -609,6 +594,60 @@ acpi_walk_resources(acpi_handle device_handle, | |||
609 | resource = ACPI_NEXT_RESOURCE(resource); | 594 | resource = ACPI_NEXT_RESOURCE(resource); |
610 | } | 595 | } |
611 | 596 | ||
597 | return_ACPI_STATUS(status); | ||
598 | } | ||
599 | |||
600 | ACPI_EXPORT_SYMBOL(acpi_walk_resource_buffer) | ||
601 | |||
602 | /******************************************************************************* | ||
603 | * | ||
604 | * FUNCTION: acpi_walk_resources | ||
605 | * | ||
606 | * PARAMETERS: device_handle - Handle to the device object for the | ||
607 | * device we are querying | ||
608 | * name - Method name of the resources we want. | ||
609 | * (METHOD_NAME__CRS, METHOD_NAME__PRS, or | ||
610 | * METHOD_NAME__AEI) | ||
611 | * user_function - Called for each resource | ||
612 | * context - Passed to user_function | ||
613 | * | ||
614 | * RETURN: Status | ||
615 | * | ||
616 | * DESCRIPTION: Retrieves the current or possible resource list for the | ||
617 | * specified device. The user_function is called once for | ||
618 | * each resource in the list. | ||
619 | * | ||
620 | ******************************************************************************/ | ||
621 | acpi_status | ||
622 | acpi_walk_resources(acpi_handle device_handle, | ||
623 | char *name, | ||
624 | acpi_walk_resource_callback user_function, void *context) | ||
625 | { | ||
626 | acpi_status status; | ||
627 | struct acpi_buffer buffer; | ||
628 | |||
629 | ACPI_FUNCTION_TRACE(acpi_walk_resources); | ||
630 | |||
631 | /* Parameter validation */ | ||
632 | |||
633 | if (!device_handle || !user_function || !name || | ||
634 | (!ACPI_COMPARE_NAME(name, METHOD_NAME__CRS) && | ||
635 | !ACPI_COMPARE_NAME(name, METHOD_NAME__PRS) && | ||
636 | !ACPI_COMPARE_NAME(name, METHOD_NAME__AEI))) { | ||
637 | return_ACPI_STATUS(AE_BAD_PARAMETER); | ||
638 | } | ||
639 | |||
640 | /* Get the _CRS/_PRS/_AEI resource list */ | ||
641 | |||
642 | buffer.length = ACPI_ALLOCATE_LOCAL_BUFFER; | ||
643 | status = acpi_rs_get_method_data(device_handle, name, &buffer); | ||
644 | if (ACPI_FAILURE(status)) { | ||
645 | return_ACPI_STATUS(status); | ||
646 | } | ||
647 | |||
648 | /* Walk the resource list and cleanup */ | ||
649 | |||
650 | status = acpi_walk_resource_buffer(&buffer, user_function, context); | ||
612 | ACPI_FREE(buffer.pointer); | 651 | ACPI_FREE(buffer.pointer); |
613 | return_ACPI_STATUS(status); | 652 | return_ACPI_STATUS(status); |
614 | } | 653 | } |