[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PATCH 18/26] scsi esp: QOM'ify some more
From: |
Hu Tao |
Subject: |
[Qemu-devel] [PATCH 18/26] scsi esp: QOM'ify some more |
Date: |
Sat, 22 Jun 2013 16:50:30 +0800 |
Introduce type constant and avoid DO_UPCAST().
Cc: Paolo Bonzini <address@hidden>
Signed-off-by: Hu Tao <address@hidden>
---
hw/scsi/esp.c | 18 ++++++++++--------
1 file changed, 10 insertions(+), 8 deletions(-)
diff --git a/hw/scsi/esp.c b/hw/scsi/esp.c
index 0207dba..aea2c94 100644
--- a/hw/scsi/esp.c
+++ b/hw/scsi/esp.c
@@ -578,6 +578,9 @@ const VMStateDescription vmstate_esp = {
}
};
+#define TYPE_ESP "esp"
+#define ESP(obj) OBJECT_CHECK(SysBusESPState, (obj), TYPE_ESP)
+
typedef struct {
SysBusDevice busdev;
MemoryRegion iomem;
@@ -623,8 +626,8 @@ void esp_init(hwaddr espaddr, int it_shift,
SysBusESPState *sysbus;
ESPState *esp;
- dev = qdev_create(NULL, "esp");
- sysbus = DO_UPCAST(SysBusESPState, busdev.qdev, dev);
+ dev = qdev_create(NULL, TYPE_ESP);
+ sysbus = ESP(dev);
esp = &sysbus->esp;
esp->dma_memory_read = dma_memory_read;
esp->dma_memory_write = dma_memory_write;
@@ -652,8 +655,7 @@ static const struct SCSIBusInfo esp_scsi_info = {
static void sysbus_esp_gpio_demux(void *opaque, int irq, int level)
{
- DeviceState *d = opaque;
- SysBusESPState *sysbus = container_of(d, SysBusESPState, busdev.qdev);
+ SysBusESPState *sysbus = opaque;
ESPState *s = &sysbus->esp;
switch (irq) {
@@ -668,7 +670,7 @@ static void sysbus_esp_gpio_demux(void *opaque, int irq,
int level)
static void sysbus_esp_init(Object *obj)
{
- SysBusESPState *sysbus = DO_UPCAST(SysBusESPState, busdev.qdev.parent_obj,
obj);
+ SysBusESPState *sysbus = ESP(obj);
memory_region_init_io(&sysbus->iomem, &sysbus_esp_mem_ops, sysbus,
"esp", ESP_REGS << sysbus->it_shift);
@@ -676,7 +678,7 @@ static void sysbus_esp_init(Object *obj)
static void sysbus_esp_realize(DeviceState *dev, Error **errp)
{
- SysBusESPState *sysbus = DO_UPCAST(SysBusESPState, busdev.qdev, dev);
+ SysBusESPState *sysbus = ESP(dev);
SysBusDevice *sb = SYS_BUS_DEVICE(dev);
ESPState *s = &sysbus->esp;
@@ -697,7 +699,7 @@ static void sysbus_esp_realize(DeviceState *dev, Error
**errp)
static void sysbus_esp_hard_reset(DeviceState *dev)
{
- SysBusESPState *sysbus = DO_UPCAST(SysBusESPState, busdev.qdev, dev);
+ SysBusESPState *sysbus = ESP(dev);
esp_hard_reset(&sysbus->esp);
}
@@ -722,7 +724,7 @@ static void sysbus_esp_class_init(ObjectClass *klass, void
*data)
}
static const TypeInfo sysbus_esp_info = {
- .name = "esp",
+ .name = TYPE_ESP,
.parent = TYPE_SYS_BUS_DEVICE,
.instance_size = sizeof(SysBusESPState),
.instance_init = sysbus_esp_init,
--
1.8.3.1
- [Qemu-devel] [PATCH 17/26] scsi esp: use realize for scsi esp, (continued)
[Qemu-devel] [PATCH 19/26] hpet: use realize for hpet, Hu Tao, 2013/06/22
[Qemu-devel] [PATCH 18/26] scsi esp: QOM'ify some more,
Hu Tao <=
[Qemu-devel] [PATCH 22/26] kvmclock: QOM'ify some more, Hu Tao, 2013/06/22
[Qemu-devel] [PATCH 25/26] isa bus: use realize for isa bus, Hu Tao, 2013/06/22
[Qemu-devel] [PATCH 23/26] kvmvapic realize, Hu Tao, 2013/06/22
[Qemu-devel] [PATCH 26/26] ehci: use realize for ehci, Hu Tao, 2013/06/22
[Qemu-devel] [PATCH 20/26] hpet: QOM'ify some more, Hu Tao, 2013/06/22
[Qemu-devel] [PATCH 24/26] ioapic: use realize for ioapic, Hu Tao, 2013/06/22