aboutsummaryrefslogtreecommitdiff
path: root/cmd/bootefi.c
diff options
context:
space:
mode:
authorSimon Glass <sjg@chromium.org>2018-06-18 08:08:25 -0600
committerAlexander Graf <agraf@suse.de>2018-07-25 14:57:44 +0200
commitbc9a638a1031a171f0b2dfa4438aa3903fa589ae (patch)
tree06344beefcc7b7e5843923738fc4add3d8435c76 /cmd/bootefi.c
parent404ea59364f1355afcd845a7405599fdc2303231 (diff)
downloadu-boot-bc9a638a1031a171f0b2dfa4438aa3903fa589ae.zip
u-boot-bc9a638a1031a171f0b2dfa4438aa3903fa589ae.tar.gz
u-boot-bc9a638a1031a171f0b2dfa4438aa3903fa589ae.tar.bz2
efi: Tidy up device-tree-size calculation in copy_fdt()
This is a bit confusing at present since it adds 4KB to the pointer, then rounds it up. It looks like a bug, but is not. Move the 4KB addition into a separate statement and expand the comment. Signed-off-by: Simon Glass <sjg@chromium.org> Signed-off-by: Alexander Graf <agraf@suse.de>
Diffstat (limited to 'cmd/bootefi.c')
-rw-r--r--cmd/bootefi.c8
1 files changed, 6 insertions, 2 deletions
diff --git a/cmd/bootefi.c b/cmd/bootefi.c
index a0fd1a3..d0f2c03 100644
--- a/cmd/bootefi.c
+++ b/cmd/bootefi.c
@@ -148,8 +148,12 @@ static void *copy_fdt(void *fdt)
fdt_ram_start = ram_start;
}
- /* Give us at least 4kb breathing room */
- fdt_size = ALIGN(fdt_size + 4096, EFI_PAGE_SIZE);
+ /*
+ * Give us at least 4KB of breathing room in case the device tree needs
+ * to be expanded later. Round up to the nearest EFI page boundary.
+ */
+ fdt_size += 4096;
+ fdt_size = ALIGN(fdt_size + EFI_PAGE_SIZE - 1, EFI_PAGE_SIZE);
fdt_pages = fdt_size >> EFI_PAGE_SHIFT;
/* Safe fdt location is at 128MB */