diff options
author | Kevin O'Connor <kevin@koconnor.net> | 2013-06-08 21:53:36 -0400 |
---|---|---|
committer | Kevin O'Connor <kevin@koconnor.net> | 2013-06-08 22:13:52 -0400 |
commit | b98a4b1dae7885097873c5f16ac3fe0ad6543155 (patch) | |
tree | 54a2e2329451e476d72ff7dec56c2fb6b30a6584 | |
parent | aab42152881dc62b37f1833e79cbdb3dfa51603b (diff) | |
download | seabios-b98a4b1dae7885097873c5f16ac3fe0ad6543155.tar.gz |
Convert PCIDevices list to use standard list manipultion code.
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
-rw-r--r-- | src/ata.c | 2 | ||||
-rw-r--r-- | src/mptable.c | 2 | ||||
-rw-r--r-- | src/pci.c | 7 | ||||
-rw-r--r-- | src/pci.h | 9 | ||||
-rw-r--r-- | src/usb-ehci.c | 2 | ||||
-rw-r--r-- | src/usb.c | 8 |
6 files changed, 15 insertions, 15 deletions
@@ -1008,7 +1008,7 @@ static const struct pci_device_id pci_ata_tbl[] = { static void ata_scan(void) { - if (CONFIG_QEMU && !PCIDevices) { + if (CONFIG_QEMU && hlist_empty(&PCIDevices)) { // No PCI devices found - probably a QEMU "-M isapc" machine. // Try using ISA ports for ATA controllers. init_controller(NULL, IRQ_ATA1 diff --git a/src/mptable.c b/src/mptable.c index 7d485eb..0413063 100644 --- a/src/mptable.c +++ b/src/mptable.c @@ -67,7 +67,7 @@ mptable_setup(void) // PCI bus struct mpt_bus *buses = (void*)cpu, *bus = buses; - if (PCIDevices) { + if (!hlist_empty(&PCIDevices)) { memset(bus, 0, sizeof(*bus)); bus->type = MPT_TYPE_BUS; bus->busid = 0; @@ -85,7 +85,7 @@ pci_next(int bdf, int bus) } } -struct pci_device *PCIDevices VARVERIFY32INIT; +struct hlist_head PCIDevices VARVERIFY32INIT; int MaxPCIBus VARFSEG; // Check if PCI is available at all @@ -107,7 +107,7 @@ pci_probe_devices(void) dprintf(3, "PCI probe\n"); struct pci_device *busdevs[256]; memset(busdevs, 0, sizeof(busdevs)); - struct pci_device **pprev = &PCIDevices; + struct hlist_node **pprev = &PCIDevices.first; int extraroots = romfile_loadint("etc/extra-pci-roots", 0); int bus = -1, lastbus = 0, rootbuses = 0, count=0; while (bus < 0xff && (bus < MaxPCIBus || rootbuses < extraroots)) { @@ -121,8 +121,7 @@ pci_probe_devices(void) return; } memset(dev, 0, sizeof(*dev)); - *pprev = dev; - pprev = &dev->next; + hlist_add(&dev->node, pprev); count++; // Find parent device. @@ -2,6 +2,7 @@ #define __PCI_H #include "types.h" // u32 +#include "list.h" // hlist_node #define PCI_ROM_SLOT 6 #define PCI_NUM_REGIONS 7 @@ -43,7 +44,7 @@ struct pci_device *pci_find_class(u16 classid); struct pci_device { u16 bdf; u8 rootbus; - struct pci_device *next; + struct hlist_node node; struct pci_device *parent; // Configuration space device information @@ -58,7 +59,7 @@ struct pci_device { }; extern u64 pcimem_start, pcimem_end; extern u64 pcimem64_start, pcimem64_end; -extern struct pci_device *PCIDevices; +extern struct hlist_head PCIDevices; extern int MaxPCIBus; int pci_probe_host(void); void pci_probe_devices(void); @@ -66,8 +67,8 @@ static inline u32 pci_classprog(struct pci_device *pci) { return (pci->class << 8) | pci->prog_if; } -#define foreachpci(PCI) \ - for (PCI=PCIDevices; PCI; PCI=PCI->next) +#define foreachpci(PCI) \ + hlist_for_each_entry(PCI, &PCIDevices, node) int pci_next(int bdf, int bus); #define foreachbdf(BDF, BUS) \ diff --git a/src/usb-ehci.c b/src/usb-ehci.c index 69a9194..144dec4 100644 --- a/src/usb-ehci.c +++ b/src/usb-ehci.c @@ -368,7 +368,7 @@ ehci_setup(struct pci_device *pci, int busid, struct pci_device *comppci) cntl->companion[count++] = comppci; else if (pci_classprog(comppci) == PCI_CLASS_SERIAL_USB_OHCI) cntl->companion[count++] = comppci; - comppci = comppci->next; + comppci = container_of(comppci->node.next, struct pci_device, node); } run_thread(configure_ehci, cntl); @@ -422,13 +422,12 @@ usb_setup(void) // Look for USB controllers int count = 0; - struct pci_device *ehcipci = PCIDevices; - struct pci_device *pci; + struct pci_device *pci, *ehcipci = NULL; foreachpci(pci) { if (pci->class != PCI_CLASS_SERIAL_USB) continue; - if (pci->bdf >= ehcipci->bdf) { + if (!ehcipci || pci->bdf >= ehcipci->bdf) { // Check to see if this device has an ehci controller int found = 0; ehcipci = pci; @@ -445,7 +444,8 @@ usb_setup(void) } if (ehcipci->class == PCI_CLASS_SERIAL_USB) found++; - ehcipci = ehcipci->next; + ehcipci = container_of( + ehcipci->node.next, struct pci_device, node); if (!ehcipci || (pci_bdf_to_busdev(ehcipci->bdf) != pci_bdf_to_busdev(pci->bdf))) // No ehci controller found. |