diff options
author | Andreas Färber <afaerber@suse.de> | 2012-11-25 02:37:14 +0100 |
---|---|---|
committer | Andreas Färber <afaerber@suse.de> | 2013-06-07 12:14:45 +0200 |
commit | db895a1e6a97e919f9b86d60c969377357b05066 (patch) | |
tree | 72f6786abe90f7fa77d2f10416df73cb9d62e35a /hw/char/debugcon.c | |
parent | a3dcca567a1d4a5c79fb9c8fe2d9a21a4a7cebd5 (diff) | |
download | qemu-db895a1e6a97e919f9b86d60c969377357b05066.zip |
isa: Use realizefn for ISADevice
Drop ISADeviceClass::init and the resulting no-op initfn and let
children implement their own realizefn. Adapt error handling.
Split off an instance_init where sensible.
Signed-off-by: Andreas Färber <afaerber@suse.de>
Diffstat (limited to 'hw/char/debugcon.c')
-rw-r--r-- | hw/char/debugcon.c | 23 |
1 files changed, 14 insertions, 9 deletions
diff --git a/hw/char/debugcon.c b/hw/char/debugcon.c index 3b0637d44f..f254841aec 100644 --- a/hw/char/debugcon.c +++ b/hw/char/debugcon.c @@ -81,27 +81,32 @@ static const MemoryRegionOps debugcon_ops = { .endianness = DEVICE_LITTLE_ENDIAN, }; -static void debugcon_init_core(DebugconState *s) +static void debugcon_realize_core(DebugconState *s, Error **errp) { if (!s->chr) { - fprintf(stderr, "Can't create debugcon device, empty char device\n"); - exit(1); + error_setg(errp, "Can't create debugcon device, empty char device"); + return; } qemu_chr_add_handlers(s->chr, NULL, NULL, NULL, s); } -static int debugcon_isa_initfn(ISADevice *dev) +static void debugcon_isa_realizefn(DeviceState *dev, Error **errp) { + ISADevice *d = ISA_DEVICE(dev); ISADebugconState *isa = ISA_DEBUGCON_DEVICE(dev); DebugconState *s = &isa->state; + Error *err = NULL; - debugcon_init_core(s); + debugcon_realize_core(s, &err); + if (err != NULL) { + error_propagate(errp, err); + return; + } memory_region_init_io(&s->io, &debugcon_ops, s, TYPE_ISA_DEBUGCON_DEVICE, 1); - memory_region_add_subregion(isa_address_space_io(dev), + memory_region_add_subregion(isa_address_space_io(d), isa->iobase, &s->io); - return 0; } static Property debugcon_isa_properties[] = { @@ -114,8 +119,8 @@ static Property debugcon_isa_properties[] = { static void debugcon_isa_class_initfn(ObjectClass *klass, void *data) { DeviceClass *dc = DEVICE_CLASS(klass); - ISADeviceClass *ic = ISA_DEVICE_CLASS(klass); - ic->init = debugcon_isa_initfn; + + dc->realize = debugcon_isa_realizefn; dc->props = debugcon_isa_properties; } |