[U-Boot] [RFC PATCH v2 5/8] cmd: part: update command to support GPT over MTD

Patrick Delaunay patrick.delaunay73 at gmail.com
Wed Nov 30 12:01:25 CET 2016


From: Patrick Delaunay <patrick.delaunay at st.com>

support part list for MTD device
> part list nand 0
> part list nor 0

Signed-off-by: Patrick Delaunay <patrick.delaunay at st.com>
Signed-off-by: Patrick Delaunay <patrick.delaunay73 at gmail.com>
---

Changes in v2: None

 cmd/part.c | 48 +++++++++++++++++++++++++++++++++++++++---------
 1 file changed, 39 insertions(+), 9 deletions(-)

diff --git a/cmd/part.c b/cmd/part.c
index 414031e..4ea0fb2 100644
--- a/cmd/part.c
+++ b/cmd/part.c
@@ -52,11 +52,15 @@ static int do_part_uuid(int argc, char * const argv[])
 static int do_part_list(int argc, char * const argv[])
 {
 	int ret;
-	struct blk_desc *desc;
+	struct blk_desc *desc = NULL;
 	char *var = NULL;
 	bool bootable = false;
 	int i;
 
+#ifdef CONFIG_EFI_PARTITION_MTD
+	struct mtd_info *mtd = NULL;
+	char mtd_dev[16];
+#endif
 	if (argc < 2)
 		return CMD_RET_USAGE;
 
@@ -81,10 +85,19 @@ static int do_part_list(int argc, char * const argv[])
 			return CMD_RET_USAGE;
 	}
 
-	ret = blk_get_device_by_str(argv[0], argv[1], &desc);
-	if (ret < 0)
-		return 1;
-
+#ifdef CONFIG_EFI_PARTITION_MTD
+	if ((strlen(argv[0]) + strlen(argv[1])) < sizeof(mtd_dev)) {
+		sprintf(mtd_dev, "%s%s", argv[0], argv[1]);
+		mtd = get_mtd_device_nm(mtd_dev);
+	}
+	if (IS_ERR(mtd)) {
+#endif
+		ret = blk_get_device_by_str(argv[0], argv[1], &desc);
+		if (ret < 0)
+			return 1;
+#ifdef CONFIG_EFI_PARTITION_MTD
+	}
+#endif
 	if (var != NULL) {
 		int p;
 		char str[512] = { '\0', };
@@ -92,10 +105,21 @@ static int do_part_list(int argc, char * const argv[])
 
 		for (p = 1; p < 128; p++) {
 			char t[5];
-			int r = part_get_info(desc, p, &info);
+			int r;
+			if (desc) {
+				r = part_get_info(desc, p, &info);
 
-			if (r != 0)
-				continue;
+				if (r != 0)
+					continue;
+			}
+#ifdef CONFIG_EFI_PARTITION_MTD
+			else {
+				r = part_get_info_efi_mtd(mtd, p, &info);
+				/* Stop for first non valid partition */
+				if (r != 0)
+					break;
+			}
+#endif
 
 			if (bootable && !info.bootable)
 				continue;
@@ -107,8 +131,14 @@ static int do_part_list(int argc, char * const argv[])
 		return 0;
 	}
 
+#ifndef CONFIG_EFI_PARTITION_MTD
 	part_print(desc);
-
+#else
+	if (desc)
+		part_print(desc);
+	else
+		part_print_efi_mtd(mtd);
+#endif
 	return 0;
 }
 
-- 
1.9.1



More information about the U-Boot mailing list