]> pilppa.org Git - linux-2.6-omap-h63xx.git/blobdiff - drivers/char/n_hdlc.c
Merge branch 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/roland...
[linux-2.6-omap-h63xx.git] / drivers / char / n_hdlc.c
index a133a62f3d5528a1ad93d6d2ee181cdaaebac295..e8332f305d72a77b9e8d0579b8b222d5e66ea0ea 100644 (file)
@@ -81,7 +81,6 @@
 #define HDLC_MAGIC 0x239e
 #define HDLC_VERSION "$Revision: 4.8 $"
 
-#include <linux/config.h>
 #include <linux/module.h>
 #include <linux/init.h>
 #include <linux/kernel.h>
@@ -191,7 +190,6 @@ static unsigned int n_hdlc_tty_poll(struct tty_struct *tty, struct file *filp,
                                    poll_table *wait);
 static int n_hdlc_tty_open(struct tty_struct *tty);
 static void n_hdlc_tty_close(struct tty_struct *tty);
-static int n_hdlc_tty_room(struct tty_struct *tty);
 static void n_hdlc_tty_receive(struct tty_struct *tty, const __u8 *cp,
                               char *fp, int count);
 static void n_hdlc_tty_wakeup(struct tty_struct *tty);
@@ -212,7 +210,6 @@ static struct tty_ldisc n_hdlc_ldisc = {
        .ioctl          = n_hdlc_tty_ioctl,
        .poll           = n_hdlc_tty_poll,
        .receive_buf    = n_hdlc_tty_receive,
-       .receive_room   = n_hdlc_tty_room,
        .write_wakeup   = n_hdlc_tty_wakeup,
 };
 
@@ -337,6 +334,7 @@ static int n_hdlc_tty_open (struct tty_struct *tty)
                
        tty->disc_data = n_hdlc;
        n_hdlc->tty    = tty;
+       tty->receive_room = 65536;
        
 #if defined(TTY_NO_WRITE_SPLIT)
        /* change tty_io write() to not split large writes into 8K chunks */
@@ -402,7 +400,12 @@ static void n_hdlc_send_frames(struct n_hdlc *n_hdlc, struct tty_struct *tty)
                /* Send the next block of data to device */
                tty->flags |= (1 << TTY_DO_WRITE_WAKEUP);
                actual = tty->driver->write(tty, tbuf->buf, tbuf->count);
-                   
+
+               /* rollback was possible and has been done */
+               if (actual == -ERESTARTSYS) {
+                       n_hdlc->tbuf = tbuf;
+                       break;
+               }
                /* if transmit error, throw frame away by */
                /* pretending it was accepted by driver */
                if (actual < 0)
@@ -477,22 +480,6 @@ static void n_hdlc_tty_wakeup(struct tty_struct *tty)
                
 }      /* end of n_hdlc_tty_wakeup() */
 
-/**
- * n_hdlc_tty_room - Return the amount of space left in the receiver's buffer
- * @tty        - pointer to associated tty instance data
- *
- * Callback function from tty driver. Return the amount of space left in the
- * receiver's buffer to decide if remote transmitter is to be throttled.
- */
-static int n_hdlc_tty_room(struct tty_struct *tty)
-{
-       if (debuglevel >= DEBUG_LEVEL_INFO)     
-               printk("%s(%d)n_hdlc_tty_room() called\n",__FILE__,__LINE__);
-       /* always return a larger number to prevent */
-       /* throttling of remote transmitter. */
-       return 65536;
-}      /* end of n_hdlc_tty_root() */
-
 /**
  * n_hdlc_tty_receive - Called by tty driver when receive data is available
  * @tty        - pointer to tty instance data
@@ -798,13 +785,14 @@ static unsigned int n_hdlc_tty_poll(struct tty_struct *tty, struct file *filp,
                poll_wait(filp, &tty->write_wait, wait);
 
                /* set bits for operations that won't block */
-               if(n_hdlc->rx_buf_list.head)
+               if (n_hdlc->rx_buf_list.head)
                        mask |= POLLIN | POLLRDNORM;    /* readable */
                if (test_bit(TTY_OTHER_CLOSED, &tty->flags))
                        mask |= POLLHUP;
-               if(tty_hung_up_p(filp))
+               if (tty_hung_up_p(filp))
                        mask |= POLLHUP;
-               if(n_hdlc->tx_free_buf_list.head)
+               if (!tty_is_writelocked(tty) &&
+                               n_hdlc->tx_free_buf_list.head)
                        mask |= POLLOUT | POLLWRNORM;   /* writable */
        }
        return mask;
@@ -879,7 +867,7 @@ static void n_hdlc_buf_put(struct n_hdlc_buf_list *list,
        spin_lock_irqsave(&list->spinlock,flags);
        
        buf->link=NULL;
-       if(list->tail)
+       if (list->tail)
                list->tail->link = buf;
        else
                list->head = buf;