Commit 0123d4ef authored by Maneesh Soni's avatar Maneesh Soni Committed by David S. Miller

[NET]: Remove attribute group when unregistering netdev from sysfs.

parent 5c675a44
......@@ -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);
......
......@@ -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",
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment