Merge branch 'release' of git://git.kernel.org/pub/scm/linux/kernel/git/aegl/linux-2.6
[pandora-kernel.git] / drivers / net / ppp_async.c
index 8d278c8..451bdb5 100644 (file)
@@ -158,9 +158,12 @@ ppp_asynctty_open(struct tty_struct *tty)
        struct asyncppp *ap;
        int err;
 
+       if (tty->ops->write == NULL)
+               return -EOPNOTSUPP;
+
        err = -ENOMEM;
        ap = kzalloc(sizeof(*ap), GFP_KERNEL);
-       if (ap == 0)
+       if (!ap)
                goto out;
 
        /* initialize the asyncppp structure */
@@ -215,7 +218,7 @@ ppp_asynctty_close(struct tty_struct *tty)
        ap = tty->disc_data;
        tty->disc_data = NULL;
        write_unlock_irq(&disc_data_lock);
-       if (ap == 0)
+       if (!ap)
                return;
 
        /*
@@ -230,10 +233,10 @@ ppp_asynctty_close(struct tty_struct *tty)
        tasklet_kill(&ap->tsk);
 
        ppp_unregister_channel(&ap->chan);
-       if (ap->rpkt != 0)
+       if (ap->rpkt)
                kfree_skb(ap->rpkt);
        skb_queue_purge(&ap->rqueue);
-       if (ap->tpkt != 0)
+       if (ap->tpkt)
                kfree_skb(ap->tpkt);
        kfree(ap);
 }
@@ -285,13 +288,13 @@ ppp_asynctty_ioctl(struct tty_struct *tty, struct file *file,
        int err, val;
        int __user *p = (int __user *)arg;
 
-       if (ap == 0)
+       if (!ap)
                return -ENXIO;
        err = -EFAULT;
        switch (cmd) {
        case PPPIOCGCHAN:
                err = -ENXIO;
-               if (ap == 0)
+               if (!ap)
                        break;
                err = -EFAULT;
                if (put_user(ppp_channel_index(&ap->chan), p))
@@ -301,7 +304,7 @@ ppp_asynctty_ioctl(struct tty_struct *tty, struct file *file,
 
        case PPPIOCGUNIT:
                err = -ENXIO;
-               if (ap == 0)
+               if (!ap)
                        break;
                err = -EFAULT;
                if (put_user(ppp_unit_number(&ap->chan), p))
@@ -350,7 +353,7 @@ ppp_asynctty_receive(struct tty_struct *tty, const unsigned char *buf,
        struct asyncppp *ap = ap_get(tty);
        unsigned long flags;
 
-       if (ap == 0)
+       if (!ap)
                return;
        spin_lock_irqsave(&ap->recv_lock, flags);
        ppp_async_input(ap, buf, cflags, count);
@@ -358,9 +361,7 @@ ppp_asynctty_receive(struct tty_struct *tty, const unsigned char *buf,
        if (!skb_queue_empty(&ap->rqueue))
                tasklet_schedule(&ap->tsk);
        ap_put(ap);
-       if (test_and_clear_bit(TTY_THROTTLED, &tty->flags)
-           && tty->driver->unthrottle)
-               tty->driver->unthrottle(tty);
+       tty_unthrottle(tty);
 }
 
 static void
@@ -369,7 +370,7 @@ ppp_asynctty_wakeup(struct tty_struct *tty)
        struct asyncppp *ap = ap_get(tty);
 
        clear_bit(TTY_DO_WRITE_WAKEUP, &tty->flags);
-       if (ap == 0)
+       if (!ap)
                return;
        set_bit(XMIT_WAKEUP, &ap->xmit_flags);
        tasklet_schedule(&ap->tsk);
@@ -377,7 +378,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",
@@ -676,7 +677,7 @@ ppp_async_push(struct asyncppp *ap)
                if (!tty_stuffed && ap->optr < ap->olim) {
                        avail = ap->olim - ap->optr;
                        set_bit(TTY_DO_WRITE_WAKEUP, &tty->flags);
-                       sent = tty->driver->write(tty, ap->optr, avail);
+                       sent = tty->ops->write(tty, ap->optr, avail);
                        if (sent < 0)
                                goto flush;     /* error, e.g. loss of CD */
                        ap->optr += sent;
@@ -684,7 +685,7 @@ ppp_async_push(struct asyncppp *ap)
                                tty_stuffed = 1;
                        continue;
                }
-               if (ap->optr >= ap->olim && ap->tpkt != 0) {
+               if (ap->optr >= ap->olim && ap->tpkt) {
                        if (ppp_async_encode(ap)) {
                                /* finished processing ap->tpkt */
                                clear_bit(XMIT_FULL, &ap->xmit_flags);
@@ -704,7 +705,7 @@ 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 != 0)))
+                     || (!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))
@@ -715,7 +716,7 @@ ppp_async_push(struct asyncppp *ap)
 
 flush:
        clear_bit(XMIT_BUSY, &ap->xmit_flags);
-       if (ap->tpkt != 0) {
+       if (ap->tpkt) {
                kfree_skb(ap->tpkt);
                ap->tpkt = NULL;
                clear_bit(XMIT_FULL, &ap->xmit_flags);
@@ -848,7 +849,7 @@ ppp_async_input(struct asyncppp *ap, const unsigned char *buf,
                s = 0;
                for (i = 0; i < count; ++i) {
                        c = buf[i];
-                       if (flags != 0 && flags[i] != 0)
+                       if (flags && flags[i] != 0)
                                continue;
                        s |= (c & 0x80)? SC_RCV_B7_1: SC_RCV_B7_0;
                        c = ((c >> 4) ^ c) & 0xf;
@@ -865,7 +866,7 @@ ppp_async_input(struct asyncppp *ap, const unsigned char *buf,
                        n = scan_ordinary(ap, buf, count);
 
                f = 0;
-               if (flags != 0 && (ap->state & SC_TOSS) == 0) {
+               if (flags && (ap->state & SC_TOSS) == 0) {
                        /* check the flags to see if any char had an error */
                        for (j = 0; j < n; ++j)
                                if ((f = flags[j]) != 0)
@@ -878,9 +879,9 @@ ppp_async_input(struct asyncppp *ap, const unsigned char *buf,
                } else if (n > 0 && (ap->state & SC_TOSS) == 0) {
                        /* stuff the chars in the skb */
                        skb = ap->rpkt;
-                       if (skb == 0) {
+                       if (!skb) {
                                skb = dev_alloc_skb(ap->mru + PPP_HDRLEN + 2);
-                               if (skb == 0)
+                               if (!skb)
                                        goto nomem;
                                ap->rpkt = skb;
                        }
@@ -927,7 +928,7 @@ ppp_async_input(struct asyncppp *ap, const unsigned char *buf,
                ++n;
 
                buf += n;
-               if (flags != 0)
+               if (flags)
                        flags += n;
                count -= n;
        }