layout: Introduce layout_next_included()

Change-Id: Ib01c8af06c3f84eafbd585760e74c3c287b9fa7d
Signed-off-by: Nico Huber <nico.h@gmx.de>
Reviewed-on: https://review.coreboot.org/c/flashrom/+/33518
Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
Reviewed-by: Arthur Heymans <arthur@aheymans.xyz>
diff --git a/layout.c b/layout.c
index 52aa388..e49189e 100644
--- a/layout.c
+++ b/layout.c
@@ -252,6 +252,24 @@
 	return lowest;
 }
 
+const struct romentry *layout_next_included(
+		const struct flashrom_layout *const layout, const struct romentry *iterator)
+{
+	const struct romentry *const end = layout->entries + layout->num_entries;
+
+	if (iterator)
+		++iterator;
+	else
+		iterator = &layout->entries[0];
+
+	for (; iterator < end; ++iterator) {
+		if (!iterator->included)
+			continue;
+		return iterator;
+	}
+	return NULL;
+}
+
 /**
  * @addtogroup flashrom-layout
  * @{