]> pilppa.org Git - linux-2.6-omap-h63xx.git/blobdiff - drivers/net/shaper.c
[NET] drivers/net: statistics cleanup #1 -- save memory and shrink code
[linux-2.6-omap-h63xx.git] / drivers / net / shaper.c
index e886e8d7cfdfbdceeec0576e87fb5b91734d6dfa..315feba7dacc0f7ca2efe9243d72a27e48f32aef 100644 (file)
@@ -86,6 +86,7 @@
 
 #include <net/dst.h>
 #include <net/arp.h>
+#include <net/net_namespace.h>
 
 struct shaper_cb {
        unsigned long   shapeclock;             /* Time it should go out */
@@ -170,7 +171,7 @@ static int shaper_start_xmit(struct sk_buff *skb, struct net_device *dev)
                 */
                if(time_after(SHAPERCB(skb)->shapeclock,jiffies + SHAPER_LATENCY)) {
                        dev_kfree_skb(skb);
-                       shaper->stats.tx_dropped++;
+                       dev->stats.tx_dropped++;
                } else
                        skb_queue_tail(&shaper->sendq, skb);
        }
@@ -181,7 +182,7 @@ static int shaper_start_xmit(struct sk_buff *skb, struct net_device *dev)
        {
                ptr=skb_dequeue(&shaper->sendq);
                 dev_kfree_skb(ptr);
-                shaper->stats.collisions++;
+                dev->stats.collisions++;
        }
        shaper_kick(shaper);
        spin_unlock(&shaper->lock);
@@ -206,8 +207,8 @@ static void shaper_queue_xmit(struct shaper *shaper, struct sk_buff *skb)
                                shaper->dev->name,newskb->priority);
                dev_queue_xmit(newskb);
 
-                shaper->stats.tx_bytes += skb->len;
-               shaper->stats.tx_packets++;
+                shaper->dev->stats.tx_bytes += skb->len;
+               shaper->dev->stats.tx_packets++;
 
                 if(sh_debug)
                        printk("Kicked new frame out.\n");
@@ -329,12 +330,6 @@ static int shaper_close(struct net_device *dev)
  *     ARP and other resolutions and not before.
  */
 
-static struct net_device_stats *shaper_get_stats(struct net_device *dev)
-{
-       struct shaper *sh=dev->priv;
-       return &sh->stats;
-}
-
 static int shaper_header(struct sk_buff *skb, struct net_device *dev,
        unsigned short type, void *daddr, void *saddr, unsigned len)
 {
@@ -488,7 +483,7 @@ static int shaper_ioctl(struct net_device *dev,  struct ifreq *ifr, int cmd)
        {
                case SHAPER_SET_DEV:
                {
-                       struct net_device *them=__dev_get_by_name(ss->ss_name);
+                       struct net_device *them=__dev_get_by_name(&init_net, ss->ss_name);
                        if(them==NULL)
                                return -ENODEV;
                        if(sh->dev)
@@ -532,14 +527,11 @@ static void __init shaper_setup(struct net_device *dev)
         *      Set up the shaper.
         */
 
-       SET_MODULE_OWNER(dev);
-
        shaper_init_priv(dev);
 
        dev->open               = shaper_open;
        dev->stop               = shaper_close;
        dev->hard_start_xmit    = shaper_start_xmit;
-       dev->get_stats          = shaper_get_stats;
        dev->set_multicast_list = NULL;
 
        /*
@@ -600,10 +592,9 @@ static int __init shaper_init(void)
                return -ENODEV;
 
        alloc_size = sizeof(*dev) * shapers;
-       devs = kmalloc(alloc_size, GFP_KERNEL);
+       devs = kzalloc(alloc_size, GFP_KERNEL);
        if (!devs)
                return -ENOMEM;
-       memset(devs, 0, alloc_size);
 
        for (i = 0; i < shapers; i++) {