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

Patrick Delaunay patrick.delaunay at st.com
Wed Mar 15 14:11:33 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>
---

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

 disk/part_efi.c | 55 ++++++++++++++++++++++++++++++-------------------------
 1 file changed, 30 insertions(+), 25 deletions(-)

diff --git a/disk/part_efi.c b/disk/part_efi.c
index 893cbbd..a25d42b 100644
--- a/disk/part_efi.c
+++ b/disk/part_efi.c
@@ -172,35 +172,13 @@ static void prepare_backup_gpt_header(gpt_header *gpt_h)
 }
 
 #if CONFIG_IS_ENABLED(EFI_PARTITION)
-/*
- * Public Functions (include/part.h)
- */
-
-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");
@@ -227,10 +205,37 @@ 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);
 	}
+}
+
+/*
+ * Public Functions (include/part.h)
+ */
+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,
-- 
1.9.1



More information about the U-Boot mailing list