summaryrefslogtreecommitdiff
path: root/hw/block
diff options
context:
space:
mode:
authorHu Tao <hutao@cn.fujitsu.com>2013-07-01 18:18:29 +0800
committerAndreas Färber <afaerber@suse.de>2013-07-23 00:37:35 +0200
commitda3bd64234dc6c77091a0fb8a2612668dbaffd37 (patch)
tree49c9a622bd75c74d3602eb52423986c0a1fed207 /hw/block
parente40b5f3e0efe49ec138ea5e3710f6dd6527e5f49 (diff)
downloadqemu-da3bd64234dc6c77091a0fb8a2612668dbaffd37.zip
pflash_cfi02: Use QOM realize for pflash_cfi02
Signed-off-by: Hu Tao <hutao@cn.fujitsu.com> Signed-off-by: Andreas Färber <afaerber@suse.de>
Diffstat (limited to 'hw/block')
-rw-r--r--hw/block/pflash_cfi02.c15
1 files changed, 7 insertions, 8 deletions
diff --git a/hw/block/pflash_cfi02.c b/hw/block/pflash_cfi02.c
index d8381ddbfc..9fc02e3d64 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;
}