aboutsummaryrefslogtreecommitdiffstats
path: root/net/core/net-sysfs.c
diff options
context:
space:
mode:
authorEric W. Biederman <ebiederm@xmission.com>2007-09-27 01:02:53 -0400
committerDavid S. Miller <davem@sunset.davemloft.net>2007-10-10 19:52:46 -0400
commit8b41d1887db718be9a2cd9e18c58ce25a4c7fd93 (patch)
tree102ef996b06916215761b619737dbb65ea685525 /net/core/net-sysfs.c
parentbb293e6a24cc2031f74775d95925e003e7250232 (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/net-sysfs.c')
-rw-r--r--net/core/net-sysfs.c13
1 files changed, 10 insertions, 3 deletions
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
21static const char fmt_hex[] = "%#x\n"; 22static const char fmt_hex[] = "%#x\n";
22static const char fmt_long_hex[] = "%#lx\n"; 23static const char fmt_long_hex[] = "%#lx\n";
23static const char fmt_dec[] = "%d\n"; 24static 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
396static int netdev_uevent(struct device *d, char **envp, 399static 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)
435static struct class net_class = { 438static 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 */
447void netdev_unregister_sysfs(struct net_device * net) 452void 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. */
456int netdev_register_sysfs(struct net_device *net) 461int 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
480int netdev_sysfs_init(void) 487int netdev_kobject_init(void)
481{ 488{
482 return class_register(&net_class); 489 return class_register(&net_class);
483} 490}