Skip to content

Commit 6bb057b

Browse files
Heikki Krogerusrafaeljw
authored andcommitted
ACPI: resource: Add helper function acpi_dev_get_memory_resources()
Wrapper function that finds all memory type resources by using acpi_dev_get_resources(). It removes the need for the drivers to check the resource data type separately. Signed-off-by: Heikki Krogerus <[email protected]> Signed-off-by: Rafael J. Wysocki <[email protected]>
1 parent 6d2b5a1 commit 6bb057b

File tree

2 files changed

+18
-0
lines changed

2 files changed

+18
-0
lines changed

drivers/acpi/resource.c

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -721,6 +721,23 @@ int acpi_dev_get_dma_resources(struct acpi_device *adev, struct list_head *list)
721721
}
722722
EXPORT_SYMBOL_GPL(acpi_dev_get_dma_resources);
723723

724+
/**
725+
* acpi_dev_get_memory_resources - Get current memory resources of a device.
726+
* @adev: ACPI device node to get the resources for.
727+
* @list: Head of the resultant list of resources (must be empty).
728+
*
729+
* This is a helper function that locates all memory type resources of @adev
730+
* with acpi_dev_get_resources().
731+
*
732+
* The number of resources in the output list is returned on success, an error
733+
* code reflecting the error condition is returned otherwise.
734+
*/
735+
int acpi_dev_get_memory_resources(struct acpi_device *adev, struct list_head *list)
736+
{
737+
return acpi_dev_get_resources(adev, list, is_memory, NULL);
738+
}
739+
EXPORT_SYMBOL_GPL(acpi_dev_get_memory_resources);
740+
724741
/**
725742
* acpi_dev_filter_resource_type - Filter ACPI resource according to resource
726743
* types

include/linux/acpi.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -506,6 +506,7 @@ int acpi_dev_get_resources(struct acpi_device *adev, struct list_head *list,
506506
void *preproc_data);
507507
int acpi_dev_get_dma_resources(struct acpi_device *adev,
508508
struct list_head *list);
509+
int acpi_dev_get_memory_resources(struct acpi_device *adev, struct list_head *list);
509510
int acpi_dev_filter_resource_type(struct acpi_resource *ares,
510511
unsigned long types);
511512

0 commit comments

Comments
 (0)