Patchwork [v2,07/13] qdev: add isa_create() function

login
register
mail settings
Submitter Gerd Hoffmann
Date Sept. 10, 2009, 9:43 a.m.
Message ID <1252575815-7824-8-git-send-email-kraxel@redhat.com>
Download mbox | patch
Permalink /patch/33301/
State Superseded
Headers show

Comments

Gerd Hoffmann - Sept. 10, 2009, 9:43 a.m.
Like isa_create_simple, but doesn't call qdev_init, so one can set
properties after creating and before initializing the device.

Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
---
 hw/isa-bus.c |   15 +++++++++++++--
 hw/isa.h     |    1 +
 2 files changed, 14 insertions(+), 2 deletions(-)

Patch

diff --git a/hw/isa-bus.c b/hw/isa-bus.c
index 3cc17b2..4ecc0f8 100644
--- a/hw/isa-bus.c
+++ b/hw/isa-bus.c
@@ -109,7 +109,7 @@  void isa_qdev_register(ISADeviceInfo *info)
     qdev_register(&info->qdev);
 }
 
-ISADevice *isa_create_simple(const char *name)
+ISADevice *isa_create(const char *name)
 {
     DeviceState *dev;
 
@@ -118,10 +118,21 @@  ISADevice *isa_create_simple(const char *name)
         return NULL;
     }
     dev = qdev_create(&isabus->qbus, name);
-    qdev_init(dev);
     return DO_UPCAST(ISADevice, qdev, dev);
 }
 
+ISADevice *isa_create_simple(const char *name)
+{
+    ISADevice *dev;
+
+    dev = isa_create(name);
+    if (qdev_init(&dev->qdev) != 0) {
+        qdev_free(&dev->qdev);
+        return NULL;
+    }
+    return dev;
+}
+
 static void isabus_dev_print(Monitor *mon, DeviceState *dev, int indent)
 {
     ISADevice *d = DO_UPCAST(ISADevice, qdev, dev);
diff --git a/hw/isa.h b/hw/isa.h
index 4582ff9..655ad62 100644
--- a/hw/isa.h
+++ b/hw/isa.h
@@ -27,6 +27,7 @@  void isa_bus_irqs(qemu_irq *irqs);
 qemu_irq isa_reserve_irq(int isairq);
 void isa_init_irq(ISADevice *dev, qemu_irq *p, int isairq);
 void isa_qdev_register(ISADeviceInfo *info);
+ISADevice *isa_create(const char *name);
 ISADevice *isa_create_simple(const char *name);
 
 extern target_phys_addr_t isa_mem_base;