drv/intel/fsp2_0/hand_off_block: rework fsp_find_extension_hob_by_guid

Use the new fsp_hob_iterator_get_next_guid_extension function in
fsp_find_extension_hob_by_guid instead of iterating through the HOB list
in this function.

TEST=AMD_FSP_DMI_HOB is still found and the same type 17 DMI info is
printed on the console.

Signed-off-by: Felix Held <felix-coreboot@felixheld.de>
Change-Id: I4d4ce14c8a5494763de3f65ed049f98a768c40a5
Reviewed-on: https://review.coreboot.org/c/coreboot/+/69478
Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
Reviewed-by: Arthur Heymans <arthur@aheymans.xyz>
diff --git a/src/drivers/intel/fsp2_0/hand_off_block.c b/src/drivers/intel/fsp2_0/hand_off_block.c
index 2738c78..2ded33699 100644
--- a/src/drivers/intel/fsp2_0/hand_off_block.c
+++ b/src/drivers/intel/fsp2_0/hand_off_block.c
@@ -233,22 +233,14 @@
 
 const void *fsp_find_extension_hob_by_guid(const uint8_t *guid, size_t *size)
 {
-	const uint8_t *hob_guid;
-	const struct hob_header *hob = fsp_get_hob_list();
+	const struct hob_header *hob_iterator;
+	const void *hob_guid;
 
-	if (!hob)
+	if (fsp_hob_iterator_init(&hob_iterator) != CB_SUCCESS)
 		return NULL;
 
-	for (; hob->type != HOB_TYPE_END_OF_HOB_LIST; hob = fsp_next_hob(hob)) {
-		if (hob->type != HOB_TYPE_GUID_EXTENSION)
-			continue;
-
-		hob_guid = hob_header_to_struct(hob);
-		if (fsp_guid_compare(hob_guid, guid)) {
-			*size = hob->length - (HOB_HEADER_LEN + 16);
-			return hob_header_to_extension_hob(hob);
-		}
-	}
+	if (fsp_hob_iterator_get_next_guid_extension(&hob_iterator, guid, &hob_guid, size) == CB_SUCCESS)
+		return hob_guid;
 
 	return NULL;
 }