From patchwork Fri Jun 14 10:50:23 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Michael Tokarev X-Patchwork-Id: 251346 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id 19AE62C007A for ; Fri, 14 Jun 2013 21:01:31 +1000 (EST) Received: from localhost ([::1]:52395 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UnRl3-0001fO-6n for incoming@patchwork.ozlabs.org; Fri, 14 Jun 2013 07:01:29 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:56914) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UnRi3-0006Lb-6E for qemu-devel@nongnu.org; Fri, 14 Jun 2013 06:58:26 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1UnRi0-0006eZ-EV for qemu-devel@nongnu.org; Fri, 14 Jun 2013 06:58:23 -0400 Received: from isrv.corpit.ru ([86.62.121.231]:46991) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UnRhz-0006d3-VO; Fri, 14 Jun 2013 06:58:20 -0400 Received: from gandalf.tls.msk.ru (mjt.vpn.tls.msk.ru [192.168.177.99]) by isrv.corpit.ru (Postfix) with ESMTP id 3CC3B4165F; Fri, 14 Jun 2013 14:58:19 +0400 (MSK) Received: by gandalf.tls.msk.ru (Postfix, from userid 1000) id 541D2519; Fri, 14 Jun 2013 14:50:47 +0400 (MSK) From: Michael Tokarev To: Anthony Liguori Date: Fri, 14 Jun 2013 14:50:23 +0400 Message-Id: <1371207042-17980-8-git-send-email-mjt@msgid.tls.msk.ru> X-Mailer: git-send-email 1.7.10.4 In-Reply-To: <1371207042-17980-1-git-send-email-mjt@msgid.tls.msk.ru> References: <1371207042-17980-1-git-send-email-mjt@msgid.tls.msk.ru> MIME-Version: 1.0 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 86.62.121.231 Cc: qemu-trivial@nongnu.org, Peter Crosthwaite , Michael Tokarev , qemu-devel@nongnu.org Subject: [Qemu-devel] [PULL 07/26] char/serial: cosmetic fixes. X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org From: Peter Crosthwaite Some cosmetic fixes to char/serial fixing some checkpatch errors. Cc: qemu-trivial@nongnu.org Signed-off-by: Peter Crosthwaite Reviewed-by: Andreas Färber Signed-off-by: Michael Tokarev --- hw/char/serial.c | 30 +++++++++++++++++++----------- 1 file changed, 19 insertions(+), 11 deletions(-) diff --git a/hw/char/serial.c b/hw/char/serial.c index 66b6348..bd6813e 100644 --- a/hw/char/serial.c +++ b/hw/char/serial.c @@ -263,8 +263,9 @@ static gboolean serial_xmit(GIOChannel *chan, GIOCondition cond, void *opaque) if (s->tsr_retry <= 0) { if (s->fcr & UART_FCR_FE) { s->tsr = fifo_get(s,XMIT_FIFO); - if (!s->xmit_fifo.count) + if (!s->xmit_fifo.count) { s->lsr |= UART_LSR_THRE; + } } else if ((s->lsr & UART_LSR_THRE)) { return FALSE; } else { @@ -461,10 +462,11 @@ static uint64_t serial_ioport_read(void *opaque, hwaddr addr, unsigned size) } else { if(s->fcr & UART_FCR_FE) { ret = fifo_get(s,RECV_FIFO); - if (s->recv_fifo.count == 0) + if (s->recv_fifo.count == 0) { s->lsr &= ~(UART_LSR_DR | UART_LSR_BI); - else + } else { qemu_mod_timer(s->fifo_timeout_timer, qemu_get_clock_ns (vm_clock) + s->char_transmit_time * 4); + } s->timeout_ipending = 0; } else { ret = s->rbr; @@ -534,15 +536,21 @@ static uint64_t serial_ioport_read(void *opaque, hwaddr addr, unsigned size) static int serial_can_receive(SerialState *s) { if(s->fcr & UART_FCR_FE) { - if(s->recv_fifo.count < UART_FIFO_LENGTH) - /* Advertise (fifo.itl - fifo.count) bytes when count < ITL, and 1 if above. If UART_FIFO_LENGTH - fifo.count is - advertised the effect will be to almost always fill the fifo completely before the guest has a chance to respond, - effectively overriding the ITL that the guest has set. */ - return (s->recv_fifo.count <= s->recv_fifo.itl) ? s->recv_fifo.itl - s->recv_fifo.count : 1; - else - return 0; + if (s->recv_fifo.count < UART_FIFO_LENGTH) { + /* + * Advertise (fifo.itl - fifo.count) bytes when count < ITL, and 1 + * if above. If UART_FIFO_LENGTH - fifo.count is advertised the + * effect will be to almost always fill the fifo completely before + * the guest has a chance to respond, effectively overriding the ITL + * that the guest has set. + */ + return (s->recv_fifo.count <= s->recv_fifo.itl) ? + s->recv_fifo.itl - s->recv_fifo.count : 1; + } else { + return 0; + } } else { - return !(s->lsr & UART_LSR_DR); + return !(s->lsr & UART_LSR_DR); } }