Revision c021f8e6

b/hw/pci.c
1299 1299
        "'io_range': { 'base': %" PRId64 ", 'limit': %" PRId64 "}, "
1300 1300
        "'memory_range': { 'base': %" PRId64 ", 'limit': %" PRId64 "}, "
1301 1301
        "'prefetchable_range': { 'base': %" PRId64 ", 'limit': %" PRId64 "} }",
1302
        dev->config[0x19], dev->config[PCI_SECONDARY_BUS],
1302
        dev->config[PCI_PRIMARY_BUS], dev->config[PCI_SECONDARY_BUS],
1303 1303
        dev->config[PCI_SUBORDINATE_BUS],
1304 1304
        pci_bridge_get_base(dev, PCI_BASE_ADDRESS_SPACE_IO),
1305 1305
        pci_bridge_get_limit(dev, PCI_BASE_ADDRESS_SPACE_IO),
......
1310 1310
        pci_bridge_get_limit(dev, PCI_BASE_ADDRESS_SPACE_MEMORY |
1311 1311
                                PCI_BASE_ADDRESS_MEM_PREFETCH));
1312 1312

  
1313
        if (dev->config[0x19] != 0) {
1314
            qdict = qobject_to_qdict(pci_bridge);
1315
            qdict_put_obj(qdict, "devices",
1316
                          pci_get_devices_list(bus, dev->config[0x19]));
1317
        }
1313
        if (dev->config[PCI_SECONDARY_BUS] != 0) {
1314
            PCIBus *child_bus = pci_find_bus(bus, dev->config[PCI_SECONDARY_BUS]);
1318 1315

  
1316
            if (child_bus) {
1317
                qdict = qobject_to_qdict(pci_bridge);
1318
                qdict_put_obj(qdict, "devices",
1319
                              pci_get_devices_list(child_bus,
1320
                                                   dev->config[PCI_SECONDARY_BUS]));
1321
            }
1322
        }
1319 1323
        qdict = qobject_to_qdict(obj);
1320 1324
        qdict_put_obj(qdict, "pci_bridge", pci_bridge);
1321 1325
    }
......
1542 1546

  
1543 1547
PCIBus *pci_find_bus(PCIBus *bus, int bus_num)
1544 1548
{
1545
    PCIBus *sec;
1549
    PCIBus *sec, *ret;
1546 1550

  
1547 1551
    if (!bus)
1548 1552
        return NULL;
......
1553 1557

  
1554 1558
    /* try child bus */
1555 1559
    QLIST_FOREACH(sec, &bus->child, sibling) {
1556

  
1557 1560
        if (!bus->parent_dev /* pci host bridge */
1558
            || (pci_bus_num(sec) <= bus_num &&
1559
                bus->parent_dev->config[PCI_SUBORDINATE_BUS])) {
1560
            return pci_find_bus(sec, bus_num);
1561
            || (pci_bus_num(sec) >= bus_num &&
1562
                bus_num <= bus->parent_dev->config[PCI_SUBORDINATE_BUS]) ) {
1563
            ret = pci_find_bus(sec, bus_num);
1564
            if (ret) {
1565
                return ret;
1566
            }
1561 1567
        }
1562 1568
    }
1563 1569

  

Also available in: Unified diff