drivers/net: Trim trailing whitespace
[sfrench/cifs-2.6.git] / drivers / net / ifb.c
index 31fb2d75dc447a79bffa71f86d728425b68472a1..6469130c1413f532633e0a87df31c821a1ae36c2 100644 (file)
@@ -1,4 +1,4 @@
-/* drivers/net/ifb.c: 
+/* drivers/net/ifb.c:
 
        The purpose of this driver is to provide a device that allows
        for sharing of resources:
@@ -8,8 +8,8 @@
        an impression of sharing.
 
        2) Allows for queueing incoming traffic for shaping instead of
-       dropping. 
-       
+       dropping.
+
        The original concept is based on what is known as the IMQ
        driver initially written by Martin Devera, later rewritten
        by Patrick McHardy and then maintained by Andre Correa.
        modify it under the terms of the GNU General Public License
        as published by the Free Software Foundation; either version
        2 of the License, or (at your option) any later version.
+
        Authors:        Jamal Hadi Salim (2005)
+
 */
 
 
-#include <linux/config.h>
 #include <linux/module.h>
 #include <linux/kernel.h>
 #include <linux/netdevice.h>
 #include <linux/etherdevice.h>
 #include <linux/init.h>
 #include <linux/moduleparam.h>
-#include <net/pkt_sched.h> 
+#include <net/pkt_sched.h>
 
 #define TX_TIMEOUT  (2*HZ)
-                                                                                
+
 #define TX_Q_LIMIT    32
 struct ifb_private {
        struct net_device_stats stats;
@@ -65,7 +64,7 @@ static struct net_device_stats *ifb_get_stats(struct net_device *dev);
 static int ifb_open(struct net_device *dev);
 static int ifb_close(struct net_device *dev);
 
-static void ri_tasklet(unsigned long dev) 
+static void ri_tasklet(unsigned long dev)
 {
 
        struct net_device *_dev = (struct net_device *)dev;
@@ -76,13 +75,13 @@ static void ri_tasklet(unsigned long dev)
        dp->st_task_enter++;
        if ((skb = skb_peek(&dp->tq)) == NULL) {
                dp->st_txq_refl_try++;
-               if (spin_trylock(&_dev->xmit_lock)) {
+               if (netif_tx_trylock(_dev)) {
                        dp->st_rxq_enter++;
                        while ((skb = skb_dequeue(&dp->rq)) != NULL) {
                                skb_queue_tail(&dp->tq, skb);
                                dp->st_rx2tx_tran++;
                        }
-                       spin_unlock(&_dev->xmit_lock);
+                       netif_tx_unlock(_dev);
                } else {
                        /* reschedule */
                        dp->st_rxq_notenter++;
@@ -110,7 +109,7 @@ static void ri_tasklet(unsigned long dev)
                }
        }
 
-       if (spin_trylock(&_dev->xmit_lock)) {
+       if (netif_tx_trylock(_dev)) {
                dp->st_rxq_check++;
                if ((skb = skb_peek(&dp->rq)) == NULL) {
                        dp->tasklet_pending = 0;
@@ -118,10 +117,10 @@ static void ri_tasklet(unsigned long dev)
                                netif_wake_queue(_dev);
                } else {
                        dp->st_rxq_rsch++;
-                       spin_unlock(&_dev->xmit_lock);
+                       netif_tx_unlock(_dev);
                        goto resched;
                }
-               spin_unlock(&_dev->xmit_lock);
+               netif_tx_unlock(_dev);
        } else {
 resched:
                dp->tasklet_pending = 1;
@@ -164,7 +163,7 @@ dropped:
                stats->rx_dropped++;
                return ret;
        } else {
-               /* 
+               /*
                 * note we could be going
                 * ingress -> egress or
                 * egress -> ingress
@@ -200,7 +199,7 @@ static struct net_device_stats *ifb_get_stats(struct net_device *dev)
        struct net_device_stats *stats = &dp->stats;
 
        pr_debug("tasklets stats %ld:%ld:%ld:%ld:%ld:%ld:%ld:%ld:%ld \n",
-               dp->st_task_enter, dp->st_txq_refl_try, dp->st_rxq_enter, 
+               dp->st_task_enter, dp->st_txq_refl_try, dp->st_rxq_enter,
                dp->st_rx2tx_tran dp->st_rxq_notenter, dp->st_rx_frm_egr,
                dp->st_rx_frm_ing, dp->st_rxq_check, dp->st_rxq_rsch );
 
@@ -251,7 +250,7 @@ static int __init ifb_init_one(int index)
                free_netdev(dev_ifb);
                dev_ifb = NULL;
        } else {
-               ifbs[index] = dev_ifb; 
+               ifbs[index] = dev_ifb;
        }
 
        return err;
@@ -261,31 +260,32 @@ static void ifb_free_one(int index)
 {
        unregister_netdev(ifbs[index]);
        free_netdev(ifbs[index]);
-} 
+}
 
 static int __init ifb_init_module(void)
-{ 
+{
        int i, err = 0;
-       ifbs = kmalloc(numifbs * sizeof(void *), GFP_KERNEL); 
+       ifbs = kmalloc(numifbs * sizeof(void *), GFP_KERNEL);
        if (!ifbs)
-               return -ENOMEM; 
+               return -ENOMEM;
        for (i = 0; i < numifbs && !err; i++)
-               err = ifb_init_one(i); 
-       if (err) { 
+               err = ifb_init_one(i);
+       if (err) {
+               i--;
                while (--i >= 0)
                        ifb_free_one(i);
        }
 
        return err;
-} 
+}
 
 static void __exit ifb_cleanup_module(void)
 {
        int i;
 
-       for (i = 0; i < numifbs; i++) 
-               ifb_free_one(i); 
-       kfree(ifbs);    
+       for (i = 0; i < numifbs; i++)
+               ifb_free_one(i);
+       kfree(ifbs);
 }
 
 module_init(ifb_init_module);