diff options
Diffstat (limited to 'net')
-rw-r--r-- | net/core/Makefile | 2 | ||||
-rw-r--r-- | net/core/dev.c | 28 | ||||
-rw-r--r-- | net/core/net-sysfs.c | 13 |
3 files changed, 20 insertions, 23 deletions
diff --git a/net/core/Makefile b/net/core/Makefile index ea9b3f32d1c0..b1332f6d0042 100644 --- a/net/core/Makefile +++ b/net/core/Makefile | |||
@@ -11,7 +11,7 @@ obj-y += dev.o ethtool.o dev_mcast.o dst.o netevent.o \ | |||
11 | neighbour.o rtnetlink.o utils.o link_watch.o filter.o | 11 | neighbour.o rtnetlink.o utils.o link_watch.o filter.o |
12 | 12 | ||
13 | obj-$(CONFIG_XFRM) += flow.o | 13 | obj-$(CONFIG_XFRM) += flow.o |
14 | obj-$(CONFIG_SYSFS) += net-sysfs.o | 14 | obj-y += net-sysfs.o |
15 | obj-$(CONFIG_NET_PKTGEN) += pktgen.o | 15 | obj-$(CONFIG_NET_PKTGEN) += pktgen.o |
16 | obj-$(CONFIG_NETPOLL) += netpoll.o | 16 | obj-$(CONFIG_NETPOLL) += netpoll.o |
17 | obj-$(CONFIG_NET_DMA) += user_dma.o | 17 | obj-$(CONFIG_NET_DMA) += user_dma.o |
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); |
diff --git a/net/core/net-sysfs.c b/net/core/net-sysfs.c index 79159db6acb9..909a03d6c0e9 100644 --- a/net/core/net-sysfs.c +++ b/net/core/net-sysfs.c | |||
@@ -18,6 +18,7 @@ | |||
18 | #include <linux/wireless.h> | 18 | #include <linux/wireless.h> |
19 | #include <net/iw_handler.h> | 19 | #include <net/iw_handler.h> |
20 | 20 | ||
21 | #ifdef CONFIG_SYSFS | ||
21 | static const char fmt_hex[] = "%#x\n"; | 22 | static const char fmt_hex[] = "%#x\n"; |
22 | static const char fmt_long_hex[] = "%#lx\n"; | 23 | static const char fmt_long_hex[] = "%#lx\n"; |
23 | static const char fmt_dec[] = "%d\n"; | 24 | static const char fmt_dec[] = "%d\n"; |
@@ -392,6 +393,8 @@ static struct attribute_group wireless_group = { | |||
392 | }; | 393 | }; |
393 | #endif | 394 | #endif |
394 | 395 | ||
396 | #endif /* CONFIG_SYSFS */ | ||
397 | |||
395 | #ifdef CONFIG_HOTPLUG | 398 | #ifdef CONFIG_HOTPLUG |
396 | static int netdev_uevent(struct device *d, char **envp, | 399 | static int netdev_uevent(struct device *d, char **envp, |
397 | int num_envp, char *buf, int size) | 400 | int num_envp, char *buf, int size) |
@@ -435,7 +438,9 @@ static void netdev_release(struct device *d) | |||
435 | static struct class net_class = { | 438 | static struct class net_class = { |
436 | .name = "net", | 439 | .name = "net", |
437 | .dev_release = netdev_release, | 440 | .dev_release = netdev_release, |
441 | #ifdef CONFIG_SYSFS | ||
438 | .dev_attrs = net_class_attributes, | 442 | .dev_attrs = net_class_attributes, |
443 | #endif /* CONFIG_SYSFS */ | ||
439 | #ifdef CONFIG_HOTPLUG | 444 | #ifdef CONFIG_HOTPLUG |
440 | .dev_uevent = netdev_uevent, | 445 | .dev_uevent = netdev_uevent, |
441 | #endif | 446 | #endif |
@@ -444,7 +449,7 @@ static struct class net_class = { | |||
444 | /* Delete sysfs entries but hold kobject reference until after all | 449 | /* Delete sysfs entries but hold kobject reference until after all |
445 | * netdev references are gone. | 450 | * netdev references are gone. |
446 | */ | 451 | */ |
447 | void netdev_unregister_sysfs(struct net_device * net) | 452 | void netdev_unregister_kobject(struct net_device * net) |
448 | { | 453 | { |
449 | struct device *dev = &(net->dev); | 454 | struct device *dev = &(net->dev); |
450 | 455 | ||
@@ -453,7 +458,7 @@ void netdev_unregister_sysfs(struct net_device * net) | |||
453 | } | 458 | } |
454 | 459 | ||
455 | /* Create sysfs entries for network device. */ | 460 | /* Create sysfs entries for network device. */ |
456 | int netdev_register_sysfs(struct net_device *net) | 461 | int netdev_register_kobject(struct net_device *net) |
457 | { | 462 | { |
458 | struct device *dev = &(net->dev); | 463 | struct device *dev = &(net->dev); |
459 | struct attribute_group **groups = net->sysfs_groups; | 464 | struct attribute_group **groups = net->sysfs_groups; |
@@ -466,6 +471,7 @@ int netdev_register_sysfs(struct net_device *net) | |||
466 | BUILD_BUG_ON(BUS_ID_SIZE < IFNAMSIZ); | 471 | BUILD_BUG_ON(BUS_ID_SIZE < IFNAMSIZ); |
467 | strlcpy(dev->bus_id, net->name, BUS_ID_SIZE); | 472 | strlcpy(dev->bus_id, net->name, BUS_ID_SIZE); |
468 | 473 | ||
474 | #ifdef CONFIG_SYSFS | ||
469 | if (net->get_stats) | 475 | if (net->get_stats) |
470 | *groups++ = &netstat_group; | 476 | *groups++ = &netstat_group; |
471 | 477 | ||
@@ -473,11 +479,12 @@ int netdev_register_sysfs(struct net_device *net) | |||
473 | if (net->wireless_handlers && net->wireless_handlers->get_wireless_stats) | 479 | if (net->wireless_handlers && net->wireless_handlers->get_wireless_stats) |
474 | *groups++ = &wireless_group; | 480 | *groups++ = &wireless_group; |
475 | #endif | 481 | #endif |
482 | #endif /* CONFIG_SYSFS */ | ||
476 | 483 | ||
477 | return device_add(dev); | 484 | return device_add(dev); |
478 | } | 485 | } |
479 | 486 | ||
480 | int netdev_sysfs_init(void) | 487 | int netdev_kobject_init(void) |
481 | { | 488 | { |
482 | return class_register(&net_class); | 489 | return class_register(&net_class); |
483 | } | 490 | } |