Michał Żygowski has uploaded this change for review. ( https://review.coreboot.org/c/flashrom/+/55848 )
Change subject: pcidev: Move pci device functions out of internal programmer ......................................................................
pcidev: Move pci device functions out of internal programmer
PCI device helper functions implemented in internal programmer are generic, not specific to this particular programmer. Move them to the common pcidev.c file which is included in all programmers requiring PCI and may be used not only for internal programmer.
Signed-off-by: Michał Żygowski michal.zygowski@3mdeb.com Change-Id: Ice40783a05c01cc78b34eb2c4a575554e9d55f8e --- M internal.c M pcidev.c 2 files changed, 58 insertions(+), 58 deletions(-)
git pull ssh://review.coreboot.org:29418/flashrom refs/changes/48/55848/1
diff --git a/internal.c b/internal.c index abd4637..005bd8d 100644 --- a/internal.c +++ b/internal.c @@ -30,64 +30,6 @@
enum chipbustype internal_buses_supported = BUS_NONE;
-struct pci_dev *pci_dev_find_vendorclass(uint16_t vendor, uint16_t devclass) -{ - struct pci_dev *temp; - struct pci_filter filter; - uint16_t tmp2; - - pci_filter_init(NULL, &filter); - filter.vendor = vendor; - - for (temp = pacc->devices; temp; temp = temp->next) - if (pci_filter_match(&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_dev *temp; - struct pci_filter filter; - - pci_filter_init(NULL, &filter); - filter.vendor = vendor; - filter.device = device; - - for (temp = pacc->devices; temp; temp = temp->next) - if (pci_filter_match(&filter, temp)) - return temp; - - return NULL; -} - -struct pci_dev *pci_card_find(uint16_t vendor, uint16_t device, - uint16_t card_vendor, uint16_t card_device) -{ - struct pci_dev *temp; - struct pci_filter filter; - - pci_filter_init(NULL, &filter); - filter.vendor = vendor; - filter.device = device; - - for (temp = pacc->devices; temp; temp = temp->next) - if (pci_filter_match(&filter, temp)) { - if ((card_vendor == - pci_read_word(temp, PCI_SUBSYSTEM_VENDOR_ID)) - && (card_device == - pci_read_word(temp, PCI_SUBSYSTEM_ID))) - return temp; - } - - return NULL; -} - #if IS_X86 void probe_superio(void) { diff --git a/pcidev.c b/pcidev.c index 9ffe05c..30bf981 100644 --- a/pcidev.c +++ b/pcidev.c @@ -333,3 +333,61 @@ register_undo_pci_write_long(dev, reg); return pci_write_long(dev, reg, data); } + +struct pci_dev *pci_dev_find_vendorclass(uint16_t vendor, uint16_t devclass) +{ + struct pci_dev *temp; + struct pci_filter filter; + uint16_t tmp2; + + pci_filter_init(NULL, &filter); + filter.vendor = vendor; + + for (temp = pacc->devices; temp; temp = temp->next) + if (pci_filter_match(&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_dev *temp; + struct pci_filter filter; + + pci_filter_init(NULL, &filter); + filter.vendor = vendor; + filter.device = device; + + for (temp = pacc->devices; temp; temp = temp->next) + if (pci_filter_match(&filter, temp)) + return temp; + + return NULL; +} + +struct pci_dev *pci_card_find(uint16_t vendor, uint16_t device, + uint16_t card_vendor, uint16_t card_device) +{ + struct pci_dev *temp; + struct pci_filter filter; + + pci_filter_init(NULL, &filter); + filter.vendor = vendor; + filter.device = device; + + for (temp = pacc->devices; temp; temp = temp->next) + if (pci_filter_match(&filter, temp)) { + if ((card_vendor == + pci_read_word(temp, PCI_SUBSYSTEM_VENDOR_ID)) + && (card_device == + pci_read_word(temp, PCI_SUBSYSTEM_ID))) + return temp; + } + + return NULL; +}