From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:35173) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bFjmU-0004m7-AS for qemu-devel@nongnu.org; Wed, 22 Jun 2016 11:09:34 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1bFjmP-0007LH-A5 for qemu-devel@nongnu.org; Wed, 22 Jun 2016 11:09:30 -0400 Received: from mx1.redhat.com ([209.132.183.28]:58580) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bFjmP-0007L2-1h for qemu-devel@nongnu.org; Wed, 22 Jun 2016 11:09:25 -0400 Date: Wed, 22 Jun 2016 16:09:21 +0100 From: "Dr. David Alan Gilbert" Message-ID: <20160622150920.GD6604@work-vm> References: <1466432945-28682-1-git-send-email-pbonzini@redhat.com> <1466432945-28682-4-git-send-email-pbonzini@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1466432945-28682-4-git-send-email-pbonzini@redhat.com> Subject: Re: [Qemu-devel] [PATCH 3/6] serial: separate serial_xmit and serial_watch_cb List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Paolo Bonzini Cc: qemu-devel@nongnu.org, bcketchum@gmail.com * Paolo Bonzini (pbonzini@redhat.com) wrote: > serial_xmit starts transmission of whatever is in the FIFO or THR; > serial_watch_cb is a wrapper around it. > > Signed-off-by: Paolo Bonzini > --- > hw/char/serial.c | 21 +++++++++++++-------- > 1 file changed, 13 insertions(+), 8 deletions(-) > > diff --git a/hw/char/serial.c b/hw/char/serial.c > index 6f0a49e..4196a2e 100644 > --- a/hw/char/serial.c > +++ b/hw/char/serial.c > @@ -106,6 +106,7 @@ do {} while (0) > #endif > > static void serial_receive1(void *opaque, const uint8_t *buf, int size); > +static void serial_xmit(SerialState *s); > > static inline void recv_fifo_put(SerialState *s, uint8_t chr) > { > @@ -223,10 +224,16 @@ static void serial_update_msl(SerialState *s) > } > } > > -static gboolean serial_xmit(GIOChannel *chan, GIOCondition cond, void *opaque) > +static gboolean serial_watch_cb(GIOChannel *chan, GIOCondition cond, > + void *opaque) > { > SerialState *s = opaque; > + serial_xmit(s); > + return FALSE; > +} Yes, with a side question. We register this with G_IO_OUT|G_IO_HUP but don't check the cond, what's this code supposed to do if it gets a HUP? Since we didn't do anything with cond before either: Reviewed-by: Dr. David Alan Gilbert > > +static void serial_xmit(SerialState *s) > +{ > do { > assert(!(s->lsr & UART_LSR_TEMT)); > if (s->tsr_retry == 0) { > @@ -254,9 +261,9 @@ static gboolean serial_xmit(GIOChannel *chan, GIOCondition cond, void *opaque) > } else if (qemu_chr_fe_write(s->chr, &s->tsr, 1) != 1) { > if (s->tsr_retry < MAX_XMIT_RETRY && > qemu_chr_fe_add_watch(s->chr, G_IO_OUT|G_IO_HUP, > - serial_xmit, s) > 0) { > + serial_watch_cb, s) > 0) { > s->tsr_retry++; > - return FALSE; > + return; > } > s->tsr_retry = 0; > } else { > @@ -269,11 +276,8 @@ static gboolean serial_xmit(GIOChannel *chan, GIOCondition cond, void *opaque) > > s->last_xmit_ts = qemu_clock_get_ns(QEMU_CLOCK_VIRTUAL); > s->lsr |= UART_LSR_TEMT; > - > - return FALSE; > } > > - > /* Setter for FCR. > is_load flag means, that value is set while loading VM state > and interrupt should not be invoked */ > @@ -331,7 +335,7 @@ static void serial_ioport_write(void *opaque, hwaddr addr, uint64_t val, > s->lsr &= ~UART_LSR_TEMT; > serial_update_irq(s); > if (s->tsr_retry == 0) { > - serial_xmit(NULL, G_IO_OUT, s); > + serial_xmit(s); > } > } > break; > @@ -647,7 +651,8 @@ static int serial_post_load(void *opaque, int version_id) > } > > assert(s->watch_tag == 0); > - s->watch_tag = qemu_chr_fe_add_watch(s->chr, G_IO_OUT|G_IO_HUP, serial_xmit, s); > + s->watch_tag = qemu_chr_fe_add_watch(s->chr, G_IO_OUT|G_IO_HUP, > + serial_watch_cb, s); > } else { > /* tsr_retry == 0 implies LSR.TEMT = 1 (transmitter empty). */ > if (!(s->lsr & UART_LSR_TEMT)) { > -- > 2.5.5 > > -- Dr. David Alan Gilbert / dgilbert@redhat.com / Manchester, UK