summaryrefslogtreecommitdiff
path: root/hw/block/pflash_cfi01.c
diff options
context:
space:
mode:
authorHu Tao <hutao@cn.fujitsu.com>2013-07-01 18:18:27 +0800
committerAndreas Färber <afaerber@suse.de>2013-07-23 00:37:35 +0200
commite40b5f3e0efe49ec138ea5e3710f6dd6527e5f49 (patch)
tree4498c1b6c4bf1cd293984278324eacd96a94fb42 /hw/block/pflash_cfi01.c
parenta3ef7a61e3706ba81e31a8092b966d6aeae5333e (diff)
downloadqemu-e40b5f3e0efe49ec138ea5e3710f6dd6527e5f49.tar.gz
qemu-e40b5f3e0efe49ec138ea5e3710f6dd6527e5f49.tar.bz2
qemu-e40b5f3e0efe49ec138ea5e3710f6dd6527e5f49.zip
pflash_cfi01: Use QOM realize for pflash_cfi01
Signed-off-by: Hu Tao <hutao@cn.fujitsu.com> [AF: Renamed argument] Signed-off-by: Andreas Färber <afaerber@suse.de>
Diffstat (limited to 'hw/block/pflash_cfi01.c')
-rw-r--r--hw/block/pflash_cfi01.c12
1 files changed, 5 insertions, 7 deletions
diff --git a/hw/block/pflash_cfi01.c b/hw/block/pflash_cfi01.c
index bfcccdd88e..2bcd7318bc 100644
--- a/hw/block/pflash_cfi01.c
+++ b/hw/block/pflash_cfi01.c
@@ -569,7 +569,7 @@ static const MemoryRegionOps pflash_cfi01_ops_le = {
.endianness = DEVICE_NATIVE_ENDIAN,
};
-static int pflash_cfi01_init(SysBusDevice *dev)
+static void pflash_cfi01_realize(DeviceState *dev, Error **errp)
{
pflash_t *pfl = CFI_PFLASH01(dev);
uint64_t total_len;
@@ -590,7 +590,7 @@ static int pflash_cfi01_init(SysBusDevice *dev)
pfl->name, total_len);
vmstate_register_ram(&pfl->mem, DEVICE(pfl));
pfl->storage = memory_region_get_ram_ptr(&pfl->mem);
- sysbus_init_mmio(dev, &pfl->mem);
+ sysbus_init_mmio(SYS_BUS_DEVICE(dev), &pfl->mem);
if (pfl->bs) {
/* read the initial flash content */
@@ -599,7 +599,8 @@ static int pflash_cfi01_init(SysBusDevice *dev)
if (ret < 0) {
vmstate_unregister_ram(&pfl->mem, DEVICE(pfl));
memory_region_destroy(&pfl->mem);
- return 1;
+ error_setg(errp, "failed to read the initial flash content");
+ return;
}
}
@@ -696,8 +697,6 @@ static int pflash_cfi01_init(SysBusDevice *dev)
pfl->cfi_table[0x3c] = 0x00;
pfl->cfi_table[0x3f] = 0x01; /* Number of protection fields */
-
- return 0;
}
static Property pflash_cfi01_properties[] = {
@@ -717,9 +716,8 @@ static Property pflash_cfi01_properties[] = {
static void pflash_cfi01_class_init(ObjectClass *klass, void *data)
{
DeviceClass *dc = DEVICE_CLASS(klass);
- SysBusDeviceClass *k = SYS_BUS_DEVICE_CLASS(klass);
- k->init = pflash_cfi01_init;
+ dc->realize = pflash_cfi01_realize;
dc->props = pflash_cfi01_properties;
dc->vmsd = &vmstate_pflash;
}