]> git.neil.brown.name Git - history.git/commitdiff
[NET]: Simplify netdev_sysfs_xxx if SYSFS is not configured.
authorStephen Hemminger <shemminger@osdl.org>
Sat, 29 May 2004 05:41:48 +0000 (22:41 -0700)
committerDavid S. Miller <davem@nuts.davemloft.net>
Sat, 29 May 2004 05:41:48 +0000 (22:41 -0700)
Don't need all the network sysfs code if CONFIG_SYSFS is not enabled.
Also:
* netdev_sysfs_unregister is declaration mismatch
* if netdev_sysfs_register fails print a warning.
  Need to still mark it as registered so the unregister_netdevice works,
  but we will probably end up leaking memory in that case.

net/core/Makefile
net/core/dev.c

index bb81a042bca1383473c6d8ce133ff0fa4108d246..a1a8ff3c2833f1832b499c1130e15ab86a1edc7e 100644 (file)
@@ -6,9 +6,10 @@ obj-y := sock.o skbuff.o iovec.o datagram.o scm.o
 
 obj-$(CONFIG_SYSCTL) += sysctl_net_core.o
 
-obj-y               += flow.o dev.o ethtool.o net-sysfs.o dev_mcast.o dst.o \
+obj-y               += flow.o dev.o ethtool.o dev_mcast.o dst.o \
                        neighbour.o rtnetlink.o utils.o link_watch.o filter.o
 
+obj-$(CONFIG_SYSFS) += net-sysfs.o
 obj-$(CONFIG_NETFILTER) += netfilter.o
 obj-$(CONFIG_NET_DIVERT) += dv.o
 obj-$(CONFIG_NET_PKTGEN) += pktgen.o
index 4d2817ff9b3c8ccc56451ba8d8353a2d7b57b76c..e77815ed835ead871caf15e5ec45732c03e2ea2e 100644 (file)
@@ -220,9 +220,15 @@ int netdev_fastroute;
 int netdev_fastroute_obstacles;
 #endif
 
+#ifdef CONFIG_SYSFS
 extern int netdev_sysfs_init(void);
 extern int netdev_register_sysfs(struct net_device *);
-extern int netdev_unregister_sysfs(struct net_device *);
+extern void netdev_unregister_sysfs(struct net_device *);
+#else
+#define netdev_sysfs_init()            (0)
+#define netdev_register_sysfs(dev)     (0)
+#define        netdev_unregister_sysfs(dev)    do { } while(0)
+#endif
 
 
 /*******************************************************************************
@@ -2971,6 +2977,7 @@ static DECLARE_MUTEX(net_todo_run_mutex);
 void netdev_run_todo(void)
 {
        struct list_head list = LIST_HEAD_INIT(list);
+       int err;
 
        /* Safe outside mutex since we only care about entries that
         * this cpu put into queue while under RTNL.
@@ -2993,7 +3000,10 @@ void netdev_run_todo(void)
 
                switch(dev->reg_state) {
                case NETREG_REGISTERING:
-                       netdev_register_sysfs(dev);
+                       err = netdev_register_sysfs(dev);
+                       if (err)
+                               printk(KERN_ERR "%s: failed sysfs registration (%d)\n",
+                                      dev->name, err);
                        dev->reg_state = NETREG_REGISTERED;
                        break;
 
@@ -3037,6 +3047,7 @@ void netdev_run_todo(void)
  */
 void free_netdev(struct net_device *dev)
 {
+#ifdef CONFIG_SYSFS
        /*  Compatiablity with error handling in drivers */
        if (dev->reg_state == NETREG_UNINITIALIZED) {
                kfree((char *)dev - dev->padded);
@@ -3048,6 +3059,9 @@ void free_netdev(struct net_device *dev)
 
        /* will free via class release */
        class_device_put(&dev->class_dev);
+#else
+       kfree((char *)dev - dev->padded);
+#endif
 }
  
 /* Synchronize with packet receive processing. */