[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PATCH 11/26] pflash_cfi02: use realize for pflash_cfi02
From: |
Hu Tao |
Subject: |
[Qemu-devel] [PATCH 11/26] pflash_cfi02: use realize for pflash_cfi02 |
Date: |
Sat, 22 Jun 2013 16:50:23 +0800 |
Cc: Kevin Wolf <address@hidden>
Cc: Stefan Hajnoczi <address@hidden>
Signed-off-by: Hu Tao <address@hidden>
---
hw/block/pflash_cfi02.c | 17 ++++++++---------
1 file changed, 8 insertions(+), 9 deletions(-)
diff --git a/hw/block/pflash_cfi02.c b/hw/block/pflash_cfi02.c
index 5f25246..45db415 100644
--- a/hw/block/pflash_cfi02.c
+++ b/hw/block/pflash_cfi02.c
@@ -586,9 +586,9 @@ static const MemoryRegionOps pflash_cfi02_ops_le = {
.endianness = DEVICE_NATIVE_ENDIAN,
};
-static int pflash_cfi02_init(SysBusDevice *dev)
+static void pflash_cfi02_realize(DeviceState *dev, Error **errp)
{
- pflash_t *pfl = FROM_SYSBUS(typeof(*pfl), dev);
+ pflash_t *pfl = DO_UPCAST(typeof(*pfl), busdev.qdev, dev);
uint32_t chip_len;
int ret;
@@ -610,14 +610,16 @@ static int pflash_cfi02_init(SysBusDevice *dev)
/* read the initial flash content */
ret = bdrv_read(pfl->bs, 0, pfl->storage, chip_len >> 9);
if (ret < 0) {
- g_free(pfl);
- return 1;
+ vmstate_unregister_ram(&pfl->orig_mem, DEVICE(pfl));
+ memory_region_destroy(&pfl->orig_mem);
+ error_setg (errp, "failed to read the initial flash content");
+ return;
}
}
pflash_setup_mappings(pfl);
pfl->rom_mode = 1;
- sysbus_init_mmio(dev, &pfl->mem);
+ sysbus_init_mmio(SYS_BUS_DEVICE(dev), &pfl->mem);
if (pfl->bs) {
pfl->ro = bdrv_is_read_only(pfl->bs);
@@ -706,8 +708,6 @@ static int pflash_cfi02_init(SysBusDevice *dev)
pfl->cfi_table[0x3b] = 0x00;
pfl->cfi_table[0x3c] = 0x00;
-
- return 0;
}
static Property pflash_cfi02_properties[] = {
@@ -730,9 +730,8 @@ static Property pflash_cfi02_properties[] = {
static void pflash_cfi02_class_init(ObjectClass *klass, void *data)
{
DeviceClass *dc = DEVICE_CLASS(klass);
- SysBusDeviceClass *k = SYS_BUS_DEVICE_CLASS(klass);
- k->init = pflash_cfi02_init;
+ dc->realize = pflash_cfi02_realize;
dc->props = pflash_cfi02_properties;
}
--
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, 2013/06/22
- [Qemu-devel] [PATCH 11/26] pflash_cfi02: use realize for pflash_cfi02,
Hu Tao <=
- [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