Edward O'Callaghan has uploaded this change for review.

View Change

pcidev: Move pci_get_dev() logic into canonical place

Change-Id: Id9ce055d5e5d347520ec5002b8c6548e60eaa0a7
Signed-off-by: Edward O'Callaghan <quasisec@google.com>
---
M board_enable.c
M pcidev.c
M programmer.h
3 files changed, 15 insertions(+), 9 deletions(-)

git pull ssh://review.coreboot.org:29418/flashrom refs/changes/76/59276/1
diff --git a/board_enable.c b/board_enable.c
index 9cf0103..ae8ce2c 100644
--- a/board_enable.c
+++ b/board_enable.c
@@ -1090,15 +1090,7 @@
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_getdev(dev);
if (!dev) {
msg_perr("MCP SMBus controller could not be found\n");
return -1;
diff --git a/pcidev.c b/pcidev.c
index 32c6d30..c9c86b8 100644
--- a/pcidev.c
+++ b/pcidev.c
@@ -157,6 +157,19 @@
return NULL;
}

+struct pci_dev *pcidev_getdev(struct pci_dev *dev)
+{
+#if !defined(OLD_PCI_GET_DEV)
+ return 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.
+ */
+ return pci_get_dev(pacc, dev->bus, dev->dev, 1);
+#endif
+}
+
static int pcidev_shutdown(void *data)
{
if (pacc == NULL) {
diff --git a/programmer.h b/programmer.h
index d6de7bc..a78ee2a 100644
--- a/programmer.h
+++ b/programmer.h
@@ -125,6 +125,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 *pcidev_getdev(struct pci_dev *dev);
/* 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

To view, visit change 59276. To unsubscribe, or for help writing mail filters, visit settings.

Gerrit-Project: flashrom
Gerrit-Branch: master
Gerrit-Change-Id: Id9ce055d5e5d347520ec5002b8c6548e60eaa0a7
Gerrit-Change-Number: 59276
Gerrit-PatchSet: 1
Gerrit-Owner: Edward O'Callaghan <quasisec@chromium.org>
Gerrit-MessageType: newchange