From patchwork Mon Jun 3 05:12:09 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peter Crosthwaite X-Patchwork-Id: 248172 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 21E9C2C0099 for ; Mon, 3 Jun 2013 15:14:36 +1000 (EST) Received: from localhost ([::1]:44922 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UjN6I-0004VE-5e for incoming@patchwork.ozlabs.org; Mon, 03 Jun 2013 01:14:34 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:35531) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UjN5x-0004SG-NQ for qemu-devel@nongnu.org; Mon, 03 Jun 2013 01:14:19 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1UjN5s-0001mx-PS for qemu-devel@nongnu.org; Mon, 03 Jun 2013 01:14:13 -0400 Received: from mail-pd0-f169.google.com ([209.85.192.169]:53606) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UjN5s-0001mm-J7 for qemu-devel@nongnu.org; Mon, 03 Jun 2013 01:14:08 -0400 Received: by mail-pd0-f169.google.com with SMTP id y11so5099176pdj.0 for ; Sun, 02 Jun 2013 22:14:07 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=sender:from:to:cc:subject:date:message-id:x-mailer:in-reply-to :references:x-gm-message-state; bh=9suX9FTr8LMnBbtSh588zL8ZEV0SMEJwuMQfDbbw/Kc=; b=QJZVSGVJpK2K14P9PHsVfOUH6igP7w/BGR/h6z5mdmJdlFf5KMEp7bGfr7pYYIOwQc NElUi/7Ssgk3b9uf6nDEthQyFjcBxv8W1WoB35FKEE1nGoD0Bwo6XBvqFGxD/S/x1/J9 Ckk3y5I0Uc0tIyqKFvP7Y0XK6cAZ+Lmx5MGj7dFluRw+dScfCZCQmc5PcCNb0efkSvDY cLS75mXlaUMQQWlUZQ5F7J65DT8RpDhNvt+nrkwF4dzrZbXPC1E9f6aYU8vHzn5UW73B sfrnBwfmWbqqcv+njvJ0zxlPBunCvbt++cSdVfnUWEliN5sT1PUDTOuTFDlqBb7MBPT0 wL0Q== X-Received: by 10.66.145.98 with SMTP id st2mr23215886pab.24.1370236447727; Sun, 02 Jun 2013 22:14:07 -0700 (PDT) Received: from localhost ([203.126.243.116]) by mx.google.com with ESMTPSA id aj2sm57449492pbc.1.2013.06.02.22.14.00 for (version=TLSv1.1 cipher=RC4-SHA bits=128/128); Sun, 02 Jun 2013 22:14:06 -0700 (PDT) From: peter.crosthwaite@xilinx.com To: qemu-devel@nongnu.org Date: Mon, 3 Jun 2013 15:12:09 +1000 Message-Id: X-Mailer: git-send-email 1.8.3.rc1.44.gb387c77.dirty In-Reply-To: References: X-Gm-Message-State: ALoCoQkAeCJmIUFwuZh9DZFkMtYiy9p4YJUwvAmrpTHhWvK2EMZWRwGC4NvEbyY6DeqhNuGBRMsl X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 209.85.192.169 Cc: qemu-trivial@nongnu.org, edgar.iglesias@gmail.com, aliguori@us.ibm.com, Peter Crosthwaite Subject: [Qemu-devel] [PATCH v1 1/3] 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 --- Needed for the next patch to pass checkpatch. Done as sep patch to not obscure that patch. 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); } }