ACPI: resource: Add helper function acpi_dev_get_memory_resources()
authorHeikki Krogerus <heikki.krogerus@linux.intel.com>
Tue, 16 Aug 2022 10:16:26 +0000 (13:16 +0300)
committerRafael J. Wysocki <rafael.j.wysocki@intel.com>
Sat, 10 Sep 2022 16:22:24 +0000 (18:22 +0200)
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 <heikki.krogerus@linux.intel.com>
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
drivers/acpi/resource.c
include/linux/acpi.h

index e644e90d18847aa318cf4ac19d16184ab9f0f228..8032d50ca9441400032cb81abb8d38b48df67472 100644 (file)
@@ -721,6 +721,23 @@ int acpi_dev_get_dma_resources(struct acpi_device *adev, struct list_head *list)
 }
 EXPORT_SYMBOL_GPL(acpi_dev_get_dma_resources);
 
+/**
+ * acpi_dev_get_memory_resources - Get current memory resources of a device.
+ * @adev: ACPI device node to get the resources for.
+ * @list: Head of the resultant list of resources (must be empty).
+ *
+ * This is a helper function that locates all memory type resources of @adev
+ * with acpi_dev_get_resources().
+ *
+ * The number of resources in the output list is returned on success, an error
+ * code reflecting the error condition is returned otherwise.
+ */
+int acpi_dev_get_memory_resources(struct acpi_device *adev, struct list_head *list)
+{
+       return acpi_dev_get_resources(adev, list, is_memory, NULL);
+}
+EXPORT_SYMBOL_GPL(acpi_dev_get_memory_resources);
+
 /**
  * acpi_dev_filter_resource_type - Filter ACPI resource according to resource
  *                                types
index 6f64b2f3dc547951b2635beb1e6a11dbd033cbee..ed4aa395cc49b9a7d2286f1e1c51cdb5d70d554e 100644 (file)
@@ -506,6 +506,7 @@ int acpi_dev_get_resources(struct acpi_device *adev, struct list_head *list,
                           void *preproc_data);
 int acpi_dev_get_dma_resources(struct acpi_device *adev,
                               struct list_head *list);
+int acpi_dev_get_memory_resources(struct acpi_device *adev, struct list_head *list);
 int acpi_dev_filter_resource_type(struct acpi_resource *ares,
                                  unsigned long types);