public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Stas Sergeev <stsp@list.ru>
To: Linux kernel <linux-kernel@vger.kernel.org>
Cc: Alan Cox <alan@lxorguk.ukuu.org.uk>
Subject: [PATCH] n_tty: fix .chars_in_buffer confusion
Date: Sat, 18 May 2013 17:20:13 +0400	[thread overview]
Message-ID: <5197800D.60601@list.ru> (raw)

[-- 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


                 reply	other threads:[~2013-05-18 13:22 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

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=5197800D.60601@list.ru \
    --to=stsp@list.ru \
    --cc=alan@lxorguk.ukuu.org.uk \
    --cc=linux-kernel@vger.kernel.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