All of lore.kernel.org
 help / color / mirror / Atom feed
* [U-Boot] [PATCH 1/2] disk: part: scan the disk if the part_type is unknow
@ 2017-12-14  6:39 Kever Yang
  2017-12-14  6:39 ` [U-Boot] [PATCH 2/2] disk: part: use common api to lookup part driver Kever Yang
  2017-12-19 15:41 ` [U-Boot] [PATCH 1/2] disk: part: scan the disk if the part_type is unknow Simon Glass
  0 siblings, 2 replies; 7+ messages in thread
From: Kever Yang @ 2017-12-14  6:39 UTC (permalink / raw)
  To: u-boot

We can get the new part table when we write a new partition table to
a blank disk with this patch, or else we have to reset the board
to get new partition table.

Signed-off-by: Kever Yang <kever.yang@rock-chips.com>
---

 disk/part.c | 24 ++++++++++++++++++------
 1 file changed, 18 insertions(+), 6 deletions(-)

diff --git a/disk/part.c b/disk/part.c
index c04e91a..b007138 100644
--- a/disk/part.c
+++ b/disk/part.c
@@ -24,16 +24,28 @@
 DECLARE_GLOBAL_DATA_PTR;
 
 #ifdef HAVE_BLOCK_DEVICE
-static struct part_driver *part_driver_lookup_type(int part_type)
+static struct part_driver *part_driver_lookup_type(struct blk_desc *dev_desc)
 {
 	struct part_driver *drv =
 		ll_entry_start(struct part_driver, part_driver);
 	const int n_ents = ll_entry_count(struct part_driver, part_driver);
 	struct part_driver *entry;
 
-	for (entry = drv; entry != drv + n_ents; entry++) {
-		if (part_type == entry->part_type)
-			return entry;
+	if (dev_desc->part_type == PART_TYPE_UNKNOWN) {
+		for (entry = drv; entry != drv + n_ents; entry++) {
+			int ret;
+
+			ret = entry->test(dev_desc);
+			if (!ret) {
+				dev_desc->part_type = entry->part_type;
+				return entry;
+			}
+		}
+	} else {
+		for (entry = drv; entry != drv + n_ents; entry++) {
+			if (dev_desc->part_type == entry->part_type)
+				return entry;
+		}
 	}
 
 	/* Not found */
@@ -286,7 +298,7 @@ void part_print(struct blk_desc *dev_desc)
 {
 	struct part_driver *drv;
 
-	drv = part_driver_lookup_type(dev_desc->part_type);
+	drv = part_driver_lookup_type(dev_desc);
 	if (!drv) {
 		printf("## Unknown partition table type %x\n",
 		       dev_desc->part_type);
@@ -315,7 +327,7 @@ int part_get_info(struct blk_desc *dev_desc, int part,
 	info->type_guid[0] = 0;
 #endif
 
-	drv = part_driver_lookup_type(dev_desc->part_type);
+	drv = part_driver_lookup_type(dev_desc);
 	if (!drv) {
 		debug("## Unknown partition table type %x\n",
 		      dev_desc->part_type);
-- 
1.9.1

^ permalink raw reply related	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2017-12-22  3:33 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-12-14  6:39 [U-Boot] [PATCH 1/2] disk: part: scan the disk if the part_type is unknow Kever Yang
2017-12-14  6:39 ` [U-Boot] [PATCH 2/2] disk: part: use common api to lookup part driver Kever Yang
2017-12-14  9:53   ` Dr. Philipp Tomsich
2017-12-15  2:34     ` Kever Yang
2017-12-15  9:08       ` Dr. Philipp Tomsich
2017-12-19 15:41 ` [U-Boot] [PATCH 1/2] disk: part: scan the disk if the part_type is unknow Simon Glass
2017-12-22  3:33   ` Kever Yang

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.