Convert AHCI detection code to use struct pci_device.
authorKevin O'Connor <kevin@koconnor.net>
Tue, 21 Jun 2011 02:22:42 +0000 (22:22 -0400)
committerKevin O'Connor <kevin@koconnor.net>
Tue, 21 Jun 2011 03:57:51 +0000 (23:57 -0400)
src/ahci.c

index b28597a4a7f4e2746289d5c589c87dc8bcb8e9cc..fb4b70c3767033eccb58cfb4752b9bb72b1d2077 100644 (file)
@@ -8,7 +8,7 @@
 #include "ioport.h" // inb
 #include "util.h" // dprintf
 #include "biosvar.h" // GET_EBDA
-#include "pci.h" // foreachbdf
+#include "pci.h" // foreachpci
 #include "pci_ids.h" // PCI_CLASS_STORAGE_OTHER
 #include "pci_regs.h" // PCI_INTERRUPT_LINE
 #include "boot.h" // add_bcv_hd
@@ -462,13 +462,13 @@ static void
 ahci_init(void)
 {
     // Scan PCI bus for ATA adapters
-    int bdf, max;
-    foreachbdf(bdf, max) {
-        if (pci_config_readw(bdf, PCI_CLASS_DEVICE) != PCI_CLASS_STORAGE_SATA)
+    struct pci_device *pci;
+    foreachpci(pci) {
+        if (pci->class != PCI_CLASS_STORAGE_SATA)
             continue;
-        if (pci_config_readb(bdf, PCI_CLASS_PROG) != 1 /* AHCI rev 1 */)
+        if (pci->prog_if != 1 /* AHCI rev 1 */)
             continue;
-        ahci_init_controller(bdf);
+        ahci_init_controller(pci->bdf);
     }
 }