lmb: Remove lmb_align_down()
We already have a macro for this. Use it instead of adding yet another
variant for alignment.
Reviewed-by: Sam Protsenko <semen.protsenko@linaro.org>
Tested-by: Sam Protsenko <semen.protsenko@linaro.org>
Signed-off-by: Ilias Apalodimas <ilias.apalodimas@linaro.org>
(cherry picked from commit 6c9f27505a)
This commit is contained in:
committed by
Simon Glass
parent
0e7756f23b
commit
bfd75a7f81
15
lib/lmb.c
15
lib/lmb.c
@@ -341,11 +341,6 @@ static long lmb_overlaps_region(struct alist *lmb_rgn_lst, phys_addr_t base,
|
||||
return (i < lmb_rgn_lst->count) ? i : -1;
|
||||
}
|
||||
|
||||
static phys_addr_t lmb_align_down(phys_addr_t addr, phys_size_t size)
|
||||
{
|
||||
return addr & ~(size - 1);
|
||||
}
|
||||
|
||||
/*
|
||||
* IOVA LMB memory maps using lmb pointers instead of the global LMB memory map.
|
||||
*/
|
||||
@@ -399,7 +394,7 @@ phys_addr_t io_lmb_alloc(struct lmb *io_lmb, phys_size_t size, ulong align)
|
||||
|
||||
if (lmbsize < size)
|
||||
continue;
|
||||
base = lmb_align_down(lmbbase + lmbsize - size, align);
|
||||
base = ALIGN_DOWN(lmbbase + lmbsize - size, align);
|
||||
|
||||
while (base && lmbbase <= base) {
|
||||
rgn = lmb_overlaps_region(&io_lmb->used_mem, base, size);
|
||||
@@ -415,7 +410,7 @@ phys_addr_t io_lmb_alloc(struct lmb *io_lmb, phys_size_t size, ulong align)
|
||||
res_base = lmb_used[rgn].base;
|
||||
if (res_base < size)
|
||||
break;
|
||||
base = lmb_align_down(res_base - size, align);
|
||||
base = ALIGN_DOWN(res_base - size, align);
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
@@ -706,13 +701,13 @@ static phys_addr_t _lmb_alloc_base(phys_size_t size, ulong align,
|
||||
continue;
|
||||
|
||||
if (max_addr == LMB_ALLOC_ANYWHERE) {
|
||||
base = lmb_align_down(lmbbase + lmbsize - size, align);
|
||||
base = ALIGN_DOWN(lmbbase + lmbsize - size, align);
|
||||
} else if (lmbbase < max_addr) {
|
||||
base = lmbbase + lmbsize;
|
||||
if (base < lmbbase)
|
||||
base = -1;
|
||||
base = min(base, max_addr);
|
||||
base = lmb_align_down(base - size, align);
|
||||
base = ALIGN_DOWN(base - size, align);
|
||||
} else {
|
||||
continue;
|
||||
}
|
||||
@@ -737,7 +732,7 @@ static phys_addr_t _lmb_alloc_base(phys_size_t size, ulong align,
|
||||
res_base = lmb_used[rgn].base;
|
||||
if (res_base < size)
|
||||
break;
|
||||
base = lmb_align_down(res_base - size, align);
|
||||
base = ALIGN_DOWN(res_base - size, align);
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
|
||||
Reference in New Issue
Block a user