[1/3] disk: part_efi: resolve endianness issues

Message ID 1401130344-15450-2-git-send-email-srae@broadcom.com
State Accepted
Commit dedf37bb61b2a4893f51f7aea2f37fe70d77ab0c
Headers show

Commit Message

Steve Rae May 26, 2014, 6:52 p.m.
Tested on little endian ARMv7 and ARMv8 configurations

Signed-off-by: Steve Rae <srae@broadcom.com>
---

 disk/part_efi.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

Comments

Tom Rini June 5, 2014, 10:47 p.m. | #1
On Mon, May 26, 2014 at 11:52:22AM -0700, Steve Rae wrote:

> Tested on little endian ARMv7 and ARMv8 configurations
> 
> Signed-off-by: Steve Rae <srae@broadcom.com>

Applied to u-boot/master, thanks!

Patch

diff --git a/disk/part_efi.c b/disk/part_efi.c
index c74b7b9..8c89740 100644
--- a/disk/part_efi.c
+++ b/disk/part_efi.c
@@ -279,7 +279,7 @@  int write_gpt_table(block_dev_desc_t *dev_desc,
 	gpt_h->header_crc32 = cpu_to_le32(calc_crc32);
 
 	if (dev_desc->block_write(dev_desc->dev,
-				  le32_to_cpu(gpt_h->last_usable_lba + 1),
+				  le32_to_cpu(gpt_h->last_usable_lba) + 1,
 				  pte_blk_cnt, gpt_e) != pte_blk_cnt)
 		goto err;
 
@@ -300,6 +300,7 @@  int gpt_fill_pte(gpt_header *gpt_h, gpt_entry *gpt_e,
 {
 	u32 offset = (u32)le32_to_cpu(gpt_h->first_usable_lba);
 	ulong start;
+	u32 last_usable_lba = (u32)le32_to_cpu(gpt_h->last_usable_lba);
 	int i, k;
 	size_t efiname_len, dosname_len;
 #ifdef CONFIG_PARTITION_UUIDS
@@ -321,7 +322,7 @@  int gpt_fill_pte(gpt_header *gpt_h, gpt_entry *gpt_e,
 			gpt_e[i].starting_lba = cpu_to_le64(offset);
 			offset += partitions[i].size;
 		}
-		if (offset >= gpt_h->last_usable_lba) {
+		if (offset >= last_usable_lba) {
 			printf("Partitions layout exceds disk size\n");
 			return -1;
 		}