linuxppc-dev.lists.ozlabs.org archive mirror
 help / color / mirror / Atom feed
From: Timur Tabi <timur@freescale.com>
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	[thread overview]
Message-ID: <1255557226-4403-1-git-send-email-timur@freescale.com> (raw)

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 <timur@freescale.com>
---

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) {
-- 
1.6.5

             reply	other threads:[~2009-10-14 21:54 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-10-14 21:53 Timur Tabi [this message]
2009-10-15 11:05 ` [PATCH] hvc_console: returning 0 from put_chars is not an error Christian Borntraeger
2009-10-15 16:09   ` Scott Wood
2009-10-15 18:41     ` Christian Borntraeger
2009-10-15 18:55       ` Timur Tabi
2009-10-15 18:57       ` Scott Wood
2009-10-15 19:26         ` Christian Borntraeger
2009-10-15 19:32           ` Scott Wood
2009-10-16  8:49             ` Hendrik Brueckner
2009-10-17 23:17               ` Timur Tabi
2009-10-16  4:46         ` Benjamin Herrenschmidt
2009-10-16 15:33           ` Scott Wood
2009-10-16 18:03             ` Benjamin Herrenschmidt

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1255557226-4403-1-git-send-email-timur@freescale.com \
    --to=timur@freescale.com \
    --cc=borntraeger@de.ibm.com \
    --cc=brueckner@linux.vnet.ibm.com \
    --cc=linuxppc-dev@ozlabs.org \
    --cc=scottwood@freescale.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).