diff options
author | Edward O'Callaghan <quasisec@google.com> | 2022-02-26 11:36:17 +1100 |
---|---|---|
committer | Edward O'Callaghan <quasisec@chromium.org> | 2022-03-04 00:01:15 +0000 |
commit | 6289508c5bb028fa4f6ed58dfef974302c5616f9 (patch) | |
tree | 4333c8cd206de1417346191060c129ea747a2d27 /pcidev.c | |
parent | bc2e3b6b79dd1383cdf3d965df2fc5c0d6596b02 (diff) | |
download | flashrom-6289508c5bb028fa4f6ed58dfef974302c5616f9.tar.gz flashrom-6289508c5bb028fa4f6ed58dfef974302c5616f9.tar.bz2 flashrom-6289508c5bb028fa4f6ed58dfef974302c5616f9.zip |
pcidev: Move scandev_inclass logic from internal to pcidev
BUG=b:220950271
TEST=```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>
Reviewed-on: https://review.coreboot.org/c/flashrom/+/59277
Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
Reviewed-by: Anastasia Klimchuk <aklm@chromium.org>
Diffstat (limited to 'pcidev.c')
-rw-r--r-- | pcidev.c | 19 |
1 files changed, 19 insertions, 0 deletions
@@ -170,6 +170,25 @@ struct pci_dev *pcidev_getdevfn(struct pci_dev *dev, const int func) #endif } +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) { |