Various Doxygen comment fixes, typo fixes, etc.
[coreboot.git] / src / devices / pci_ops.c
index 08792f209d7ca80419cfbbbfc89e7e4564d97621..c3237dbdbfde98fd9db61bd71a02b282ec1103db 100644 (file)
 #include <device/pci_ids.h>
 #include <device/pci_ops.h>
 
+/*
+ * The only consumer of the return value of get_pbus() is ops_pci_bus().
+ * ops_pci_bus() can handle being passed NULL and auto-picks working ops.
+ */
 static struct bus *get_pbus(device_t dev)
 {
-       struct bus *pbus;
+       struct bus *pbus = NULL;
 
        if (!dev)
-               printk_alert("get_pbus: dev is NULL!\n");
-
-       pbus = dev->bus;
+               die("get_pbus: dev is NULL!\n");
+       else
+               pbus = dev->bus;
 
        while(pbus && pbus->dev && !ops_pci_bus(pbus)) {
                if (pbus == pbus->dev->bus) {
-                       printk_alert("%s in endless loop looking for a parent "
-                               "bus with ops_pci_bus for %s, breaking out\n",
+                       printk(BIOS_ALERT, "%s in endless loop looking for a parent "
+                               "bus with ops_pci_bus for %s, breaking out.\n",
                                 __func__, dev_path(dev));
                        break;
                }
                pbus = pbus->dev->bus;
        }
        if (!pbus || !pbus->dev || !pbus->dev->ops || !pbus->dev->ops->ops_pci_bus) {
-               printk_alert("%s Cannot find pci bus operations", dev_path(dev));
-               die("");
-               for(;;);
+               /* This can happen before the device tree is set up completely. */
+               //printk(BIOS_EMERG, "%s: Cannot find pci bus operations.\n", dev_path(dev));
+               pbus = NULL;
        }
        return pbus;
 }
@@ -87,7 +91,7 @@ void pci_write_config32(device_t dev, unsigned where, uint32_t val)
        ops_pci_bus(pbus)->write32(pbus, dev->bus->secondary, dev->path.pci.devfn, where, val);
 }
 
-#if MMCONF_SUPPORT
+#if CONFIG_MMCONF_SUPPORT
 uint8_t pci_mmio_read_config8(device_t dev, unsigned where)
 {
        struct bus *pbus = get_pbus(dev);