From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1MMfvH-0001bE-Tn for qemu-devel@nongnu.org; Fri, 03 Jul 2009 06:23:15 -0400 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1MMfvC-0001Vf-CI for qemu-devel@nongnu.org; Fri, 03 Jul 2009 06:23:14 -0400 Received: from [199.232.76.173] (port=51437 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1MMfvC-0001VL-2m for qemu-devel@nongnu.org; Fri, 03 Jul 2009 06:23:10 -0400 Received: from mx2.redhat.com ([66.187.237.31]:57936) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1MMfv9-0005yR-W5 for qemu-devel@nongnu.org; Fri, 03 Jul 2009 06:23:08 -0400 Received: from int-mx2.corp.redhat.com (int-mx2.corp.redhat.com [172.16.27.26]) by mx2.redhat.com (8.13.8/8.13.8) with ESMTP id n63AN79e002952 for ; Fri, 3 Jul 2009 06:23:07 -0400 From: Gerd Hoffmann Date: Fri, 3 Jul 2009 12:22:48 +0200 Message-Id: <1246616578-6560-4-git-send-email-kraxel@redhat.com> In-Reply-To: <1246616578-6560-1-git-send-email-kraxel@redhat.com> References: <1246616578-6560-1-git-send-email-kraxel@redhat.com> Subject: [Qemu-devel] [PATCH 03/13] qdev/pci: make pci_create return DeviceState instead of PCIDevice. List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: Gerd Hoffmann Rationale: wanna use it as callback in qdev code. Signed-off-by: Gerd Hoffmann --- hw/pc.c | 12 ++++++------ hw/pci-hotplug.c | 6 +++--- hw/pci.c | 10 ++++------ hw/pci.h | 2 +- hw/ppc440_bamboo.c | 6 +++--- hw/ppce500_mpc8544ds.c | 6 +++--- 6 files changed, 20 insertions(+), 22 deletions(-) diff --git a/hw/pc.c b/hw/pc.c index bdcec52..2b89356 100644 --- a/hw/pc.c +++ b/hw/pc.c @@ -1094,7 +1094,7 @@ static void pc_init1(ram_addr_t ram_size, ram_addr_t below_4g_mem_size, above_4g_mem_size = 0; int bios_size, isa_bios_size, oprom_area_size; PCIBus *pci_bus; - PCIDevice *pci_dev; + DeviceState *qdev; int piix3_devfn = -1; CPUState *env; qemu_irq *cpu_irq; @@ -1400,17 +1400,17 @@ static void pc_init1(ram_addr_t ram_size, int unit_id = 0; while ((index = drive_get_index(IF_VIRTIO, 0, unit_id)) != -1) { - pci_dev = pci_create("virtio-blk-pci", - drives_table[index].devaddr); - qdev_init(&pci_dev->qdev); + qdev = pci_create("virtio-blk-pci", + drives_table[index].devaddr); + qdev_init(qdev); unit_id++; } } /* Add virtio balloon device */ if (pci_enabled && virtio_balloon) { - pci_dev = pci_create("virtio-balloon-pci", virtio_balloon_devaddr); - qdev_init(&pci_dev->qdev); + qdev = pci_create("virtio-balloon-pci", virtio_balloon_devaddr); + qdev_init(qdev); } /* Add virtio console devices */ diff --git a/hw/pci-hotplug.c b/hw/pci-hotplug.c index d0f2911..0781b52 100644 --- a/hw/pci-hotplug.c +++ b/hw/pci-hotplug.c @@ -97,7 +97,7 @@ static PCIDevice *qemu_pci_hot_add_storage(Monitor *mon, const char *devaddr, const char *opts) { - PCIDevice *dev; + DeviceState *dev; int type = -1, drive_idx = -1; char buf[128]; @@ -139,8 +139,8 @@ static PCIDevice *qemu_pci_hot_add_storage(Monitor *mon, dev = NULL; } if (dev) - qdev_init(&dev->qdev); - return dev; + qdev_init(dev); + return DO_UPCAST(PCIDevice, qdev, dev); } void pci_device_hot_add(Monitor *mon, const char *pci_addr, const char *type, diff --git a/hw/pci.c b/hw/pci.c index 07b62e9..f0cc36c 100644 --- a/hw/pci.c +++ b/hw/pci.c @@ -764,7 +764,7 @@ void pci_info(Monitor *mon) pci_for_each_device(0, pci_info_device); } -PCIDevice *pci_create(const char *name, const char *devaddr) +DeviceState *pci_create(const char *name, const char *devaddr) { PCIBus *bus; int devfn; @@ -779,7 +779,7 @@ PCIDevice *pci_create(const char *name, const char *devaddr) dev = qdev_create(&bus->qbus, name); qdev_prop_set_uint32(dev, "devfn", devfn); - return (PCIDevice *)dev; + return dev; } static const char * const pci_nic_models[] = { @@ -811,7 +811,6 @@ PCIDevice *pci_nic_init(NICInfo *nd, const char *default_model, const char *default_devaddr) { const char *devaddr = nd->devaddr ? nd->devaddr : default_devaddr; - PCIDevice *pci_dev; DeviceState *dev; int i; @@ -819,12 +818,11 @@ PCIDevice *pci_nic_init(NICInfo *nd, const char *default_model, for (i = 0; pci_nic_models[i]; i++) { if (strcmp(nd->model, pci_nic_models[i]) == 0) { - pci_dev = pci_create(pci_nic_names[i], devaddr); - dev = &pci_dev->qdev; + dev = pci_create(pci_nic_names[i], devaddr); dev->nd = nd; qdev_init(dev); nd->private = dev; - return pci_dev; + return DO_UPCAST(PCIDevice, qdev, dev); } } diff --git a/hw/pci.h b/hw/pci.h index cbfea6a..17563ed 100644 --- a/hw/pci.h +++ b/hw/pci.h @@ -324,7 +324,7 @@ typedef struct { void pci_qdev_register(PCIDeviceInfo *info); void pci_qdev_register_many(PCIDeviceInfo *info); -PCIDevice *pci_create(const char *name, const char *devaddr); +DeviceState *pci_create(const char *name, const char *devaddr); PCIDevice *pci_create_simple(PCIBus *bus, int devfn, const char *name); /* lsi53c895a.c */ diff --git a/hw/ppc440_bamboo.c b/hw/ppc440_bamboo.c index d9ef3ec..b6b8f8a 100644 --- a/hw/ppc440_bamboo.c +++ b/hw/ppc440_bamboo.c @@ -90,7 +90,7 @@ static void bamboo_init(ram_addr_t ram_size, { unsigned int pci_irq_nrs[4] = { 28, 27, 26, 25 }; PCIBus *pcibus; - PCIDevice *pci_dev; + DeviceState *qdev; CPUState *env; uint64_t elf_entry; uint64_t elf_lowaddr; @@ -111,8 +111,8 @@ static void bamboo_init(ram_addr_t ram_size, /* Add virtio block devices. */ while ((i = drive_get_index(IF_VIRTIO, 0, unit_id)) != -1) { - pci_dev = pci_create("virtio-blk-pci", drives_table[i].devaddr); - qdev_init(&pci_dev->qdev); + qdev = pci_create("virtio-blk-pci", drives_table[i].devaddr); + qdev_init(qdev); unit_id++; } diff --git a/hw/ppce500_mpc8544ds.c b/hw/ppce500_mpc8544ds.c index c0e367d..d21eb95 100644 --- a/hw/ppce500_mpc8544ds.c +++ b/hw/ppce500_mpc8544ds.c @@ -157,7 +157,7 @@ static void mpc8544ds_init(ram_addr_t ram_size, const char *cpu_model) { PCIBus *pci_bus; - PCIDevice *pci_dev; + DeviceState *qdev; CPUState *env; uint64_t elf_entry; uint64_t elf_lowaddr; @@ -220,8 +220,8 @@ static void mpc8544ds_init(ram_addr_t ram_size, /* Add virtio block devices. */ while ((i = drive_get_index(IF_VIRTIO, 0, unit_id)) != -1) { - pci_dev = pci_create("virtio-blk-pci", drives_table[i].devaddr); - qdev_init(&pci_dev->qdev); + qdev = pci_create("virtio-blk-pci", drives_table[i].devaddr); + qdev_init(qdev); unit_id++; } -- 1.6.2.5