qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Qemu-devel] Re: [PATCH 36/61] pci: use QLIST_ macro instead of direct l


From: Michael S. Tsirkin
Subject: [Qemu-devel] Re: [PATCH 36/61] pci: use QLIST_ macro instead of direct list manipulation.
Date: Wed, 30 Sep 2009 13:54:19 +0200
User-agent: Mutt/1.5.19 (2009-01-05)

On Wed, Sep 30, 2009 at 07:18:12PM +0900, Isaku Yamahata wrote:
> 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 <address@hidden>

Acked-by: Michael S. Tsirkin <address@hidden>

> ---
>  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
> 
> 




reply via email to

[Prev in Thread] Current Thread [Next in Thread]