提交 2f12688b 编写于 作者: A Andreas Färber 提交者: Anthony Liguori

ide: QOM'ify ISA IDE

Introduce type constant and cast macro to obsolete DO_UPCAST().
Add missing braces.

Prepares for ISA realizefn.
Signed-off-by: NAndreas Färber <afaerber@suse.de>
Signed-off-by: NAndreas Färber <afaerber@suse.de>
Message-id: 1367093935-29091-7-git-send-email-afaerber@suse.de
Signed-off-by: NAnthony Liguori <aliguori@us.ibm.com>
上级 29bb5317
...@@ -33,8 +33,12 @@ ...@@ -33,8 +33,12 @@
/***********************************************************/ /***********************************************************/
/* ISA IDE definitions */ /* ISA IDE definitions */
#define TYPE_ISA_IDE "isa-ide"
#define ISA_IDE(obj) OBJECT_CHECK(ISAIDEState, (obj), TYPE_ISA_IDE)
typedef struct ISAIDEState { typedef struct ISAIDEState {
ISADevice dev; ISADevice parent_obj;
IDEBus bus; IDEBus bus;
uint32_t iobase; uint32_t iobase;
uint32_t iobase2; uint32_t iobase2;
...@@ -44,7 +48,7 @@ typedef struct ISAIDEState { ...@@ -44,7 +48,7 @@ typedef struct ISAIDEState {
static void isa_ide_reset(DeviceState *d) 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); ide_bus_reset(&s->bus);
} }
...@@ -63,9 +67,9 @@ static const VMStateDescription vmstate_ide_isa = { ...@@ -63,9 +67,9 @@ static const VMStateDescription vmstate_ide_isa = {
static int isa_ide_initfn(ISADevice *dev) 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); ide_init_ioport(&s->bus, dev, s->iobase, s->iobase2);
isa_init_irq(dev, &s->irq, s->isairq); isa_init_irq(dev, &s->irq, s->isairq);
ide_init2(&s->bus, s->irq); ide_init2(&s->bus, s->irq);
...@@ -76,22 +80,27 @@ static int isa_ide_initfn(ISADevice *dev) ...@@ -76,22 +80,27 @@ static int isa_ide_initfn(ISADevice *dev)
ISADevice *isa_ide_init(ISABus *bus, int iobase, int iobase2, int isairq, ISADevice *isa_ide_init(ISABus *bus, int iobase, int iobase2, int isairq,
DriveInfo *hd0, DriveInfo *hd1) DriveInfo *hd0, DriveInfo *hd1)
{ {
ISADevice *dev; DeviceState *dev;
ISADevice *isadev;
ISAIDEState *s; ISAIDEState *s;
dev = isa_create(bus, "isa-ide"); isadev = isa_create(bus, TYPE_ISA_IDE);
qdev_prop_set_uint32(&dev->qdev, "iobase", iobase); dev = DEVICE(isadev);
qdev_prop_set_uint32(&dev->qdev, "iobase2", iobase2); qdev_prop_set_uint32(dev, "iobase", iobase);
qdev_prop_set_uint32(&dev->qdev, "irq", isairq); qdev_prop_set_uint32(dev, "iobase2", iobase2);
if (qdev_init(&dev->qdev) < 0) qdev_prop_set_uint32(dev, "irq", isairq);
if (qdev_init(dev) < 0) {
return NULL; return NULL;
}
s = DO_UPCAST(ISAIDEState, dev, dev); s = ISA_IDE(dev);
if (hd0) if (hd0) {
ide_create_drive(&s->bus, 0, hd0); ide_create_drive(&s->bus, 0, hd0);
if (hd1) }
if (hd1) {
ide_create_drive(&s->bus, 1, hd1); ide_create_drive(&s->bus, 1, hd1);
return dev; }
return isadev;
} }
static Property isa_ide_properties[] = { static Property isa_ide_properties[] = {
...@@ -112,7 +121,7 @@ static void isa_ide_class_initfn(ObjectClass *klass, void *data) ...@@ -112,7 +121,7 @@ static void isa_ide_class_initfn(ObjectClass *klass, void *data)
} }
static const TypeInfo isa_ide_info = { static const TypeInfo isa_ide_info = {
.name = "isa-ide", .name = TYPE_ISA_IDE,
.parent = TYPE_ISA_DEVICE, .parent = TYPE_ISA_DEVICE,
.instance_size = sizeof(ISAIDEState), .instance_size = sizeof(ISAIDEState),
.class_init = isa_ide_class_initfn, .class_init = isa_ide_class_initfn,
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册