Patchwork [1/7] seabios: pci: introduce helper function to find device from table and initialize it.

login
register
mail settings
Submitter Isaku Yamahata
Date July 12, 2010, 11:47 a.m.
Message ID <b464d851724332fc63e2acedef5fc86ea6e33382.1278935094.git.yamahata@valinux.co.jp>
Download mbox | patch
Permalink /patch/58604/
State New
Headers show

Comments

Isaku Yamahata - July 12, 2010, 11:47 a.m.
introduce helper function to find device from table and initialize it.
pci_find_init_device(). This will be used later.

Signed-off-by: Isaku Yamahata <yamahata@valinux.co.jp>
---
 src/pci.c |   12 ++++++++++++
 src/pci.h |    1 +
 2 files changed, 13 insertions(+), 0 deletions(-)

Patch

diff --git a/src/pci.c b/src/pci.c
index c54b084..611d0e2 100644
--- a/src/pci.c
+++ b/src/pci.c
@@ -203,3 +203,15 @@  int pci_init_device(const struct pci_device_id *ids, u16 bdf, void *arg)
     }
     return -1;
 }
+
+int pci_find_init_device(const struct pci_device_id *ids, void *arg)
+{
+    int bdf, max;
+
+    foreachpci(bdf, max) {
+        if (pci_init_device(ids, bdf, arg) == 0) {
+            return bdf;
+        }
+    }
+    return -1;
+}
diff --git a/src/pci.h b/src/pci.h
index fa6a32d..9c3108c 100644
--- a/src/pci.h
+++ b/src/pci.h
@@ -93,6 +93,7 @@  struct pci_device_id {
     }
 
 int pci_init_device(const struct pci_device_id *table, u16 bdf, void *arg);
+int pci_find_init_device(const struct pci_device_id *ids, void *arg);
 
 // pirtable.c
 void create_pirtable(void);