[U-Boot] [PATCH v6 02/18] disk: part: refactor part_print_efi to prepare GPT over MTD

Patrick Delaunay patrick.delaunay at st.com
Thu May 11 07:51:52 UTC 2017


split part_print_efi : create sub-functions part_print_gpt()

Signed-off-by: Patrick Delaunay <patrick.delaunay at st.com>
Reviewed-by: Christophe KERELLO <christophe.kerello at st.com>
Reviewed-by: Simon Glass <sjg at chromium.org>
---

Changes in v6:
- add comment for function part_print_gpt and part_print_efi

Changes in v5: None
Changes in v4: None
Changes in v3: None
Changes in v2: None

 disk/part_efi.c | 63 ++++++++++++++++++++++++++++++++++++---------------------
 1 file changed, 40 insertions(+), 23 deletions(-)

diff --git a/disk/part_efi.c b/disk/part_efi.c
index 1b7ba27..88e925b 100644
--- a/disk/part_efi.c
+++ b/disk/part_efi.c
@@ -175,34 +175,18 @@ static void prepare_backup_gpt_header(gpt_header *gpt_h)
 
 #if CONFIG_IS_ENABLED(EFI_PARTITION)
 /*
- * Public Functions (include/part.h)
+ * part_print_gpt() - display GUID Partition Table information
+ *
+ * @param gpt_head - pointer to GPT header
+ * @param gpt_pte - pointer to GPT partion entry array
  */
-
-void part_print_efi(struct blk_desc *dev_desc)
+static void part_print_gpt(gpt_header *gpt_head,
+			   gpt_entry *gpt_pte)
 {
-	ALLOC_CACHE_ALIGN_BUFFER_PAD(gpt_header, gpt_head, 1, dev_desc->blksz);
-	gpt_entry *gpt_pte = NULL;
 	int i = 0;
 	char uuid[37];
 	unsigned char *uuid_bin;
 
-	/* This function validates AND fills in the GPT header and PTE */
-	if (is_gpt_valid(dev_desc, GPT_PRIMARY_PARTITION_TABLE_LBA,
-			 gpt_head, &gpt_pte) != 1) {
-		printf("%s: *** ERROR: Invalid GPT ***\n", __func__);
-		if (is_gpt_valid(dev_desc, (dev_desc->lba - 1),
-				 gpt_head, &gpt_pte) != 1) {
-			printf("%s: *** ERROR: Invalid Backup GPT ***\n",
-			       __func__);
-			return;
-		} else {
-			printf("%s: ***        Using Backup GPT ***\n",
-			       __func__);
-		}
-	}
-
-	debug("%s: gpt-entry at %p\n", __func__, gpt_pte);
-
 	printf("Part\tStart LBA\tEnd LBA\t\tName\n");
 	printf("\tAttributes\n");
 	printf("\tType GUID\n");
@@ -229,10 +213,39 @@ void part_print_efi(struct blk_desc *dev_desc)
 		uuid_bin_to_str(uuid_bin, uuid, UUID_STR_FORMAT_GUID);
 		printf("\tguid:\t%s\n", uuid);
 	}
+}
+
+/*
+ * part_print_efi() - display EFI Partition information
+ *
+ * @param dev_desc - pointer to block device descriptor
+ */
+void part_print_efi(struct blk_desc *dev_desc)
+{
+	ALLOC_CACHE_ALIGN_BUFFER_PAD(gpt_header, gpt_head, 1, dev_desc->blksz);
+	gpt_entry *gpt_pte = NULL;
+
+	/* This function validates AND fills in the GPT header and PTE */
+	if (is_gpt_valid(dev_desc, GPT_PRIMARY_PARTITION_TABLE_LBA,
+			 gpt_head, &gpt_pte) != 1) {
+		printf("%s: *** ERROR: Invalid GPT ***\n", __func__);
+		if (is_gpt_valid(dev_desc, (dev_desc->lba - 1),
+				 gpt_head, &gpt_pte) != 1) {
+			printf("%s: *** ERROR: Invalid Backup GPT ***\n",
+			       __func__);
+			return;
+		} else {
+			printf("%s: ***        Using Backup GPT ***\n",
+			       __func__);
+		}
+	}
+
+	debug("%s: gpt-entry at %p\n", __func__, gpt_pte);
+
+	part_print_gpt(gpt_head, gpt_pte);
 
 	/* Remember to free pte */
 	free(gpt_pte);
-	return;
 }
 
 int part_get_info_efi(struct blk_desc *dev_desc, int part,
@@ -349,6 +362,10 @@ static int set_protective_mbr(struct blk_desc *dev_desc)
 	return 0;
 }
 
+/*
+ * Public Functions (include/part.h)
+ */
+
 int write_gpt_table(struct blk_desc *dev_desc,
 		gpt_header *gpt_h, gpt_entry *gpt_e)
 {
-- 
1.9.1



More information about the U-Boot mailing list