patch-2.2.10 linux/drivers/char/n_hdlc.c
Next file: linux/drivers/char/pc110pad.c
Previous file: linux/drivers/char/cyclades.c
Back to the patch index
Back to the overall index
- Lines: 70
- Date:
Fri Jun 11 13:08:47 1999
- Orig file:
v2.2.9/linux/drivers/char/n_hdlc.c
- Orig date:
Mon Mar 29 11:09:11 1999
diff -u --recursive --new-file v2.2.9/linux/drivers/char/n_hdlc.c linux/drivers/char/n_hdlc.c
@@ -9,6 +9,7 @@
* Al Longyear <longyear@netcom.com>, Paul Mackerras <Paul.Mackerras@cs.anu.edu.au>
*
* Original release 01/11/99
+ * ==FILEDATE 19990524==
*
* This code is released under the GNU General Public License (GPL)
*
@@ -72,7 +73,7 @@
*/
#define HDLC_MAGIC 0x239e
-#define HDLC_VERSION "1.0"
+#define HDLC_VERSION "1.2"
#include <linux/version.h>
#include <linux/config.h>
@@ -813,6 +814,8 @@
{
struct n_hdlc *n_hdlc = tty2n_hdlc (tty);
int error = 0;
+ int count;
+ unsigned long flags;
if (debuglevel >= DEBUG_LEVEL_INFO)
printk("%s(%d)n_hdlc_tty_ioctl() called %d\n",
@@ -824,21 +827,29 @@
switch (cmd) {
case FIONREAD:
- {
- /* report count of read data available */
- /* in next available frame (if any) */
- int count;
- unsigned long flags;
- spin_lock_irqsave(&n_hdlc->rx_buf_list.spinlock,flags);
- if (n_hdlc->rx_buf_list.head)
- count = n_hdlc->rx_buf_list.head->count;
- else
- count = 0;
- spin_unlock_irqrestore(&n_hdlc->rx_buf_list.spinlock,flags);
- PUT_USER (error, count, (int *) arg);
- }
+ /* report count of read data available */
+ /* in next available frame (if any) */
+ spin_lock_irqsave(&n_hdlc->rx_buf_list.spinlock,flags);
+ if (n_hdlc->rx_buf_list.head)
+ count = n_hdlc->rx_buf_list.head->count;
+ else
+ count = 0;
+ spin_unlock_irqrestore(&n_hdlc->rx_buf_list.spinlock,flags);
+ PUT_USER (error, count, (int *) arg);
break;
-
+
+ case TIOCOUTQ:
+ /* get the pending tx byte count in the driver */
+ count = tty->driver.chars_in_buffer ?
+ tty->driver.chars_in_buffer(tty) : 0;
+ /* add size of next output frame in queue */
+ spin_lock_irqsave(&n_hdlc->tx_buf_list.spinlock,flags);
+ if (n_hdlc->tx_buf_list.head)
+ count += n_hdlc->tx_buf_list.head->count;
+ spin_unlock_irqrestore(&n_hdlc->tx_buf_list.spinlock,flags);
+ PUT_USER (error, count, (int*)arg);
+ break;
+
default:
error = n_tty_ioctl (tty, file, cmd, arg);
break;
FUNET's LINUX-ADM group, linux-adm@nic.funet.fi
TCL-scripts by Sam Shen (who was at: slshen@lbl.gov)