lmb: add a max parameter in the struct lmb_region
Add a max parameter in lmb_region struct to handle test
in lmb_add_region without using the MAX_LMB_REGIONS
define.
This patch allows to modify these size independently for
memory of reserved regions in the next patches.
Signed-off-by: Patrick Delaunay <patrick.delaunay@foss.st.com>
diff --git a/lib/lmb.c b/lib/lmb.c
index 5cf419f..a926198 100644
--- a/lib/lmb.c
+++ b/lib/lmb.c
@@ -95,6 +95,9 @@
void lmb_init(struct lmb *lmb)
{
+ lmb->memory.max = MAX_LMB_REGIONS;
+ lmb->reserved.max = MAX_LMB_REGIONS;
+
lmb->memory.cnt = 0;
lmb->reserved.cnt = 0;
}
@@ -179,7 +182,7 @@
if (coalesced)
return coalesced;
- if (rgn->cnt >= MAX_LMB_REGIONS)
+ if (rgn->cnt >= rgn->max)
return -1;
/* Couldn't coalesce the LMB, so add it to the sorted table. */