From becdfa00cfa2995e859ccefa4b7d72a72eb96581 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= Date: Sat, 22 Oct 2016 12:52:51 +0300 Subject: char: replace PROP_CHR with CharBackend MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Store the property in a CharBackend instead of CharDriverState*. This also replace systematically chr by chr.chr to access the CharDriverState*. The following patches will replace it with calls to qemu_chr_fe CharBackend functions. Signed-off-by: Marc-André Lureau Message-Id: <20161022095318.17775-12-marcandre.lureau@redhat.com> Signed-off-by: Paolo Bonzini --- hw/char/digic-uart.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'hw/char/digic-uart.c') diff --git a/hw/char/digic-uart.c b/hw/char/digic-uart.c index e96a9b2d8d..fb4969fc50 100644 --- a/hw/char/digic-uart.c +++ b/hw/char/digic-uart.c @@ -76,10 +76,10 @@ static void digic_uart_write(void *opaque, hwaddr addr, uint64_t value, switch (addr) { case R_TX: - if (s->chr) { + if (s->chr.chr) { /* XXX this blocks entire thread. Rewrite to use * qemu_chr_fe_write and background I/O callbacks */ - qemu_chr_fe_write_all(s->chr, &ch, 1); + qemu_chr_fe_write_all(s->chr.chr, &ch, 1); } break; @@ -147,8 +147,8 @@ static void digic_uart_realize(DeviceState *dev, Error **errp) { DigicUartState *s = DIGIC_UART(dev); - if (s->chr) { - qemu_chr_add_handlers(s->chr, uart_can_rx, uart_rx, uart_event, s); + if (s->chr.chr) { + qemu_chr_add_handlers(s->chr.chr, uart_can_rx, uart_rx, uart_event, s); } } -- cgit v1.2.3 From 5345fdb4467816c44f6752b3a1f4e73aa25919f9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= Date: Sat, 22 Oct 2016 12:52:55 +0300 Subject: char: use qemu_chr_fe* functions with CharBackend argument MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This also switches from qemu_chr_add_handlers() to qemu_chr_fe_set_handlers(). Note that qemu_chr_fe_set_handlers() now takes the focus when fe_open (qemu_chr_add_handlers() did take the focus) Signed-off-by: Marc-André Lureau Message-Id: <20161022095318.17775-16-marcandre.lureau@redhat.com> Signed-off-by: Paolo Bonzini --- hw/char/digic-uart.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'hw/char/digic-uart.c') diff --git a/hw/char/digic-uart.c b/hw/char/digic-uart.c index fb4969fc50..c7b3db631d 100644 --- a/hw/char/digic-uart.c +++ b/hw/char/digic-uart.c @@ -79,7 +79,7 @@ static void digic_uart_write(void *opaque, hwaddr addr, uint64_t value, if (s->chr.chr) { /* XXX this blocks entire thread. Rewrite to use * qemu_chr_fe_write and background I/O callbacks */ - qemu_chr_fe_write_all(s->chr.chr, &ch, 1); + qemu_chr_fe_write_all(&s->chr, &ch, 1); } break; @@ -148,7 +148,8 @@ static void digic_uart_realize(DeviceState *dev, Error **errp) DigicUartState *s = DIGIC_UART(dev); if (s->chr.chr) { - qemu_chr_add_handlers(s->chr.chr, uart_can_rx, uart_rx, uart_event, s); + qemu_chr_fe_set_handlers(&s->chr, uart_can_rx, uart_rx, + uart_event, s, NULL); } } -- cgit v1.2.3 From fa394ed625731c18f904578903718bf16617fe92 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= Date: Sat, 22 Oct 2016 12:52:59 +0300 Subject: char: make some qemu_chr_fe skip if no driver MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit In most cases, front ends do not care about the side effect of CharBackend, so we can simply skip the checks and call the qemu_chr_fe functions even without associated CharDriver. Signed-off-by: Marc-André Lureau Message-Id: <20161022095318.17775-20-marcandre.lureau@redhat.com> Signed-off-by: Paolo Bonzini --- hw/char/digic-uart.c | 14 +++++--------- 1 file changed, 5 insertions(+), 9 deletions(-) (limited to 'hw/char/digic-uart.c') diff --git a/hw/char/digic-uart.c b/hw/char/digic-uart.c index c7b3db631d..2955e19f67 100644 --- a/hw/char/digic-uart.c +++ b/hw/char/digic-uart.c @@ -76,11 +76,9 @@ static void digic_uart_write(void *opaque, hwaddr addr, uint64_t value, switch (addr) { case R_TX: - if (s->chr.chr) { - /* XXX this blocks entire thread. Rewrite to use - * qemu_chr_fe_write and background I/O callbacks */ - qemu_chr_fe_write_all(&s->chr, &ch, 1); - } + /* XXX this blocks entire thread. Rewrite to use + * qemu_chr_fe_write and background I/O callbacks */ + qemu_chr_fe_write_all(&s->chr, &ch, 1); break; case R_ST: @@ -147,10 +145,8 @@ static void digic_uart_realize(DeviceState *dev, Error **errp) { DigicUartState *s = DIGIC_UART(dev); - if (s->chr.chr) { - qemu_chr_fe_set_handlers(&s->chr, uart_can_rx, uart_rx, - uart_event, s, NULL); - } + qemu_chr_fe_set_handlers(&s->chr, uart_can_rx, uart_rx, + uart_event, s, NULL); } static void digic_uart_init(Object *obj) -- cgit v1.2.3 From 39ab61c6d0757ed95badc9315857effdb64e4aa0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= Date: Sat, 22 Oct 2016 12:53:03 +0300 Subject: char: remove explicit_fe_open, use a set_handlers argument MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit No need to keep explicit_fe_open around if it affects only a qemu_chr_fe_set_handlers(). Use an additional argument instead. Signed-off-by: Marc-André Lureau Message-Id: <20161022095318.17775-24-marcandre.lureau@redhat.com> Signed-off-by: Paolo Bonzini --- hw/char/digic-uart.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'hw/char/digic-uart.c') diff --git a/hw/char/digic-uart.c b/hw/char/digic-uart.c index 2955e19f67..029f5bbf5e 100644 --- a/hw/char/digic-uart.c +++ b/hw/char/digic-uart.c @@ -146,7 +146,7 @@ static void digic_uart_realize(DeviceState *dev, Error **errp) DigicUartState *s = DIGIC_UART(dev); qemu_chr_fe_set_handlers(&s->chr, uart_can_rx, uart_rx, - uart_event, s, NULL); + uart_event, s, NULL, true); } static void digic_uart_init(Object *obj) -- cgit v1.2.3