All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] n_tty: fix .chars_in_buffer confusion
@ 2013-05-18 13:20 Stas Sergeev
  0 siblings, 0 replies; only message in thread
From: Stas Sergeev @ 2013-05-18 13:20 UTC (permalink / raw)
  To: Linux kernel; +Cc: Alan Cox

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

Hi.

I think there is a confusion with n_tty_chars_in_buffer(): it
calculates the amount of input chars, but is used as a
.chars_in_buffer member of tty_ldisc_ops, which, AFAIK,
should calculate the amount of _output_ chars buffered.

Here is the patch that changes this.
Since it doesn't fix any problem I can practically observe,
the chances are high that I am missing something obvious.

Can someone please take a look if there is really a bug here?

[-- Attachment #2: 0001-n_tty-fix-.chars_in_buffer-confusion.patch --]
[-- Type: text/x-patch, Size: 2330 bytes --]

>From cea19eda592e61db780e3ce1a7bf9a5f0899a0fc Mon Sep 17 00:00:00 2001
From: Stas Sergeev <stsp@users.sourceforge.net>
Date: Sat, 18 May 2013 15:06:39 +0400
Subject: [PATCH] n_tty: fix .chars_in_buffer confusion

n_tty_chars_in_buffer() was calculating the amount of input
chars, not output chars. It therefore should not be used as
a .chars_in_buffer member.
This patch removes it from tty_ldisc_ops and renames to
chars_in_input_buffer()

Signed-off-by: Stas Sergeev <stsp@users.sourceforge.net>
---
 drivers/tty/n_tty.c | 9 ++++-----
 1 file changed, 4 insertions(+), 5 deletions(-)

diff --git a/drivers/tty/n_tty.c b/drivers/tty/n_tty.c
index 3f228c9..0567235 100644
--- a/drivers/tty/n_tty.c
+++ b/drivers/tty/n_tty.c
@@ -253,7 +253,7 @@ static void n_tty_flush_buffer(struct tty_struct *tty)
 }
 
 /**
- *	n_tty_chars_in_buffer	-	report available bytes
+ *	chars_in_input_buffer	-	report available bytes
  *	@tty: tty device
  *
  *	Report the number of characters buffered to be delivered to user
@@ -262,7 +262,7 @@ static void n_tty_flush_buffer(struct tty_struct *tty)
  *	Locking: read_lock
  */
 
-static ssize_t n_tty_chars_in_buffer(struct tty_struct *tty)
+static ssize_t chars_in_input_buffer(struct tty_struct *tty)
 {
 	struct n_tty_data *ldata = tty->disc_data;
 	unsigned long flags;
@@ -1977,7 +1977,7 @@ do_it_again:
 		}
 
 		/* If there is enough space in the read buffer now, let the
-		 * low-level driver know. We use n_tty_chars_in_buffer() to
+		 * low-level driver know. We use chars_in_input_buffer() to
 		 * check the buffer, as it now knows about canonical mode.
 		 * Otherwise, if the driver is throttled and the line is
 		 * longer than TTY_THRESHOLD_UNTHROTTLE in canonical mode,
@@ -1985,7 +1985,7 @@ do_it_again:
 		 */
 		while (1) {
 			tty_set_flow_change(tty, TTY_UNTHROTTLE_SAFE);
-			if (n_tty_chars_in_buffer(tty) > TTY_THRESHOLD_UNTHROTTLE)
+			if (chars_in_input_buffer(tty) > TTY_THRESHOLD_UNTHROTTLE)
 				break;
 			if (!tty->count)
 				break;
@@ -2206,7 +2206,6 @@ struct tty_ldisc_ops tty_ldisc_N_TTY = {
 	.open            = n_tty_open,
 	.close           = n_tty_close,
 	.flush_buffer    = n_tty_flush_buffer,
-	.chars_in_buffer = n_tty_chars_in_buffer,
 	.read            = n_tty_read,
 	.write           = n_tty_write,
 	.ioctl           = n_tty_ioctl,
-- 
1.7.11.7


^ permalink raw reply related	[flat|nested] only message in thread

only message in thread, other threads:[~2013-05-18 13:22 UTC | newest]

Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-05-18 13:20 [PATCH] n_tty: fix .chars_in_buffer confusion Stas Sergeev

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.