From mboxrd@z Thu Jan 1 00:00:00 1970 From: Tomasz Wroblewski Subject: Re: [PATCH] V2 pci uart - better cope with UART being temporarily unavailable Date: Tue, 27 Aug 2013 15:36:39 +0200 Message-ID: <521CAB67.3020409@citrix.com> References: <1377598539-21973-1-git-send-email-tomasz.wroblewski@citrix.com> <521CB72B02000078000EEBE7@nat28.tlf.novell.com> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii"; Format="flowed" Content-Transfer-Encoding: 7bit Return-path: Received: from mail6.bemta4.messagelabs.com ([85.158.143.247]) by lists.xen.org with esmtp (Exim 4.72) (envelope-from ) id 1VEJSc-0002Ty-0T for xen-devel@lists.xenproject.org; Tue, 27 Aug 2013 13:37:30 +0000 In-Reply-To: <521CB72B02000078000EEBE7@nat28.tlf.novell.com> List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Sender: xen-devel-bounces@lists.xen.org Errors-To: xen-devel-bounces@lists.xen.org To: Jan Beulich Cc: xen-devel , keir@xen.org List-Id: xen-devel@lists.xenproject.org >> --- a/xen/drivers/char/serial.c >> +++ b/xen/drivers/char/serial.c >> @@ -111,15 +111,18 @@ static void __serial_putc(struct serial_port *port, char c) >> if ( port->tx_log_everything ) >> { >> /* Buffer is full: we spin waiting for space to appear. */ >> - unsigned int n; >> + int n; >> >> while ( (n = port->driver->tx_ready(port)) == 0 ) >> cpu_relax(); >> - while ( n-- ) >> - port->driver->putc( >> - port, >> - port->txbuf[mask_serial_txbuf_idx(port->txbufc++)]); >> - port->txbuf[mask_serial_txbuf_idx(port->txbufp++)] = c; >> + if (n> 0) >> + { >> + while ( n-- ) > "while ( n--> 0 )" can achieve the same without the extra if() > and with just a one line change. Thanks for review - agree with most comments except this one, we need to avoid executing "port->txbuf[mask_serial_txbuf_idx(port->txbufp++)] = c" if port is offline, since in this case the while loop will not consume pull any character out of the buffer, and it will stay full, and we should just drop the char. The "if" I added pulled the buffer insert into its body.