From: Gerd Hoffmann <kraxel@redhat.com>
To: qemu-devel@nongnu.org
Cc: Gerd Hoffmann <kraxel@redhat.com>
Subject: [Qemu-devel] [PATCH 03/13] qdev/pci: make pci_create return DeviceState instead of PCIDevice.
Date: Fri, 10 Jul 2009 13:26:09 +0200 [thread overview]
Message-ID: <1247225179-5495-4-git-send-email-kraxel@redhat.com> (raw)
In-Reply-To: <1247225179-5495-1-git-send-email-kraxel@redhat.com>
Rationale: wanna use it as callback in qdev code.
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
---
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 73f2a4b..a52fe3a 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
next prev parent reply other threads:[~2009-07-10 11:26 UTC|newest]
Thread overview: 28+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-07-10 11:26 [Qemu-devel] [PATCH v2 0/13] qdev patches: properties, -device switch, id=<tag> & more Gerd Hoffmann
2009-07-10 11:26 ` [Qemu-devel] [PATCH 01/13] qdev: rework device properties Gerd Hoffmann
2009-07-10 17:13 ` Paul Brook
2009-07-10 19:28 ` Gerd Hoffmann
2009-07-10 19:42 ` Paul Brook
2009-07-10 20:10 ` Gerd Hoffmann
2009-07-10 11:26 ` [Qemu-devel] [PATCH 02/13] qdev: factor out driver search to qdev_find_info() Gerd Hoffmann
2009-07-10 11:26 ` Gerd Hoffmann [this message]
2009-07-10 11:26 ` [Qemu-devel] [PATCH 04/13] qdev: add generic qdev_device_add() Gerd Hoffmann
2009-07-10 17:23 ` Paul Brook
2009-07-10 20:27 ` Gerd Hoffmann
2009-07-10 20:51 ` Paul Brook
2009-07-14 7:40 ` Gerd Hoffmann
2009-07-14 23:43 ` Markus Armbruster
2009-07-15 1:28 ` Markus Armbruster
2009-07-15 6:26 ` Gerd Hoffmann
2009-07-10 11:26 ` [Qemu-devel] [PATCH 05/13] qdev: add -device command line option Gerd Hoffmann
2009-07-10 11:26 ` [Qemu-devel] [PATCH 06/13] qdev: add no_user, alias and desc Gerd Hoffmann
2009-07-10 11:26 ` [Qemu-devel] [PATCH 07/13] qdev: es1370 description Gerd Hoffmann
2009-07-10 11:26 ` [Qemu-devel] [PATCH 08/13] qdev: convert all vga Gerd Hoffmann
2009-07-10 11:26 ` [Qemu-devel] [PATCH 09/13] qdev/pci: hook up i440fx Gerd Hoffmann
2009-07-10 11:26 ` [Qemu-devel] [PATCH 10/13] qdev: add user-specified identifier to devices Gerd Hoffmann
2009-07-10 17:31 ` Paul Brook
2009-07-10 19:03 ` Gerd Hoffmann
2009-07-10 11:26 ` [Qemu-devel] [PATCH 11/13] switch balloon initialization to -device Gerd Hoffmann
2009-07-10 11:26 ` [Qemu-devel] [PATCH 12/13] qdev: add id= support for pci nics Gerd Hoffmann
2009-07-10 11:26 ` [Qemu-devel] [PATCH 13/13] qdev: print device id in "info pci" Gerd Hoffmann
-- strict thread matches above, loose matches on Subject: below --
2009-07-03 10:22 [Qemu-devel] [PATCH 0/13] qdev patches: properties, -device switch, id=<tag> & more Gerd Hoffmann
2009-07-03 10:22 ` [Qemu-devel] [PATCH 03/13] qdev/pci: make pci_create return DeviceState instead of PCIDevice Gerd Hoffmann
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1247225179-5495-4-git-send-email-kraxel@redhat.com \
--to=kraxel@redhat.com \
--cc=qemu-devel@nongnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).