]> git.hungrycats.org Git - linux/commitdiff
[NET]: Remove attribute group when unregistering netdev from sysfs.
authorManeesh Soni <maneesh@in.ibm.com>
Thu, 25 Sep 2003 14:02:26 +0000 (07:02 -0700)
committerDavid S. Miller <davem@nuts.ninka.net>
Thu, 25 Sep 2003 14:02:26 +0000 (07:02 -0700)
net/core/dev.c
net/core/net-sysfs.c

index d6f77d31f4963436adf381c2e719330b1c1769ac..8d09c29789725819b1b50cce7d034aecd0ac4c6c 100644 (file)
@@ -179,6 +179,7 @@ int netdev_fastroute_obstacles;
 
 extern int netdev_sysfs_init(void);
 extern int netdev_register_sysfs(struct net_device *);
+extern int netdev_unregister_sysfs(struct net_device *);
 
 
 /*******************************************************************************
@@ -2819,7 +2820,7 @@ void netdev_run_todo(void)
                        break;
 
                case NETREG_UNREGISTERING:
-                       class_device_del(&dev->class_dev);
+                       netdev_unregister_sysfs(dev);
                        dev->reg_state = NETREG_UNREGISTERED;
 
                        netdev_wait_allrefs(dev);
index 3ff9e58a06c821d2074a9209293d68d309ea6eb9..b1fa8f6ccc2a5f01745046edcffd84391eeab397 100644 (file)
@@ -383,6 +383,21 @@ static struct class net_class = {
 #endif
 };
 
+void netdev_unregister_sysfs(struct net_device * net)
+{
+       struct class_device * class_dev = &(net->class_dev);
+
+       if (net->get_stats)
+               sysfs_remove_group(&class_dev->kobj, &netstat_group);
+
+#ifdef WIRELESS_EXT
+       if (net->get_wireless_stats)
+               sysfs_remove_group(&class_dev->kobj, &wireless_group);
+#endif
+       class_device_del(class_dev);
+
+}
+
 /* Create sysfs entries for network device. */
 int netdev_register_sysfs(struct net_device *net)
 {
@@ -411,9 +426,15 @@ int netdev_register_sysfs(struct net_device *net)
 #ifdef WIRELESS_EXT
        if (net->get_wireless_stats &&
            (ret = sysfs_create_group(&class_dev->kobj, &wireless_group)))
-               goto out_unreg; 
-#endif
+               goto out_cleanup; 
+
+       return 0;
+out_cleanup:
+       if (net->get_stats)
+               sysfs_remove_group(&class_dev->kobj, &netstat_group);
+#else
        return 0;
+#endif
 
 out_unreg:
        printk(KERN_WARNING "%s: sysfs attribute registration failed %d\n",