diff --git a/drivers/pci.c b/drivers/pci.c index ae9a0bc..73dde79 100644 --- a/drivers/pci.c +++ b/drivers/pci.c @@ -510,38 +510,43 @@ static void ob_pci_add_properties(pci_addr addr, const pci_dev_t *pci_dev, set_int_property(dev, "cache-line-size", pci_config_read16(addr, PCI_CACHE_LINE_SIZE)); - if (pci_dev->type) { - push_str(pci_dev->type); - fword("encode-string"); - push_str("device_type"); - fword("property"); + if (pci_dev) { + if (pci_dev->type) { + push_str(pci_dev->type); + fword("encode-string"); + push_str("device_type"); + fword("property"); + } + if (pci_dev->model) { + push_str(pci_dev->model); + fword("encode-string"); + push_str("model"); + fword("property"); + } + if (pci_dev->compat) + set_property(dev, "compatible", + pci_dev->compat, pci_compat_len(pci_dev)); + + if (pci_dev->acells) + set_int_property(dev, "#address-cells", + pci_dev->acells); + if (pci_dev->scells) + set_int_property(dev, "#size-cells", + pci_dev->scells); + if (pci_dev->icells) + set_int_property(dev, "#interrupt-cells", + pci_dev->icells); } - if (pci_dev->model) { - push_str(pci_dev->model); - fword("encode-string"); - push_str("model"); - fword("property"); - } - if (pci_dev->compat) - set_property(dev, "compatible", - pci_dev->compat, pci_compat_len(pci_dev)); pci_set_reg(config); pci_set_assigned_addresses(config); pci_set_interrupt_map(config); - if (pci_dev->acells) - set_int_property(dev, "#address-cells", pci_dev->acells); - if (pci_dev->scells) - set_int_property(dev, "#size-cells", pci_dev->scells); - if (pci_dev->icells) - set_int_property(dev, "#interrupt-cells", pci_dev->icells); - #ifdef CONFIG_DEBUG_PCI printk("\n"); #endif - if (pci_dev->config_cb) + if (pci_dev && pci_dev->config_cb) pci_dev->config_cb(config); } diff --git a/drivers/pci_database.c b/drivers/pci_database.c index 538215c..4fdd347 100644 --- a/drivers/pci_database.c +++ b/drivers/pci_database.c @@ -1022,7 +1022,9 @@ const pci_dev_t *pci_find_device (uint8_t class, uint8_t subclass, break; } } - find_device: +find_device: + if (dev == NULL) + goto bad_device; for (;; dev++) { if (dev->vendor == 0xFFFF && dev->product == 0xFFFF) { goto bad_device; @@ -1055,7 +1057,7 @@ const pci_dev_t *pci_find_device (uint8_t class, uint8_t subclass, return new; } } - bad_device: +bad_device: printk("Cannot manage '%s' PCI device type '%s':\n %x %x (%x %x %x)\n", name, type, vendor, product, class, subclass, iface);