Commit a978d871 authored by Stephen Hemminger's avatar Stephen Hemminger

[NET]: Move code inline if short and used once.

Now that unregister_sysfs got smaller, just eliminate it and call
class_device_unregister directly.  netdev_finish_unregister is called
one place, therefore it is easier to understand if we just put those
few lines into wait_allrefs state machine.
parent 93bd2085
...@@ -187,7 +187,6 @@ int netdev_fastroute_obstacles; ...@@ -187,7 +187,6 @@ 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 void netdev_unregister_sysfs(struct net_device *);
/******************************************************************************* /*******************************************************************************
...@@ -2710,38 +2709,17 @@ int register_netdevice(struct net_device *dev) ...@@ -2710,38 +2709,17 @@ int register_netdevice(struct net_device *dev)
goto out; goto out;
} }
/** /*
* netdev_finish_unregister - complete unregistration * netdev_wait_allrefs - wait until all references are gone.
* @dev: device
* *
* Destroy and free a dead device. A value of zero is returned on * This is called when unregistering network devices.
* success. *
* Any protocol or device that holds a reference should register
* for netdevice notification, and cleanup and put back the
* reference if they receive an UNREGISTER event.
* We can get stuck here if buggy protocols don't correctly
* call dev_put.
*/ */
static int netdev_finish_unregister(struct net_device *dev)
{
BUG_TRAP(!dev->ip_ptr);
BUG_TRAP(!dev->ip6_ptr);
BUG_TRAP(!dev->dn_ptr);
if (dev->reg_state != NETREG_UNREGISTERED) {
printk(KERN_ERR "Freeing alive device %p, %s\n",
dev, dev->name);
return 0;
}
#ifdef NET_REFCNT_DEBUG
printk(KERN_DEBUG "netdev_finish_unregister: %s%s.\n", dev->name,
(dev->destructor != NULL)?"":", old style");
#endif
/* It must be the very last action, after this 'dev' may point
* to freed up memory.
*/
if (dev->destructor)
dev->destructor(dev);
return 0;
}
static void netdev_wait_allrefs(struct net_device *dev) static void netdev_wait_allrefs(struct net_device *dev)
{ {
unsigned long rebroadcast_time, warning_time; unsigned long rebroadcast_time, warning_time;
...@@ -2837,13 +2815,23 @@ void netdev_run_todo(void) ...@@ -2837,13 +2815,23 @@ void netdev_run_todo(void)
break; break;
case NETREG_UNREGISTERING: case NETREG_UNREGISTERING:
netdev_unregister_sysfs(dev); class_device_unregister(&dev->class_dev);
dev->reg_state = NETREG_UNREGISTERED; dev->reg_state = NETREG_UNREGISTERED;
netdev_wait_allrefs(dev); netdev_wait_allrefs(dev);
/* paranoia */
BUG_ON(atomic_read(&dev->refcnt)); BUG_ON(atomic_read(&dev->refcnt));
BUG_TRAP(!dev->ip_ptr);
netdev_finish_unregister(dev); BUG_TRAP(!dev->ip6_ptr);
BUG_TRAP(!dev->dn_ptr);
/* It must be the very last action,
* after this 'dev' may point to freed up memory.
*/
if (dev->destructor)
dev->destructor(dev);
break; break;
default: default:
......
...@@ -341,11 +341,6 @@ int netdev_register_sysfs(struct net_device *net) ...@@ -341,11 +341,6 @@ int netdev_register_sysfs(struct net_device *net)
return ret; return ret;
} }
void netdev_unregister_sysfs(struct net_device *net)
{
class_device_unregister(&net->class_dev);
}
int netdev_sysfs_init(void) int netdev_sysfs_init(void)
{ {
return class_register(&net_class); return class_register(&net_class);
......
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