Re: [U-Boot] [PATCH v5 03/16] disk: part: refactor part_get_info_efi to prepare GPT over MTD

2017-04-16 Thread Simon Glass
On 13 April 2017 at 03:52, Patrick Delaunay  wrote:
> create sub-functions part_get_disk_info()
>
> Signed-off-by: Patrick Delaunay 
> Reviewed-by: Christophe KERELLO 
> ---
>
> Changes in v5: None
> Changes in v4: None
> Changes in v3: None
> Changes in v2: None
>
>  disk/part_efi.c | 49 +++--
>  1 file changed, 27 insertions(+), 22 deletions(-)

Reviewed-by: Simon Glass 

Would be useful to add comments for the functions you create.
___
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot


[U-Boot] [PATCH v5 03/16] disk: part: refactor part_get_info_efi to prepare GPT over MTD

2017-04-13 Thread Patrick Delaunay
create sub-functions part_get_disk_info()

Signed-off-by: Patrick Delaunay 
Reviewed-by: Christophe KERELLO 
---

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

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

diff --git a/disk/part_efi.c b/disk/part_efi.c
index 4264b80..60521b3 100644
--- a/disk/part_efi.c
+++ b/disk/part_efi.c
@@ -209,6 +209,32 @@ static void part_print_gpt(gpt_header *gpt_head,
}
 }
 
+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(_pte[part - 1]));
+   strcpy((char *)info->type, "U-Boot");
+   info->bootable = is_bootable(_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);
+}
+
 /*
  * Public Functions (include/part.h)
  */
@@ -275,28 +301,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(_pte[part - 1]));
-   strcpy((char *)info->type, "U-Boot");
-   info->bootable = is_bootable(_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
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot