aboutsummaryrefslogtreecommitdiffstats
path: root/drivers
diff options
context:
space:
mode:
authorPaul Fulghum <paulkf@microgate.com>2009-06-22 13:42:56 -0400
committerLinus Torvalds <torvalds@linux-foundation.org>2009-06-22 14:32:24 -0400
commitbe10eb7589337e5defbe214dae038a53dd21add8 (patch)
tree2b1d131baa30260531b51c3288d3cfef7deaf7ed /drivers
parent90ceb9644d7cdec00a90255473359a7e2bb537a9 (diff)
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: Paul Fulghum <paulkf@microgate.com> Signed-off-by: Alan Cox <alan@linux.intel.com> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'drivers')
-rw-r--r--drivers/char/n_hdlc.c46
1 files changed, 37 insertions, 9 deletions
diff --git a/drivers/char/n_hdlc.c b/drivers/char/n_hdlc.c
index 461ece591a5b..1c43c8cdee25 100644
--- a/drivers/char/n_hdlc.c
+++ b/drivers/char/n_hdlc.c
@@ -10,7 +10,6 @@
10 * Paul Mackerras <Paul.Mackerras@cs.anu.edu.au> 10 * Paul Mackerras <Paul.Mackerras@cs.anu.edu.au>
11 * 11 *
12 * Original release 01/11/99 12 * Original release 01/11/99
13 * $Id: n_hdlc.c,v 4.8 2003/05/06 21:18:51 paulkf Exp $
14 * 13 *
15 * This code is released under the GNU General Public License (GPL) 14 * This code is released under the GNU General Public License (GPL)
16 * 15 *
@@ -79,7 +78,6 @@
79 */ 78 */
80 79
81#define HDLC_MAGIC 0x239e 80#define HDLC_MAGIC 0x239e
82#define HDLC_VERSION "$Revision: 4.8 $"
83 81
84#include <linux/module.h> 82#include <linux/module.h>
85#include <linux/init.h> 83#include <linux/init.h>
@@ -114,7 +112,7 @@
114#define MAX_HDLC_FRAME_SIZE 65535 112#define MAX_HDLC_FRAME_SIZE 65535
115#define DEFAULT_RX_BUF_COUNT 10 113#define DEFAULT_RX_BUF_COUNT 10
116#define MAX_RX_BUF_COUNT 60 114#define MAX_RX_BUF_COUNT 60
117#define DEFAULT_TX_BUF_COUNT 1 115#define DEFAULT_TX_BUF_COUNT 3
118 116
119struct n_hdlc_buf { 117struct n_hdlc_buf {
120 struct n_hdlc_buf *link; 118 struct n_hdlc_buf *link;
@@ -199,6 +197,31 @@ static void n_hdlc_tty_wakeup(struct tty_struct *tty);
199#define tty2n_hdlc(tty) ((struct n_hdlc *) ((tty)->disc_data)) 197#define tty2n_hdlc(tty) ((struct n_hdlc *) ((tty)->disc_data))
200#define n_hdlc2tty(n_hdlc) ((n_hdlc)->tty) 198#define n_hdlc2tty(n_hdlc) ((n_hdlc)->tty)
201 199
200static void flush_rx_queue(struct tty_struct *tty)
201{
202 struct n_hdlc *n_hdlc = tty2n_hdlc(tty);
203 struct n_hdlc_buf *buf;
204
205 while ((buf = n_hdlc_buf_get(&n_hdlc->rx_buf_list)))
206 n_hdlc_buf_put(&n_hdlc->rx_free_buf_list, buf);
207}
208
209static void flush_tx_queue(struct tty_struct *tty)
210{
211 struct n_hdlc *n_hdlc = tty2n_hdlc(tty);
212 struct n_hdlc_buf *buf;
213 unsigned long flags;
214
215 while ((buf = n_hdlc_buf_get(&n_hdlc->tx_buf_list)))
216 n_hdlc_buf_put(&n_hdlc->tx_free_buf_list, buf);
217 spin_lock_irqsave(&n_hdlc->tx_buf_list.spinlock, flags);
218 if (n_hdlc->tbuf) {
219 n_hdlc_buf_put(&n_hdlc->tx_free_buf_list, n_hdlc->tbuf);
220 n_hdlc->tbuf = NULL;
221 }
222 spin_unlock_irqrestore(&n_hdlc->tx_buf_list.spinlock, flags);
223}
224
202static struct tty_ldisc_ops n_hdlc_ldisc = { 225static struct tty_ldisc_ops n_hdlc_ldisc = {
203 .owner = THIS_MODULE, 226 .owner = THIS_MODULE,
204 .magic = TTY_LDISC_MAGIC, 227 .magic = TTY_LDISC_MAGIC,
@@ -211,6 +234,7 @@ static struct tty_ldisc_ops n_hdlc_ldisc = {
211 .poll = n_hdlc_tty_poll, 234 .poll = n_hdlc_tty_poll,
212 .receive_buf = n_hdlc_tty_receive, 235 .receive_buf = n_hdlc_tty_receive,
213 .write_wakeup = n_hdlc_tty_wakeup, 236 .write_wakeup = n_hdlc_tty_wakeup,
237 .flush_buffer = flush_rx_queue,
214}; 238};
215 239
216/** 240/**
@@ -341,10 +365,7 @@ static int n_hdlc_tty_open (struct tty_struct *tty)
341 set_bit(TTY_NO_WRITE_SPLIT,&tty->flags); 365 set_bit(TTY_NO_WRITE_SPLIT,&tty->flags);
342#endif 366#endif
343 367
344 /* Flush any pending characters in the driver and discipline. */ 368 /* flush receive data from driver */
345 if (tty->ldisc->ops->flush_buffer)
346 tty->ldisc->ops->flush_buffer(tty);
347
348 tty_driver_flush_buffer(tty); 369 tty_driver_flush_buffer(tty);
349 370
350 if (debuglevel >= DEBUG_LEVEL_INFO) 371 if (debuglevel >= DEBUG_LEVEL_INFO)
@@ -763,6 +784,14 @@ static int n_hdlc_tty_ioctl(struct tty_struct *tty, struct file *file,
763 error = put_user(count, (int __user *)arg); 784 error = put_user(count, (int __user *)arg);
764 break; 785 break;
765 786
787 case TCFLSH:
788 switch (arg) {
789 case TCIOFLUSH:
790 case TCOFLUSH:
791 flush_tx_queue(tty);
792 }
793 /* fall through to default */
794
766 default: 795 default:
767 error = n_tty_ioctl_helper(tty, file, cmd, arg); 796 error = n_tty_ioctl_helper(tty, file, cmd, arg);
768 break; 797 break;
@@ -919,8 +948,7 @@ static struct n_hdlc_buf* n_hdlc_buf_get(struct n_hdlc_buf_list *list)
919} /* end of n_hdlc_buf_get() */ 948} /* end of n_hdlc_buf_get() */
920 949
921static char hdlc_banner[] __initdata = 950static char hdlc_banner[] __initdata =
922 KERN_INFO "HDLC line discipline: version " HDLC_VERSION 951 KERN_INFO "HDLC line discipline maxframe=%u\n";
923 ", maxframe=%u\n";
924static char hdlc_register_ok[] __initdata = 952static char hdlc_register_ok[] __initdata =
925 KERN_INFO "N_HDLC line discipline registered.\n"; 953 KERN_INFO "N_HDLC line discipline registered.\n";
926static char hdlc_register_fail[] __initdata = 954static char hdlc_register_fail[] __initdata =