diff options
author | Sughosh Ganu <sughosh.ganu@linaro.org> | 2025-03-03 19:02:31 +0530 |
---|---|---|
committer | Tom Rini <trini@konsulko.com> | 2025-03-17 19:39:27 -0600 |
commit | 2bf5811e22efffe37bf5dccb8d13529c51fc65dd (patch) | |
tree | a56e594b179e8d846a56cc588d9e1a8e84bd01af /lib/lmb.c | |
parent | fa5b4f5a5f99d1f4ab995d07845d2bff50aaabb7 (diff) |
lmb: optimise the lmb allocation functions
The actual logic to allocate a region of memory is in the
_lmb_alloc_base() function. The lmb_alloc() API function calls
lmb_alloc_base(), which then calls _lmb_alloc_base() to do the
allocation. Instead, call the _lmb_alloc_base() directly from both the
allocation API's, and move the error message to the _lmb_alloc_base().
Signed-off-by: Sughosh Ganu <sughosh.ganu@linaro.org>
Diffstat (limited to 'lib/lmb.c')
-rw-r--r-- | lib/lmb.c | 16 |
1 files changed, 6 insertions, 10 deletions
diff --git a/lib/lmb.c b/lib/lmb.c index b42a512f6c0..981ea1b2ca0 100644 --- a/lib/lmb.c +++ b/lib/lmb.c @@ -724,26 +724,22 @@ static phys_addr_t _lmb_alloc_base(phys_size_t size, ulong align, base = ALIGN_DOWN(res_base - size, align); } } + + log_debug("%s: Failed to allocate 0x%lx bytes below 0x%lx\n", + __func__, (ulong)size, (ulong)max_addr); + return 0; } phys_addr_t lmb_alloc(phys_size_t size, ulong align) { - return lmb_alloc_base(size, align, LMB_ALLOC_ANYWHERE, LMB_NONE); + return _lmb_alloc_base(size, align, LMB_ALLOC_ANYWHERE, LMB_NONE); } phys_addr_t lmb_alloc_base(phys_size_t size, ulong align, phys_addr_t max_addr, uint flags) { - phys_addr_t alloc; - - alloc = _lmb_alloc_base(size, align, max_addr, flags); - - if (alloc == 0) - printf("ERROR: Failed to allocate 0x%lx bytes below 0x%lx.\n", - (ulong)size, (ulong)max_addr); - - return alloc; + return _lmb_alloc_base(size, align, max_addr, flags); } phys_addr_t lmb_alloc_addr(phys_addr_t base, phys_size_t size, u32 flags) |