aboutsummaryrefslogtreecommitdiff
path: root/hw
diff options
context:
space:
mode:
authorMarc-André Lureau <marcandre.lureau@redhat.com>2016-10-22 12:52:58 +0300
committerPaolo Bonzini <pbonzini@redhat.com>2016-10-24 15:27:21 +0200
commitc39860e6dc90f6ee2e82ee078f978c5d7f3df86a (patch)
tree7af723a578b9f33ee172254b20fd9bbdd519cd0c /hw
parent5d300164d00cf9d37a4481831d2c993255dfa0e8 (diff)
downloadqemu-c39860e6dc90f6ee2e82ee078f978c5d7f3df86a.zip
qemu-c39860e6dc90f6ee2e82ee078f978c5d7f3df86a.tar.gz
qemu-c39860e6dc90f6ee2e82ee078f978c5d7f3df86a.tar.bz2
char: replace qemu_chr_claim/release with qemu_chr_fe_init/deinit
Now that all front end use qemu_chr_fe_init(), we can move chardev claiming in init(), and add a function deinit() to release the chardev and cleanup handlers. The qemu_chr_fe_claim_no_fail() for property are gone, since the property will raise an error instead. In other cases, where there is already an error path, an error is raised instead. Finally, other cases are handled by &error_abort in qemu_chr_fe_init(). Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com> Message-Id: <20161022095318.17775-19-marcandre.lureau@redhat.com> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Diffstat (limited to 'hw')
-rw-r--r--hw/arm/pxa2xx.c1
-rw-r--r--hw/char/mcf_uart.c1
-rw-r--r--hw/char/serial.c2
-rw-r--r--hw/char/sh_serial.c1
-rw-r--r--hw/char/xen_console.c16
-rw-r--r--hw/core/qdev-properties-system.c14
-rw-r--r--hw/usb/ccid-card-passthru.c1
-rw-r--r--hw/usb/redirect.c2
8 files changed, 11 insertions, 27 deletions
diff --git a/hw/arm/pxa2xx.c b/hw/arm/pxa2xx.c
index 798c05b..cd98379 100644
--- a/hw/arm/pxa2xx.c
+++ b/hw/arm/pxa2xx.c
@@ -1976,7 +1976,6 @@ static void pxa2xx_fir_realize(DeviceState *dev, Error **errp)
PXA2xxFIrState *s = PXA2XX_FIR(dev);
if (s->chr.chr) {
- qemu_chr_fe_claim_no_fail(s->chr.chr);
qemu_chr_fe_set_handlers(&s->chr, pxa2xx_fir_is_empty,
pxa2xx_fir_rx, pxa2xx_fir_event, s, NULL);
}
diff --git a/hw/char/mcf_uart.c b/hw/char/mcf_uart.c
index cc3db13..b505343 100644
--- a/hw/char/mcf_uart.c
+++ b/hw/char/mcf_uart.c
@@ -285,7 +285,6 @@ void *mcf_uart_init(qemu_irq irq, CharDriverState *chr)
s->irq = irq;
if (chr) {
qemu_chr_fe_init(&s->chr, chr, &error_abort);
- qemu_chr_fe_claim_no_fail(chr);
qemu_chr_fe_set_handlers(&s->chr, mcf_uart_can_receive,
mcf_uart_receive, mcf_uart_event, s, NULL);
}
diff --git a/hw/char/serial.c b/hw/char/serial.c
index 509bc25..54f80c6 100644
--- a/hw/char/serial.c
+++ b/hw/char/serial.c
@@ -905,7 +905,7 @@ void serial_realize_core(SerialState *s, Error **errp)
void serial_exit_core(SerialState *s)
{
- qemu_chr_fe_set_handlers(&s->chr, NULL, NULL, NULL, NULL, NULL);
+ qemu_chr_fe_deinit(&s->chr);
qemu_unregister_reset(serial_reset, s);
}
diff --git a/hw/char/sh_serial.c b/hw/char/sh_serial.c
index 8d82986..8bb45db 100644
--- a/hw/char/sh_serial.c
+++ b/hw/char/sh_serial.c
@@ -397,7 +397,6 @@ void sh_serial_init(MemoryRegion *sysmem,
memory_region_add_subregion(sysmem, A7ADDR(base), &s->iomem_a7);
if (chr) {
- qemu_chr_fe_claim_no_fail(chr);
qemu_chr_fe_init(&s->chr, chr, &error_abort);
qemu_chr_fe_set_handlers(&s->chr, sh_serial_can_receive1,
sh_serial_receive1,
diff --git a/hw/char/xen_console.c b/hw/char/xen_console.c
index 5e5aca1..f664366 100644
--- a/hw/char/xen_console.c
+++ b/hw/char/xen_console.c
@@ -245,15 +245,8 @@ static int con_initialise(struct XenDevice *xendev)
xen_be_bind_evtchn(&con->xendev);
if (con->chr.chr) {
- if (qemu_chr_fe_claim(con->chr.chr) == 0) {
- qemu_chr_fe_set_handlers(&con->chr, xencons_can_receive,
- xencons_receive, NULL, con, NULL);
- } else {
- xen_be_printf(xendev, 0,
- "xen_console_init error chardev %s already used\n",
- con->chr.chr->label);
- con->chr.chr = NULL;
- }
+ qemu_chr_fe_set_handlers(&con->chr, xencons_can_receive,
+ xencons_receive, NULL, con, NULL);
}
xen_be_printf(xendev, 1, "ring mfn %d, remote port %d, local port %d, limit %zd\n",
@@ -268,10 +261,7 @@ static void con_disconnect(struct XenDevice *xendev)
{
struct XenConsole *con = container_of(xendev, struct XenConsole, xendev);
- if (con->chr.chr) {
- qemu_chr_fe_set_handlers(&con->chr, NULL, NULL, NULL, NULL, NULL);
- qemu_chr_fe_release(con->chr.chr);
- }
+ qemu_chr_fe_deinit(&con->chr);
xen_be_unbind_evtchn(&con->xendev);
if (con->sring) {
diff --git a/hw/core/qdev-properties-system.c b/hw/core/qdev-properties-system.c
index 6d45d32..c35f0f5 100644
--- a/hw/core/qdev-properties-system.c
+++ b/hw/core/qdev-properties-system.c
@@ -206,13 +206,12 @@ static void set_chr(Object *obj, Visitor *v, const char *name, void *opaque,
object_get_typename(obj), prop->name, str);
return;
}
- if (qemu_chr_fe_claim(s) != 0) {
- error_setg(errp, "Property '%s.%s' can't take value '%s', it's in use",
- object_get_typename(obj), prop->name, str);
+
+ if (!qemu_chr_fe_init(be, s, errp)) {
+ error_prepend(errp, "Property '%s.%s' can't take value '%s': ",
+ object_get_typename(obj), prop->name, str);
return;
}
-
- qemu_chr_fe_init(be, s, errp);
}
static void release_chr(Object *obj, const char *name, void *opaque)
@@ -221,10 +220,7 @@ static void release_chr(Object *obj, const char *name, void *opaque)
Property *prop = opaque;
CharBackend *be = qdev_get_prop_ptr(dev, prop);
- if (be->chr) {
- qemu_chr_fe_set_handlers(be, NULL, NULL, NULL, NULL, NULL);
- qemu_chr_fe_release(be->chr);
- }
+ qemu_chr_fe_deinit(be);
}
PropertyInfo qdev_prop_chr = {
diff --git a/hw/usb/ccid-card-passthru.c b/hw/usb/ccid-card-passthru.c
index a8c8684..369a8f1 100644
--- a/hw/usb/ccid-card-passthru.c
+++ b/hw/usb/ccid-card-passthru.c
@@ -266,6 +266,7 @@ static void ccid_card_vscard_drop_connection(PassthruState *card)
{
CharDriverState *chr = qemu_chr_fe_get_driver(&card->cs);
+ qemu_chr_fe_deinit(&card->cs);
qemu_chr_delete(chr);
card->vscard_in_pos = card->vscard_in_hdr = 0;
}
diff --git a/hw/usb/redirect.c b/hw/usb/redirect.c
index 0fb2e9a..6f5ad20 100644
--- a/hw/usb/redirect.c
+++ b/hw/usb/redirect.c
@@ -1430,9 +1430,9 @@ static void usbredir_handle_destroy(USBDevice *udev)
USBRedirDevice *dev = USB_REDIRECT(udev);
CharDriverState *chr = qemu_chr_fe_get_driver(&dev->cs);
+ qemu_chr_fe_deinit(&dev->cs);
qemu_chr_delete(chr);
- dev->cs.chr = NULL;
/* Note must be done after qemu_chr_close, as that causes a close event */
qemu_bh_delete(dev->chardev_close_bh);
qemu_bh_delete(dev->device_reject_bh);