summaryrefslogtreecommitdiff
path: root/hw/char/imx_serial.c
diff options
context:
space:
mode:
authorMarc-André Lureau <marcandre.lureau@redhat.com>2016-10-22 12:52:59 +0300
committerPaolo Bonzini <pbonzini@redhat.com>2016-10-24 15:27:21 +0200
commitfa394ed625731c18f904578903718bf16617fe92 (patch)
tree224ba9825ba286e3fcffc48394a3a4c1afbc9531 /hw/char/imx_serial.c
parentc39860e6dc90f6ee2e82ee078f978c5d7f3df86a (diff)
downloadqemu-fa394ed625731c18f904578903718bf16617fe92.tar.gz
qemu-fa394ed625731c18f904578903718bf16617fe92.tar.bz2
qemu-fa394ed625731c18f904578903718bf16617fe92.zip
char: make some qemu_chr_fe skip if no driver
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 <marcandre.lureau@redhat.com> Message-Id: <20161022095318.17775-20-marcandre.lureau@redhat.com> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Diffstat (limited to 'hw/char/imx_serial.c')
-rw-r--r--hw/char/imx_serial.c26
1 files changed, 9 insertions, 17 deletions
diff --git a/hw/char/imx_serial.c b/hw/char/imx_serial.c
index d9a0a25d44..8dbb7b26e6 100644
--- a/hw/char/imx_serial.c
+++ b/hw/char/imx_serial.c
@@ -121,9 +121,7 @@ static uint64_t imx_serial_read(void *opaque, hwaddr offset,
s->usr2 &= ~USR2_RDR;
s->uts1 |= UTS1_RXEMPTY;
imx_update(s);
- if (s->chr.chr) {
- qemu_chr_fe_accept_input(&s->chr);
- }
+ qemu_chr_fe_accept_input(&s->chr);
}
return c;
@@ -182,11 +180,9 @@ static void imx_serial_write(void *opaque, hwaddr offset,
case 0x10: /* UTXD */
ch = value;
if (s->ucr2 & UCR2_TXEN) {
- 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);
s->usr1 &= ~USR1_TRDY;
imx_update(s);
s->usr1 |= USR1_TRDY;
@@ -215,9 +211,7 @@ static void imx_serial_write(void *opaque, hwaddr offset,
}
if (value & UCR2_RXEN) {
if (!(s->ucr2 & UCR2_RXEN)) {
- if (s->chr.chr) {
- qemu_chr_fe_accept_input(&s->chr);
- }
+ qemu_chr_fe_accept_input(&s->chr);
}
}
s->ucr2 = value & 0xffff;
@@ -319,12 +313,10 @@ static void imx_serial_realize(DeviceState *dev, Error **errp)
{
IMXSerialState *s = IMX_SERIAL(dev);
- if (s->chr.chr) {
- qemu_chr_fe_set_handlers(&s->chr, imx_can_receive, imx_receive,
- imx_event, s, NULL);
- } else {
- DPRINTF("No char dev for uart\n");
- }
+ DPRINTF("char dev for uart: %p\n", qemu_chr_fe_get_driver(&s->chr));
+
+ qemu_chr_fe_set_handlers(&s->chr, imx_can_receive, imx_receive,
+ imx_event, s, NULL);
}
static void imx_serial_init(Object *obj)