aboutsummaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorHeinrich Schuchardt2018-11-18 17:58:49 +0100
committerAlexander Graf2018-12-02 21:59:37 +0100
commitc3772ca1e38f36f2486b44c27094421442414e5e (patch)
tree9e0796c02e18c264c21bf0f3964cd20490174843 /lib
parent42910ff1baa9c6bf9e0eecbe252bf06e11861fa8 (diff)
efi_loader: macro efi_size_in_pages()
When allocating EFI memory pages the size in bytes has to be converted to pages. Provide a macro efi_size_in_pages() for this conversion. Use it in the EFI subsystem and correct related comments. Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de> Signed-off-by: Alexander Graf <agraf@suse.de>
Diffstat (limited to 'lib')
-rw-r--r--lib/efi_loader/efi_memory.c6
1 files changed, 3 insertions, 3 deletions
diff --git a/lib/efi_loader/efi_memory.c b/lib/efi_loader/efi_memory.c
index 307e6f77ab7..5359118b4d7 100644
--- a/lib/efi_loader/efi_memory.c
+++ b/lib/efi_loader/efi_memory.c
@@ -397,7 +397,7 @@ efi_status_t efi_allocate_pages(int type, int memory_type,
void *efi_alloc(uint64_t len, int memory_type)
{
uint64_t ret = 0;
- uint64_t pages = (len + EFI_PAGE_MASK) >> EFI_PAGE_SHIFT;
+ uint64_t pages = efi_size_in_pages(len);
efi_status_t r;
r = efi_allocate_pages(EFI_ALLOCATE_ANY_PAGES, memory_type, pages,
@@ -440,8 +440,8 @@ efi_status_t efi_allocate_pool(int pool_type, efi_uintn_t size, void **buffer)
{
efi_status_t r;
struct efi_pool_allocation *alloc;
- u64 num_pages = (size + sizeof(struct efi_pool_allocation) +
- EFI_PAGE_MASK) >> EFI_PAGE_SHIFT;
+ u64 num_pages = efi_size_in_pages(size +
+ sizeof(struct efi_pool_allocation));
if (!buffer)
return EFI_INVALID_PARAMETER;