bonding: fix potential deadlock in bond_uninit()
[safe/jmp/linux-2.6] / drivers / net / ppp_async.c
index f1a52de..6a375ea 100644 (file)
@@ -36,7 +36,7 @@
 
 #define PPP_VERSION    "2.4.2"
 
-#define OBUFSIZE       256
+#define OBUFSIZE       4096
 
 /* Structure for storing local state. */
 struct asyncppp {
@@ -157,6 +157,7 @@ ppp_asynctty_open(struct tty_struct *tty)
 {
        struct asyncppp *ap;
        int err;
+       int speed;
 
        if (tty->ops->write == NULL)
                return -EOPNOTSUPP;
@@ -187,6 +188,8 @@ ppp_asynctty_open(struct tty_struct *tty)
        ap->chan.private = ap;
        ap->chan.ops = &async_ops;
        ap->chan.mtu = PPP_MRU;
+       speed = tty_get_baud_rate(tty);
+       ap->chan.speed = speed;
        err = ppp_register_channel(&ap->chan);
        if (err)
                goto out_free;
@@ -233,11 +236,9 @@ ppp_asynctty_close(struct tty_struct *tty)
        tasklet_kill(&ap->tsk);
 
        ppp_unregister_channel(&ap->chan);
-       if (ap->rpkt)
-               kfree_skb(ap->rpkt);
+       kfree_skb(ap->rpkt);
        skb_queue_purge(&ap->rqueue);
-       if (ap->tpkt)
-               kfree_skb(ap->tpkt);
+       kfree_skb(ap->tpkt);
        kfree(ap);
 }
 
@@ -293,9 +294,6 @@ ppp_asynctty_ioctl(struct tty_struct *tty, struct file *file,
        err = -EFAULT;
        switch (cmd) {
        case PPPIOCGCHAN:
-               err = -ENXIO;
-               if (!ap)
-                       break;
                err = -EFAULT;
                if (put_user(ppp_channel_index(&ap->chan), p))
                        break;
@@ -303,9 +301,6 @@ ppp_asynctty_ioctl(struct tty_struct *tty, struct file *file,
                break;
 
        case PPPIOCGUNIT:
-               err = -ENXIO;
-               if (!ap)
-                       break;
                err = -EFAULT;
                if (put_user(ppp_unit_number(&ap->chan), p))
                        break;
@@ -342,10 +337,7 @@ ppp_asynctty_poll(struct tty_struct *tty, struct file *file, poll_table *wait)
        return 0;
 }
 
-/*
- * This can now be called from hard interrupt level as well
- * as soft interrupt level or mainline.
- */
+/* May sleep, don't call from interrupt level or with interrupts disabled */
 static void
 ppp_asynctty_receive(struct tty_struct *tty, const unsigned char *buf,
                  char *cflags, int count)
@@ -378,7 +370,7 @@ ppp_asynctty_wakeup(struct tty_struct *tty)
 }
 
 
-static struct tty_ldisc ppp_ldisc = {
+static struct tty_ldisc_ops ppp_ldisc = {
        .owner  = THIS_MODULE,
        .magic  = TTY_LDISC_MAGIC,
        .name   = "ppp",
@@ -566,8 +558,8 @@ ppp_async_encode(struct asyncppp *ap)
                 * Start of a new packet - insert the leading FLAG
                 * character if necessary.
                 */
-               if (islcp || flag_time == 0
-                   || time_after_eq(jiffies, ap->last_xmit + flag_time))
+               if (islcp || flag_time == 0 ||
+                   time_after_eq(jiffies, ap->last_xmit + flag_time))
                        *buf++ = PPP_FLAG;
                ap->last_xmit = jiffies;
                fcs = PPP_INITFCS;
@@ -704,8 +696,8 @@ ppp_async_push(struct asyncppp *ap)
                 */
                clear_bit(XMIT_BUSY, &ap->xmit_flags);
                /* any more work to do? if not, exit the loop */
-               if (!(test_bit(XMIT_WAKEUP, &ap->xmit_flags)
-                     || (!tty_stuffed && ap->tpkt)))
+               if (!(test_bit(XMIT_WAKEUP, &ap->xmit_flags) ||
+                     (!tty_stuffed && ap->tpkt)))
                        break;
                /* more work to do, see if we can do it now */
                if (test_and_set_bit(XMIT_BUSY, &ap->xmit_flags))
@@ -762,8 +754,8 @@ scan_ordinary(struct asyncppp *ap, const unsigned char *buf, int count)
 
        for (i = 0; i < count; ++i) {
                c = buf[i];
-               if (c == PPP_ESCAPE || c == PPP_FLAG
-                   || (c < 0x20 && (ap->raccm & (1 << c)) != 0))
+               if (c == PPP_ESCAPE || c == PPP_FLAG ||
+                   (c < 0x20 && (ap->raccm & (1 << c)) != 0))
                        break;
        }
        return i;