aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBob Moore <robert.moore@intel.com>2012-12-30 19:03:58 -0500
committerRafael J. Wysocki <rafael.j.wysocki@intel.com>2013-01-10 06:36:19 -0500
commitafb1bbee804f473f70dc890a94cb9f0acc358012 (patch)
tree0134588c1d6f57615f848e771079ea530562f420
parent1cd4e951e59ec1754ceafa41562280b42000707e (diff)
ACPICA: Resources: New interface, AcpiWalkResourceBuffer.
Implements a new interface for walking resource lists that it at a lower level than the existing AcpiWalkResources. (Method is not executed.) Signed-off-by: Bob Moore <robert.moore@intel.com> Signed-off-by: Lv Zheng <lv.zheng@intel.com> Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
-rw-r--r--drivers/acpi/acpica/rsxface.c101
-rw-r--r--include/acpi/acpixf.h5
-rw-r--r--include/acpi/actypes.h4
3 files changed, 79 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
542acpi_status 539acpi_status
543acpi_walk_resources(acpi_handle device_handle, 540acpi_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
600ACPI_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 ******************************************************************************/
621acpi_status
622acpi_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}
diff --git a/include/acpi/acpixf.h b/include/acpi/acpixf.h
index 3c9c783b6604..afacb5a9671a 100644
--- a/include/acpi/acpixf.h
+++ b/include/acpi/acpixf.h
@@ -444,6 +444,11 @@ acpi_get_event_resources(acpi_handle device_handle,
444 struct acpi_buffer *ret_buffer); 444 struct acpi_buffer *ret_buffer);
445 445
446acpi_status 446acpi_status
447acpi_walk_resource_buffer(struct acpi_buffer *buffer,
448 acpi_walk_resource_callback user_function,
449 void *context);
450
451acpi_status
447acpi_walk_resources(acpi_handle device, 452acpi_walk_resources(acpi_handle device,
448 char *name, 453 char *name,
449 acpi_walk_resource_callback user_function, void *context); 454 acpi_walk_resource_callback user_function, void *context);
diff --git a/include/acpi/actypes.h b/include/acpi/actypes.h
index 6882227d1706..3de70eddd4e5 100644
--- a/include/acpi/actypes.h
+++ b/include/acpi/actypes.h
@@ -881,6 +881,10 @@ struct acpi_buffer {
881 void *pointer; /* pointer to buffer */ 881 void *pointer; /* pointer to buffer */
882}; 882};
883 883
884/* Free a buffer created in an struct acpi_buffer via ACPI_ALLOCATE_LOCAL_BUFFER */
885
886#define ACPI_FREE_BUFFER(b) ACPI_FREE(b.pointer)
887
884/* 888/*
885 * name_type for acpi_get_name 889 * name_type for acpi_get_name
886 */ 890 */