[PATCH v2 12/14] lmb: Tidy up lmb_overlaps_region()
Simon Glass
sjg at chromium.org
Fri Sep 1 03:13:50 CEST 2023
Add a comment to define what this returns. Return a specific error when
no overlap is found.
Signed-off-by: Simon Glass <sjg at chromium.org>
---
(no changes since v1)
lib/lmb.c | 11 +++++++++--
1 file changed, 9 insertions(+), 2 deletions(-)
diff --git a/lib/lmb.c b/lib/lmb.c
index 0c6244ca47f8..8a299c97b3ad 100644
--- a/lib/lmb.c
+++ b/lib/lmb.c
@@ -386,6 +386,13 @@ int lmb_reserve(struct lmb *lmb, phys_addr_t base, phys_size_t size)
return lmb_reserve_flags(lmb, base, size, LMB_NONE);
}
+/**
+ * lmb_overlaps_region() - Check if a region overlaps a given base/size
+ *
+ * @base: base address of the memory region
+ * @size: size of the memory region
+ * Returns: Region number of overlapping region, if found, else -ENOENT
+ */
static int lmb_overlaps_region(struct lmb_region *rgn, phys_addr_t base,
phys_size_t size)
{
@@ -396,10 +403,10 @@ static int lmb_overlaps_region(struct lmb_region *rgn, phys_addr_t base,
phys_size_t asize = rgn->area[i].size;
if (lmb_addrs_overlap(base, size, abase, asize))
- break;
+ return i;
}
- return i < rgn->cnt ? i : -1;
+ return -ENOENT;
}
phys_addr_t lmb_alloc(struct lmb *lmb, phys_size_t size, ulong align)
--
2.42.0.283.g2d96d420d3-goog
More information about the U-Boot
mailing list