mirror of
https://github.com/u-boot/u-boot.git
synced 2025-04-27 07:51:38 +00:00
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>
This commit is contained in:
parent
793e21b83d
commit
6c9f27505a
1 changed files with 5 additions and 10 deletions
15
lib/lmb.c
15
lib/lmb.c
|
@ -342,11 +342,6 @@ static long lmb_overlaps_region(struct alist *lmb_rgn_lst, phys_addr_t base,
|
||||||
return (i < lmb_rgn_lst->count) ? i : -1;
|
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.
|
* IOVA LMB memory maps using lmb pointers instead of the global LMB memory map.
|
||||||
*/
|
*/
|
||||||
|
@ -400,7 +395,7 @@ phys_addr_t io_lmb_alloc(struct lmb *io_lmb, phys_size_t size, ulong align)
|
||||||
|
|
||||||
if (lmbsize < size)
|
if (lmbsize < size)
|
||||||
continue;
|
continue;
|
||||||
base = lmb_align_down(lmbbase + lmbsize - size, align);
|
base = ALIGN_DOWN(lmbbase + lmbsize - size, align);
|
||||||
|
|
||||||
while (base && lmbbase <= base) {
|
while (base && lmbbase <= base) {
|
||||||
rgn = lmb_overlaps_region(&io_lmb->used_mem, base, size);
|
rgn = lmb_overlaps_region(&io_lmb->used_mem, base, size);
|
||||||
|
@ -416,7 +411,7 @@ phys_addr_t io_lmb_alloc(struct lmb *io_lmb, phys_size_t size, ulong align)
|
||||||
res_base = lmb_used[rgn].base;
|
res_base = lmb_used[rgn].base;
|
||||||
if (res_base < size)
|
if (res_base < size)
|
||||||
break;
|
break;
|
||||||
base = lmb_align_down(res_base - size, align);
|
base = ALIGN_DOWN(res_base - size, align);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -709,13 +704,13 @@ static phys_addr_t _lmb_alloc_base(phys_size_t size, ulong align,
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
if (max_addr == LMB_ALLOC_ANYWHERE) {
|
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) {
|
} else if (lmbbase < max_addr) {
|
||||||
base = lmbbase + lmbsize;
|
base = lmbbase + lmbsize;
|
||||||
if (base < lmbbase)
|
if (base < lmbbase)
|
||||||
base = -1;
|
base = -1;
|
||||||
base = min(base, max_addr);
|
base = min(base, max_addr);
|
||||||
base = lmb_align_down(base - size, align);
|
base = ALIGN_DOWN(base - size, align);
|
||||||
} else {
|
} else {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
@ -740,7 +735,7 @@ static phys_addr_t _lmb_alloc_base(phys_size_t size, ulong align,
|
||||||
res_base = lmb_used[rgn].base;
|
res_base = lmb_used[rgn].base;
|
||||||
if (res_base < size)
|
if (res_base < size)
|
||||||
break;
|
break;
|
||||||
base = lmb_align_down(res_base - size, align);
|
base = ALIGN_DOWN(res_base - size, align);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
|
|
Loading…
Add table
Reference in a new issue