summaryrefslogtreecommitdiff
path: root/lib/lmb.c
diff options
context:
space:
mode:
authorIlias Apalodimas <ilias.apalodimas@linaro.org>2024-10-23 18:22:00 +0300
committerTom Rini <trini@konsulko.com>2024-10-29 16:17:47 -0600
commit0f57b009e649e9d140b7f662599a5ace506e2418 (patch)
tree22083d34e326c8312b87964726d00536f418c3bc /lib/lmb.c
parent92e75ee47f12131306b6a0c501bf8b7cedfe3818 (diff)
lmb: Fix lmb_add_region_flags() return codes and testing
The function description says this should return 0 or -1 on failures. When regions coalesce though this returns the number of coalescedregions which is confusing and requires special handling of the return code. On top of that no one is using the number of coalesced regions. So let's just return 0 on success and adjust our selftests accordingly Signed-off-by: Ilias Apalodimas <ilias.apalodimas@linaro.org> Reviewed-by: Caleb Connolly <caleb.connolly@linaro.org>
Diffstat (limited to 'lib/lmb.c')
-rw-r--r--lib/lmb.c10
1 files changed, 5 insertions, 5 deletions
diff --git a/lib/lmb.c b/lib/lmb.c
index bf261db999e..24d1ebe586b 100644
--- a/lib/lmb.c
+++ b/lib/lmb.c
@@ -451,7 +451,7 @@ static long lmb_add_region_flags(struct alist *lmb_rgn_lst, phys_addr_t base,
}
if (coalesced)
- return coalesced;
+ return 0;
if (alist_full(lmb_rgn_lst) &&
!alist_expand_by(lmb_rgn_lst, lmb_rgn_lst->alloc))
@@ -488,7 +488,7 @@ long lmb_add(phys_addr_t base, phys_size_t size)
struct alist *lmb_rgn_lst = &lmb.free_mem;
ret = lmb_add_region(lmb_rgn_lst, base, size);
- if (ret < 0)
+ if (ret)
return ret;
if (lmb_should_notify(LMB_NONE))
@@ -584,8 +584,8 @@ long lmb_reserve_flags(phys_addr_t base, phys_size_t size, enum lmb_flags flags)
struct alist *lmb_rgn_lst = &lmb.used_mem;
ret = lmb_add_region_flags(lmb_rgn_lst, base, size, flags);
- if (ret < 0)
- return -1;
+ if (ret)
+ return ret;
if (lmb_should_notify(flags))
return lmb_map_update_notify(base, size, MAP_OP_RESERVE);
@@ -652,7 +652,7 @@ static phys_addr_t _lmb_alloc_base(phys_size_t size, ulong align,
if (rgn < 0) {
/* This area isn't reserved, take it */
if (lmb_add_region_flags(&lmb.used_mem, base,
- size, flags) < 0)
+ size, flags))
return 0;
if (lmb_should_notify(flags)) {