mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH] Combine two one-character CR-LF writes into one two-character write for O_ONLCR
@ 2009-08-13 17:54 David VomLehn
  2009-08-13 18:15 ` Greg KH
  2009-08-13 19:50 ` Alan Cox
  0 siblings, 2 replies; 8+ messages in thread
From: David VomLehn @ 2009-08-13 17:54 UTC (permalink / raw)
  To: linux-kernel; +Cc: greg, linux-usb

When handling output of a newline character in O_ONLCR mode, the n_tty.c
do_output_char() function uses the struct tty_operations function write_room()
to determine whether it is possible to write two characters. It uses
tty_put_char() for each character which, for the USB generic serial driver,
translates into a write() for each character. For the USB generic serial
driver the value returned by write_room() only applies to the next write().
A second write() done in quick succession will fail because the write URB
buffer is still busy from the first write(). In this case, it results in the
printing of a carriage return without the following line feed.

This patch combines the two write() calls into a single, two-character, write().

Signed-off-by: David VomLehn
---
 drivers/char/n_tty.c |    8 ++++----
 1 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/drivers/char/n_tty.c b/drivers/char/n_tty.c
index 973be2f..bf06c61 100644
--- a/drivers/char/n_tty.c
+++ b/drivers/char/n_tty.c
@@ -297,12 +297,12 @@ static int do_output_char(unsigned char c, struct tty_struct *tty, int space)
 		if (O_ONLRET(tty))
 			tty->column = 0;
 		if (O_ONLCR(tty)) {
-			if (space < 2)
+			static const char crlf[] = {'\r', '\n'};
+			if (space < ARRAY_SIZE(crlf))
 				return -1;
 			tty->canon_column = tty->column = 0;
-			tty_put_char(tty, '\r');
-			tty_put_char(tty, c);
-			return 2;
+			tty->ops->write(tty, crlf, ARRAY_SIZE(crlf));
+			return ARRAY_SIZE(crlf);
 		}
 		tty->canon_column = tty->column;
 		break;

^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2009-08-13 21:30 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2009-08-13 17:54 [PATCH] Combine two one-character CR-LF writes into one two-character write for O_ONLCR David VomLehn
2009-08-13 18:15 ` Greg KH
2009-08-13 18:42   ` David VomLehn
2009-08-13 19:47     ` Alan Cox
2009-08-13 19:50 ` Alan Cox
2009-08-13 19:55   ` David VomLehn
2009-08-13 19:58     ` Alan Cox
2009-08-13 21:27     ` Greg KH

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®