lmb: change the return code on lmb_alloc_addr()
Ben reports a failure to boot the kernel on hardware that starts its
physical memory from 0x0.
The reason is that lmb_alloc_addr(), which is supposed to reserve a
specific address, takes the address as the first argument, but then also
returns the address for success or failure and treats 0 as a failure.
Since we already know the address change the prototype to return an int.
Reported-by: Ben Schneider <ben@bens.haus>
Signed-off-by: Ilias Apalodimas <ilias.apalodimas@linaro.org>
Tested-by: Ben Schneider <ben@bens.haus>
Reviewed-by: Sughosh Ganu <sughosh.ganu@linaro.org>
diff --git a/lib/lmb.c b/lib/lmb.c
index 93fc1be..61bb13d 100644
--- a/lib/lmb.c
+++ b/lib/lmb.c
@@ -714,7 +714,7 @@
return alloc;
}
-phys_addr_t lmb_alloc_addr(phys_addr_t base, phys_size_t size, u32 flags)
+int lmb_alloc_addr(phys_addr_t base, phys_size_t size, u32 flags)
{
long rgn;
struct lmb_region *lmb_memory = lmb.available_mem.data;
@@ -731,11 +731,11 @@
base + size - 1, 1)) {
/* ok, reserve the memory */
if (!lmb_reserve(base, size, flags))
- return base;
+ return 0;
}
}
- return 0;
+ return -1;
}
/* Return number of bytes from a given address that are free */