pcidev: Move scandev_inclass logic from internal to pcidev

Tested: ```sudo ./flashrom -p internal -r /tmp/bios
<snip>
Found Programmer flash chip "Opaque flash chip" (16384 kB, Programmer-specific) mapped at physical address 0x0000000000000000.
Reading flash... done.
```

Change-Id: I1978e178fb73485f1c5c7e732853522847267cee
Signed-off-by: Edward O'Callaghan <quasisec@google.com>
Original-Reviewed-on: https://review.coreboot.org/c/flashrom/+/59277
Original-Reviewed-by: Anastasia Klimchuk <aklm@chromium.org>
Reviewed-on: https://review.coreboot.org/c/flashrom-stable/+/72302
Reviewed-by: Nico Huber <nico.h@gmx.de>
Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
diff --git a/board_enable.c b/board_enable.c
index d2e1c35..5f444df 100644
--- a/board_enable.c
+++ b/board_enable.c
@@ -783,7 +783,7 @@
 	uint16_t base;
 	uint8_t val, bit, offset;
 
-	dev = pci_dev_find_vendorclass(0x1106, 0x0601);
+	dev = pcidev_find_vendorclass(0x1106, 0x0601);
 	switch (dev->device_id) {
 	case 0x3177:	/* VT8235 */
 	case 0x3227:	/* VT8237/VT8237R */
@@ -1074,7 +1074,7 @@
 	}
 
 	/* Check for the ISA bridge first. */
-	dev = pci_dev_find_vendorclass(0x10DE, 0x0601);
+	dev = pcidev_find_vendorclass(0x10DE, 0x0601);
 	switch (dev->device_id) {
 	case 0x0030: /* CK804 */
 	case 0x0050: /* MCP04 */
diff --git a/chipset_enable.c b/chipset_enable.c
index 459819a..c9b668c 100644
--- a/chipset_enable.c
+++ b/chipset_enable.c
@@ -121,11 +121,11 @@
 {
 	struct pci_dev *sbdev;
 
-	sbdev = pci_dev_find_vendorclass(vendor, 0x0601);
+	sbdev = pcidev_find_vendorclass(vendor, 0x0601);
 	if (!sbdev)
-		sbdev = pci_dev_find_vendorclass(vendor, 0x0680);
+		sbdev = pcidev_find_vendorclass(vendor, 0x0680);
 	if (!sbdev)
-		sbdev = pci_dev_find_vendorclass(vendor, 0x0000);
+		sbdev = pcidev_find_vendorclass(vendor, 0x0000);
 	if (!sbdev)
 		msg_perr("No southbridge found for %s!\n", name);
 	if (sbdev)
diff --git a/internal.c b/internal.c
index 2e2d166..86ac35a 100644
--- a/internal.c
+++ b/internal.c
@@ -26,25 +26,6 @@
 #include "hwaccess_x86_io.h"
 #endif
 
-struct pci_dev *pci_dev_find_vendorclass(uint16_t vendor, uint16_t devclass)
-{
-	struct pci_dev *temp = NULL;
-	struct pci_filter filter;
-	uint16_t tmp2;
-
-	pci_filter_init(NULL, &filter);
-	filter.vendor = vendor;
-
-	while ((temp = pcidev_scandev(&filter, temp))) {
-		/* Read PCI class */
-		tmp2 = pci_read_word(temp, 0x0a);
-		if (tmp2 == devclass)
-			return temp;
-	}
-
-	return NULL;
-}
-
 struct pci_dev *pci_dev_find(uint16_t vendor, uint16_t device)
 {
 	struct pci_filter filter;
diff --git a/mcp6x_spi.c b/mcp6x_spi.c
index 26ed647..dd76e60 100644
--- a/mcp6x_spi.c
+++ b/mcp6x_spi.c
@@ -103,7 +103,7 @@
 	struct pci_dev *smbusdev;
 
 	/* Look for the SMBus device (SMBus PCI class) */
-	smbusdev = pci_dev_find_vendorclass(0x10de, 0x0c05);
+	smbusdev = pcidev_find_vendorclass(0x10de, 0x0c05);
 	if (!smbusdev) {
 		if (want_spi) {
 			msg_perr("ERROR: SMBus device not found. Not enabling "
diff --git a/pcidev.c b/pcidev.c
index a20d24b..3515871 100644
--- a/pcidev.c
+++ b/pcidev.c
@@ -160,6 +160,25 @@
 	return NULL;
 }
 
+struct pci_dev *pcidev_find_vendorclass(uint16_t vendor, uint16_t devclass)
+{
+	struct pci_dev *temp = NULL;
+	struct pci_filter filter;
+	uint16_t tmp2;
+
+	pci_filter_init(NULL, &filter);
+	filter.vendor = vendor;
+
+	while ((temp = pcidev_scandev(&filter, temp))) {
+		/* Read PCI class */
+		tmp2 = pci_read_word(temp, PCI_CLASS_DEVICE);
+		if (tmp2 == devclass)
+			return temp;
+	}
+
+	return NULL;
+}
+
 static int pcidev_shutdown(void *data)
 {
 	if (pacc == NULL) {
diff --git a/programmer.h b/programmer.h
index 40c47ad..763ed67 100644
--- a/programmer.h
+++ b/programmer.h
@@ -123,6 +123,7 @@
 uintptr_t pcidev_readbar(struct pci_dev *dev, int bar);
 struct pci_dev *pcidev_init(const struct dev_entry *devs, int bar);
 struct pci_dev *pcidev_scandev(struct pci_filter *filter, struct pci_dev *start);
+struct pci_dev *pcidev_find_vendorclass(uint16_t vendor, uint16_t devclass);
 /* rpci_write_* are reversible writes. The original PCI config space register
  * contents will be restored on shutdown.
  * To clone the pci_dev instances internally, the `pacc` global
@@ -256,7 +257,6 @@
 #define SUPERIO_VENDOR_WINBOND	0x2
 #endif
 #if NEED_PCI == 1
-struct pci_dev *pci_dev_find_vendorclass(uint16_t vendor, uint16_t devclass);
 struct pci_dev *pci_dev_find(uint16_t vendor, uint16_t device);
 struct pci_dev *pci_card_find(uint16_t vendor, uint16_t device,
 			      uint16_t card_vendor, uint16_t card_device);