[RFC,07/13] libflash/libffs: Always add entries to the end of the TOC

Message ID 20170829062506.8317-8-cyril.bur@au1.ibm.com
State New
Headers show
Series
  • Rework flash TOC generation
Related show

Commit Message

Cyril Bur Aug. 29, 2017, 6:25 a.m.
It turns out that sorted order isn't the best idea. This removes
flexibility from the caller. If the user wants their partitions in
sorted order, they should insert them in sorted order.

Signed-off-by: Cyril Bur <cyril.bur@au1.ibm.com>
---
 libflash/libffs.c | 20 +-------------------
 1 file changed, 1 insertion(+), 19 deletions(-)

Patch

diff --git a/libflash/libffs.c b/libflash/libffs.c
index 822169b7..0159c07b 100644
--- a/libflash/libffs.c
+++ b/libflash/libffs.c
@@ -598,25 +598,7 @@  static int __ffs_entry_add(struct ffs_hdr *hdr, struct ffs_entry *entry)
 		return FFS_ERR_BAD_PART_BASE;
 	}
 
-	/*
-	 * A header can't have zero entries. Was asserted.
-	 */
-	list_for_each(&hdr->entries, ent, list)
-		if (entry->base < ent->base)
-			break;
-
-	if (ent == list_top(&hdr->entries, struct ffs_entry, list)) {
-		/*
-		 * This should never happen because the partition entry
-		 * should ALWAYS be here
-		 */
-		fprintf(stderr, "Warning: replacing first entry in FFS header\n");
-		list_add(&hdr->entries, &entry->list);
-	} else if (!ent) {
-		list_add_tail(&hdr->entries, &entry->list);
-	} else {
-		list_add_before(&hdr->entries, &entry->list, &ent->list);
-	}
+	list_add_tail(&hdr->entries, &entry->list);
 
 	return 0;
 }