gianfar: Fix Rx/Tx HW interrupt coalescing counter reset procedure.
[safe/jmp/linux-2.6] / drivers / net / ppp_async.c
index 933e2f3..f023d5b 100644 (file)
@@ -159,12 +159,11 @@ ppp_asynctty_open(struct tty_struct *tty)
        int err;
 
        err = -ENOMEM;
-       ap = kmalloc(sizeof(*ap), GFP_KERNEL);
-       if (ap == 0)
+       ap = kzalloc(sizeof(*ap), GFP_KERNEL);
+       if (!ap)
                goto out;
 
        /* initialize the asyncppp structure */
-       memset(ap, 0, sizeof(*ap));
        ap->tty = tty;
        ap->mru = PPP_MRU;
        spin_lock_init(&ap->xmit_lock);
@@ -216,7 +215,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;
 
        /*
@@ -231,10 +230,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);
 }
@@ -286,13 +285,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))
@@ -302,7 +301,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))
@@ -310,16 +309,11 @@ ppp_asynctty_ioctl(struct tty_struct *tty, struct file *file,
                err = 0;
                break;
 
-       case TCGETS:
-       case TCGETA:
-               err = n_tty_ioctl(tty, file, cmd, arg);
-               break;
-
        case TCFLSH:
                /* flush our buffers and the serial port's buffer */
                if (arg == TCIOFLUSH || arg == TCOFLUSH)
                        ppp_async_flush_output(ap);
-               err = n_tty_ioctl(tty, file, cmd, arg);
+               err = tty_perform_flush(tty, arg);
                break;
 
        case FIONREAD:
@@ -330,7 +324,8 @@ ppp_asynctty_ioctl(struct tty_struct *tty, struct file *file,
                break;
 
        default:
-               err = -ENOIOCTLCMD;
+               /* Try the various mode ioctls */
+               err = tty_mode_ioctl(tty, file, cmd, arg);
        }
 
        ap_put(ap);
@@ -355,7 +350,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);
@@ -374,7 +369,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);
@@ -689,7 +684,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);
@@ -709,7 +704,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))
@@ -720,7 +715,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);
@@ -802,9 +797,9 @@ process_input_packet(struct asyncppp *ap)
 
        /* check for address/control and protocol compression */
        p = skb->data;
-       if (p[0] == PPP_ALLSTATIONS && p[1] == PPP_UI) {
+       if (p[0] == PPP_ALLSTATIONS) {
                /* chop off address/control */
-               if (skb->len < 3)
+               if (p[1] != PPP_UI || skb->len < 3)
                        goto err;
                p = skb_pull(skb, 2);
        }
@@ -853,7 +848,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;
@@ -870,7 +865,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)
@@ -883,9 +878,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;
                        }
@@ -932,7 +927,7 @@ ppp_async_input(struct asyncppp *ap, const unsigned char *buf,
                ++n;
 
                buf += n;
-               if (flags != 0)
+               if (flags)
                        flags += n;
                count -= n;
        }