]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
resource: Document find_resource_space() and resource_constraint
authorIlpo Järvinen <ilpo.jarvinen@linux.intel.com>
Tue, 7 May 2024 10:25:18 +0000 (13:25 +0300)
committerBjorn Helgaas <bhelgaas@google.com>
Tue, 28 May 2024 16:14:13 +0000 (11:14 -0500)
Document find_resource_space() and the struct resource_constraint as they
are going to be exposed outside of resource.c.

Link: https://lore.kernel.org/r/20240507102523.57320-4-ilpo.jarvinen@linux.intel.com
Tested-by: Lidong Wang <lidong.wang@intel.com>
Signed-off-by: Ilpo Järvinen <ilpo.jarvinen@linux.intel.com>
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
Reviewed-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Reviewed-by: Mika Westerberg <mika.westerberg@linux.intel.com>
kernel/resource.c

index e163e0a8f2f8d39ecf0ff856e12ba97514d9980d..3f15a32d9c422cbdc6b1b0d4cabe365b11428229 100644 (file)
@@ -48,7 +48,19 @@ struct resource iomem_resource = {
 };
 EXPORT_SYMBOL(iomem_resource);
 
-/* constraints to be met while allocating resources */
+/**
+ * struct resource_constraint - constraints to be met while searching empty
+ *                             resource space
+ * @min:               The minimum address for the memory range
+ * @max:               The maximum address for the memory range
+ * @align:             Alignment for the start address of the empty space
+ * @alignf:            Additional alignment constraints callback
+ * @alignf_data:       Data provided for @alignf callback
+ *
+ * Contains the range and alignment constraints that have to be met during
+ * find_resource_space(). @alignf can be NULL indicating no alignment beyond
+ * @align is necessary.
+ */
 struct resource_constraint {
        resource_size_t min, max, align;
        resource_size_t (*alignf)(void *, const struct resource *,
@@ -686,8 +698,19 @@ next:              if (!this || this->end == root->end)
        return -EBUSY;
 }
 
-/*
- * Find empty space in the resource tree given range and alignment.
+/**
+ * find_resource_space - Find empty space in the resource tree
+ * @root:      Root resource descriptor
+ * @new:       Resource descriptor awaiting an empty resource space
+ * @size:      The minimum size of the empty space
+ * @constraint:        The range and alignment constraints to be met
+ *
+ * Finds an empty space under @root in the resource tree satisfying range and
+ * alignment @constraints.
+ *
+ * Return:
+ * * %0                - if successful, @new members start, end, and flags are altered.
+ * * %-EBUSY   - if no empty space was found.
  */
 static int find_resource_space(struct resource *root, struct resource *new,
                               resource_size_t size,