[U-Boot] [PATCH v4 12/16] cmd: part: update command to support GPT over MTD

Patrick Delaunay patrick.delaunay at st.com
Wed Mar 15 14:11:43 UTC 2017


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

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

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

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

diff --git a/cmd/part.c b/cmd/part.c
index 8ba0598..36ec915 100644
--- a/cmd/part.c
+++ b/cmd/part.c
@@ -48,10 +48,14 @@ 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;
@@ -77,10 +81,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', };
@@ -88,10 +101,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 (r != 0)
-				continue;
+			if (desc) {
+				r = part_get_info(desc, p, &info);
+				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;
@@ -100,10 +124,18 @@ static int do_part_list(int argc, char * const argv[])
 			strcat(str, t);
 		}
 		setenv(var, str);
+
 		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