Merge master.kernel.org:/home/rmk/linux-2.6-arm
[pandora-kernel.git] / drivers / net / ppp_generic.c
index ad4b58a..0df7e92 100644 (file)
@@ -273,7 +273,7 @@ static int ppp_connect_channel(struct channel *pch, int unit);
 static int ppp_disconnect_channel(struct channel *pch);
 static void ppp_destroy_channel(struct channel *pch);
 
-static struct class_simple *ppp_class;
+static struct class *ppp_class;
 
 /* Translates a PPP protocol number to a NP index (NP == network protocol) */
 static inline int proto_to_npindex(int proto)
@@ -858,12 +858,12 @@ static int __init ppp_init(void)
        printk(KERN_INFO "PPP generic driver version " PPP_VERSION "\n");
        err = register_chrdev(PPP_MAJOR, "ppp", &ppp_device_fops);
        if (!err) {
-               ppp_class = class_simple_create(THIS_MODULE, "ppp");
+               ppp_class = class_create(THIS_MODULE, "ppp");
                if (IS_ERR(ppp_class)) {
                        err = PTR_ERR(ppp_class);
                        goto out_chrdev;
                }
-               class_simple_device_add(ppp_class, MKDEV(PPP_MAJOR, 0), NULL, "ppp");
+               class_device_create(ppp_class, MKDEV(PPP_MAJOR, 0), NULL, "ppp");
                err = devfs_mk_cdev(MKDEV(PPP_MAJOR, 0),
                                S_IFCHR|S_IRUSR|S_IWUSR, "ppp");
                if (err)
@@ -876,8 +876,8 @@ out:
        return err;
 
 out_class:
-       class_simple_device_remove(MKDEV(PPP_MAJOR,0));
-       class_simple_destroy(ppp_class);
+       class_device_destroy(ppp_class, MKDEV(PPP_MAJOR,0));
+       class_destroy(ppp_class);
 out_chrdev:
        unregister_chrdev(PPP_MAJOR, "ppp");
        goto out;
@@ -1232,13 +1232,11 @@ static int ppp_mp_explode(struct ppp *ppp, struct sk_buff *skb)
        navail = 0;     /* total # of usable channels (not deregistered) */
        hdrlen = (ppp->flags & SC_MP_XSHORTSEQ)? MPHDRLEN_SSN: MPHDRLEN;
        i = 0;
-       list = &ppp->channels;
-       while ((list = list->next) != &ppp->channels) {
-               pch = list_entry(list, struct channel, clist);
+       list_for_each_entry(pch, &ppp->channels, clist) {
                navail += pch->avail = (pch->chan != NULL);
                if (pch->avail) {
-                       if (skb_queue_len(&pch->file.xq) == 0
-                           || !pch->had_frag) {
+                       if (skb_queue_empty(&pch->file.xq) ||
+                           !pch->had_frag) {
                                pch->avail = 2;
                                ++nfree;
                        }
@@ -1280,6 +1278,7 @@ static int ppp_mp_explode(struct ppp *ppp, struct sk_buff *skb)
 
        /* skip to the channel after the one we last used
           and start at that one */
+       list = &ppp->channels;
        for (i = 0; i < ppp->nxchan; ++i) {
                list = list->next;
                if (list == &ppp->channels) {
@@ -1374,8 +1373,8 @@ static int ppp_mp_explode(struct ppp *ppp, struct sk_buff *skb)
 
                /* try to send it down the channel */
                chan = pch->chan;
-               if (skb_queue_len(&pch->file.xq)
-                   || !chan->ops->start_xmit(chan, frag))
+               if (!skb_queue_empty(&pch->file.xq) ||
+                   !chan->ops->start_xmit(chan, frag))
                        skb_queue_tail(&pch->file.xq, frag);
                pch->had_frag = 1;
                p += flen;
@@ -1412,7 +1411,7 @@ ppp_channel_push(struct channel *pch)
 
        spin_lock_bh(&pch->downl);
        if (pch->chan != 0) {
-               while (skb_queue_len(&pch->file.xq) > 0) {
+               while (!skb_queue_empty(&pch->file.xq)) {
                        skb = skb_dequeue(&pch->file.xq);
                        if (!pch->chan->ops->start_xmit(pch->chan, skb)) {
                                /* put the packet back and try again later */
@@ -1426,7 +1425,7 @@ ppp_channel_push(struct channel *pch)
        }
        spin_unlock_bh(&pch->downl);
        /* see if there is anything from the attached unit to be sent */
-       if (skb_queue_len(&pch->file.xq) == 0) {
+       if (skb_queue_empty(&pch->file.xq)) {
                read_lock_bh(&pch->upl);
                ppp = pch->ppp;
                if (ppp != 0)
@@ -1657,7 +1656,6 @@ ppp_receive_nonmp_frame(struct ppp *ppp, struct sk_buff *skb)
                        skb->dev = ppp->dev;
                        skb->protocol = htons(npindex_to_ethertype[npi]);
                        skb->mac.raw = skb->data;
-                       skb->input_dev = ppp->dev;
                        netif_rx(skb);
                        ppp->dev->last_rx = jiffies;
                }
@@ -1731,7 +1729,7 @@ static void
 ppp_receive_mp_frame(struct ppp *ppp, struct sk_buff *skb, struct channel *pch)
 {
        u32 mask, seq;
-       struct list_head *l;
+       struct channel *ch;
        int mphdrlen = (ppp->flags & SC_MP_SHORTSEQ)? MPHDRLEN_SSN: MPHDRLEN;
 
        if (!pskb_may_pull(skb, mphdrlen) || ppp->mrru == 0)
@@ -1785,8 +1783,7 @@ ppp_receive_mp_frame(struct ppp *ppp, struct sk_buff *skb, struct channel *pch)
         * The list of channels can't change because we have the receive
         * side of the ppp unit locked.
         */
-       for (l = ppp->channels.next; l != &ppp->channels; l = l->next) {
-               struct channel *ch = list_entry(l, struct channel, clist);
+       list_for_each_entry(ch, &ppp->channels, clist) {
                if (seq_before(ch->lastseq, seq))
                        seq = ch->lastseq;
        }
@@ -2272,10 +2269,8 @@ static struct compressor_entry *
 find_comp_entry(int proto)
 {
        struct compressor_entry *ce;
-       struct list_head *list = &compressor_list;
 
-       while ((list = list->next) != &compressor_list) {
-               ce = list_entry(list, struct compressor_entry, list);
+       list_for_each_entry(ce, &compressor_list, list) {
                if (ce->comp->compress_proto == proto)
                        return ce;
        }
@@ -2541,20 +2536,15 @@ static struct channel *
 ppp_find_channel(int unit)
 {
        struct channel *pch;
-       struct list_head *list;
 
-       list = &new_channels;
-       while ((list = list->next) != &new_channels) {
-               pch = list_entry(list, struct channel, list);
+       list_for_each_entry(pch, &new_channels, list) {
                if (pch->file.index == unit) {
                        list_del(&pch->list);
                        list_add(&pch->list, &all_channels);
                        return pch;
                }
        }
-       list = &all_channels;
-       while ((list = list->next) != &all_channels) {
-               pch = list_entry(list, struct channel, list);
+       list_for_each_entry(pch, &all_channels, list) {
                if (pch->file.index == unit)
                        return pch;
        }
@@ -2654,8 +2644,8 @@ static void __exit ppp_cleanup(void)
        if (unregister_chrdev(PPP_MAJOR, "ppp") != 0)
                printk(KERN_ERR "PPP: failed to unregister PPP device\n");
        devfs_remove("ppp");
-       class_simple_device_remove(MKDEV(PPP_MAJOR, 0));
-       class_simple_destroy(ppp_class);
+       class_device_destroy(ppp_class, MKDEV(PPP_MAJOR, 0));
+       class_destroy(ppp_class);
 }
 
 /*