Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 350873
b: refs/heads/master
c: afb1bbe
h: refs/heads/master
i:
  350871: 14d347f
v: v3
  • Loading branch information
Bob Moore authored and Rafael J. Wysocki committed Jan 10, 2013
1 parent 43c210e commit 4bddf7f
Show file tree
Hide file tree
Showing 4 changed files with 80 additions and 32 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: 1cd4e951e59ec1754ceafa41562280b42000707e
refs/heads/master: afb1bbee804f473f70dc890a94cb9f0acc358012
101 changes: 70 additions & 31 deletions trunk/drivers/acpi/acpica/rsxface.c
Original file line number Diff line number Diff line change
Expand Up @@ -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.
*
Expand Down Expand Up @@ -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) */

Expand Down Expand Up @@ -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);
}
Expand Down
5 changes: 5 additions & 0 deletions trunk/include/acpi/acpixf.h
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
4 changes: 4 additions & 0 deletions trunk/include/acpi/actypes.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
*/
Expand Down

0 comments on commit 4bddf7f

Please sign in to comment.