ACPICA: Resources: New interface, AcpiWalkResourceBuffer.
authorBob Moore <robert.moore@intel.com>
Mon, 31 Dec 2012 00:03:58 +0000 (00:03 +0000)
committerRafael J. Wysocki <rafael.j.wysocki@intel.com>
Thu, 10 Jan 2013 11:36:19 +0000 (12:36 +0100)
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>
drivers/acpi/acpica/rsxface.c
include/acpi/acpixf.h
include/acpi/actypes.h

index 3a5ace7e53525fc5757c6645e8b45ad74ac42f6c..a4086aabe865d94546e3345ff1f1c5476c0232d2 100644 (file)
@@ -423,7 +423,7 @@ ACPI_EXPORT_SYMBOL(acpi_resource_to_address64)
  *
  * RETURN:      Status
  *
- * DESCRIPTION: Walk a resource template for the specified evice to find a
+ * DESCRIPTION: Walk a resource template for the specified device to find a
  *              vendor-defined resource that matches the supplied UUID and
  *              UUID subtype. Returns a struct acpi_resource of type Vendor.
  *
@@ -522,57 +522,42 @@ acpi_rs_match_vendor_resource(struct acpi_resource *resource, void *context)
 
 /*******************************************************************************
  *
- * FUNCTION:    acpi_walk_resources
+ * FUNCTION:    acpi_walk_resource_buffer
  *
- * PARAMETERS:  device_handle   - Handle to the device object for the
- *                                device we are querying
- *              name            - Method name of the resources we want.
- *                                (METHOD_NAME__CRS, METHOD_NAME__PRS, or
- *                                METHOD_NAME__AEI)
+ * PARAMETERS:  buffer          - Formatted buffer returned by one of the
+ *                                various Get*Resource functions
  *              user_function   - Called for each resource
  *              context         - Passed to user_function
  *
  * RETURN:      Status
  *
- * DESCRIPTION: Retrieves the current or possible resource list for the
- *              specified device. The user_function is called once for
- *              each resource in the list.
+ * DESCRIPTION: Walks the input resource template. The user_function is called
+ *              once for each resource in the list.
  *
  ******************************************************************************/
+
 acpi_status
-acpi_walk_resources(acpi_handle device_handle,
-                   char *name,
-                   acpi_walk_resource_callback user_function, void *context)
+acpi_walk_resource_buffer(struct acpi_buffer * buffer,
+                         acpi_walk_resource_callback user_function,
+                         void *context)
 {
-       acpi_status status;
-       struct acpi_buffer buffer;
+       acpi_status status = AE_OK;
        struct acpi_resource *resource;
        struct acpi_resource *resource_end;
 
-       ACPI_FUNCTION_TRACE(acpi_walk_resources);
+       ACPI_FUNCTION_TRACE(acpi_walk_resource_buffer);
 
        /* Parameter validation */
 
-       if (!device_handle || !user_function || !name ||
-           (!ACPI_COMPARE_NAME(name, METHOD_NAME__CRS) &&
-            !ACPI_COMPARE_NAME(name, METHOD_NAME__PRS) &&
-            !ACPI_COMPARE_NAME(name, METHOD_NAME__AEI))) {
+       if (!buffer || !buffer->pointer || !user_function) {
                return_ACPI_STATUS(AE_BAD_PARAMETER);
        }
 
-       /* Get the _CRS/_PRS/_AEI resource list */
-
-       buffer.length = ACPI_ALLOCATE_LOCAL_BUFFER;
-       status = acpi_rs_get_method_data(device_handle, name, &buffer);
-       if (ACPI_FAILURE(status)) {
-               return_ACPI_STATUS(status);
-       }
-
-       /* Buffer now contains the resource list */
+       /* Buffer contains the resource list and length */
 
-       resource = ACPI_CAST_PTR(struct acpi_resource, buffer.pointer);
+       resource = ACPI_CAST_PTR(struct acpi_resource, buffer->pointer);
        resource_end =
-           ACPI_ADD_PTR(struct acpi_resource, buffer.pointer, buffer.length);
+           ACPI_ADD_PTR(struct acpi_resource, buffer->pointer, buffer->length);
 
        /* Walk the resource list until the end_tag is found (or buffer end) */
 
@@ -609,6 +594,60 @@ acpi_walk_resources(acpi_handle device_handle,
                resource = ACPI_NEXT_RESOURCE(resource);
        }
 
+       return_ACPI_STATUS(status);
+}
+
+ACPI_EXPORT_SYMBOL(acpi_walk_resource_buffer)
+
+/*******************************************************************************
+ *
+ * FUNCTION:    acpi_walk_resources
+ *
+ * PARAMETERS:  device_handle   - Handle to the device object for the
+ *                                device we are querying
+ *              name            - Method name of the resources we want.
+ *                                (METHOD_NAME__CRS, METHOD_NAME__PRS, or
+ *                                METHOD_NAME__AEI)
+ *              user_function   - Called for each resource
+ *              context         - Passed to user_function
+ *
+ * RETURN:      Status
+ *
+ * DESCRIPTION: Retrieves the current or possible resource list for the
+ *              specified device. The user_function is called once for
+ *              each resource in the list.
+ *
+ ******************************************************************************/
+acpi_status
+acpi_walk_resources(acpi_handle device_handle,
+                   char *name,
+                   acpi_walk_resource_callback user_function, void *context)
+{
+       acpi_status status;
+       struct acpi_buffer buffer;
+
+       ACPI_FUNCTION_TRACE(acpi_walk_resources);
+
+       /* Parameter validation */
+
+       if (!device_handle || !user_function || !name ||
+           (!ACPI_COMPARE_NAME(name, METHOD_NAME__CRS) &&
+            !ACPI_COMPARE_NAME(name, METHOD_NAME__PRS) &&
+            !ACPI_COMPARE_NAME(name, METHOD_NAME__AEI))) {
+               return_ACPI_STATUS(AE_BAD_PARAMETER);
+       }
+
+       /* Get the _CRS/_PRS/_AEI resource list */
+
+       buffer.length = ACPI_ALLOCATE_LOCAL_BUFFER;
+       status = acpi_rs_get_method_data(device_handle, name, &buffer);
+       if (ACPI_FAILURE(status)) {
+               return_ACPI_STATUS(status);
+       }
+
+       /* Walk the resource list and cleanup */
+
+       status = acpi_walk_resource_buffer(&buffer, user_function, context);
        ACPI_FREE(buffer.pointer);
        return_ACPI_STATUS(status);
 }
index 3c9c783b6604c828f089f2fc417443f6a91edaaa..afacb5a9671af86ef7a5507987fcd5e37f1cb35c 100644 (file)
@@ -443,6 +443,11 @@ acpi_status
 acpi_get_event_resources(acpi_handle device_handle,
                         struct acpi_buffer *ret_buffer);
 
+acpi_status
+acpi_walk_resource_buffer(struct acpi_buffer *buffer,
+                         acpi_walk_resource_callback user_function,
+                         void *context);
+
 acpi_status
 acpi_walk_resources(acpi_handle device,
                    char *name,
index 6882227d170657956699b1624a424685439e7ed0..3de70eddd4e5d23fc475e308864dad321b75371e 100644 (file)
@@ -881,6 +881,10 @@ struct acpi_buffer {
        void *pointer;          /* pointer to buffer */
 };
 
+/* Free a buffer created in an struct acpi_buffer via ACPI_ALLOCATE_LOCAL_BUFFER */
+
+#define ACPI_FREE_BUFFER(b)         ACPI_FREE(b.pointer)
+
 /*
  * name_type for acpi_get_name
  */