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/serial.c | |
parent | a3dcca567a1d4a5c79fb9c8fe2d9a21a4a7cebd5 (diff) | |
download | qemu-db895a1e6a97e919f9b86d60c969377357b05066.zip qemu-db895a1e6a97e919f9b86d60c969377357b05066.tar.gz qemu-db895a1e6a97e919f9b86d60c969377357b05066.tar.bz2 |
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/serial.c')
-rw-r--r-- | hw/char/serial.c | 22 |
1 files changed, 17 insertions, 5 deletions
diff --git a/hw/char/serial.c b/hw/char/serial.c index 66b6348..f2701e8 100644 --- a/hw/char/serial.c +++ b/hw/char/serial.c @@ -670,11 +670,11 @@ static void serial_reset(void *opaque) qemu_irq_lower(s->irq); } -void serial_init_core(SerialState *s) +void serial_realize_core(SerialState *s, Error **errp) { if (!s->chr) { - fprintf(stderr, "Can't create serial device, empty char device\n"); - exit(1); + error_setg(errp, "Can't create serial device, empty char device"); + return; } s->modem_status_poll = qemu_new_timer_ns(vm_clock, (QEMUTimerCB *) serial_update_msl, s); @@ -713,13 +713,19 @@ SerialState *serial_init(int base, qemu_irq irq, int baudbase, CharDriverState *chr, MemoryRegion *system_io) { SerialState *s; + Error *err = NULL; s = g_malloc0(sizeof(SerialState)); s->irq = irq; s->baudbase = baudbase; s->chr = chr; - serial_init_core(s); + serial_realize_core(s, &err); + if (err != NULL) { + fprintf(stderr, "%s\n", error_get_pretty(err)); + error_free(err); + exit(1); + } vmstate_register(NULL, base, &vmstate_serial, s); @@ -769,6 +775,7 @@ SerialState *serial_mm_init(MemoryRegion *address_space, CharDriverState *chr, enum device_endian end) { SerialState *s; + Error *err = NULL; s = g_malloc0(sizeof(SerialState)); @@ -777,7 +784,12 @@ SerialState *serial_mm_init(MemoryRegion *address_space, s->baudbase = baudbase; s->chr = chr; - serial_init_core(s); + serial_realize_core(s, &err); + if (err != NULL) { + fprintf(stderr, "%s\n", error_get_pretty(err)); + error_free(err); + exit(1); + } vmstate_register(NULL, base, &vmstate_serial, s); memory_region_init_io(&s->io, &serial_mm_ops[end], s, |