linux-next.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Joe Peterson <joe@skyrush.com>
To: Linus Torvalds <torvalds@linux-foundation.org>
Cc: Stephen Rothwell <sfr@canb.auug.org.au>, Greg KH <greg@kroah.com>,
	linux-next@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: linux-next: manual merge of the tty tree with the  tree
Date: Mon, 07 Sep 2009 15:55:44 -0600	[thread overview]
Message-ID: <4AA58160.7080908@skyrush.com> (raw)
In-Reply-To: <alpine.LFD.2.01.0909071104340.25628@localhost.localdomain>

[-- Attachment #1: Type: text/plain, Size: 1012 bytes --]

Linus Torvalds wrote:
> Hmm. I think that the "honor opost flag for echoes" patch is actually 
> wrong.
> 
> We check O_OPOST() in the _caller_ for the regular write case, and that
> test actually looks like this:
> 
> 	if (O_OPOST(tty) && !(test_bit(TTY_HW_COOK_OUT, &tty->flags))) {
> 
> so at a minimum, if we add it to process_output() we should likely add it 
> in the same format. But if we need that test, I'd rather do it in the 
> caller anyway, like we already do for regular writes.

Yes, very true.  The old opost() function also contained the O_OPOST
check (i.e. causing a double check for normal writes), and you are right
that we should not reintroduce it (and it makes sense for the caller to
check it).

There is only the one case in which the O_OPOST check is needed before
calling do_output_char() (in process_echoes()), so we could just inline
the test there.  Take a look at my new attached patch (untested also).
I'll test and resubmit, assuming there are no objections.

					-Thanks, Joe

[-- Attachment #2: n_tty-honor-opost-flag-for-echoes.patch --]
[-- Type: text/plain, Size: 2102 bytes --]

--- n_tty.c.orig	2009-09-07 13:54:32.460678337 -0600
+++ n_tty.c	2009-09-07 15:48:51.191033405 -0600
@@ -272,7 +272,8 @@ static inline int is_continuation(unsign
  *
  *	This is a helper function that handles one output character
  *	(including special characters like TAB, CR, LF, etc.),
- *	putting the results in the tty driver's write buffer.
+ *	doing OPOST processing and putting the results in the
+ *	tty driver's write buffer.
  *
  *	Note that Linux currently ignores TABDLY, CRDLY, VTDLY, FFDLY
  *	and NLDLY.  They simply aren't relevant in the world today.
@@ -351,8 +352,9 @@ static int do_output_char(unsigned char 
  *	@c: character (or partial unicode symbol)
  *	@tty: terminal device
  *
- *	Perform OPOST processing.  Returns -1 when the output device is
- *	full and the character must be retried.
+ *	Output one character with OPOST processing.
+ *	Returns -1 when the output device is full and the character
+ *	must be retried.
  *
  *	Locking: output_lock to protect column state and space left
  *		 (also, this is called from n_tty_write under the
@@ -378,8 +380,11 @@ static int process_output(unsigned char 
 /**
  *	process_output_block		-	block post processor
  *	@tty: terminal device
- *	@inbuf: user buffer
- *	@nr: number of bytes
+ *	@buf: character buffer
+ *	@nr: number of bytes to output
+ *
+ *	Output a block of characters with OPOST processing.
+ *	Returns the number of characters output.
  *
  *	This path is used to speed up block console writes, among other
  *	things when processing blocks of output data. It handles only
@@ -606,12 +611,18 @@ static void process_echoes(struct tty_st
 			if (no_space_left)
 				break;
 		} else {
-			int retval;
-
-			retval = do_output_char(c, tty, space);
-			if (retval < 0)
-				break;
-			space -= retval;
+			if (O_OPOST(tty) &&
+			    !(test_bit(TTY_HW_COOK_OUT, &tty->flags))) {
+				int retval = do_output_char(c, tty, space);
+				if (retval < 0)
+					break;
+				space -= retval;
+			} else {
+				if (!space)
+					break;
+				tty_put_char(tty, c);
+				space -= 1;
+			}
 			cp += 1;
 			nr -= 1;
 		}

  reply	other threads:[~2009-09-07 21:55 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-09-07  9:13 linux-next: manual merge of the tty tree with the tree Stephen Rothwell
2009-09-07 18:22 ` Linus Torvalds
2009-09-07 21:55   ` Joe Peterson [this message]
2009-09-08 16:06     ` Greg KH
2009-09-09 21:05       ` Joe Peterson

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=4AA58160.7080908@skyrush.com \
    --to=joe@skyrush.com \
    --cc=greg@kroah.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-next@vger.kernel.org \
    --cc=sfr@canb.auug.org.au \
    --cc=torvalds@linux-foundation.org \
    /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).