[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [RFC 13/34] ide: QOM'ify ISA IDE
From: |
Andreas Färber |
Subject: |
[Qemu-devel] [RFC 13/34] ide: QOM'ify ISA IDE |
Date: |
Mon, 26 Nov 2012 01:12:25 +0100 |
Introduce type constant and cast macro to obsolete DO_UPCAST().
Add missing braces.
Prepares for ISA realizefn.
Signed-off-by: Andreas Färber <address@hidden>
---
hw/ide/isa.c | 41 +++++++++++++++++++++++++----------------
1 Datei geändert, 25 Zeilen hinzugefügt(+), 16 Zeilen entfernt(-)
diff --git a/hw/ide/isa.c b/hw/ide/isa.c
index 8ab2718..4d55885 100644
--- a/hw/ide/isa.c
+++ b/hw/ide/isa.c
@@ -33,8 +33,12 @@
/***********************************************************/
/* ISA IDE definitions */
+#define TYPE_ISA_IDE "isa-ide"
+#define ISA_IDE(obj) OBJECT_CHECK(ISAIDEState, (obj), TYPE_ISA_IDE)
+
typedef struct ISAIDEState {
- ISADevice dev;
+ ISADevice parent_obj;
+
IDEBus bus;
uint32_t iobase;
uint32_t iobase2;
@@ -44,7 +48,7 @@ typedef struct ISAIDEState {
static void isa_ide_reset(DeviceState *d)
{
- ISAIDEState *s = container_of(d, ISAIDEState, dev.qdev);
+ ISAIDEState *s = ISA_IDE(d);
ide_bus_reset(&s->bus);
}
@@ -63,9 +67,9 @@ static const VMStateDescription vmstate_ide_isa = {
static int isa_ide_initfn(ISADevice *dev)
{
- ISAIDEState *s = DO_UPCAST(ISAIDEState, dev, dev);
+ ISAIDEState *s = ISA_IDE(dev);
- ide_bus_new(&s->bus, &s->dev.qdev, 0);
+ ide_bus_new(&s->bus, DEVICE(dev), 0);
ide_init_ioport(&s->bus, dev, s->iobase, s->iobase2);
isa_init_irq(dev, &s->irq, s->isairq);
ide_init2(&s->bus, s->irq);
@@ -76,22 +80,27 @@ static int isa_ide_initfn(ISADevice *dev)
ISADevice *isa_ide_init(ISABus *bus, int iobase, int iobase2, int isairq,
DriveInfo *hd0, DriveInfo *hd1)
{
- ISADevice *dev;
+ DeviceState *dev;
+ ISADevice *isadev;
ISAIDEState *s;
- dev = isa_create(bus, "isa-ide");
- qdev_prop_set_uint32(&dev->qdev, "iobase", iobase);
- qdev_prop_set_uint32(&dev->qdev, "iobase2", iobase2);
- qdev_prop_set_uint32(&dev->qdev, "irq", isairq);
- if (qdev_init(&dev->qdev) < 0)
+ isadev = isa_create(bus, TYPE_ISA_IDE);
+ dev = DEVICE(isadev);
+ qdev_prop_set_uint32(dev, "iobase", iobase);
+ qdev_prop_set_uint32(dev, "iobase2", iobase2);
+ qdev_prop_set_uint32(dev, "irq", isairq);
+ if (qdev_init(dev) < 0) {
return NULL;
+ }
- s = DO_UPCAST(ISAIDEState, dev, dev);
- if (hd0)
+ s = ISA_IDE(dev);
+ if (hd0) {
ide_create_drive(&s->bus, 0, hd0);
- if (hd1)
+ }
+ if (hd1) {
ide_create_drive(&s->bus, 1, hd1);
- return dev;
+ }
+ return isadev;
}
static Property isa_ide_properties[] = {
@@ -111,8 +120,8 @@ static void isa_ide_class_initfn(ObjectClass *klass, void
*data)
dc->props = isa_ide_properties;
}
-static TypeInfo isa_ide_info = {
- .name = "isa-ide",
+static const TypeInfo isa_ide_info = {
+ .name = TYPE_ISA_IDE,
.parent = TYPE_ISA_DEVICE,
.instance_size = sizeof(ISAIDEState),
.class_init = isa_ide_class_initfn,
--
1.7.10.4
- [Qemu-devel] [RFC 23/34] sga: QOM'ify, (continued)
- [Qemu-devel] [RFC 23/34] sga: QOM'ify, Andreas Färber, 2012/11/25
- [Qemu-devel] [RFC 17/34] parallel: QOM'ify, Andreas Färber, 2012/11/25
- [Qemu-devel] [RFC 21/34] sb16: QOM'ify, Andreas Färber, 2012/11/25
- [Qemu-devel] [RFC 22/34] serial: QOM'ify ISA serial, Andreas Färber, 2012/11/25
- [Qemu-devel] [RFC 10/34] i82374: QOM'ify, Andreas Färber, 2012/11/25
- [Qemu-devel] [RFC 08/34] debugcon: QOM'ify ISA debug console, Andreas Färber, 2012/11/25
- [Qemu-devel] [RFC 14/34] m48t59: QOM'ify ISA M48T59 NVRAM, Andreas Färber, 2012/11/25
- [Qemu-devel] [RFC 02/34] qbus: QOM'ify qbus_realize(), Andreas Färber, 2012/11/25
- [Qemu-devel] [RFC 29/34] i8254: QOM'ify, Andreas Färber, 2012/11/25
- [Qemu-devel] [RFC 09/34] fdc: QOM'ify ISA floppy controller, Andreas Färber, 2012/11/25
- [Qemu-devel] [RFC 13/34] ide: QOM'ify ISA IDE,
Andreas Färber <=
- [Qemu-devel] [RFC 24/34] vga-isa: QOM'ify ISA VGA, Andreas Färber, 2012/11/25
- [Qemu-devel] [RFC 32/34] i8259: QOM'ify some more, Andreas Färber, 2012/11/25
- [Qemu-devel] [PATCH 01/34] qdev: Eliminate qdev_free() in favor of QOM, Andreas Färber, 2012/11/25
- [Qemu-devel] [PATCH 11/34] i8259: Fix PIC_COMMON() macro, Andreas Färber, 2012/11/25
- [Qemu-devel] [RFC 03/34] qdev: Fold state enum into bool realized, Andreas Färber, 2012/11/25
- [Qemu-devel] [RFC 30/34] kvm/i8254: QOM'ify some more, Andreas Färber, 2012/11/25
- [Qemu-devel] [RFC 33/34] kvm/i8259: QOM'ify some more, Andreas Färber, 2012/11/25