Commit be10eb75 authored by Paul Fulghum's avatar Paul Fulghum Committed by Linus Torvalds

tty: n_hdlc add buffer flushing

Add flush_buffer tty callback to flush rx buffers.
Add TCFLSH ioctl processing to flush tx buffers.
Increase default tx buffers from 1 to 3.
Remove unneeded flush_buffer call in open callback.
Remove vendor specific CVS version string.
Signed-off-by: default avatarPaul Fulghum <paulkf@microgate.com>
Signed-off-by: default avatarAlan Cox <alan@linux.intel.com>
Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
parent 90ceb964
...@@ -10,7 +10,6 @@ ...@@ -10,7 +10,6 @@
* Paul Mackerras <Paul.Mackerras@cs.anu.edu.au> * Paul Mackerras <Paul.Mackerras@cs.anu.edu.au>
* *
* Original release 01/11/99 * Original release 01/11/99
* $Id: n_hdlc.c,v 4.8 2003/05/06 21:18:51 paulkf Exp $
* *
* This code is released under the GNU General Public License (GPL) * This code is released under the GNU General Public License (GPL)
* *
...@@ -79,7 +78,6 @@ ...@@ -79,7 +78,6 @@
*/ */
#define HDLC_MAGIC 0x239e #define HDLC_MAGIC 0x239e
#define HDLC_VERSION "$Revision: 4.8 $"
#include <linux/module.h> #include <linux/module.h>
#include <linux/init.h> #include <linux/init.h>
...@@ -114,7 +112,7 @@ ...@@ -114,7 +112,7 @@
#define MAX_HDLC_FRAME_SIZE 65535 #define MAX_HDLC_FRAME_SIZE 65535
#define DEFAULT_RX_BUF_COUNT 10 #define DEFAULT_RX_BUF_COUNT 10
#define MAX_RX_BUF_COUNT 60 #define MAX_RX_BUF_COUNT 60
#define DEFAULT_TX_BUF_COUNT 1 #define DEFAULT_TX_BUF_COUNT 3
struct n_hdlc_buf { struct n_hdlc_buf {
struct n_hdlc_buf *link; struct n_hdlc_buf *link;
...@@ -199,6 +197,31 @@ static void n_hdlc_tty_wakeup(struct tty_struct *tty); ...@@ -199,6 +197,31 @@ static void n_hdlc_tty_wakeup(struct tty_struct *tty);
#define tty2n_hdlc(tty) ((struct n_hdlc *) ((tty)->disc_data)) #define tty2n_hdlc(tty) ((struct n_hdlc *) ((tty)->disc_data))
#define n_hdlc2tty(n_hdlc) ((n_hdlc)->tty) #define n_hdlc2tty(n_hdlc) ((n_hdlc)->tty)
static void flush_rx_queue(struct tty_struct *tty)
{
struct n_hdlc *n_hdlc = tty2n_hdlc(tty);
struct n_hdlc_buf *buf;
while ((buf = n_hdlc_buf_get(&n_hdlc->rx_buf_list)))
n_hdlc_buf_put(&n_hdlc->rx_free_buf_list, buf);
}
static void flush_tx_queue(struct tty_struct *tty)
{
struct n_hdlc *n_hdlc = tty2n_hdlc(tty);
struct n_hdlc_buf *buf;
unsigned long flags;
while ((buf = n_hdlc_buf_get(&n_hdlc->tx_buf_list)))
n_hdlc_buf_put(&n_hdlc->tx_free_buf_list, buf);
spin_lock_irqsave(&n_hdlc->tx_buf_list.spinlock, flags);
if (n_hdlc->tbuf) {
n_hdlc_buf_put(&n_hdlc->tx_free_buf_list, n_hdlc->tbuf);
n_hdlc->tbuf = NULL;
}
spin_unlock_irqrestore(&n_hdlc->tx_buf_list.spinlock, flags);
}
static struct tty_ldisc_ops n_hdlc_ldisc = { static struct tty_ldisc_ops n_hdlc_ldisc = {
.owner = THIS_MODULE, .owner = THIS_MODULE,
.magic = TTY_LDISC_MAGIC, .magic = TTY_LDISC_MAGIC,
...@@ -211,6 +234,7 @@ static struct tty_ldisc_ops n_hdlc_ldisc = { ...@@ -211,6 +234,7 @@ static struct tty_ldisc_ops n_hdlc_ldisc = {
.poll = n_hdlc_tty_poll, .poll = n_hdlc_tty_poll,
.receive_buf = n_hdlc_tty_receive, .receive_buf = n_hdlc_tty_receive,
.write_wakeup = n_hdlc_tty_wakeup, .write_wakeup = n_hdlc_tty_wakeup,
.flush_buffer = flush_rx_queue,
}; };
/** /**
...@@ -341,10 +365,7 @@ static int n_hdlc_tty_open (struct tty_struct *tty) ...@@ -341,10 +365,7 @@ static int n_hdlc_tty_open (struct tty_struct *tty)
set_bit(TTY_NO_WRITE_SPLIT,&tty->flags); set_bit(TTY_NO_WRITE_SPLIT,&tty->flags);
#endif #endif
/* Flush any pending characters in the driver and discipline. */ /* flush receive data from driver */
if (tty->ldisc->ops->flush_buffer)
tty->ldisc->ops->flush_buffer(tty);
tty_driver_flush_buffer(tty); tty_driver_flush_buffer(tty);
if (debuglevel >= DEBUG_LEVEL_INFO) if (debuglevel >= DEBUG_LEVEL_INFO)
...@@ -763,6 +784,14 @@ static int n_hdlc_tty_ioctl(struct tty_struct *tty, struct file *file, ...@@ -763,6 +784,14 @@ static int n_hdlc_tty_ioctl(struct tty_struct *tty, struct file *file,
error = put_user(count, (int __user *)arg); error = put_user(count, (int __user *)arg);
break; break;
case TCFLSH:
switch (arg) {
case TCIOFLUSH:
case TCOFLUSH:
flush_tx_queue(tty);
}
/* fall through to default */
default: default:
error = n_tty_ioctl_helper(tty, file, cmd, arg); error = n_tty_ioctl_helper(tty, file, cmd, arg);
break; break;
...@@ -919,8 +948,7 @@ static struct n_hdlc_buf* n_hdlc_buf_get(struct n_hdlc_buf_list *list) ...@@ -919,8 +948,7 @@ static struct n_hdlc_buf* n_hdlc_buf_get(struct n_hdlc_buf_list *list)
} /* end of n_hdlc_buf_get() */ } /* end of n_hdlc_buf_get() */
static char hdlc_banner[] __initdata = static char hdlc_banner[] __initdata =
KERN_INFO "HDLC line discipline: version " HDLC_VERSION KERN_INFO "HDLC line discipline maxframe=%u\n";
", maxframe=%u\n";
static char hdlc_register_ok[] __initdata = static char hdlc_register_ok[] __initdata =
KERN_INFO "N_HDLC line discipline registered.\n"; KERN_INFO "N_HDLC line discipline registered.\n";
static char hdlc_register_fail[] __initdata = static char hdlc_register_fail[] __initdata =
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment