linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Paul Fulghum <paulkf@microgate.com>
To: Antonino Ingargiola <tritemio@gmail.com>
Cc: Alan Cox <alan@lxorguk.ukuu.org.uk>,
	linux-usb-users@lists.sourceforge.net,
	linux-kernel@vger.kernel.org
Subject: Re: [SOLVED] Serial buffer corruption [was Re: FTDI usb-serial possible bug]
Date: Fri, 04 May 2007 09:49:20 -0500	[thread overview]
Message-ID: <1178290160.3913.2.camel@amdx2.microgate.com> (raw)
In-Reply-To: <463B4988.9090005@microgate.com>

Here is a patch against 2.6.21 which flushes the tty flip buffer
on ioctl(TCFLSH) for input.

--- a/drivers/char/tty_io.c	2007-04-25 22:08:32.000000000 -0500
+++ b/drivers/char/tty_io.c	2007-05-04 09:30:01.000000000 -0500
@@ -365,6 +365,28 @@ static void tty_buffer_free(struct tty_s
 }
 
 /**
+ *	tty_buffer_flush		-	flush full tty buffers
+ *	@tty: tty to flush
+ *
+ *	flush all the buffers containing receive data
+ *
+ *	Locking: none
+ */
+
+static void tty_buffer_flush(struct tty_struct *tty)
+{
+	struct tty_buffer *thead;
+	unsigned long flags;
+
+	spin_lock_irqsave(&tty->buf.lock, flags);
+	while((thead = tty->buf.head) != NULL) {
+		tty->buf.head = thead->next;
+		tty_buffer_free(tty, thead);
+	}
+	spin_unlock_irqrestore(&tty->buf.lock, flags);
+}
+
+/**
  *	tty_buffer_find		-	find a free tty buffer
  *	@tty: tty owning the buffer
  *	@size: characters wanted
@@ -1240,6 +1262,7 @@ void tty_ldisc_flush(struct tty_struct *
 			ld->flush_buffer(tty);
 		tty_ldisc_deref(ld);
 	}
+	tty_buffer_flush(tty);
 }
 
 EXPORT_SYMBOL_GPL(tty_ldisc_flush);
@@ -3336,6 +3359,15 @@ int tty_ioctl(struct inode * inode, stru
 		case TIOCMBIC:
 		case TIOCMBIS:
 			return tty_tiocmset(tty, file, cmd, p);
+		case TCFLSH:
+			switch (arg) {
+			case TCIFLUSH:
+			case TCIOFLUSH:
+				/* flush tty buffer and allow ldisc to process ioctl */
+				tty_buffer_flush(tty);
+				break;
+			}
+			break;
 	}
 	if (tty->driver->ioctl) {
 		retval = (tty->driver->ioctl)(tty, file, cmd, arg);



  reply	other threads:[~2007-05-04 14:49 UTC|newest]

Thread overview: 59+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-05-04  8:38 [SOLVED] Serial buffer corruption [was Re: FTDI usb-serial possible bug] Antonino Ingargiola
2007-05-04  8:49 ` Oliver Neukum
     [not found]   ` <5486cca80705040229g53933671m658bd028cadca155@mail.gmail.com>
2007-05-04  9:33     ` Antonino Ingargiola
2007-05-04 13:41       ` Oliver Neukum
2007-05-04 14:45       ` Paul Fulghum
2007-05-04 14:56         ` Paul Fulghum
2007-05-04 14:49           ` Paul Fulghum [this message]
2007-05-04 16:04             ` Antonino Ingargiola
2007-05-04 16:56               ` Antonino Ingargiola
2007-05-04 18:02                 ` Paul Fulghum
2007-05-04 17:13                   ` Antonino Ingargiola
2007-05-04 17:20                     ` Paul Fulghum
2007-05-04 17:25                       ` Antonino Ingargiola
2007-05-04 17:41                         ` Paul Fulghum
2007-05-04 18:46                           ` Antonino Ingargiola
2007-05-04 19:06                             ` Antonino Ingargiola
2007-05-04 19:49                               ` Paul Fulghum
2007-05-04 21:21                                 ` Antonino Ingargiola
2007-05-04 10:57                                   ` Paul Fulghum
2007-05-05  9:53                                     ` Antonino Ingargiola
2007-05-05  9:56                                       ` Antonino Ingargiola
2007-05-05 10:19                                       ` Antonino Ingargiola
2007-05-04 23:30                                   ` Paul Fulghum
2007-05-05  8:26                                     ` Paul Fulghum
2007-05-05 15:11                                       ` Antonino Ingargiola
2007-05-05 16:43                                         ` Paul Fulghum
2007-05-05 16:08                                           ` Paul Fulghum
2007-05-05 16:15                                             ` Paul Fulghum
2007-05-05 16:26                                               ` Antonino Ingargiola
2007-05-05 16:58                                                 ` Antonino Ingargiola
2007-05-05 17:04                                                   ` Paul Fulghum
2007-05-05 18:08                                                     ` Antonino Ingargiola
2007-05-05 18:35                                                       ` Oliver Neukum
2007-05-06  7:06                                                         ` Antonino Ingargiola
2007-05-09  9:53                                                           ` Antonino Ingargiola
2007-05-09 10:42                                                         ` Gene Heskett
2007-05-09 11:02                                                         ` Gene Heskett
2007-05-09 12:00                                                         ` Gene Heskett
2007-05-05 16:36                                             ` Alan Cox
2007-05-05 16:54                                               ` Oliver Neukum
2007-05-05 21:49                                                 ` Alan Cox
2007-05-05 18:07                                               ` Oliver Neukum
2007-05-05 21:52                                                 ` Alan Cox
2007-05-06  7:29                                                   ` Antonino Ingargiola
2007-05-06 12:28                                                     ` Alan Cox
2007-05-06 16:39                                                       ` Antonino Ingargiola
2007-05-06 16:46                                                         ` Alan Cox
2007-05-06 21:51                                                       ` [Linux-usb-users] " Alan Stern
2007-05-07  8:07                                                         ` Antonino Ingargiola
2007-05-06 14:35                                                     ` Paul Fulghum
2007-05-07  9:11                                                       ` [Linux-usb-users] " Diego Zuccato
2007-05-07 16:34                                                         ` Alan Stern
2007-05-07 16:51                                                           ` Oliver Neukum
2007-05-07 18:25                                                             ` Alan Stern
2007-05-07 17:58                                                           ` Stephen Beaver
2007-05-06 14:49                                                   ` Paul Fulghum
2007-05-05 16:46                                             ` Oliver Neukum
2007-05-05 16:56                                               ` Paul Fulghum
2007-05-05 17:09                                                 ` Antonino Ingargiola

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=1178290160.3913.2.camel@amdx2.microgate.com \
    --to=paulkf@microgate.com \
    --cc=alan@lxorguk.ukuu.org.uk \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-usb-users@lists.sourceforge.net \
    --cc=tritemio@gmail.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).