diff options
author | Eric W. Biederman <ebiederm@xmission.com> | 2007-09-27 01:02:53 -0400 |
---|---|---|
committer | David S. Miller <davem@sunset.davemloft.net> | 2007-10-10 19:52:46 -0400 |
commit | 8b41d1887db718be9a2cd9e18c58ce25a4c7fd93 (patch) | |
tree | 102ef996b06916215761b619737dbb65ea685525 /net/core/dev.c | |
parent | bb293e6a24cc2031f74775d95925e003e7250232 (diff) |
[NET]: Fix running without sysfs
When sysfs support is compiled out the kernel still keeps and maintains
the kobject tree. So it is not safe to skip our kobject reference counting or
to avoid becoming members of the kobject tree. It is safe to not add
the networking specific sysfs attributes.
This patch removes the sysfs special cases from net/core/dev.c
renames functions from netdev_sysfs_xxxx to netdev_kobject_xxxx
and always compiles in net-sysfs.c
net-sysfs.c is modified with a CONFIG_SYSFS guard around the parts
that are actually sysfs specific.
Signed-off-by: Eric W. Biederman <ebiederm@xmission.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'net/core/dev.c')
-rw-r--r-- | net/core/dev.c | 28 |
1 files changed, 9 insertions, 19 deletions
diff --git a/net/core/dev.c b/net/core/dev.c index 080d32c4034f..3923d5133050 100644 --- a/net/core/dev.c +++ b/net/core/dev.c | |||
@@ -249,15 +249,9 @@ static RAW_NOTIFIER_HEAD(netdev_chain); | |||
249 | 249 | ||
250 | DEFINE_PER_CPU(struct softnet_data, softnet_data); | 250 | DEFINE_PER_CPU(struct softnet_data, softnet_data); |
251 | 251 | ||
252 | #ifdef CONFIG_SYSFS | 252 | extern int netdev_kobject_init(void); |
253 | extern int netdev_sysfs_init(void); | 253 | extern int netdev_register_kobject(struct net_device *); |
254 | extern int netdev_register_sysfs(struct net_device *); | 254 | extern void netdev_unregister_kobject(struct net_device *); |
255 | extern void netdev_unregister_sysfs(struct net_device *); | ||
256 | #else | ||
257 | #define netdev_sysfs_init() (0) | ||
258 | #define netdev_register_sysfs(dev) (0) | ||
259 | #define netdev_unregister_sysfs(dev) do { } while(0) | ||
260 | #endif | ||
261 | 255 | ||
262 | #ifdef CONFIG_DEBUG_LOCK_ALLOC | 256 | #ifdef CONFIG_DEBUG_LOCK_ALLOC |
263 | /* | 257 | /* |
@@ -3575,7 +3569,7 @@ int register_netdevice(struct net_device *dev) | |||
3575 | if (!dev->rebuild_header) | 3569 | if (!dev->rebuild_header) |
3576 | dev->rebuild_header = default_rebuild_header; | 3570 | dev->rebuild_header = default_rebuild_header; |
3577 | 3571 | ||
3578 | ret = netdev_register_sysfs(dev); | 3572 | ret = netdev_register_kobject(dev); |
3579 | if (ret) | 3573 | if (ret) |
3580 | goto err_uninit; | 3574 | goto err_uninit; |
3581 | dev->reg_state = NETREG_REGISTERED; | 3575 | dev->reg_state = NETREG_REGISTERED; |
@@ -3838,7 +3832,6 @@ EXPORT_SYMBOL(alloc_netdev_mq); | |||
3838 | */ | 3832 | */ |
3839 | void free_netdev(struct net_device *dev) | 3833 | void free_netdev(struct net_device *dev) |
3840 | { | 3834 | { |
3841 | #ifdef CONFIG_SYSFS | ||
3842 | /* Compatibility with error handling in drivers */ | 3835 | /* Compatibility with error handling in drivers */ |
3843 | if (dev->reg_state == NETREG_UNINITIALIZED) { | 3836 | if (dev->reg_state == NETREG_UNINITIALIZED) { |
3844 | kfree((char *)dev - dev->padded); | 3837 | kfree((char *)dev - dev->padded); |
@@ -3850,9 +3843,6 @@ void free_netdev(struct net_device *dev) | |||
3850 | 3843 | ||
3851 | /* will free via device release */ | 3844 | /* will free via device release */ |
3852 | put_device(&dev->dev); | 3845 | put_device(&dev->dev); |
3853 | #else | ||
3854 | kfree((char *)dev - dev->padded); | ||
3855 | #endif | ||
3856 | } | 3846 | } |
3857 | 3847 | ||
3858 | /* Synchronize with packet receive processing. */ | 3848 | /* Synchronize with packet receive processing. */ |
@@ -3921,8 +3911,8 @@ void unregister_netdevice(struct net_device *dev) | |||
3921 | /* Notifier chain MUST detach us from master device. */ | 3911 | /* Notifier chain MUST detach us from master device. */ |
3922 | BUG_TRAP(!dev->master); | 3912 | BUG_TRAP(!dev->master); |
3923 | 3913 | ||
3924 | /* Remove entries from sysfs */ | 3914 | /* Remove entries from kobject tree */ |
3925 | netdev_unregister_sysfs(dev); | 3915 | netdev_unregister_kobject(dev); |
3926 | 3916 | ||
3927 | /* Finish processing unregister after unlock */ | 3917 | /* Finish processing unregister after unlock */ |
3928 | net_set_todo(dev); | 3918 | net_set_todo(dev); |
@@ -4053,9 +4043,9 @@ int dev_change_net_namespace(struct net_device *dev, struct net *net, const char | |||
4053 | dev->iflink = dev->ifindex; | 4043 | dev->iflink = dev->ifindex; |
4054 | } | 4044 | } |
4055 | 4045 | ||
4056 | /* Fixup sysfs */ | 4046 | /* Fixup kobjects */ |
4057 | err = device_rename(&dev->dev, dev->name); | 4047 | err = device_rename(&dev->dev, dev->name); |
4058 | BUG_ON(err); | 4048 | WARN_ON(err); |
4059 | 4049 | ||
4060 | /* Add the device back in the hashes */ | 4050 | /* Add the device back in the hashes */ |
4061 | list_netdevice(dev); | 4051 | list_netdevice(dev); |
@@ -4358,7 +4348,7 @@ static int __init net_dev_init(void) | |||
4358 | if (dev_proc_init()) | 4348 | if (dev_proc_init()) |
4359 | goto out; | 4349 | goto out; |
4360 | 4350 | ||
4361 | if (netdev_sysfs_init()) | 4351 | if (netdev_kobject_init()) |
4362 | goto out; | 4352 | goto out; |
4363 | 4353 | ||
4364 | INIT_LIST_HEAD(&ptype_all); | 4354 | INIT_LIST_HEAD(&ptype_all); |