From 27f6fc194b852920ebe6a46e8a497673d6634697 Mon Sep 17 00:00:00 2001 From: Samuel Thibault Date: Fri, 6 Jul 2012 01:10:57 -0300 Subject: Fix probing for all PCI buses, not only 0 and 2 * libdde_linux26/lib/src/arch/l4/pci.c (pci_bus, pci_bus1): Remove variables. (l4dde26_init_pci): Use ddekit_pci_get_device to find out all buses to be probed for. --- libdde_linux26/lib/src/arch/l4/pci.c | 31 +++++++++++++++---------------- 1 file changed, 15 insertions(+), 16 deletions(-) diff --git a/libdde_linux26/lib/src/arch/l4/pci.c b/libdde_linux26/lib/src/arch/l4/pci.c index c393fd3a..b50a7353 100644 --- a/libdde_linux26/lib/src/arch/l4/pci.c +++ b/libdde_linux26/lib/src/arch/l4/pci.c @@ -24,10 +24,6 @@ typedef struct l4dde_pci_dev { /** List of Linux-DDEKit PCIDev mappings */ static LIST_HEAD(pcidev_mappings); -/** PCI bus */ -static struct pci_bus *pci_bus = NULL; -static struct pci_bus *pci_bus1 = NULL; - static int l4dde26_pci_read(struct pci_bus *bus, unsigned int devfn, int where, int size, u32 *val); static int l4dde26_pci_write(struct pci_bus *bus, unsigned int devfn, int where, int size, u32 val); @@ -187,18 +183,21 @@ int pcibios_enable_device(struct pci_dev *dev, int mask) void __init l4dde26_init_pci(void) { ddekit_pci_init(); - - // TODO it's a temporary solution to handle 2 buses. - // we need to find a way to detect buses. - pci_bus = pci_create_bus(NULL, 0, &dde_pcibus_ops, NULL); - Assert(pci_bus); - - pci_do_scan_bus(pci_bus); - - pci_bus1 = pci_create_bus(NULL, 2, &dde_pcibus_ops, NULL); - Assert(pci_bus1); - - pci_do_scan_bus(pci_bus1); + int nr; + char found[256] = { }; + int bus, slot, func; + + for (nr = 0; ; nr++) { + if (ddekit_pci_get_device(nr, &bus, &slot, &func) != 0) + break; + if (!found[bus]) { + struct pci_bus *pci_bus = pci_create_bus(NULL, bus, &dde_pcibus_ops, NULL); + Assert(pci_bus); + pci_do_scan_bus(pci_bus); + + found[bus] = 1; + } + } INITIALIZE_INITVAR(dde26_pci); } -- cgit v1.2.3