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