aboutsummaryrefslogtreecommitdiff
path: root/disk
diff options
context:
space:
mode:
authorMaxime Ripard <maxime.ripard@free-electrons.com>2017-08-23 16:01:30 +0200
committerTom Rini <trini@konsulko.com>2017-09-03 11:04:47 -0400
commit89d33a2c0dce785b8c503399db91eec520def249 (patch)
tree24ebb69075a1086ea7ff6c6fadf04572f02538d7 /disk
parent41a85fe3b926385816e1958e2e4a521cae79921e (diff)
downloadu-boot-89d33a2c0dce785b8c503399db91eec520def249.zip
u-boot-89d33a2c0dce785b8c503399db91eec520def249.tar.gz
u-boot-89d33a2c0dce785b8c503399db91eec520def249.tar.bz2
part: efi: Fix offset
Both the config option and the DT options specify the offset to set the GPT at in bytes, yet the code treats those values as block numbers. Fix that. Signed-off-by: Maxime Ripard <maxime.ripard@free-electrons.com> Reviewed-by: Tom Rini <trini@konsulko.com> Reviewed-by: Philipp Tomsich <philipp.tomsich@theobroma-systems.com>
Diffstat (limited to 'disk')
-rw-r--r--disk/part_efi.c10
1 files changed, 7 insertions, 3 deletions
diff --git a/disk/part_efi.c b/disk/part_efi.c
index 71c3cb3..75d0a78 100644
--- a/disk/part_efi.c
+++ b/disk/part_efi.c
@@ -534,6 +534,7 @@ int gpt_fill_pte(gpt_header *gpt_h, gpt_entry *gpt_e,
static uint32_t partition_entries_offset(struct blk_desc *dev_desc)
{
uint32_t offset_blks = 2;
+ uint32_t __maybe_unused offset_bytes;
int __maybe_unused config_offset;
#if defined(CONFIG_EFI_PARTITION_ENTRIES_OFF)
@@ -545,8 +546,9 @@ static uint32_t partition_entries_offset(struct blk_desc *dev_desc)
* the disk) for the entries can be set in
* CONFIG_EFI_PARTITION_ENTRIES_OFF.
*/
- offset_blks =
+ offset_bytes =
PAD_TO_BLOCKSIZE(CONFIG_EFI_PARTITION_ENTRIES_OFF, dev_desc);
+ offset_blks = offset_bytes / dev_desc->blksz;
#endif
#if defined(CONFIG_OF_CONTROL)
@@ -558,8 +560,10 @@ static uint32_t partition_entries_offset(struct blk_desc *dev_desc)
config_offset = fdtdec_get_config_int(gd->fdt_blob,
"u-boot,efi-partition-entries-offset",
-EINVAL);
- if (config_offset != -EINVAL)
- offset_blks = PAD_TO_BLOCKSIZE(config_offset, dev_desc);
+ if (config_offset != -EINVAL) {
+ offset_bytes = PAD_TO_BLOCKSIZE(config_offset, dev_desc);
+ offset_blks = offset_bytes / dev_desc->blksz;
+ }
#endif
debug("efi: partition entries offset (in blocks): %d\n", offset_blks);