Merge tag 'sound-fix-4.6-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/tiwai...
[deliverable/linux.git] / net / 6lowpan / core.c
index faf65baed617d5c5b39d9cadd5ef0264ea546d59..34e44c0c08368eb5699dd101c4a2c3f35adadfab 100644 (file)
@@ -20,7 +20,7 @@
 int lowpan_register_netdevice(struct net_device *dev,
                              enum lowpan_lltypes lltype)
 {
-       int ret;
+       int i, ret;
 
        dev->addr_len = EUI64_ADDR_LEN;
        dev->type = ARPHRD_6LOWPAN;
@@ -29,6 +29,10 @@ int lowpan_register_netdevice(struct net_device *dev,
 
        lowpan_priv(dev)->lltype = lltype;
 
+       spin_lock_init(&lowpan_priv(dev)->ctx.lock);
+       for (i = 0; i < LOWPAN_IPHC_CTX_TABLE_SIZE; i++)
+               lowpan_priv(dev)->ctx.table[i].id = i;
+
        ret = register_netdevice(dev);
        if (ret < 0)
                return ret;
@@ -68,6 +72,32 @@ void lowpan_unregister_netdev(struct net_device *dev)
 }
 EXPORT_SYMBOL(lowpan_unregister_netdev);
 
+static int lowpan_event(struct notifier_block *unused,
+                       unsigned long event, void *ptr)
+{
+       struct net_device *dev = netdev_notifier_info_to_dev(ptr);
+       int i;
+
+       if (dev->type != ARPHRD_6LOWPAN)
+               return NOTIFY_DONE;
+
+       switch (event) {
+       case NETDEV_DOWN:
+               for (i = 0; i < LOWPAN_IPHC_CTX_TABLE_SIZE; i++)
+                       clear_bit(LOWPAN_IPHC_CTX_FLAG_ACTIVE,
+                                 &lowpan_priv(dev)->ctx.table[i].flags);
+               break;
+       default:
+               return NOTIFY_DONE;
+       }
+
+       return NOTIFY_OK;
+}
+
+static struct notifier_block lowpan_notifier = {
+       .notifier_call = lowpan_event,
+};
+
 static int __init lowpan_module_init(void)
 {
        int ret;
@@ -76,6 +106,12 @@ static int __init lowpan_module_init(void)
        if (ret < 0)
                return ret;
 
+       ret = register_netdevice_notifier(&lowpan_notifier);
+       if (ret < 0) {
+               lowpan_debugfs_exit();
+               return ret;
+       }
+
        request_module_nowait("ipv6");
 
        request_module_nowait("nhc_dest");
@@ -92,6 +128,7 @@ static int __init lowpan_module_init(void)
 static void __exit lowpan_module_exit(void)
 {
        lowpan_debugfs_exit();
+       unregister_netdevice_notifier(&lowpan_notifier);
 }
 
 module_init(lowpan_module_init);
This page took 0.029781 seconds and 5 git commands to generate.