[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Qemu-devel] [PATCH V13 4/9] pci.c: Add opaque argument to pci_for_e
From: |
Michael S. Tsirkin |
Subject: |
Re: [Qemu-devel] [PATCH V13 4/9] pci.c: Add opaque argument to pci_for_each_device. |
Date: |
Thu, 14 Jun 2012 22:38:22 +0300 |
On Thu, Jun 14, 2012 at 06:01:44PM +0100, Anthony PERARD wrote:
> The purpose is to have a more generic pci_for_each_device by passing an extra
> argument to the function called on every device.
>
> This patch will be used in a next patch.
>
> Signed-off-by: Anthony PERARD <address@hidden>
> Acked-by: Stefano Stabellini <address@hidden>
Acked-by: Michael S. Tsirkin <address@hidden>
> ---
> hw/pci.c | 11 +++++++----
> hw/pci.h | 4 +++-
> hw/xen_platform.c | 8 ++++----
> 3 files changed, 14 insertions(+), 9 deletions(-)
>
> diff --git a/hw/pci.c b/hw/pci.c
> index 127b7ac..d6537e3 100644
> --- a/hw/pci.c
> +++ b/hw/pci.c
> @@ -1127,7 +1127,9 @@ static const pci_class_desc pci_class_descriptions[] =
> };
>
> static void pci_for_each_device_under_bus(PCIBus *bus,
> - void (*fn)(PCIBus *b, PCIDevice
> *d))
> + void (*fn)(PCIBus *b, PCIDevice *d,
> + void *opaque),
> + void *opaque)
> {
> PCIDevice *d;
> int devfn;
> @@ -1135,18 +1137,19 @@ static void pci_for_each_device_under_bus(PCIBus *bus,
> for(devfn = 0; devfn < ARRAY_SIZE(bus->devices); devfn++) {
> d = bus->devices[devfn];
> if (d) {
> - fn(bus, d);
> + fn(bus, d, opaque);
> }
> }
> }
>
> void pci_for_each_device(PCIBus *bus, int bus_num,
> - void (*fn)(PCIBus *b, PCIDevice *d))
> + void (*fn)(PCIBus *b, PCIDevice *d, void *opaque),
> + void *opaque)
> {
> bus = pci_find_bus_nr(bus, bus_num);
>
> if (bus) {
> - pci_for_each_device_under_bus(bus, fn);
> + pci_for_each_device_under_bus(bus, fn, opaque);
> }
> }
>
> diff --git a/hw/pci.h b/hw/pci.h
> index 7f223c0..95b608c 100644
> --- a/hw/pci.h
> +++ b/hw/pci.h
> @@ -312,7 +312,9 @@ PCIDevice *pci_nic_init(NICInfo *nd, const char
> *default_model,
> PCIDevice *pci_nic_init_nofail(NICInfo *nd, const char *default_model,
> const char *default_devaddr);
> int pci_bus_num(PCIBus *s);
> -void pci_for_each_device(PCIBus *bus, int bus_num, void (*fn)(PCIBus *bus,
> PCIDevice *d));
> +void pci_for_each_device(PCIBus *bus, int bus_num,
> + void (*fn)(PCIBus *bus, PCIDevice *d, void *opaque),
> + void *opaque);
> PCIBus *pci_find_root_bus(int domain);
> int pci_find_domain(const PCIBus *bus);
> PCIDevice *pci_find_device(PCIBus *bus, int bus_num, uint8_t devfn);
> diff --git a/hw/xen_platform.c b/hw/xen_platform.c
> index 0214f37..c1fe984 100644
> --- a/hw/xen_platform.c
> +++ b/hw/xen_platform.c
> @@ -83,7 +83,7 @@ static void log_writeb(PCIXenPlatformState *s, char val)
> #define UNPLUG_ALL_NICS 2
> #define UNPLUG_AUX_IDE_DISKS 4
>
> -static void unplug_nic(PCIBus *b, PCIDevice *d)
> +static void unplug_nic(PCIBus *b, PCIDevice *d, void *o)
> {
> if (pci_get_word(d->config + PCI_CLASS_DEVICE) ==
> PCI_CLASS_NETWORK_ETHERNET) {
> @@ -96,10 +96,10 @@ static void unplug_nic(PCIBus *b, PCIDevice *d)
>
> static void pci_unplug_nics(PCIBus *bus)
> {
> - pci_for_each_device(bus, 0, unplug_nic);
> + pci_for_each_device(bus, 0, unplug_nic, NULL);
> }
>
> -static void unplug_disks(PCIBus *b, PCIDevice *d)
> +static void unplug_disks(PCIBus *b, PCIDevice *d, void *o)
> {
> if (pci_get_word(d->config + PCI_CLASS_DEVICE) ==
> PCI_CLASS_STORAGE_IDE) {
> @@ -109,7 +109,7 @@ static void unplug_disks(PCIBus *b, PCIDevice *d)
>
> static void pci_unplug_disks(PCIBus *bus)
> {
> - pci_for_each_device(bus, 0, unplug_disks);
> + pci_for_each_device(bus, 0, unplug_disks, NULL);
> }
>
> static void platform_fixed_ioport_writew(void *opaque, uint32_t addr,
> uint32_t val)
> --
> Anthony PERARD
- [Qemu-devel] [PATCH V13 0/9] Xen PCI Passthrough, Anthony PERARD, 2012/06/14
- [Qemu-devel] [PATCH V13 5/9] qdev-properties: Introduce pci-host-devaddr., Anthony PERARD, 2012/06/14
- [Qemu-devel] [PATCH V13 2/9] configure: Introduce --enable-xen-pci-passthrough., Anthony PERARD, 2012/06/14
- [Qemu-devel] [PATCH V13 8/9] Introduce apic-msidef.h, Anthony PERARD, 2012/06/14
- [Qemu-devel] [PATCH V13 4/9] pci.c: Add opaque argument to pci_for_each_device., Anthony PERARD, 2012/06/14
- [Qemu-devel] [PATCH V13 3/9] Introduce XenHostPCIDevice to access a pci device on the host., Anthony PERARD, 2012/06/14
- [Qemu-devel] [PATCH V13 1/9] pci_ids: Add INTEL_82599_SFP_VF id., Anthony PERARD, 2012/06/14
- [Qemu-devel] [PATCH V13 9/9] Introduce Xen PCI Passthrough, MSI (3/3), Anthony PERARD, 2012/06/14
- [Qemu-devel] [PATCH V13 7/9] Introduce Xen PCI Passthrough, PCI config space helpers (2/3), Anthony PERARD, 2012/06/14
- [Qemu-devel] [PATCH V13 6/9] Introduce Xen PCI Passthrough, qdevice (1/3), Anthony PERARD, 2012/06/14
- Re: [Qemu-devel] [PATCH V13 0/9] Xen PCI Passthrough, Michael S. Tsirkin, 2012/06/14