device/pci_rom: rework PCI ID remapping in pci_rom_probe

Only call cbfs_boot_map_optionrom/cbfs_boot_map_optionrom_revision once
and pass the already remapped PCI ID to it. This avoids the spurious
warning that the CBFS file wasn't found from the first
cbfs_boot_map_optionrom call in cases where the PCI ID needs to be
remapped to get the right ID for which a file in CBFS exists.

Signed-off-by: Felix Held <felix-coreboot@felixheld.de>
Change-Id: If7da78c69dd702280a78996a5823972516e0319b
Reviewed-on: https://review.coreboot.org/c/coreboot/+/73612
Reviewed-by: Martin Roth <martin.roth@amd.corp-partner.google.com>
Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
diff --git a/src/device/pci_rom.c b/src/device/pci_rom.c
index 8480626..a454c9e 100644
--- a/src/device/pci_rom.c
+++ b/src/device/pci_rom.c
@@ -60,24 +60,14 @@
 
 	/* If the ROM is in flash, then don't check the PCI device for it. */
 	if (CONFIG(CHECK_REV_IN_OPROM_NAME)) {
-		rom_header = cbfs_boot_map_optionrom_revision(dev->vendor, dev->device, rev);
 		map_oprom_vendev_rev(&mapped_vendev, &mapped_rev);
+		rom_header = cbfs_boot_map_optionrom_revision(mapped_vendev >> 16,
+							      mapped_vendev & 0xffff,
+							      mapped_rev);
 	} else {
-		rom_header = cbfs_boot_map_optionrom(dev->vendor, dev->device);
 		mapped_vendev = map_oprom_vendev(vendev);
-	}
-
-	if (!rom_header) {
-		if (CONFIG(CHECK_REV_IN_OPROM_NAME) &&
-				(vendev != mapped_vendev || rev != mapped_rev)) {
-			rom_header = cbfs_boot_map_optionrom_revision(
-					mapped_vendev >> 16,
-					mapped_vendev & 0xffff, mapped_rev);
-		} else if (vendev != mapped_vendev) {
-			rom_header = cbfs_boot_map_optionrom(
-					mapped_vendev >> 16,
-					mapped_vendev & 0xffff);
-		}
+		rom_header = cbfs_boot_map_optionrom(mapped_vendev >> 16,
+						     mapped_vendev & 0xffff);
 	}
 
 	if (rom_header) {