[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PATCH 12/26] pflash-cfi02: QOM'ify some more
From: |
Hu Tao |
Subject: |
[Qemu-devel] [PATCH 12/26] pflash-cfi02: QOM'ify some more |
Date: |
Sat, 22 Jun 2013 16:50:24 +0800 |
Introduce type constant and avoid DO_UPCAST().
Cc: Kevin Wolf <address@hidden>
Cc: Stefan Hajnoczi <address@hidden>
Signed-off-by: Hu Tao <address@hidden>
---
hw/block/pflash_cfi02.c | 16 ++++++++--------
1 file changed, 8 insertions(+), 8 deletions(-)
diff --git a/hw/block/pflash_cfi02.c b/hw/block/pflash_cfi02.c
index 45db415..412de7f 100644
--- a/hw/block/pflash_cfi02.c
+++ b/hw/block/pflash_cfi02.c
@@ -55,6 +55,9 @@ do { \
#define PFLASH_LAZY_ROMD_THRESHOLD 42
+#define TYPE_CFI_PFLASH02 "cfi.pflash02"
+#define CFI_PFLASH02(obj) OBJECT_CHECK(pflash_t, (obj), TYPE_CFI_PFLASH02)
+
struct pflash_t {
SysBusDevice busdev;
BlockDriverState *bs;
@@ -588,7 +591,7 @@ static const MemoryRegionOps pflash_cfi02_ops_le = {
static void pflash_cfi02_realize(DeviceState *dev, Error **errp)
{
- pflash_t *pfl = DO_UPCAST(typeof(*pfl), busdev.qdev, dev);
+ pflash_t *pfl = CFI_PFLASH02(dev);
uint32_t chip_len;
int ret;
@@ -736,7 +739,7 @@ static void pflash_cfi02_class_init(ObjectClass *klass,
void *data)
}
static const TypeInfo pflash_cfi02_info = {
- .name = "cfi.pflash02",
+ .name = TYPE_CFI_PFLASH02,
.parent = TYPE_SYS_BUS_DEVICE,
.instance_size = sizeof(struct pflash_t),
.class_init = pflash_cfi02_class_init,
@@ -759,10 +762,7 @@ pflash_t *pflash_cfi02_register(hwaddr base,
uint16_t unlock_addr0, uint16_t unlock_addr1,
int be)
{
- DeviceState *dev = qdev_create(NULL, "cfi.pflash02");
- SysBusDevice *busdev = SYS_BUS_DEVICE(dev);
- pflash_t *pfl = (pflash_t *)object_dynamic_cast(OBJECT(dev),
- "cfi.pflash02");
+ DeviceState *dev = qdev_create(NULL, TYPE_CFI_PFLASH02);
if (bs && qdev_prop_set_drive(dev, "drive", bs)) {
abort();
@@ -781,6 +781,6 @@ pflash_t *pflash_cfi02_register(hwaddr base,
qdev_prop_set_string(dev, "name", name);
qdev_init_nofail(dev);
- sysbus_mmio_map(busdev, 0, base);
- return pfl;
+ sysbus_mmio_map(SYS_BUS_DEVICE(dev), 0, base);
+ return CFI_PFLASH02(dev);
}
--
1.8.3.1
- Re: [Qemu-devel] [PATCH 01/26] ohci: use realize for ohci, (continued)
[Qemu-devel] [PATCH 03/26] i440fx-pcihost: use realize for i440fx-pcihost, Hu Tao, 2013/06/22
[Qemu-devel] [PATCH 02/26] ohci: QOM'ify some more, Hu Tao, 2013/06/22
[Qemu-devel] [PATCH 04/26] i440fx: use type-safe cast instead of directly access of parent dev, Hu Tao, 2013/06/22
[Qemu-devel] [PATCH 09/26] pflash_cfi01: use realize for pflash_cfi01, Hu Tao, 2013/06/22
[Qemu-devel] [PATCH 07/26] fdc: use realize for fdc., Hu Tao, 2013/06/22
[Qemu-devel] [PATCH 05/26] q35: use realize for q35 host, Hu Tao, 2013/06/22
[Qemu-devel] [PATCH 10/26] pflash-cfi01: QOM'ify some more, Hu Tao, 2013/06/22
[Qemu-devel] [PATCH 12/26] pflash-cfi02: QOM'ify some more,
Hu Tao <=
[Qemu-devel] [PATCH 11/26] pflash_cfi02: use realize for pflash_cfi02, Hu Tao, 2013/06/22
[Qemu-devel] [PATCH 08/26] fdc: QOM'ify some more, Hu Tao, 2013/06/22
[Qemu-devel] [PATCH 14/26] ahci: QOM'ify some more, Hu Tao, 2013/06/22
[Qemu-devel] [PATCH 06/26] q35: use type-safe cast instead of directly access of parent dev, Hu Tao, 2013/06/22
[Qemu-devel] [PATCH 15/26] fwcfg: use realize for fwcfg, Hu Tao, 2013/06/22
[Qemu-devel] [PATCH 16/26] fwcfg: QOM'ify some more, Hu Tao, 2013/06/22
[Qemu-devel] [PATCH 17/26] scsi esp: use realize for scsi esp, Hu Tao, 2013/06/22
[Qemu-devel] [PATCH 13/26] ahci: use realize for ahci, Hu Tao, 2013/06/22
[Qemu-devel] [PATCH 21/26] kvmclock: use realize for kvmclock, Hu Tao, 2013/06/22