From patchwork Wed Oct 14 21:53:46 2009 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Timur Tabi X-Patchwork-Id: 36030 Return-Path: X-Original-To: patchwork-incoming@ozlabs.org Delivered-To: patchwork-incoming@ozlabs.org Received: from bilbo.ozlabs.org (localhost [127.0.0.1]) by ozlabs.org (Postfix) with ESMTP id 7A39AB7E07 for ; Thu, 15 Oct 2009 08:54:10 +1100 (EST) Received: by ozlabs.org (Postfix) id B2629B7B84; Thu, 15 Oct 2009 08:54:04 +1100 (EST) Delivered-To: linuxppc-dev@ozlabs.org Received: from az33egw02.freescale.net (az33egw02.freescale.net [192.88.158.103]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (Client CN "az33egw02.freescale.net", Issuer "Thawte Premium Server CA" (verified OK)) by ozlabs.org (Postfix) with ESMTPS id 581F5B7334 for ; Thu, 15 Oct 2009 08:54:03 +1100 (EST) Received: from az33smr01.freescale.net (az33smr01.freescale.net [10.64.34.199]) by az33egw02.freescale.net (8.14.3/az33egw02) with ESMTP id n9ELrlx8000917; Wed, 14 Oct 2009 14:53:47 -0700 (MST) Received: from localhost.localdomain (efes.am.freescale.net [10.82.123.3]) by az33smr01.freescale.net (8.13.1/8.13.0) with ESMTP id n9ELuHVP026087; Wed, 14 Oct 2009 16:56:18 -0500 (CDT) From: Timur Tabi To: linuxppc-dev@ozlabs.org, scottwood@freescale.com, borntraeger@de.ibm.com, brueckner@linux.vnet.ibm.com Subject: [PATCH] hvc_console: returning 0 from put_chars is not an error Date: Wed, 14 Oct 2009 16:53:46 -0500 Message-Id: <1255557226-4403-1-git-send-email-timur@freescale.com> X-Mailer: git-send-email 1.6.5 X-Brightmail-Tracker: AAAAAQAAAWE= X-BeenThere: linuxppc-dev@lists.ozlabs.org X-Mailman-Version: 2.1.12 Precedence: list List-Id: Linux on PowerPC Developers Mail List List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: linuxppc-dev-bounces+patchwork-incoming=ozlabs.org@lists.ozlabs.org Errors-To: linuxppc-dev-bounces+patchwork-incoming=ozlabs.org@lists.ozlabs.org hvc_console_print() calls the HVC client driver's put_chars() callback to write some characters to the console. If the callback returns 0, that indicates that no characters were written (perhaps the output buffer is full), but hvc_console_print() treats that as an error and discards the rest of the buffer. So change hvc_console_print() to just loop and call put_chars() again if it returns a 0 return code. This change makes hvc_console_print() behave more like hvc_push(), which does check for a 0 return code and re-schedules itself. Signed-off-by: Timur Tabi --- This patch might cause a hang in drivers that return 0 in case of error, instead of a negative number, but those drivers are broken anyway. This patch might fix drivers that return 0 to indicate that they're busy, such as arch/powerpc/platforms/pseries/hvconsole.c. It will break drivers that return 0 if their output buffer is full, but where those buffers cannot be emptied while the kernel is in a loop. drivers/char/hvc_console.c | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-) diff --git a/drivers/char/hvc_console.c b/drivers/char/hvc_console.c index 25ce15b..0c94907 100644 --- a/drivers/char/hvc_console.c +++ b/drivers/char/hvc_console.c @@ -161,7 +161,7 @@ static void hvc_console_print(struct console *co, const char *b, } } else { r = cons_ops[index]->put_chars(vtermnos[index], c, i); - if (r <= 0) { + if (r < 0) { /* throw away chars on error */ i = 0; } else if (r > 0) {