]> pilppa.org Git - linux-2.6-omap-h63xx.git/blobdiff - drivers/net/loopback.c
ipg: balance locking in irq handler
[linux-2.6-omap-h63xx.git] / drivers / net / loopback.c
index b6d4ae3ad506a387dbd152591e3f10044905c2cb..fa147cd5d68c07e2b8e434ffad5db9c55891b58d 100644 (file)
@@ -154,6 +154,7 @@ static int loopback_xmit(struct sk_buff *skb, struct net_device *dev)
 #endif
        dev->last_rx = jiffies;
 
+       /* it's OK to use per_cpu_ptr() because BHs are off */
        pcpu_lstats = netdev_priv(dev);
        lb_stats = per_cpu_ptr(pcpu_lstats, smp_processor_id());
        lb_stats->bytes += skb->len;
@@ -221,7 +222,8 @@ static void loopback_dev_free(struct net_device *dev)
 }
 
 /*
- * The loopback device is special. There is only one instance.
+ * The loopback device is special. There is only one instance
+ * per network namespace.
  */
 static void loopback_setup(struct net_device *dev)
 {
@@ -240,7 +242,7 @@ static void loopback_setup(struct net_device *dev)
                | NETIF_F_NO_CSUM
                | NETIF_F_HIGHDMA
                | NETIF_F_LLTX
-               | NETIF_F_NETNS_LOCAL,
+               | NETIF_F_NETNS_LOCAL;
        dev->ethtool_ops        = &loopback_ethtool_ops;
        dev->header_ops         = &eth_header_ops;
        dev->init = loopback_dev_init;
@@ -248,7 +250,7 @@ static void loopback_setup(struct net_device *dev)
 }
 
 /* Setup and register the loopback device. */
-static int loopback_net_init(struct net *net)
+static __net_init int loopback_net_init(struct net *net)
 {
        struct net_device *dev;
        int err;
@@ -263,27 +265,26 @@ static int loopback_net_init(struct net *net)
        if (err)
                goto out_free_netdev;
 
-       err = 0;
        net->loopback_dev = dev;
+       return 0;
 
-out:
-       if (err)
-               panic("loopback: Failed to register netdevice: %d\n", err);
-       return err;
 
 out_free_netdev:
        free_netdev(dev);
-       goto out;
+out:
+       if (net == &init_net)
+               panic("loopback: Failed to register netdevice: %d\n", err);
+       return err;
 }
 
-static void loopback_net_exit(struct net *net)
+static __net_exit void loopback_net_exit(struct net *net)
 {
        struct net_device *dev = net->loopback_dev;
 
        unregister_netdev(dev);
 }
 
-static struct pernet_operations loopback_net_ops = {
+static struct pernet_operations __net_initdata loopback_net_ops = {
        .init = loopback_net_init,
        .exit = loopback_net_exit,
 };
@@ -293,4 +294,7 @@ static int __init loopback_init(void)
        return register_pernet_device(&loopback_net_ops);
 }
 
+/* Loopback is special. It should be initialized before any other network
+ * device and network subsystem.
+ */
 fs_initcall(loopback_init);