1
0
mirror of https://review.coreboot.org/flashrom.git synced 2025-04-27 23:22:37 +02:00

pcidev: Move pci_get_dev() logic into canonical place

BUG=b:220950271
TEST=```sudo ./flashrom -p internal --flash-size
<snip>
Found Programmer flash chip "Opaque flash chip" (16384 kB, Programmer-specific) mapped at physical address 0x0000000000000000.
16777216
```

Change-Id: Id9ce055d5e5d347520ec5002b8c6548e60eaa0a7
Signed-off-by: Edward O'Callaghan <quasisec@google.com>
Reviewed-on: https://review.coreboot.org/c/flashrom/+/59276
Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
Reviewed-by: Subrata Banik <subratabanik@google.com>
This commit is contained in:
Edward O'Callaghan 2021-11-13 13:29:06 +11:00 committed by Edward O'Callaghan
parent 12dbc4e045
commit 00194eadde
3 changed files with 15 additions and 9 deletions

View File

@ -1094,15 +1094,7 @@ static int nvidia_mcp_gpio_set(int gpio, int raise)
return -1;
}
#if !defined(OLD_PCI_GET_DEV)
dev = pci_get_dev(pacc, dev->domain, dev->bus, dev->dev, 1);
#else
/* pciutils/libpci before version 2.2 is too old to support
* PCI domains. Such old machines usually don't have domains
* besides domain 0, so this is not a problem.
*/
dev = pci_get_dev(pacc, dev->bus, dev->dev, 1);
#endif
dev = pcidev_getdevfn(dev, 1);
if (!dev) {
msg_perr("MCP SMBus controller could not be found\n");
return -1;

View File

@ -157,6 +157,19 @@ struct pci_dev *pcidev_scandev(struct pci_filter *filter, struct pci_dev *start)
return NULL;
}
struct pci_dev *pcidev_getdevfn(struct pci_dev *dev, const int func)
{
#if !defined(OLD_PCI_GET_DEV)
return pci_get_dev(pacc, dev->domain, dev->bus, dev->dev, func);
#else
/* pciutils/libpci before version 2.2 is too old to support
* PCI domains. Such old machines usually don't have domains
* besides domain 0, so this is not a problem.
*/
return pci_get_dev(pacc, dev->bus, dev->dev, func);
#endif
}
static int pcidev_shutdown(void *data)
{
if (pacc == NULL) {

View File

@ -126,6 +126,7 @@ int pci_init_common(void);
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_getdevfn(struct pci_dev *dev, const int func);
/* 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