Merge git://git.kernel.org/pub/scm/linux/kernel/git/davem/net-2.6
[pandora-kernel.git] / drivers / net / ppp_synctty.c
index f0c6a19..801d8f9 100644 (file)
@@ -42,9 +42,9 @@
 #include <linux/if_ppp.h>
 #include <linux/ppp_channel.h>
 #include <linux/spinlock.h>
+#include <linux/completion.h>
 #include <linux/init.h>
 #include <asm/uaccess.h>
-#include <asm/semaphore.h>
 
 #define PPP_VERSION    "2.4.2"
 
@@ -70,7 +70,7 @@ struct syncppp {
        struct tasklet_struct tsk;
 
        atomic_t        refcnt;
-       struct semaphore dead_sem;
+       struct completion dead_cmp;
        struct ppp_channel chan;        /* interface to generic ppp layer */
 };
 
@@ -195,7 +195,7 @@ static struct syncppp *sp_get(struct tty_struct *tty)
 static void sp_put(struct syncppp *ap)
 {
        if (atomic_dec_and_test(&ap->refcnt))
-               up(&ap->dead_sem);
+               complete(&ap->dead_cmp);
 }
 
 /*
@@ -207,6 +207,9 @@ ppp_sync_open(struct tty_struct *tty)
        struct syncppp *ap;
        int err;
 
+       if (tty->ops->write == NULL)
+               return -EOPNOTSUPP;
+
        ap = kzalloc(sizeof(*ap), GFP_KERNEL);
        err = -ENOMEM;
        if (!ap)
@@ -225,7 +228,7 @@ ppp_sync_open(struct tty_struct *tty)
        tasklet_init(&ap->tsk, ppp_sync_process, (unsigned long) ap);
 
        atomic_set(&ap->refcnt, 1);
-       init_MUTEX_LOCKED(&ap->dead_sem);
+       init_completion(&ap->dead_cmp);
 
        ap->chan.private = ap;
        ap->chan.ops = &sync_ops;
@@ -273,7 +276,7 @@ ppp_sync_close(struct tty_struct *tty)
         * by the time it returns.
         */
        if (!atomic_dec_and_test(&ap->refcnt))
-               down(&ap->dead_sem);
+               wait_for_completion(&ap->dead_cmp);
        tasklet_kill(&ap->tsk);
 
        ppp_unregister_channel(&ap->chan);
@@ -398,9 +401,7 @@ ppp_sync_receive(struct tty_struct *tty, const unsigned char *buf,
        if (!skb_queue_empty(&ap->rqueue))
                tasklet_schedule(&ap->tsk);
        sp_put(ap);
-       if (test_and_clear_bit(TTY_THROTTLED, &tty->flags)
-           && tty->driver->unthrottle)
-               tty->driver->unthrottle(tty);
+       tty_unthrottle(tty);
 }
 
 static void
@@ -417,7 +418,7 @@ ppp_sync_wakeup(struct tty_struct *tty)
 }
 
 
-static struct tty_ldisc ppp_sync_ldisc = {
+static struct tty_ldisc_ops ppp_sync_ldisc = {
        .owner  = THIS_MODULE,
        .magic  = TTY_LDISC_MAGIC,
        .name   = "pppsync",
@@ -560,7 +561,7 @@ static void ppp_sync_process(unsigned long arg)
  * Procedures for encapsulation and framing.
  */
 
-struct sk_buff*
+static struct sk_buff*
 ppp_sync_txmunge(struct syncppp *ap, struct sk_buff *skb)
 {
        int proto;
@@ -653,7 +654,7 @@ ppp_sync_push(struct syncppp *ap)
                        tty_stuffed = 0;
                if (!tty_stuffed && ap->tpkt) {
                        set_bit(TTY_DO_WRITE_WAKEUP, &tty->flags);
-                       sent = tty->driver->write(tty, ap->tpkt->data, ap->tpkt->len);
+                       sent = tty->ops->write(tty, ap->tpkt->data, ap->tpkt->len);
                        if (sent < 0)
                                goto flush;     /* error, e.g. loss of CD */
                        if (sent < ap->tpkt->len) {