[coreboot] [PATCH]libpayload: implement libpci interface
Peter Stuge
peter at stuge.se
Wed Jun 23 01:18:07 CEST 2010
Patrick Georgi wrote:
> attached patch provides a libpci implementation sufficient to get
> flashrom to compile. It should work but is untested beyond what flashrom
> does. It's also incomplete: libpci has many more capabilities than
> exposed in this variant.
>
> No pciutils code was harmed in its production - this code was written by
> looking at flashrom's expectations, so licensing is clean.
>
> Signed-off-by: Patrick Georgi <patrick.georgi at coresystems.de>
With one important comment and one about style, this is:
Acked-by: Peter Stuge <peter at stuge.se>
> +++ libpci/libpci.c (Revision 0)
..
> +int pci_filter_match(struct pci_filter* pf, struct pci_dev* dev)
> +{
> + int match = 1;
> + if ((pf->domain > -1) && (pf->domain != dev->domain)) match = 0;
> + if ((pf->bus > -1) && (pf->bus != dev->bus)) match = 0;
> + if ((pf->dev > -1) && (pf->dev != dev->dev)) match = 0;
> + if ((pf->func > -1) && (pf->func != dev->func)) match = 0;
> + if ((pf->vendor > -1) && (pf->vendor != dev->vendor_id)) match = 0;
> + if ((pf->device > -1) && (pf->device != dev->device_id)) match = 0;
> + return match;
> +}
Maybe skip the variable and return directly? I'd also like the return
to be on it's own line.
> +struct pci_dev *pci_get_dev(struct pci_access* pacc, u16 domain, u8 bus, u8 dev, u8 func)
> +{
> + struct pci_dev *cur;
> + for (cur = pacc->devices; cur != NULL; cur = cur->next) {
> + if ((cur->domain == domain) && (cur->bus == bus) && (cur->dev == dev) && (cur->func == func)) break;
> + cur = cur->next;
> + }
> + /* FIXME: is NULL the right answer if device not found? */
> + return cur;
> +}
This function doesn't search, it "creates" a struct pci_dev using
pci_alloc() + PCI_DEV(), so it may even be possible to remove
libpci_to_lb().
//Peter
More information about the coreboot
mailing list