From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1MswIe-0004lq-SZ for qemu-devel@nongnu.org; Wed, 30 Sep 2009 06:20:48 -0400 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1MswIM-0004Yx-T4 for qemu-devel@nongnu.org; Wed, 30 Sep 2009 06:20:37 -0400 Received: from [199.232.76.173] (port=43893 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1MswIM-0004YV-Pt for qemu-devel@nongnu.org; Wed, 30 Sep 2009 06:20:26 -0400 Received: from mail.valinux.co.jp ([210.128.90.3]:55872) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1MswIL-0005q3-Pt for qemu-devel@nongnu.org; Wed, 30 Sep 2009 06:20:26 -0400 From: Isaku Yamahata Date: Wed, 30 Sep 2009 19:18:12 +0900 Message-Id: <1254305917-14784-37-git-send-email-yamahata@valinux.co.jp> In-Reply-To: <1254305917-14784-1-git-send-email-yamahata@valinux.co.jp> References: <1254305917-14784-1-git-send-email-yamahata@valinux.co.jp> Subject: [Qemu-devel] [PATCH 36/61] pci: use QLIST_ macro instead of direct list manipulation. List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org, anthony@codemonkey.ws Cc: yamahata@valinux.co.jp For maintenance, use QLIST_ macro instead of direct list implementation for PCIBus::next which implements singly linked list. This patch replace it with QLIST_ macro. Signed-off-by: Isaku Yamahata --- hw/pci.c | 16 +++++++--------- 1 files changed, 7 insertions(+), 9 deletions(-) diff --git a/hw/pci.c b/hw/pci.c index b358d80..757fe7b 100644 --- a/hw/pci.c +++ b/hw/pci.c @@ -45,7 +45,7 @@ struct PCIBus { void *irq_opaque; PCIDevice *devices[256]; PCIDevice *parent_dev; - PCIBus *next; + QLIST_ENTRY(PCIBus) next; /* The bus IRQ state is the logical OR of the connected devices. Keep a count of the number of devices with raised IRQs. */ int nirq; @@ -70,7 +70,7 @@ static void pci_set_irq(void *opaque, int irq_num, int level); target_phys_addr_t pci_mem_base; static uint16_t pci_default_sub_vendor_id = PCI_SUBVENDOR_ID_REDHAT_QUMRANET; static uint16_t pci_default_sub_device_id = PCI_SUBDEVICE_ID_QEMU; -static PCIBus *first_bus; +static QLIST_HEAD(, PCIBus) first_bus; static const VMStateDescription vmstate_pcibus = { .name = "PCIBUS", @@ -113,8 +113,7 @@ PCIBus *pci_register_bus(DeviceState *parent, const char *name, bus->devfn_min = devfn_min; bus->nirq = nirq; bus->irq_count = qemu_mallocz(nirq * sizeof(bus->irq_count[0])); - bus->next = first_bus; - first_bus = bus; + QLIST_INSERT_HEAD(&first_bus, bus, next); vmstate_register(nbus++, &vmstate_pcibus, bus); qemu_register_reset(pci_bus_reset, bus); return bus; @@ -129,8 +128,7 @@ static PCIBus *pci_register_secondary_bus(PCIDevice *dev, bus = FROM_QBUS(PCIBus, qbus_create(&pci_bus_info, &dev->qdev, name)); bus->map_irq = map_irq; bus->parent_dev = dev; - bus->next = dev->bus->next; - dev->bus->next = bus; + QLIST_INSERT_AFTER(dev->bus, bus, next); return bus; } @@ -650,7 +648,7 @@ static PCIBus *pci_find_bus_from(PCIBus *from, int bus_num) PCIBus *s = from; while (s && s->bus_num != bus_num) - s = s->next; + s = QLIST_NEXT(s, next); return s; } @@ -1025,7 +1023,7 @@ static void pci_info_device(PCIDevice *d) void pci_for_each_device(int bus_num, void (*fn)(PCIDevice *d)) { - PCIBus *bus = first_bus; + PCIBus *bus = QLIST_FIRST(&first_bus); PCIDevice *d; int devfn; @@ -1129,7 +1127,7 @@ static void pci_bridge_write_config(PCIDevice *d, PCIBus *pci_find_bus(int bus_num) { - return pci_find_bus_from(first_bus, bus_num); + return pci_find_bus_from(QLIST_FIRST(&first_bus), bus_num); } PCIDevice *pci_find_device(int bus_num, int slot, int function) -- 1.6.0.2