[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PULL 45/55] pflash_cfi02: Use QOM realize for pflash_cfi02
From: |
Andreas Färber |
Subject: |
[Qemu-devel] [PULL 45/55] pflash_cfi02: Use QOM realize for pflash_cfi02 |
Date: |
Tue, 23 Jul 2013 01:46:26 +0200 |
From: Hu Tao <address@hidden>
Signed-off-by: Hu Tao <address@hidden>
Signed-off-by: Andreas Färber <address@hidden>
---
hw/block/pflash_cfi02.c | 15 +++++++--------
1 file changed, 7 insertions(+), 8 deletions(-)
diff --git a/hw/block/pflash_cfi02.c b/hw/block/pflash_cfi02.c
index d8381dd..9fc02e3 100644
--- a/hw/block/pflash_cfi02.c
+++ b/hw/block/pflash_cfi02.c
@@ -592,7 +592,7 @@ 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 = CFI_PFLASH02(dev);
uint32_t chip_len;
@@ -616,14 +616,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);
@@ -712,8 +714,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[] = {
@@ -736,9 +736,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.1.4
- [Qemu-devel] [PULL 35/55] pflash-cfi01: QOM'ify some more, (continued)
- [Qemu-devel] [PULL 35/55] pflash-cfi01: QOM'ify some more, Andreas Färber, 2013/07/22
- [Qemu-devel] [PULL 34/55] fdc: QOM'ify some more, Andreas Färber, 2013/07/22
- [Qemu-devel] [PULL 32/55] q35: Use type-safe cast instead of direct access of parent dev, Andreas Färber, 2013/07/22
- [Qemu-devel] [PULL 36/55] pflash-cfi02: QOM'ify some more, Andreas Färber, 2013/07/22
- [Qemu-devel] [PULL 38/55] fwcfg: QOM'ify some more, Andreas Färber, 2013/07/22
- [Qemu-devel] [PULL 37/55] ahci: QOM'ify some more, Andreas Färber, 2013/07/22
- [Qemu-devel] [PULL 39/55] scsi/esp: QOM'ify some more, Andreas Färber, 2013/07/22
- [Qemu-devel] [PULL 41/55] kvm/clock: QOM'ify some more, Andreas Färber, 2013/07/22
- [Qemu-devel] [PULL 40/55] hpet: QOM'ify some more, Andreas Färber, 2013/07/22
- [Qemu-devel] [PULL 44/55] pflash_cfi01: Use QOM realize for pflash_cfi01, Andreas Färber, 2013/07/22
- [Qemu-devel] [PULL 45/55] pflash_cfi02: Use QOM realize for pflash_cfi02,
Andreas Färber <=
- [Qemu-devel] [PULL 42/55] fdc: Use QOM realize for fdc, Andreas Färber, 2013/07/22
- [Qemu-devel] [PULL 43/55] fdc: Improve error propagation for QOM realize, Andreas Färber, 2013/07/22
- [Qemu-devel] [PULL 46/55] ahci: Use QOM realize for ahci, Andreas Färber, 2013/07/22
- [Qemu-devel] [PULL 48/55] scsi/esp: Use QOM realize for scsi esp, Andreas Färber, 2013/07/22
- [Qemu-devel] [PULL 49/55] megasas: Legacy command line handling fix, Andreas Färber, 2013/07/22
- [Qemu-devel] [PULL 47/55] fw_cfg: Use QOM realize for fw_cfg, Andreas Färber, 2013/07/22
- [Qemu-devel] [PULL 52/55] kvm/clock: Use QOM realize for kvmclock, Andreas Färber, 2013/07/22
- [Qemu-devel] [PULL 51/55] hpet: Use QOM realize for hpet, Andreas Färber, 2013/07/22
- [Qemu-devel] [PULL 53/55] kvmvapic: Use QOM realize, Andreas Färber, 2013/07/22
- [Qemu-devel] [PULL 54/55] ioapic: Use QOM realize for ioapic, Andreas Färber, 2013/07/22