create sub-functions part_get_disk_info()

Signed-off-by: Patrick Delaunay <[email protected]>
Reviewed-by: Christophe KERELLO <[email protected]>
Reviewed-by: Simon Glass <[email protected]>
---

Changes in v6:
- add comment for function part_get_disk_info

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

 disk/part_efi.c | 57 +++++++++++++++++++++++++++++++++++----------------------
 1 file changed, 35 insertions(+), 22 deletions(-)

diff --git a/disk/part_efi.c b/disk/part_efi.c
index 88e925b..16608e7 100644
--- a/disk/part_efi.c
+++ b/disk/part_efi.c
@@ -216,6 +216,40 @@ static void part_print_gpt(gpt_header *gpt_head,
 }
 
 /*
+ * part_get_disk_info() - extract partition information for one GPT entry
+ *
+ * @param part - index of entry in gpt_pte
+ * @param blksz - blksize
+ * @param gpt_pte - pointer to GPT partion entry array
+ * @param gpt_pte - pointer to disk partition (output)
+ */
+static void part_get_disk_info(int part, unsigned int blksz,
+                              gpt_entry *gpt_pte, disk_partition_t *info)
+{
+       /* The 'lbaint_t' casting may limit the maximum disk size to 2 TB */
+       info->start = (lbaint_t)le64_to_cpu(gpt_pte[part - 1].starting_lba);
+       /* The ending LBA is inclusive, to calculate size, add 1 to it */
+       info->size = (lbaint_t)le64_to_cpu(gpt_pte[part - 1].ending_lba) + 1
+                    - info->start;
+       info->blksz = blksz;
+
+       sprintf((char *)info->name, "%s", print_efiname(&gpt_pte[part - 1]));
+       strcpy((char *)info->type, "U-Boot");
+       info->bootable = is_bootable(&gpt_pte[part - 1]);
+#if CONFIG_IS_ENABLED(PARTITION_UUIDS)
+       uuid_bin_to_str(gpt_pte[part - 1].unique_partition_guid.b, info->uuid,
+                       UUID_STR_FORMAT_GUID);
+#endif
+#ifdef CONFIG_PARTITION_TYPE_GUID
+       uuid_bin_to_str(gpt_pte[part - 1].partition_type_guid.b,
+                       info->type_guid, UUID_STR_FORMAT_GUID);
+#endif
+
+       debug("%s: start 0x" LBAF ", size 0x" LBAF ", name %s\n", __func__,
+             info->start, info->size, info->name);
+}
+
+/*
  * part_print_efi() - display EFI Partition information
  *
  * @param dev_desc - pointer to block device descriptor
@@ -283,28 +317,7 @@ int part_get_info_efi(struct blk_desc *dev_desc, int part,
                return -1;
        }
 
-       /* The 'lbaint_t' casting may limit the maximum disk size to 2 TB */
-       info->start = (lbaint_t)le64_to_cpu(gpt_pte[part - 1].starting_lba);
-       /* The ending LBA is inclusive, to calculate size, add 1 to it */
-       info->size = (lbaint_t)le64_to_cpu(gpt_pte[part - 1].ending_lba) + 1
-                    - info->start;
-       info->blksz = dev_desc->blksz;
-
-       sprintf((char *)info->name, "%s",
-                       print_efiname(&gpt_pte[part - 1]));
-       strcpy((char *)info->type, "U-Boot");
-       info->bootable = is_bootable(&gpt_pte[part - 1]);
-#if CONFIG_IS_ENABLED(PARTITION_UUIDS)
-       uuid_bin_to_str(gpt_pte[part - 1].unique_partition_guid.b, info->uuid,
-                       UUID_STR_FORMAT_GUID);
-#endif
-#ifdef CONFIG_PARTITION_TYPE_GUID
-       uuid_bin_to_str(gpt_pte[part - 1].partition_type_guid.b,
-                       info->type_guid, UUID_STR_FORMAT_GUID);
-#endif
-
-       debug("%s: start 0x" LBAF ", size 0x" LBAF ", name %s\n", __func__,
-             info->start, info->size, info->name);
+       part_get_disk_info(part, dev_desc->blksz, gpt_pte, info);
 
        /* Remember to free pte */
        free(gpt_pte);
-- 
1.9.1

_______________________________________________
U-Boot mailing list
[email protected]
https://lists.denx.de/listinfo/u-boot

Reply via email to